From 1a43012cca09e70ae2563842227b2d3dd425b9ab Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 1 Feb 2026 17:28:24 +0100 Subject: [PATCH] Add utility to push an SDL event with data --- app/src/events.c | 10 +++++++--- app/src/events.h | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/events.c b/app/src/events.c index ca7e4008..a9694ed6 100644 --- a/app/src/events.c +++ b/app/src/events.c @@ -6,9 +6,13 @@ #include "util/thread.h" bool -sc_push_event_impl(uint32_t type, const char *name) { - SDL_Event event; - event.type = type; +sc_push_event_impl(uint32_t type, void* ptr, const char *name) { + SDL_Event event = { + .user = { + .type = type, + .data1 = ptr, + } + }; bool ok = SDL_PushEvent(&event); if (!ok) { LOGE("Could not post %s event: %s", name, SDL_GetError()); diff --git a/app/src/events.h b/app/src/events.h index 8667bc57..7e2ad38c 100644 --- a/app/src/events.h +++ b/app/src/events.h @@ -22,9 +22,10 @@ enum { }; bool -sc_push_event_impl(uint32_t type, const char *name); +sc_push_event_impl(uint32_t type, void* ptr, const char *name); -#define sc_push_event(TYPE) sc_push_event_impl(TYPE, # TYPE) +#define sc_push_event(TYPE) sc_push_event_impl(TYPE, NULL, # TYPE) +#define sc_push_event_with_data(TYPE, PTR) sc_push_event_impl(TYPE, PTR, # TYPE) typedef void (*sc_runnable_fn)(void *userdata);