sdlGetJoystickPlayerIndex function joystick

int sdlGetJoystickPlayerIndex(
  1. Pointer<SdlJoystick> joystick
)

Get the player index of an opened joystick.

For XInput controllers this returns the XInput user index. Many joysticks will not be able to supply this information.

\param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). \returns the player index, or -1 if it's not available.

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

\since This function is available since SDL 3.2.0.

\sa SDL_SetJoystickPlayerIndex

extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick)

Implementation

int sdlGetJoystickPlayerIndex(Pointer<SdlJoystick> joystick) {
  final sdlGetJoystickPlayerIndexLookupFunction = _libSdl
      .lookupFunction<
        Int32 Function(Pointer<SdlJoystick> joystick),
        int Function(Pointer<SdlJoystick> joystick)
      >('SDL_GetJoystickPlayerIndex');
  return sdlGetJoystickPlayerIndexLookupFunction(joystick);
}