# HG changeset patch # User Michael Pavone # Date 1742977024 25200 # Node ID 69c1093f87263e7710e9a2ee2c97e224c146572f # Parent 844ca8377b45519895c853b19008ea2ecaaab172 Ignore devices with 3-axes and no buttons since these are generally not gamepads/joysticks but accelerometers or gyros diff -r 844ca8377b45 -r 69c1093f8726 render_sdl.c --- a/render_sdl.c Wed Mar 26 01:15:52 2025 -0700 +++ b/render_sdl.c Wed Mar 26 01:17:04 2025 -0700 @@ -946,24 +946,29 @@ case SDL_JOYAXISMOTION: handle_joy_axis(lock_joystick_index(render_find_joystick_index(event->jaxis.which), -1), event->jaxis.axis, event->jaxis.value); break; - case SDL_JOYDEVICEADDED: - if (event->jdevice.which < MAX_JOYSTICKS) { - int index = lowest_unused_joystick_index(); - if (index >= 0) { - SDL_Joystick * joy = joysticks[index] = SDL_JoystickOpen(event->jdevice.which); - joystick_sdl_index[index] = event->jdevice.which; - joystick_index_locked[index] = 0; - if (gc_events_enabled) { - controllers[index] = SDL_GameControllerOpen(event->jdevice.which); - } - if (joy) { - debug_message("Joystick %d added: %s\n", index, SDL_JoystickName(joy)); - debug_message("\tNum Axes: %d\n\tNum Buttons: %d\n\tNum Hats: %d\n", SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy), SDL_JoystickNumHats(joy)); - handle_joy_added(index); - } + case SDL_JOYDEVICEADDED: { + int index = lowest_unused_joystick_index(); + if (index >= 0) { + SDL_Joystick * joy = SDL_JoystickOpen(event->jdevice.which); + if (SDL_JoystickNumAxes(joy) == 3 && SDL_JoystickNumButtons(joy) == 0) { + //probably just an acclerometer or gyro + SDL_JoystickClose(joy); + break; + } + joysticks[index] = joy; + joystick_sdl_index[index] = event->jdevice.which; + joystick_index_locked[index] = 0; + if (gc_events_enabled) { + controllers[index] = SDL_GameControllerOpen(event->jdevice.which); + } + if (joy) { + debug_message("Joystick %d added: %s\n", index, SDL_JoystickName(joy)); + debug_message("\tNum Axes: %d\n\tNum Buttons: %d\n\tNum Hats: %d\n", SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy), SDL_JoystickNumHats(joy)); + handle_joy_added(index); } } break; + } case SDL_JOYDEVICEREMOVED: { int index = render_find_joystick_index(event->jdevice.which); if (index >= 0) {