Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In SDL2, when is SDL_JoystickInstanceID different than SDL_JoystickOpen(n)?

Tags:

sdl

In SDL2 the documentation suggests that the number used to open the joystick (between 0 and SDL_NumJoysticks()) can be different than the SDL_JoystickID which; used to reference the stick in events. When are these numbers different?

like image 958
joeforker Avatar asked Nov 20 '25 02:11

joeforker


1 Answers

Code should assume the numbers are always different (even if they happen to be the same sometimes). For example, when you get a SDL_ControllerAxisEvent, the which field should match the value of SDL_JoystickInstanceID() for one of your open joystick handles. You can use SDL_JoystickFromInstanceID() to get the joystick handle from the which value.

like image 151
jamieguinan Avatar answered Nov 22 '25 03:11

jamieguinan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!