sdlAddGamepadMappingsFromFile function
Load a set of gamepad mappings from a file.
You can call this function several times, if needed, to load different database files.
If a new mapping is loaded for an already known gamepad GUID, the later version will overwrite the one currently loaded.
Any new mappings for already plugged in controllers will generate SDL_EVENT_GAMEPAD_ADDED events.
Mappings not belonging to the current platform or with no platform field specified will be ignored (i.e. mappings for Linux will be ignored in Windows, etc).
\param file the mappings file to load. \returns the number of mappings added or -1 on failure; 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.1.3.
\sa SDL_AddGamepadMapping \sa SDL_AddGamepadMappingsFromIO \sa SDL_GetGamepadMapping \sa SDL_GetGamepadMappingForGUID \sa SDL_HINT_GAMECONTROLLERCONFIG \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE \sa SDL_EVENT_GAMEPAD_ADDED
extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file)
Implementation
int sdlAddGamepadMappingsFromFile(String? file) {
final sdlAddGamepadMappingsFromFileLookupFunction = libSdl3.lookupFunction<
Int32 Function(Pointer<Utf8> file),
int Function(Pointer<Utf8> file)>('SDL_AddGamepadMappingsFromFile');
final filePointer = file != null ? file.toNativeUtf8() : nullptr;
final result = sdlAddGamepadMappingsFromFileLookupFunction(filePointer);
calloc.free(filePointer);
return result;
}