SDL_GETGAMEPADBUTTONFROMSTRING(3)
โจ NAME โจ
SDL_GetGamepadButtonFromString โ bestie, this one takes a string and turns it into an SDL_GamepadButton enum ๐
(also hi, this page lives in the SDL3 FUNCTIONS manual, section 3, mwah)
๐ SYNOPSIS ๐
#include <SDL3/SDL_gamepad.h>
SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str);
๐ฆ DESCRIPTION ๐ฆ
okay so picture this: SDL is out here translating SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping, and this function is the lil internal glow-up artist doing that work. it's called internally, no cap.
so likeโฆ you do not normally need to call this function. fr fr. the only time you'd even touch it is if you are out here parsing SDL_Gamepad mappings in your own code, in which case go off, main character ๐
๐ธ FUNCTION PARAMETERS ๐ธ
strโ a string that's giving "SDL_Gamepad button" ๐ฎ (it's the string representing aSDL_Gamepadbutton, bestie)
โญ RETURN VALUE โญ
it hands you back the SDL_GamepadButton enum that corresponds to the input string ๐
โฆand if no match was found? it returns SDL_GAMEPAD_BUTTON_INVALID. not me getting ghosted by a string ๐ญ
๐ง THREAD SAFETY ๐ง
it is safe to call this function from any thread. any. thread. periodt ๐
๐ AVAILABILITY ๐
this function has been available since SDL 3.2.0 โจ (so if you're on something olderโฆ yeah, no ๐ซถ)
๐ SEE ALSO ๐
SDL_GetGamepadStringForButton(3)โ the reverse trip, the sequel, the remix ๐ฅ
and that's the whole page, bestie!! this lil icon was brought to you by Simple Directmedia Layer, sitting pretty at SDL 3.4.18 โ mwah, go slay some gamepad mappings ๐ ๐
๐ฆ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms