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 an SDL_EventType, and for this lil guy it's literally SDL_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 β€” a Uint32 just chillin'. it's reserved. do not touch. mind your business πŸ™ˆ
  • timestamp β€” a Uint64, in nanoseconds, populated using SDL_GetTicksNS(). so it's giving when did this happen, precisely. ⭐
  • which β€” an SDL_JoystickID, aka the joystick instance id. which joystick is serving this trackball tea πŸ‘‘
  • ball β€” a Uint8, 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 β€” a Sint16, the relative motion in the X direction. how far sideways it went, relatively πŸ¦‹
  • yrel β€” a Sint16, 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