libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.53k stars 1.77k forks source link

SDL_NumJoysticks() is returning 2 joysticks when only 1 is plugged in #10451

Open ishhuss opened 1 month ago

ishhuss commented 1 month ago

Hello, when using only one controller, SDL is recognizing two controllers. This is causing issues when reading inputs as it is reading different values from two different addresses. I am using a linux machine. Is SDL maybe reading by both by-id and by-path?

RandyGaul commented 1 week ago

I noticed a similar bug where SDL would report two events and two unique SDL_JoystickID's for plugging in a single controller.

Repro steps:

For some reason this bug doesn't seem to appear if more than one controller is plugged in. It only occurs when going from 1, to 0, then back to 1 controller. It's also sporadic and happens about 75% of the time, where 25% of the time only one SDL_EVENT_JOYSTICK_ADDED would get produced.

slouken commented 1 week ago

I noticed a similar bug where SDL would report two events and two unique SDL_JoystickID's for plugging in a single controller.

Repro steps:

  • Start the application with a single XBOX controller (I was able to reproduce this with 360 + xbox one controllers)
  • Unplug the controller
  • Plug the controller back in

For some reason this bug doesn't seem to appear if more than one controller is plugged in. It only occurs when going from 1, to 0, then back to 1 controller. It's also sporadic and happens about 75% of the time, where 25% of the time only one SDL_EVENT_JOYSTICK_ADDED would get produced.

What are the GUIDs of the joysticks?

RandyGaul commented 1 week ago

SDL_GUID 03004d6e5e040000ea02000000007701 for SDL_JoystickID 4 Joypad 1 connected. SDL_GUID 0300938d5e040000ff02000000007200 for SDL_JoystickID 5 Joypad 2 connected.