sdlGamepadHasButton function

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

Query whether a gamepad has a given button.

This merely reports whether the gamepad's mapping defined this button, as that is all the information SDL has about the physical device.

\param gamepad a gamepad. \param button a button enum value (an SDL_GamepadButton value). \returns true if the gamepad has this button, false otherwise.

\since This function is available since SDL 3.1.3.

\sa SDL_GamepadHasAxis

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

Implementation

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