From f0d76713c28e10d773e98a0d41c4f681f6dce820 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 16 Jul 2023 00:38:06 +0200 Subject: [PATCH] renamed function delegates ending with _t to end with _fn --- src/corelib/assets.c | 2 +- src/corelib/assets.h | 8 ++++---- src/corelib/input.c | 8 ++++---- src/corelib/input.h | 24 ++++++++++++------------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/corelib/assets.c b/src/corelib/assets.c index 537f864..2c32ed2 100644 --- a/src/corelib/assets.c +++ b/src/corelib/assets.c @@ -18,7 +18,7 @@ static resource_t* insert_asset(const resource_t* resource) { return inserted; } -void add_arbitrary_asset(void* memory, deleter_t deleter) { +void add_arbitrary_asset(void* memory, deleter_fn deleter) { char name_buf[99]; // generate the name of the arbitrary block based on adresses sprintf(name_buf, "%p%p", memory, deleter); diff --git a/src/corelib/assets.h b/src/corelib/assets.h index 89360ef..85a727a 100644 --- a/src/corelib/assets.h +++ b/src/corelib/assets.h @@ -17,7 +17,7 @@ typedef enum resourcetype_t { RESOURCETYPE_MAX } resourcetype_t; -typedef void(*deleter_t)(void* target); +typedef void(*deleter_fn)(void* target); typedef struct resource_t { resourcetype_t type; @@ -31,13 +31,13 @@ typedef struct resource_t { } font; struct { void* memory; - deleter_t deleter; + deleter_fn deleter; } arbitrary_type; }; } resource_t; -extern void add_arbitrary_asset(void* memory, deleter_t deleter); -extern void add_arbitrary_asset_by_name(void* memory, deleter_t deleter, const char* name); +extern void add_arbitrary_asset(void* memory, deleter_fn deleter); +extern void add_arbitrary_asset_by_name(void* memory, deleter_fn deleter, const char* name); extern SDL_Texture* load_texture(const char* file); extern TTF_Font* load_font(const char* file, int size); extern SDL_Texture* get_texture(const char* file); diff --git a/src/corelib/input.c b/src/corelib/input.c index df5c666..fd1e771 100644 --- a/src/corelib/input.c +++ b/src/corelib/input.c @@ -17,7 +17,7 @@ static uint32_t _mouse_left_seconds = 0; static float _scroll_delta = 0; 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)); g_key_listeners_endptr->type = INPUT_LISTENER_AXIS; 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; } -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)); g_key_listeners_endptr->type = INPUT_LISTENER_MOUSE; g_key_listeners_endptr->mouse.delegate = delegate; ++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)); g_key_listeners_endptr->type = INPUT_LISTENER_BUTTON; 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; } -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)); g_key_listeners_endptr->type = INPUT_LISTENER_SCROLL; g_key_listeners_endptr->scroll.delegate = delegate; diff --git a/src/corelib/input.h b/src/corelib/input.h index 9be54d6..aadc16c 100644 --- a/src/corelib/input.h +++ b/src/corelib/input.h @@ -7,11 +7,6 @@ extern "C" { #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 { INPUT_LISTENER_MOUSE, INPUT_LISTENER_AXIS, @@ -40,23 +35,28 @@ typedef struct input_listener_t { } 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); +typedef void(*input_scroll_fn)(float delta); extern const Uint8* g_key_states; extern void add_key_listener(SDL_Scancode negative, SDL_Scancode positive, - input_axis_delegate_t delegate); -extern void add_mouse_listener(input_mouse_delegate_t delegate); -extern void add_mouse_button_listener(uint32_t button, input_button_delegate_t delegate); -extern void add_scroll_listener(input_scroll_delegate_t delegate); -extern void remove_listener_at(size_t index); + input_axis_fn delegate); +extern void add_mouse_listener(input_mouse_fn delegate); +extern void add_mouse_button_listener(uint32_t button, input_button_fn delegate); +extern void add_scroll_listener(input_scroll_fn delegate); + extern void mouse_screen_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 update_input(); 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 }