SDL_GetGamepadProperties(3)

πŸ’– SDL_GetGamepadProperties πŸ’–

okay bestie, welcome to SDL_GetGamepadProperties(3) β€” it's a real one from the SDL3 functions era, and it's lowkey the key to the whole "what can this controller even DO" mystery. let's get into it πŸŽ€


✨ NAME ✨

SDL_GetGamepadProperties β€” get the properties associated with an opened gamepad. that's it, that's the vibe. it's giving "let me peek at the receipts on this controller" πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_gamepad.h>

SDL_PropertiesID SDL_GetGamepadProperties(SDL_Gamepad *gamepad);

one header, one function, one SDL_Gamepad * going in, one SDL_PropertiesID coming out. periodt 🫢


✨ DESCRIPTION ✨

so here's the tea: these properties are shared with the underlying joystick object. meaning the gamepad isn't out here being mysterious on its own β€” it's riding on the joystick's whole situation. iykyk πŸ¦‹

the following read-only properties are provided by SDL. read-only!! you are NOT writing to these, you are just reading them and being grateful πŸ™ˆ

  • SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN β€” true if this gamepad has an LED that has adjustable brightness ✨
  • SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN β€” true if this gamepad has an LED that has adjustable color 🌈
  • SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN β€” true if this gamepad has a player LED πŸ‘‘
  • SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN β€” true if this gamepad has left/right rumble πŸ’€
  • SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN β€” true if this gamepad has simple trigger rumble πŸ”₯

five booleans, five little "does my controller have this" checks. main character energy fr fr πŸŽ€


🌸 FUNCTION PARAMETERS 🌸

  • gamepad β€” a gamepad identifier previously returned by SDL_OpenGamepad(). like, you gotta have opened it first bestie, we can't manifest properties out of thin air 😭

✨ RETURN VALUE ✨

returns a valid property ID on success, or 0 on failure. and if it's a fail? call SDL_GetError() for more information β€” she will tell you what went wrong, no cap πŸ’…


🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. yes you heard me. any thread. go wild, be free, thread responsibly 🌸


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older, that's a you problem bestie, upgrade πŸ¦‹


ngl, the whole point is simple: open a gamepad, ask it what it's capable of, and don't assume. assumptions are NOT cute here πŸ™ˆ

okay that's the whole page, slay πŸ’– written by the Simple Directmedia Layer crew, for SDL 3.4.18, and yeah it's the SDL_GetGamepadProperties(3) girlies' moment β€” go read your properties, you've earned it βœ¨πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from