Skip to content

Commit fda0e83

Browse files
committed
Merge pull request godotengine#111192 from Nintorch/fix-joy-weird-presses
Fix invalid reported joypad presses
2 parents 7abe27b + 4a3bf06 commit fda0e83

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/sdl/joypad_sdl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ void JoypadSDL::process_events() {
232232
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
233233
SKIP_EVENT_FOR_GAMEPAD;
234234

235+
// Some devices report pressing buttons with indices like 232+, 241+, etc. that are not valid,
236+
// so we ignore them here.
237+
if (sdl_event.jbutton.button >= (int)JoyButton::MAX) {
238+
continue;
239+
}
240+
235241
Input::get_singleton()->joy_button(
236242
joy_id,
237243
static_cast<JoyButton>(sdl_event.jbutton.button), // Godot button constants are intentionally the same as SDL's, so we can just straight up use them

0 commit comments

Comments
 (0)