renamed function delegates ending with _t to end with _fn

pull/14/head
Sara 2023-07-16 00:38:06 +02:00
parent 6085dbaed0
commit f0d76713c2
4 changed files with 21 additions and 21 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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
}