renamed function delegates ending with _t to end with _fn
parent
6085dbaed0
commit
f0d76713c2
|
@ -18,7 +18,7 @@ static resource_t* insert_asset(const resource_t* resource) {
|
||||||
return inserted;
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_arbitrary_asset(void* memory, deleter_t deleter) {
|
void add_arbitrary_asset(void* memory, deleter_fn deleter) {
|
||||||
char name_buf[99];
|
char name_buf[99];
|
||||||
// generate the name of the arbitrary block based on adresses
|
// generate the name of the arbitrary block based on adresses
|
||||||
sprintf(name_buf, "%p%p", memory, deleter);
|
sprintf(name_buf, "%p%p", memory, deleter);
|
||||||
|
|
|
@ -17,7 +17,7 @@ typedef enum resourcetype_t {
|
||||||
RESOURCETYPE_MAX
|
RESOURCETYPE_MAX
|
||||||
} resourcetype_t;
|
} resourcetype_t;
|
||||||
|
|
||||||
typedef void(*deleter_t)(void* target);
|
typedef void(*deleter_fn)(void* target);
|
||||||
|
|
||||||
typedef struct resource_t {
|
typedef struct resource_t {
|
||||||
resourcetype_t type;
|
resourcetype_t type;
|
||||||
|
@ -31,13 +31,13 @@ typedef struct resource_t {
|
||||||
} font;
|
} font;
|
||||||
struct {
|
struct {
|
||||||
void* memory;
|
void* memory;
|
||||||
deleter_t deleter;
|
deleter_fn deleter;
|
||||||
} arbitrary_type;
|
} arbitrary_type;
|
||||||
};
|
};
|
||||||
} resource_t;
|
} resource_t;
|
||||||
|
|
||||||
extern void add_arbitrary_asset(void* memory, deleter_t deleter);
|
extern void add_arbitrary_asset(void* memory, deleter_fn deleter);
|
||||||
extern void add_arbitrary_asset_by_name(void* memory, deleter_t deleter, const char* name);
|
extern void add_arbitrary_asset_by_name(void* memory, deleter_fn deleter, const char* name);
|
||||||
extern SDL_Texture* load_texture(const char* file);
|
extern SDL_Texture* load_texture(const char* file);
|
||||||
extern TTF_Font* load_font(const char* file, int size);
|
extern TTF_Font* load_font(const char* file, int size);
|
||||||
extern SDL_Texture* get_texture(const char* file);
|
extern SDL_Texture* get_texture(const char* file);
|
||||||
|
|
|
@ -17,7 +17,7 @@ static uint32_t _mouse_left_seconds = 0;
|
||||||
static float _scroll_delta = 0;
|
static float _scroll_delta = 0;
|
||||||
|
|
||||||
void add_key_listener(SDL_Scancode negative, SDL_Scancode positive,
|
void add_key_listener(SDL_Scancode negative, SDL_Scancode positive,
|
||||||
input_axis_delegate_t delegate) {
|
input_axis_fn delegate) {
|
||||||
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
||||||
g_key_listeners_endptr->type = INPUT_LISTENER_AXIS;
|
g_key_listeners_endptr->type = INPUT_LISTENER_AXIS;
|
||||||
g_key_listeners_endptr->axis.delegate = delegate;
|
g_key_listeners_endptr->axis.delegate = delegate;
|
||||||
|
@ -28,14 +28,14 @@ void add_key_listener(SDL_Scancode negative, SDL_Scancode positive,
|
||||||
++g_key_listeners_endptr;
|
++g_key_listeners_endptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_mouse_listener(input_mouse_delegate_t delegate) {
|
void add_mouse_listener(input_mouse_fn delegate) {
|
||||||
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
||||||
g_key_listeners_endptr->type = INPUT_LISTENER_MOUSE;
|
g_key_listeners_endptr->type = INPUT_LISTENER_MOUSE;
|
||||||
g_key_listeners_endptr->mouse.delegate = delegate;
|
g_key_listeners_endptr->mouse.delegate = delegate;
|
||||||
++g_key_listeners_endptr;
|
++g_key_listeners_endptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_mouse_button_listener(uint32_t button, input_button_delegate_t delegate) {
|
void add_mouse_button_listener(uint32_t button, input_button_fn delegate) {
|
||||||
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
||||||
g_key_listeners_endptr->type = INPUT_LISTENER_BUTTON;
|
g_key_listeners_endptr->type = INPUT_LISTENER_BUTTON;
|
||||||
g_key_listeners_endptr->button.delegate = delegate;
|
g_key_listeners_endptr->button.delegate = delegate;
|
||||||
|
@ -44,7 +44,7 @@ void add_mouse_button_listener(uint32_t button, input_button_delegate_t delegate
|
||||||
++g_key_listeners_endptr;
|
++g_key_listeners_endptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_scroll_listener(input_scroll_delegate_t delegate) {
|
void add_scroll_listener(input_scroll_fn delegate) {
|
||||||
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
memset(g_key_listeners_endptr, 0x0, sizeof(input_listener_t));
|
||||||
g_key_listeners_endptr->type = INPUT_LISTENER_SCROLL;
|
g_key_listeners_endptr->type = INPUT_LISTENER_SCROLL;
|
||||||
g_key_listeners_endptr->scroll.delegate = delegate;
|
g_key_listeners_endptr->scroll.delegate = delegate;
|
||||||
|
|
|
@ -7,11 +7,6 @@ extern "C" {
|
||||||
|
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
|
|
||||||
typedef void(*input_axis_delegate_t)(int value);
|
|
||||||
typedef void(*input_mouse_delegate_t)(float dx, float dy);
|
|
||||||
typedef void(*input_button_delegate_t)(int down);
|
|
||||||
typedef void(*input_scroll_delegate_t)(float delta);
|
|
||||||
|
|
||||||
enum INPUT_LISTENER_TYPE_T {
|
enum INPUT_LISTENER_TYPE_T {
|
||||||
INPUT_LISTENER_MOUSE,
|
INPUT_LISTENER_MOUSE,
|
||||||
INPUT_LISTENER_AXIS,
|
INPUT_LISTENER_AXIS,
|
||||||
|
@ -40,23 +35,28 @@ typedef struct input_listener_t {
|
||||||
} scroll;
|
} scroll;
|
||||||
};
|
};
|
||||||
} input_listener_t;
|
} 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);
|
||||||
|
typedef void(*input_scroll_fn)(float delta);
|
||||||
|
|
||||||
extern const Uint8* g_key_states;
|
extern const Uint8* g_key_states;
|
||||||
|
|
||||||
extern void add_key_listener(SDL_Scancode negative, SDL_Scancode positive,
|
extern void add_key_listener(SDL_Scancode negative, SDL_Scancode positive,
|
||||||
input_axis_delegate_t delegate);
|
input_axis_fn delegate);
|
||||||
extern void add_mouse_listener(input_mouse_delegate_t delegate);
|
extern void add_mouse_listener(input_mouse_fn delegate);
|
||||||
extern void add_mouse_button_listener(uint32_t button, input_button_delegate_t delegate);
|
extern void add_mouse_button_listener(uint32_t button, input_button_fn delegate);
|
||||||
extern void add_scroll_listener(input_scroll_delegate_t delegate);
|
extern void add_scroll_listener(input_scroll_fn delegate);
|
||||||
extern void remove_listener_at(size_t index);
|
|
||||||
extern void mouse_screen_position(float* ox, float* oy);
|
extern void mouse_screen_position(float* ox, float* oy);
|
||||||
extern void mouse_world_position(float* ox, float* oy);
|
extern void mouse_world_position(float* ox, float* oy);
|
||||||
|
|
||||||
|
extern int input_get_keydown(SDL_Scancode scancode);
|
||||||
|
extern int input_get_mousedown(int mousebtn);
|
||||||
|
|
||||||
extern void input_init();
|
extern void input_init();
|
||||||
extern void update_input();
|
extern void update_input();
|
||||||
extern void input_notify_event(SDL_Event event);
|
extern void input_notify_event(SDL_Event event);
|
||||||
extern int input_get_keydown(SDL_Scancode scancode);
|
|
||||||
extern int input_get_mousedown(int mousebtn);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue