sdlGetGamepadNameForId function
Get the implementation dependent name of a gamepad.
This can be called before any gamepads are opened.
\param instance_id the joystick instance ID. \returns the name of the selected gamepad. 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_GetGamepadName \sa SDL_GetGamepads
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id)
Implementation
String? sdlGetGamepadNameForId(int instanceId) {
final sdlGetGamepadNameForIdLookupFunction = libSdl3.lookupFunction<
Pointer<Utf8> Function(Uint32 instanceId),
Pointer<Utf8> Function(int instanceId)>('SDL_GetGamepadNameForID');
final result = sdlGetGamepadNameForIdLookupFunction(instanceId);
if (result == nullptr) {
return null;
}
return result.toDartString();
}