summaryrefslogtreecommitdiff
path: root/src/main/engine/engine.c
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-18 11:35:29 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-18 11:35:29 +0200
commit77a456b65b3d21213db9a5c88076f511b753e07c (patch)
tree1830d08ee89a05a94e7a690d86425cd232d2cd6a /src/main/engine/engine.c
parent4b4f73e7e3d55b8217bbbc2b51c0e147614be192 (diff)
downloadtris-77a456b65b3d21213db9a5c88076f511b753e07c.tar.gz
tris-77a456b65b3d21213db9a5c88076f511b753e07c.zip
Add the mouse button pressed in the graphics engine
Diffstat (limited to 'src/main/engine/engine.c')
-rw-r--r--src/main/engine/engine.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c
index e0da00c..e619dc7 100644
--- a/src/main/engine/engine.c
+++ b/src/main/engine/engine.c
@@ -46,6 +46,7 @@ static int frames;
static time_t end;
void (*dispatch_ui_event)(int);
+void (*on_mouse_pressed)();
void
engine_init(int w, int h)
@@ -108,6 +109,12 @@ engine_loop(void (*draw_frame)())
ui_loop();
}
+void
+engine_on_mouse_pressed(void (*event)())
+{
+ on_mouse_pressed = event;
+}
+
static void
engine_dispatch_ui_events(int type)
{
@@ -116,6 +123,9 @@ engine_dispatch_ui_events(int type)
#ifdef X11
case ButtonPress:
event_type = ENGINE_MOUSE_PRESSED;
+ if (on_mouse_pressed != NULL) {
+ on_mouse_pressed();
+ }
break;
#endif
default: