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β theSDL_Joystickyou wanna query. your blorbo. π«Άballβ the ball index to query; ball indices start at index0. 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 π
SDL_GetNumJoystickBalls(3)β bc sometimes you gotta count the balls before you query the balls. iykyk. π
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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms