SDL_IsGamepad(3)

✨ SDL_IsGamepad ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the universe πŸŽ€ this one's short, sweet, and honestly kinda iconic β€” it's your lil vibe check for joysticks πŸ’…

πŸ’– NAME πŸ’–

SDL_IsGamepad β€” the "hey, is this controller actually gamepad-coded?" checker. It tells you whether the joystick you're eyeing is supported by the gamepad interface. no cap, that's the whole job πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gamepad.h>

bool SDL_IsGamepad(SDL_JoystickID instance_id);

like. one function. one arg. one bool. it's giving minimalism and we're obsessed 😌


πŸ“ FUNCTION PARAMETERS πŸ“

  • instance_id β€” the joystick instance ID, bestie. that's the lil handle you pass in so it knows which joystick we're talking about πŸ”

πŸ’€ RETURN VALUE πŸ’€

  • Returns true if the given joystick is supported by the gamepad interface β€” slay, it's a real one πŸ‘‘
  • Returns false if it isn't, or if it's an invalid index β€” not me getting handed a fake ID 😭

so like, false is doing double duty here: "nope, not a gamepad" and "nope, that index doesn't even exist." two for one, lowkey efficient fr fr ✨


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. periodt. go wild, call it from wherever, it does not care πŸ’…


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on anything older, it's not ghosting you, it literally doesn't exist yet πŸ™ˆ


🫢 SEE ALSO 🫢

go read those next, they're the main character energy follow-ups to this one πŸ’œ


and that's the whole page, bestie!! brought to you by Simple Directmedia Layer, version SDL 3.4.18 πŸŽ€ tysm for reading, mwah, go check if your controller is a gamepad πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from