What is the relationship between SDL_Joystick
and SDL_GameController
? These are the only things I know of right now:
SDL_GameController
and related functions are all part of a new API introduced in SDL2.SDL_GameController
and related functions are built on top of the existingSDL_Joystick
API.- (Working Draft) You can obtain an instance of
SDL_Joystick
by calling on the functionSDL_GameControllerGetJoystick()
and passing in an instance ofSDL_GameController
. - (Working Draft) You can obtain an instance of
SDL_GameController
first by calling onSDL_JoystickInstanceID()
and passing in an instance ofSDL_Joystick
, then pass in theSDL_JoystickID
toSDL_GameControllerFromInstanceID
.
Even though SDL_Joystick
and SDL_GameController
are both interchangeable, it seems like SDL_GameController
is here to replace and slowly succeed the SDL_Joystick
.
Reason is, when polling for SDL_Event
, the SDL_Event
instance contains both the SDL_Event::jbutton
and SDL_Event::cbutton
structs, representing the SDL_Joystick
buttons and SDL_GameController
buttons, respectively. I guess I can use either one, or both, button events for the player controls.
I could be wrong here.
I would like to ask:
SDL_Joystick
is the parent class ofSDL_GameController
? – ApologeteIf you use SDL_GameController in a game instead SDL_Joystick, you'll have the same button mapping on every device you port your game on.
Is this true? – Apologete