diff options
Diffstat (limited to 'src/main/engine')
-rw-r--r-- | src/main/engine/engine.c | 31 | ||||
-rw-r--r-- | src/main/engine/engine.h | 5 |
2 files changed, 36 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; +} diff --git a/src/main/engine/engine.h b/src/main/engine/engine.h index 691d8ec..fc4c5b9 100644 --- a/src/main/engine/engine.h +++ b/src/main/engine/engine.h @@ -20,8 +20,13 @@ #ifndef __ENGINE_H__ #define __ENGINE_H__ +enum EngineInput { + ENGINE_MOUSE_PRESSED = 4 +}; + void engine_init(int width, int height); void engine_draw_line(int x1, int y1, int x2, int y2); void engine_loop(void (*draw_frame)()); +void engine_input(void (*f_input)(int engine_input)); #endif /* __ENGINE_H__ */ |