SDL_GetGamepadProductForID(3)

πŸ’– SDL_GetGamepadProductForID πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual β€” yes the actual manual, we're being ✨official✨ today β€” and it's all about SDL_GetGamepadProductForID. Let me tell you everything, no cap.


✨ NAME ✨

SDL_GetGamepadProductForID</purpose> β€” get the USB product ID of a gamepad, if it's available. that's it, that's the whole vibe πŸŽ€


✨ SYNOPSIS ✨

so you gotta pull in the header first, obviously:

#include <SDL3/SDL_gamepad.h>

and then the function itself is giving:

Uint16 SDL_GetGamepadProductForID(SDL_JoystickID instance_id);

look at her. Uint16 returning, SDL_JoystickID taking. iconic.


✨ DESCRIPTION ✨

bestie the tea is that you can call this before any gamepads are even opened. like, you don't have to have anything connected-and-initialized, she'll still talk to you 🫢

and if the product ID isn't available, this function returns 0. so a 0 is the "idk her" answer. don't read into it, it's not a real product ID.


✨ FUNCTION PARAMETERS ✨

  • instance_id β€” the joystick instance ID. yeah, that one. the identifier thingy for the joystick you're asking about πŸ’…

✨ RETURN VALUE ✨

she returns the USB product ID of the gamepad you selected 🌸

and if you call her on an invalid index? she returns zero. not an error code, not a crash, just a lil 0. it's giving polite rejection 😭

✨ THREAD SAFETY ✨

it is safe to call this function from any thread. ANY thread. go off, queen πŸ‘‘ multithreaded and unbothered.


✨ AVAILABILITY ✨

this function has been available since SDL 3.2.0. so if you're on something older, sorry babe, she wasn't born yet πŸ™ˆ


✨ SEE ALSO ✨

the friend group:


k that's the whole page, mwah πŸ’‹ this lil love letter came to you from Simple Directmedia Layer, version SDL 3.4.18 β€” go read the real thing, ily, bye πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from