SDL_JoyBallEvent(3type)
π SDL_JoyBallEvent β joystick trackball motion event structure (event.jball.*) π
okay bestie, this is a page from the SDL3 DATATYPES corner of the SDL manual, and it's all about the vibe of a trackball on your joystick going brrrr in some direction. It's the struct you get handed when a joystick trackball moves. That's it, that's the whole plot. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_events.h>
typedef struct SDL_JoyBallEvent
{
SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BALL_MOTION */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
Uint8 ball; /**< The joystick trackball index */
Uint8 padding1;
Uint8 padding2;
Uint8 padding3;
Sint16 xrel; /**< The relative motion in the X direction */
Sint16 yrel; /**< The relative motion in the Y direction */
} SDL_JoyBallEvent;
no cap, let's walk the fields one by one because every single one of them matters π«Ά
typeβ it's anSDL_EventType, and for this lil guy it's literallySDL_EVENT_JOYSTICK_BALL_MOTION. so like, that's how you know what you're looking at when it shows up in the event queue πreservedβ aUint32just chillin'. it's reserved. do not touch. mind your business πtimestampβ aUint64, in nanoseconds, populated usingSDL_GetTicksNS(). so it's giving when did this happen, precisely. βwhichβ anSDL_JoystickID, aka the joystick instance id. which joystick is serving this trackball tea πballβ aUint8, the joystick trackball index. because yes, a joystick can have more than one trackball, and this one is telling you which one is the main character here πpadding1βUint8. padding. it's padding bestie. that's the whole job.padding2βUint8. more padding. slay.padding3βUint8. the third one. iconique trio honestly β¨xrelβ aSint16, the relative motion in the X direction. how far sideways it went, relatively π¦yrelβ aSint16, the relative motion in the Y direction. how far up/down it went, relatively π¦
fr fr: those are relative motions, not absolute positions. the struct is telling you how much it moved, not where it is. don't get it twisted π
πΈ AVAILABILITY πΈ
this struct is available since SDL 3.2.0. so if you're on anything older, it's simply not giving. upgrade, periodt. π
and that's the whole page, bestie!! go forth and handle your trackball events with main character energy π§π
mwah π β brought to you by the lovely humans at Simple Directmedia Layer, from the SDL 3.4.18 era of the SDL 3 datatypes saga.
π¦ 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