SDL_GetJoystickBall(3)

πŸ’– SDL_GetJoystickBall πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual, and today's main character is SDL_GetJoystickBall(3) β€” the little guy that tells you how much a trackball moved since the last time you asked. πŸŽ€


✨ NAME ✨

SDL_GetJoystickBall β€” get the ball axis change since the last poll. 🎾


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_joystick.h>

bool SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” trackballs can only return relative motion since the last call to SDL_GetJoystickBall(). like, they don't know where they are, they only know how far they just rolled. those motion deltas get dropped right into dx and dy. πŸ’…

and the reality check: most joysticks do not have trackballs. so if you're out here vibe checking your controller and getting nothing back, that's probably why. πŸ™ˆ


πŸ‘‘ FUNCTION PARAMETERS πŸ‘‘

  • joystick β€” the SDL_Joystick you wanna query. your blorbo. 🫢
  • ball β€” the ball index to query; ball indices start at index 0. yes, zero-indexed, we love that for us. ✨
  • dx β€” stores the difference in the x axis position since the last poll. ➑️
  • dy β€” stores the difference in the y axis position since the last poll. ⬇️

⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and if it fails, pls call SDL_GetError() for more information. don't just sit there wondering bestie, the error message is right there. 😭


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. no cap, any thread. go wild. πŸ”₯


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older… not me being the bearer of bad news but it's giving ✨unsupported✨.


πŸ”— SEE ALSO πŸ”—


that's the whole page bestie, slay, go forth and read your trackball deltas πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­

this iconic little entry came to you from Simple Directmedia Layer, rocking SDL 3.4.18 β€” mwah, periodt. πŸ’œ

πŸ“¦ where this page comes from