SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS(3)

โœจ SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS โœจ

okay bestie gather round, because this one is a hint in the SDL3 family, living its best life in the SDL3 functions manual, and its whole personality is deciding whether SDL_hid_enumerate() goes snooping through every HID device on the system or just chills with the controllers. ๐ŸŽฎ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <SDL3/SDL_hints.h>

#define SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS "SDL_HIDAPI_ENUMERATE_ONLY_CONTROLLERS"

like yes, it's a #define, it's a string, it's literally that exact string, no notes. ๐Ÿซถ


๐Ÿ’– DESCRIPTION ๐Ÿ’–

so the way this works is you set the variable to one of these two values and SDL does the thing:

  • "0" โ€” SDL_hid_enumerate() will enumerate all HID devices. all of them. the whole roster. ๐ŸŒˆ
  • "1" โ€” SDL_hid_enumerate() will only enumerate controllers. (default) ๐Ÿ‘‘

and here's the tea on why "1" is the default, because it's not just a vibe, it's self-preservation: by default SDL will only enumerate controllers, to reduce risk of hanging or crashing on devices with bad drivers, and to avoid macOS keyboard capture permission prompts. so yeah, defaulting to controllers-only is lowkey a safety feature and highkey a "please don't let a cursed driver take down the whole app" feature. ๐Ÿ˜ญ

not me being dramatic, but the bad-driver hang/crash risk is real and the macOS permission prompts are real, so if you flip this to "0" you're doing it on purpose, periodt.

also good news: this hint can be set anytime. โฐโœจ no weird timing rules, no "only before init" nonsense, set it whenever your heart desires.


๐Ÿฆ‹ AVAILABILITY ๐Ÿฆ‹

this hint has been available since SDL 3.2.0. so if you're on anything older, bestie, it's not there yet โ€” go update. ๐Ÿงš


๐ŸŽ€ a lil sign-off ๐ŸŽ€

that's the whole page, mwah ๐Ÿ’– โ€” brought to you by Simple Directmedia Layer, running on SDL 3.4.18, and you can find it hanging out in the SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS(3) section of your friendly neighbourhood manual. go forth and enumerate responsibly. ๐Ÿ‘‘๐ŸŒธ

๐Ÿ“ฆ where this page comes from