blob: ad56aa97ba64dc5fb84ec5a65b49a766ed5f569c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "saffron_api.h"
#include <saffron.h>
#include <SDL3/SDL.h>
#include <stdio.h>
bool hook_callback(SDL_Event* event) {
printf("got an event!\n");
return false; // we didnt consume the event
}
bool hook_callback_2(SDL_Event* event) {
printf("second hook got an event!\n");
return true; // we consumed the event
}
bool hook_callback_3(SDL_Event* event) {
printf("you should never see this, a hook with higher priority (hook_callback_2) should have consumed this event\n");
return false;
}
int main() {
saffron_init();
SaffronWindow* window = saffron_window_new("Saffron hooks test", 800, 600);
saffron_hook_sdl_all_events(window, hook_callback, 999);
saffron_hook_sdl_all_events(window, hook_callback_2, 2);
saffron_hook_sdl_all_events(window, hook_callback_3, 1);
saffron_window_main(window);
saffron_window_free(window);
saffron_quit();
return 0;
}
|