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?
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.