SDL_JoyButtonEvent(3type)

โœจ SDL_JoyButtonEvent โœจ

okay bestie, welcome to the SDL_JoyButtonEvent page ๐Ÿ’– this is a SDL3 DATATYPES situation, and it's literally the joystick button event structure โ€” you'll find it chilling under event.jbutton.* ๐ŸŽฎ


๐ŸŒธ NAME ๐ŸŒธ

SDL_JoyButtonEvent โ€” the joystick button event structure (aka event.jbutton.*) ๐Ÿ‘‘


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <SDL3/SDL_events.h>

typedef struct SDL_JoyButtonEvent
{
    SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP */
    Uint32 reserved;
    Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
    SDL_JoystickID which; /**< The joystick instance id */
    Uint8 button;       /**< The joystick button index */
    bool down;      /**< true if the button is pressed */
    Uint8 padding1;
    Uint8 padding2;
} SDL_JoyButtonEvent;

๐Ÿ’… DESCRIPTION ๐Ÿ’…

so like, picture this: somebody smashes a button on their joystick and SDL is like "noted ๐Ÿ“" and hands you one of these bad boys. no cap, that's the whole vibe.

let's do a little field-by-field vibe check, shall we? ๐Ÿงš

  • type โ€” an SDL_EventType, and it's either SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP. that's it, those are the only two options, periodt ๐Ÿ’€
  • reserved โ€” a Uint32 just sitting there. reserved. do not perceive it ๐Ÿ™ˆ
  • timestamp โ€” a Uint64, measured in nanoseconds, populated using SDL_GetTicksNS(). so you know exactly when the button got pressed, down to the nanosecond, main character energy fr fr โฑ๏ธ
  • which โ€” an SDL_JoystickID, the joystick instance id. which joystick was it? this field knows ๐Ÿ”ฅ
  • button โ€” a Uint8, the joystick button index. which button? this field knows too ๐Ÿ‘‘
  • down โ€” a bool, true if the button is pressed. iconic behaviour honestly ๐Ÿ’–
  • padding1 โ€” a Uint8. padding. yes bestie, the name is the whole description ๐ŸŽ€
  • padding2 โ€” a Uint8. padding's sequel. the way that struct alignment needs it... iykyk โœจ
lowkey important: reserved, padding1 and padding2 are not for you. they exist so the struct lines up nicely. leave them alone bestie ๐Ÿซถ

๐ŸŒˆ AVAILABILITY ๐ŸŒˆ

this struct has been around since SDL 3.2.0 โ€” so if you're on 3.2.0 or later, she's available and she's serving ๐Ÿซถ


and that's the whole page, you ate that ๐Ÿ“ go forth and handle your joystick buttons with confidence, bestie. no notes. ๐Ÿ’œ

this lil' datatype page comes from Simple Directmedia Layer, version SDL 3.4.18 โ€” mwah, slay, bye ๐Ÿ‘‹โœจ

๐Ÿ“ฆ where this page comes from