SDL_GetJoystickButton(3)

โœจ SDL_GetJoystickButton โœจ

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetJoystickButton(3) โ€” she's tiny, she's mighty, and she's literally just here to tell you if a button is being pressed rn. ๐ŸŽฎ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

SDL_GetJoystickButton โ€” get the current state of a button on a joystick. that's it, that's the whole job. no cap.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <SDL3/SDL_joystick.h>

bool SDL_GetJoystickButton(SDL_Joystick *joystick, int button);

look at her. one include, one function call. iykyk. โœจ


๐Ÿฆ‹ FUNCTION PARAMETERS ๐Ÿฆ‹

  • joystick โ€” an SDL_Joystick structure containing joystick information. it's the whole vibe of your controller, packaged up all cute. ๐Ÿ•น๏ธ
  • button โ€” the button index to get the state from; indices start at index 0. so the first button is 0, not 1, periodt. don't be out here passing 1 and expecting button numero uno. ๐Ÿ’…

๐Ÿ’œ RETURN VALUE ๐Ÿ’œ

Returns true if the button is pressed, false otherwise. that's the whole tea. โ˜•โœจ


๐Ÿงš THREAD SAFETY ๐Ÿงš

It is safe to call this function from any thread. yes bestie, ANY THREAD. go wild, go feral, spawn all the threads you want, she's not gonna be weird about it. ๐Ÿซถ


๐ŸŒˆ AVAILABILITY ๐ŸŒˆ

This function is available since SDL 3.2.0. so if you're on anything older than that... no she's not there. upgrade era. ๐Ÿ‘‘


โญ SEE ALSO โญ

  • SDL_GetNumJoystickButtons(3) โ€” for when you need to know how many buttons exist in the first place before you go indexing into them. iconic duo fr fr. ๐Ÿ”ฅ

okay that's the whole page, mwah. ๐Ÿ’– this little love letter to the SDL 3 docs comes to you from Simple Directmedia Layer, version SDL 3.4.18 โ€” shoutout to the whole SDL crew, they ate and left no crumbs. ๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from