SDL_JoystickGetBall(3)
π SDL_JoystickGetBall(3) π
okay so bestie, we're in the SDL API Reference today and the vibe is trackballs. yes, those little rolling balls. they still exist. sit with me. π
β¨ NAME β¨
SDL_JoystickGetBall β get that relative trackball motion, no cap π¦
πΈ SYNOPSIS πΈ
#include "SDL.h"
int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
π DESCRIPTION π
So like, this function gets you the ball axis change. that's it, that's the whole job. πβοΈ
Here's the tea though: trackballs can only return relative motion β meaning the movement since the last call to SDL_JoystickGetBall. these motion deltas get placed into dx and dy. so don't come in here expecting absolute coordinates, bestie, because you will not be getting them. it's giving deltas only. π«Ά
π₯ RETURN VALUE π₯
Returns 0 on success or -1 on failure. iconic behaviour, honestly. β¨
π EXAMPLES π
int delta_x, delta_y;
SDL_Joystick *joy;
.
.
.
SDL_JoystickUpdate();
if(SDL_JoystickGetBall(joy, 0, &delta_x, &delta_y)==-1)
printf("TrackBall Read Error!
");
printf("Trackball Delta- X:%d, Y:%d
", delta_x, delta_y);
look at that. SDL_JoystickUpdate() first (mandatory, don't skip it, she's the main character of this snippet), then vibe check the return value against -1, then print your deltas. π
the way those printf strings have a literal line break right in the middle of them? yeah. that's exactly how it's written in the original, and I am not touching it. copy it character for character, fr fr. π
π¦ SEE ALSO π¦
SDL_JoystickNumBalls β go count your balls, bestie π
and that's a wrap on the SDL manual page, brought to you by SDL itself, dated Tue 11 Sep 2001, 23:00. yes, 2001. the trackball lore is ancient and we respect it. periodt. πβ¨π
π¦ where this page comes from
- debian bookworm: libsdl1.2-dev 1.2.15+dfsg2-8 Β· LGPL-2.1-or-later
- nixos 26.05: SDL_sixel 0-unstable-2016-02-06
- nixpkgs unstable: SDL_sixel 0-unstable-2016-02-06
- ubuntu jammy: libsdl1.2-dev 1.2.15+dfsg2-6 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms