SDL_ADDGAMEPADMAPPINGSFROMFILE(3)

πŸ’– SDL_AddGamepadMappingsFromFile(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_AddGamepadMappingsFromFile πŸŽ€βœ¨


✨ NAME ✨

SDL_AddGamepadMappingsFromFile β€” load a set of gamepad mappings from a file. yes literally that's the whole thing, she does one job and she ATE πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gamepad.h>

int SDL_AddGamepadMappingsFromFile(const char *file);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe. you can call this function several times if you need to β€” like, no limit, do your thing β€” to load different database files. she's not possessive, she's flexible πŸ’–

if a new mapping gets loaded for a gamepad GUID that's already known, the later version will overwrite the one currently loaded. last one in wins, no cap, that's just how she moves πŸ‘‘

any new mappings for controllers that are already plugged in will generate SDL_EVENT_GAMEPAD_ADDED events. so like, your controller gets noticed and the event says hi 🌈

and now the part where you gotta pay attention: mappings that don't belong to the current platform, or that have no platform field specified, get ignored. so if you're on Windows, all those Linux mappings? ignored. bye. not her problem πŸ™ˆ


πŸ“ FUNCTION PARAMETERS πŸ“

  • file β€” the mappings file to load. that's the one. that's the file. load it. 🫢

⭐ RETURN VALUE ⭐

returns the number of mappings added, or -1 on failure. and if it fails? call SDL_GetError() for more information, because she's not gonna explain herself, the error string will 😭


πŸ’œ THREAD SAFETY πŸ’œ

it is safe to call this function from any thread. go off, queen, parallelise 🧚


🌟 AVAILABILITY 🌟

this function is available since SDL 3.2.0. if you're on something older, sorry bestie, no mapping party for you πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie πŸ’– brought to you by Simple Directmedia Layer, SDL 3.4.18, and the SDL_AddGamepadMappingsFromFile(3) girlies. go forth and map those gamepads, iykyk πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from