From 8cf381005ef147c22b3119febda085bed82239e4 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Tue, 29 Apr 2025 21:46:18 -0400 Subject: [PATCH] Handle controller up events even while binding inputs to avoid spamming the bind button --- src/game/input.cpp | 4 ++++ src/ui/ui_state.cpp | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/game/input.cpp b/src/game/input.cpp index 16775e7..f06a5b1 100644 --- a/src/game/input.cpp +++ b/src/game/input.cpp @@ -287,6 +287,10 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) { case SDL_EventType::SDL_DROPCOMPLETE: recompui::drop_files(DropState.files_dropped); break; + case SDL_EventType::SDL_CONTROLLERBUTTONUP: + // Always queue button up events to avoid missing them during binding. + recompui::queue_event(*event); + break; default: queue_if_enabled(event); break; diff --git a/src/ui/ui_state.cpp b/src/ui/ui_state.cpp index 32d2215..d1201fb 100644 --- a/src/ui/ui_state.cpp +++ b/src/ui/ui_state.cpp @@ -585,6 +585,15 @@ void draw_hook(RT64::RenderCommandList* command_list, RT64::RenderFramebuffer* s while (recompui::try_deque_event(cur_event)) { bool context_capturing_input = recompui::is_context_capturing_input(); bool context_capturing_mouse = recompui::is_context_capturing_mouse(); + + // Handle up button events even when input is disabled to avoid missing them during binding. + if (cur_event.type == SDL_EventType::SDL_CONTROLLERBUTTONUP) { + int sdl_key = cont_button_to_key(cur_event.cbutton); + if (sdl_key == latest_controller_key_pressed) { + latest_controller_key_pressed = SDLK_UNKNOWN; + } + } + if (!recomp::all_input_disabled()) { bool is_mouse_input = false; // Implement some additional behavior for specific events on top of what RmlUi normally does with them. @@ -630,13 +639,6 @@ void draw_hook(RT64::RenderCommandList* command_list, RT64::RenderFramebuffer* s cont_interacted = true; break; } - case SDL_EventType::SDL_CONTROLLERBUTTONUP: { - int sdl_key = cont_button_to_key(cur_event.cbutton); - if (sdl_key == latest_controller_key_pressed) { - latest_controller_key_pressed = SDLK_UNKNOWN; - } - break; - } case SDL_EventType::SDL_KEYDOWN: non_mouse_interacted = true; kb_interacted = true;