GamepadsSDL 3.2
SDL_GetGamepadButton
Asks whether a gamepad button is held right now.
Signature
bool SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
How it works
The polling counterpart of the SDL_EVENT_GAMEPAD_BUTTON_DOWN / _UP events. Face buttons are named by POSITION, because the labels differ between brands: SOUTH is the bottom one (Xbox A, PlayStation Cross), EAST the right one (Xbox B, PlayStation Circle).
Parameters
gamepadSDL_Gamepad *
The gamepad.
Return value
true while the button is held.
Example
example.cpp
1if (SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_SOUTH) && player.onGround)
2 player.jump();