getAxis method

int getAxis(
  1. int axis
)

Get the current state of an axis control on a gamepad.

The axis indices start at index 0.

For thumbsticks, the state is a value ranging from -32768 (up/left) to 32767 (down/right).

Triggers range from 0 when released to 32767 when fully pressed, and never return a negative value. Note that this differs from the value reported by the lower-level SDL_GetJoystickAxis(), which normally uses the full range.

Note that for invalid gamepads or axes, this will return 0. Zero is also a valid value in normal operation; usually it means a centered axis.

\param gamepad a gamepad. \param axis an axis index (one of the SDL_GamepadAxis values). \returns axis state.

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

\since This function is available since SDL 3.2.0.

\sa SDL_GamepadHasAxis \sa SDL_GetGamepadButton

extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)

{@category gamepad}

Implementation

int getAxis(int axis) => sdlGetGamepadAxis(this, axis);