SDL icon indicating copy to clipboard operation
SDL copied to clipboard

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

Open ishhuss opened this issue 1 year ago • 4 comments

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?

ishhuss avatar Aug 01 '24 17:08 ishhuss

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.

RandyGaul avatar Sep 17 '24 00:09 RandyGaul

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?

slouken avatar Sep 17 '24 03:09 slouken

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

RandyGaul avatar Sep 17 '24 03:09 RandyGaul

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

Can you debug and see why SDL_IsXInputDevice() is not returning true in SDL_windows_gaming_input.c?

slouken avatar Oct 06 '24 21:10 slouken