sdlSetGamepadMapping function
Set the current mapping of a joystick or gamepad.
Details about mappings are discussed with SDL_AddGamepadMapping().
\param instance_id the joystick instance ID. \param mapping the mapping to use for this device, or NULL to clear the mapping. \returns true on success or false on failure; call SDL_GetError() for more information.
\since This function is available since SDL 3.1.3.
\sa SDL_AddGamepadMapping \sa SDL_GetGamepadMapping
extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping)
Implementation
bool sdlSetGamepadMapping(int instanceId, String? mapping) {
final sdlSetGamepadMappingLookupFunction = libSdl3.lookupFunction<
Uint8 Function(Uint32 instanceId, Pointer<Utf8> mapping),
int Function(
int instanceId, Pointer<Utf8> mapping)>('SDL_SetGamepadMapping');
final mappingPointer = mapping != null ? mapping.toNativeUtf8() : nullptr;
final result =
sdlSetGamepadMappingLookupFunction(instanceId, mappingPointer) == 1;
calloc.free(mappingPointer);
return result;
}