SDL_hid_init(3)

✨ SDL_hid_init ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_hid_init(3) and honestly? she's a little queen. πŸŽ€


🌸 NAME 🌸

SDL_hid_init β€” initialize the HIDAPI library. that's it. that's the job. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_hidapi.h>

int SDL_hid_init(void);

no arguments, no drama, just vibes. ✨


πŸ’– DESCRIPTION πŸ’–

so this function initializes the HIDAPI library. that's the whole thing. 🫢

but here's the tea: calling it is not strictly necessary, because it's gonna get called automatically by SDL_hid_enumerate() and by any of the SDL_hid_open_*() functions if it turns out they need it. so she's like, self-sufficient. independent. main character energy. πŸ‘‘

however β€” and this is the part you actually need to remember β€” you should still call this function at the beginning of execution if there's a chance that HIDAPI handles could get opened by different threads simultaneously. like, if your threads are all reaching for handles at the same time with no adult supervision? yeah, call it up front. no cap. 😭

⚠️ also every single call to this function needs a matching call to SDL_hid_exit(). they're a package deal, fr fr. don't leave her hanging. πŸ’€

🌈 RETURN VALUE 🌈

  • returns 0 on success ✨
  • returns a negative error code on failure 😭 β€” and in that case you should call SDL_GetError() for more info, she'll tell you what went wrong. πŸ“

⭐ AVAILABILITY ⭐

this function has been available since SDL 3.2.0. she's been here. she's established. respect it. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_hid_exit(3) β€” the other half of the duo, go read her too 🧚

Simple Directmedia Layer made this one, it's from SDL 3.4.18, and that's the whole SDL_hid_init(3) page β€” slay, stay hydrated, and don't forget your matching SDL_hid_exit() bestie πŸ’–βœ¨πŸŒΈπŸ¦‹πŸŽ€

πŸ“¦ where this page comes from