The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
[Linux][SDL2.0.4] - Bug ? or normal behavior ?
videca


Joined: 04 Feb 2017
Posts: 2
Hello,

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 Shocked 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 ? Rolling Eyes 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 ?

Thanks.