diff options
Diffstat (limited to 'src/saffron_event_hooks.c')
| -rw-r--r-- | src/saffron_event_hooks.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/saffron_event_hooks.c b/src/saffron_event_hooks.c new file mode 100644 index 0000000..d3a2c43 --- /dev/null +++ b/src/saffron_event_hooks.c @@ -0,0 +1,19 @@ +#include "saffron_api.h" +#include <SDL3/SDL.h> +#include <saffron.h> +#include <saffron_event_hooks.h> + +void saffron_hook_sdl_all_events(SaffronWindow* window, bool (*callback)(SDL_Event* event), int priority) { + window->hooks[window->hook_count].callback = callback; + window->hooks[window->hook_count].priority = priority; + window->hook_count++; + for (int i = 0; i < window->hook_count; i++) { + for (int j = i + 1; j < window->hook_count; j++) { + if (window->hooks[j].priority > window->hooks[i].priority) { + SfInternalEventHook tmp = window->hooks[i]; + window->hooks[i] = window->hooks[j]; + window->hooks[j] = tmp; + } + } + } +} |
