Skip to content

Commit 4a3bf06

Browse files
committed
Fix invalid reported joypad presses
1 parent 7fbc3a5 commit 4a3bf06

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
@@ -228,6 +228,12 @@ void JoypadSDL::process_events() {
228228
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
229229
SKIP_EVENT_FOR_GAMEPAD;
230230

231+
// Some devices report pressing buttons with indices like 232+, 241+, etc. that are not valid,
232+
// so we ignore them here.
233+
if (sdl_event.jbutton.button >= (int)JoyButton::MAX) {
234+
continue;
235+
}
236+
231237
Input::get_singleton()->joy_button(
232238
joy_id,
233239
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)