diff render_sdl.c @ 2695:84771c6e31c5

Allow keybinds to still fire for debug windows with no Nuklear UI
author Michael Pavone <pavone@retrodev.com>
date Thu, 19 Jun 2025 20:34:00 -0700
parents 46dba737b931
children
line wrap: on
line diff
--- a/render_sdl.c	Thu Jun 19 20:24:14 2025 -0700
+++ b/render_sdl.c	Thu Jun 19 20:34:00 2025 -0700
@@ -958,19 +958,30 @@
 	return ui * ui_scale_y + 0.5f;
 }
 
+static uint8_t has_event_handler(SDL_Window *win)
+{
+	for (uint8_t i = 0; i < num_extras; i++)
+	{
+		if (extras[i].win == win) {
+			return extras[i].on_event != NULL;
+		}
+	}
+	return 0;
+}
+
 static int32_t handle_event(SDL_Event *event)
 {
 	SDL_Window *event_win = NULL;
 	switch (event->type) {
 	case SDL_KEYDOWN:
 		event_win = SDL_GetWindowFromID(event->key.windowID);
-		if (event_win == main_window) {
+		if (event_win == main_window || !has_event_handler(event_win)) {
 			handle_keydown(event->key.keysym.sym, scancode_map[event->key.keysym.scancode]);
 		}
 		break;
 	case SDL_KEYUP:
 		event_win = SDL_GetWindowFromID(event->key.windowID);
-		if (event_win == main_window) {
+		if (event_win == main_window || !has_event_handler(event_win)) {
 			handle_keyup(event->key.keysym.sym, scancode_map[event->key.keysym.scancode]);
 		}
 		break;