SDL_GetJoystickProductForID(3)

πŸ’– SDL_GetJoystickProductForID πŸ’–

okay bestie, so this one lives in the SDL3 FUNCTIONS manual, and it's genuinely one of the cutest little lookups in the whole joystick section. let's get into it πŸŽ€


✨ NAME ✨

SDL_GetJoystickProductForID β€” get the USB product ID of a joystick, if it's available. that's it, that's the whole job πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_joystick.h>

Uint16 SDL_GetJoystickProductForID(SDL_JoystickID instance_id);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: this function can be called before any joysticks are opened. like, you don't have to crack open a joystick first, it'll just tell you the deal. no cap.

and if the product ID isn't available? it just returns 0. no drama, no crash, just a lil zero. 🫢


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • instance_id β€” the joystick instance ID. that's the lil handle you use to say "yeah, that joystick, the one right there." ✨

πŸ‘‘ RETURN VALUE πŸ‘‘

it hands you back the USB product ID of the joystick you selected. slay.

but fr fr, if you call it with an invalid instance_id, you're getting 0 back. that's the vibe check failing, respectfully. πŸ’€


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. go off, queen β€” spawn all the threads you want, this one's chill. 🧚


⭐ AVAILABILITY ⭐

this function has been available since SDL 3.2.0. so if you're on something older than that... not me being the bearer of bad news 😭


πŸ”₯ SEE ALSO πŸ”₯

go read those too, they're iconic in their own right πŸ’–


lowkey important reminder: if you've got an invalid instance_id, 0 is what you get back β€” both when the product ID isn't available and when the ID itself is bogus. no guessing games, that's just how it is ✨

and that's the whole page, bestie!! written up by Simple Directmedia Layer, for SDL 3.4.18 β€” the manual name up top is SDL_GetJoystickProductForID(3), in case you forgot where you were. mwah, go forth and identify those USB products πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from