moved definitions of INPUT_LISTENER_TYPE_T and input_listener_t to input.c

pull/14/head
Sara 2023-07-16 00:38:36 +02:00
parent f0d76713c2
commit f9236e4182
2 changed files with 28 additions and 28 deletions

View File

@ -6,6 +6,34 @@
#include "SDL2/SDL_render.h"
#include <SDL2/SDL_events.h>
enum INPUT_LISTENER_TYPE_T {
INPUT_LISTENER_MOUSE,
INPUT_LISTENER_AXIS,
INPUT_LISTENER_SCROLL,
INPUT_LISTENER_BUTTON,
};
typedef struct input_listener_t {
enum INPUT_LISTENER_TYPE_T type;
union {
struct {
input_axis_fn delegate;
SDL_Scancode positive, negative;
int last_positive, last_negative;
} axis;
struct {
input_mouse_fn delegate;
} mouse;
struct {
input_button_fn delegate;
uint32_t button;
int last;
} button;
struct {
input_scroll_fn delegate;
} scroll;
};
} input_listener_t;
const Uint8* g_key_states = NULL;
input_listener_t g_key_listeners[24];

View File

@ -7,34 +7,6 @@ extern "C" {
#include "SDL2/SDL.h"
enum INPUT_LISTENER_TYPE_T {
INPUT_LISTENER_MOUSE,
INPUT_LISTENER_AXIS,
INPUT_LISTENER_SCROLL,
INPUT_LISTENER_BUTTON,
};
typedef struct input_listener_t {
enum INPUT_LISTENER_TYPE_T type;
union {
struct {
input_axis_delegate_t delegate;
SDL_Scancode positive, negative;
int last_positive, last_negative;
} axis;
struct {
input_mouse_delegate_t delegate;
} mouse;
struct {
input_button_delegate_t delegate;
uint32_t button;
int last;
} button;
struct {
input_scroll_delegate_t delegate;
} scroll;
};
} input_listener_t;
typedef void(*input_axis_fn)(int value);
typedef void(*input_mouse_fn)(float dx, float dy);
typedef void(*input_button_fn)(int down);