SDL_GetJoystickProduct(3)

✨ SDL_GetJoystickProduct ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one's a lil bop called SDL_GetJoystickProduct and it is exactly as unhinged-simple as it sounds πŸ’–


🌸 NAME 🌸

SDL_GetJoystickProduct β€” get the USB product ID of an opened joystick, if available. that "if available" is doing a LOT of heavy lifting btw, we'll get there 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_joystick.h>

Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick);

like. one include, one function, one Uint16 coming back at ya. iconic behavior honestly ✨


πŸ’… DESCRIPTION πŸ’…

so here's the tea, bestie: you hand it a joystick, it gives you back the USB product ID. that's it. that's the whole vibe πŸ¦‹

BUT β€” and this is the part where I need you to lock in β€” if the product ID isn't available this function returns 0. so if you get a 0 back, don't be out here thinking "omg the product ID is literally zero", no ma'am. that's the "idk bestie" answer. it's giving unavailable, not zero πŸ’€


πŸ“ FUNCTION PARAMETERS πŸ“

  • joystick β€” the SDL_Joystick you got from SDL_OpenJoystick(). that's the one, the only, the main character πŸ‘‘

⭐ RETURN VALUE ⭐

returns the USB product ID of the selected joystick, or 0 if it's unavailable. periodt. that's the whole return value. no secret third thing 🌈


πŸ”₯ THREAD SAFETY πŸ”₯

it is safe to call this function from any thread. yes, ANY. go wild, no cap, thread it up 🧚


πŸ‘‘ AVAILABILITY πŸ‘‘

this function has been available since SDL 3.2.0. so if you're on something older... my condolences, bestie, upgrade πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page!! written up by Simple Directmedia Layer, running on SDL 3.4.18 β€” mwah, slay, go read your joystick's product ID, I'm obsessed with you πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from