sdlGameControllerGetAxis function

int sdlGameControllerGetAxis(
  1. Pointer<SdlGameController> gamecontroller,
  2. int axis
)

Get the current state of an axis control on a game controller.

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.

\param gamecontroller a game controller \param axis an axis index (one of the SDL_GameControllerAxis values) \returns axis state (including 0) on success or 0 (also) on failure; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_GameControllerGetButton

extern DECLSPEC Sint16 SDLCALL SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)

Implementation

int sdlGameControllerGetAxis(
    Pointer<SdlGameController> gamecontroller, int axis) {
  final sdlGameControllerGetAxisLookupFunction = libSdl2.lookupFunction<
      Int16 Function(Pointer<SdlGameController> gamecontroller, Int32 axis),
      int Function(Pointer<SdlGameController> gamecontroller,
          int axis)>('SDL_GameControllerGetAxis');
  return sdlGameControllerGetAxisLookupFunction(gamecontroller, axis);
}