sdlGetJoystickName function

String? sdlGetJoystickName(
  1. Pointer<SdlJoystick> joystick
)

Get the implementation dependent name of a joystick.

\param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). \returns the name of the selected joystick. If no name can be found, this function returns NULL; call SDL_GetError() for more information.

\since This function is available since SDL 3.1.3.

\sa SDL_GetJoystickNameForID

extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick)

Implementation

String? sdlGetJoystickName(Pointer<SdlJoystick> joystick) {
  final sdlGetJoystickNameLookupFunction = libSdl3.lookupFunction<
      Pointer<Utf8> Function(Pointer<SdlJoystick> joystick),
      Pointer<Utf8> Function(
          Pointer<SdlJoystick> joystick)>('SDL_GetJoystickName');
  final result = sdlGetJoystickNameLookupFunction(joystick);
  if (result == nullptr) {
    return null;
  }
  return result.toDartString();
}