diff options
author | 2025-05-17 14:10:39 +0200 | |
---|---|---|
committer | 2025-05-17 14:10:39 +0200 | |
commit | 268790307bde4859ac6ee5ac6c3d19ada9ed5a11 (patch) | |
tree | d0f0a0574cf33526668307bafc269a1a3d7df6e6 /src/main/engine/engine.c | |
parent | a3027cce6f5f7753147edc49aa4403a013338c3d (diff) | |
download | tris-268790307bde4859ac6ee5ac6c3d19ada9ed5a11.tar.gz tris-268790307bde4859ac6ee5ac6c3d19ada9ed5a11.zip |
Add the maanagement of mouse press event
Diffstat (limited to 'src/main/engine/engine.c')
-rw-r--r-- | src/main/engine/engine.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index e45909a..e0da00c 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -21,6 +21,11 @@ #include <time.h> #include <GL/gl.h> #include "../ui/ui.h" +#include "engine.h" + +#ifdef X11 +#include <X11/Xlib.h> +#endif #define RANGE_GL 2.0f @@ -40,6 +45,8 @@ static time_t start; static int frames; static time_t end; +void (*dispatch_ui_event)(int); + void engine_init(int w, int h) { @@ -100,3 +107,27 @@ engine_loop(void (*draw_frame)()) ui_loop(); } + +static void +engine_dispatch_ui_events(int type) +{ + int event_type = 0; + switch (type) { +#ifdef X11 + case ButtonPress: + event_type = ENGINE_MOUSE_PRESSED; + break; +#endif + default: + event_type = 0; + break; + } + dispatch_ui_event(event_type); +} + +void +engine_input(void (*f_input)(int engine_input)) +{ + ui_set_generic_listener(engine_dispatch_ui_events); + dispatch_ui_event = f_input; +} |