I'm trying to handle Joysticks with SDL2, the actual version I'm using is 2.0.4 (from the distrib repo) on linux 4.4.0 (LinuxMint 18 )
I'm facing what seems to me, a stranger behavior :
I have a loop with SDL_WaitEvent(&event);
I have only one joystick (Logitech Extreme 3D Pro) which I'm connecting and disconnecting, again and again
When SDL_JOYDEVICEADDED appears 'event.jdevice.which' is always 0, which seems logic given that I've only one joystick
But for every next events SDL_JOYBUTTONDOWN / SDL_JOYBUTTONUP / SDL_JOYAXISMOTION / SDL_JOYHATMOTION / SDL_JOYDEVICEREMOVED,
the 'event.j*.which' value is incrementing
each time I disconnect and reconnect the joystick
When SDL_JOYDEVICEADDED appears, I'm calling SDL_JoystickOpen()
when SDL_JOYDEVICEREMOVED appears, I'm calling SDL_JoystickClose();
- Did I miss something ?
Is there something else than SDL_JoystickClose() to call, to release all ressources of one joystick ?
- Do you have the same behavior ?
- Don't you think that the normal behavior should be : when a SDL_JOYDEVICEADDED 'event.jdevice.which' should match every other 'event.j*.which' of other events, and most of all, should not increment when disconnecting/connecting ?