SDL_hid_enumerate(3)

πŸ’– SDL_hid_enumerate(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the internet, where today's main character is SDL_hid_enumerate β€” the girl who goes out and finds every HID device for you. no cap. πŸŽ€


✨ NAME ✨

SDL_hid_enumerate β€” Enumerate the HID Devices. that's it, that's the job. she makes a list and she checks it twice. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_hidapi.h>

SDL_hid_device_info * SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id);

🌸 DESCRIPTION 🌸

so here's the vibe: this function hands you back a linked list of every HID device chilling on the system that matches vendor_id and product_id. it's giving roll call. πŸ“‹

  • set vendor_id to 0 and literally any vendor matches β€” she's not picky, she's generous.
  • set product_id to 0 and any product matches, same energy.
  • set both vendor_id and product_id to 0 and you get ALL the HID devices. the whole party. every single one. πŸŽ‰
✨ heads up bestie: by default SDL will only enumerate controllers. and honestly? that's on purpose β€” it keeps you from hanging or crashing on bad drivers. but if you're feeling brave, SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS can be set to "0" to enumerate all HID devices. you do you. πŸ’€

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • vendor_id β€” the Vendor ID (VID) of the types of device to open, or 0 to match any vendor. πŸ’–
  • product_id β€” the Product ID (PID) of the types of device to open, or 0 to match any product. 🫢

⭐ RETURN VALUE ⭐

she returns a pointer to a linked list of type SDL_hid_device_info β€” all the tea about the HID devices attached to the system. β˜•

or NULL in the case of failure. 😭 (not the slay we wanted.)

🚨 and listen: you must free this linked list by calling SDL_hid_free_enumeration(). don't just leave her hanging, that's a memory leak and it's not cute. πŸ™ˆ

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on an older SDL, she does not exist yet. sorry bestie. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, babe. every flag, every default, every warning, all of it. ate and left no crumbs. πŸ’…βœ¨

β€” with love from the <b>Simple Directmedia Layer</b> girlies, <b>SDL 3.4.18</b>, dated <b>SDL_hid_enumerate(3)</b> πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from