sdlGetJoystickNameForId function joystick

String? sdlGetJoystickNameForId(
  1. int instanceId
)

Get the implementation dependent name of a joystick.

This can be called before any joysticks are opened.

\param instance_id the joystick instance ID. \returns the name of the selected joystick. If no name can be found, this function returns NULL; call SDL_GetError() for more information.

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

\since This function is available since SDL 3.2.0.

\sa SDL_GetJoystickName \sa SDL_GetJoysticks

extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID instance_id)

Implementation

String? sdlGetJoystickNameForId(int instanceId) {
  final sdlGetJoystickNameForIdLookupFunction = _libSdl
      .lookupFunction<
        Pointer<Utf8> Function(Uint32 instanceId),
        Pointer<Utf8> Function(int instanceId)
      >('SDL_GetJoystickNameForID');
  final result = sdlGetJoystickNameForIdLookupFunction(instanceId);
  if (result == nullptr) {
    return null;
  }
  return result.toDartString();
}