sdlGetGamepadButton function

bool sdlGetGamepadButton(
  1. Pointer<SdlGamepad> gamepad,
  2. int button
)

Get the current state of a button on a gamepad.

\param gamepad a gamepad. \param button a button index (one of the SDL_GamepadButton values). \returns true if the button is pressed, false otherwise.

\since This function is available since SDL 3.1.3.

\sa SDL_GamepadHasButton \sa SDL_GetGamepadAxis

extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)

Implementation

bool sdlGetGamepadButton(Pointer<SdlGamepad> gamepad, int button) {
  final sdlGetGamepadButtonLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlGamepad> gamepad, Int32 button),
      int Function(
          Pointer<SdlGamepad> gamepad, int button)>('SDL_GetGamepadButton');
  return sdlGetGamepadButtonLookupFunction(gamepad, button) == 1;
}