Hi all, I’d appreciate some help with this issue I’ve encountered in SDL 2.0.3 with game controller events. The issue is that after disconnecting and reconnecting a game controller, subsequent events generated for that controller have the wrong joystick index. This appears to be a bug, but it’s possible I’ve misunderstood something. Assistance would be appreciated.
Reproduction steps:
- Connect a game controller and start the application, or connect a game controller while running the application (both cases produce the same result).
- Handle the event SDL_CONTROLLERDEVICEADDED and note the joystick device index given by SDL_Event::cdevice.which.
- Generate input events by using the device (such as SDL_CONTROLLERBUTTONDOWN) and note the joystick device index given by (for example) SDL_Event::cbutton.which. Observe that the index matches the one noted in step 2.
- Disconnect the device.
- Handle the event SDL_CONTROLLERDEVICEREMOVED and note the joystick device index given by SDL_Event::cdevice.which.
- Reconnect the device.
- Handle the event SDL_CONTROLLERDEVICEADDED and note the joystick device index given by SDL_Event::cdevice.which.
- Generate input events by using the device (such as SDL_CONTROLLERBUTTONDOWN) and note the joystick device index given by (for example) SDL_Event::cbutton.which. Observe that the index does not match the one noted in step 7.
Thanks in advance.