From 3a1b863dc6dc33f535a50cf183d670faed5e4aac Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 25 Sep 2026 00:01:56 -0600 Subject: [PATCH] Support mouse bindings for actions Fixes #2525 --- src/dusk/action_bindings.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index 2c97c2c894..b274e0e502 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -75,10 +75,16 @@ void updateActionBindings() { // If keyboard is active for this port u32 count = 0; if (PADGetKeyButtonBindings(port, &count) != nullptr) { - int numKeys = 0; - const bool* kbState = SDL_GetKeyboardState(&numKeys); - if (kbState[button]) { - actionPressData[port][static_cast(action)].pressedCurFrame = true; + if (button <= PAD_KEY_MOUSE_LEFT && button >= PAD_KEY_MOUSE_X2) { + const auto mouseButtons = SDL_GetMouseState(nullptr, nullptr); + actionPressData[port][static_cast(action)].pressedCurFrame = + (mouseButtons & SDL_BUTTON_MASK(-button - 1)) != 0; + } else { + int numKeys = 0; + const bool* kbState = SDL_GetKeyboardState(&numKeys); + if (button >= 0 && button < numKeys && kbState[button]) { + actionPressData[port][static_cast(action)].pressedCurFrame = true; + } } } else { // If controller is active