sdlGetGamepadButton function gamepad

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.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.2.0.

\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 = _libSdl
      .lookupFunction<
        Uint8 Function(Pointer<SdlGamepad> gamepad, Int32 button),
        int Function(Pointer<SdlGamepad> gamepad, int button)
      >('SDL_GetGamepadButton');
  return sdlGetGamepadButtonLookupFunction(gamepad, button) == 1;
}