From 1d50fc26b44b7a06505f2f443bf838e5665c6a9b Mon Sep 17 00:00:00 2001 From: Nintorch <92302738+Nintorch@users.noreply.github.com> Date: Fri, 3 Oct 2025 11:35:09 +0500 Subject: [PATCH] Fix invalid reported joypad presses (cherry picked from commit 4a3bf069a6466cec127cff03b3d5be5b98b50caa) --- drivers/sdl/joypad_sdl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/sdl/joypad_sdl.cpp b/drivers/sdl/joypad_sdl.cpp index 65be32f6820..85e43be7554 100644 --- a/drivers/sdl/joypad_sdl.cpp +++ b/drivers/sdl/joypad_sdl.cpp @@ -234,6 +234,12 @@ void JoypadSDL::process_events() { case SDL_EVENT_JOYSTICK_BUTTON_DOWN: SKIP_EVENT_FOR_GAMEPAD; + // Some devices report pressing buttons with indices like 232+, 241+, etc. that are not valid, + // so we ignore them here. + if (sdl_event.jbutton.button >= (int)JoyButton::MAX) { + continue; + } + Input::get_singleton()->joy_button( joy_id, static_cast(sdl_event.jbutton.button), // Godot button constants are intentionally the same as SDL's, so we can just straight up use them