SDL_GamepadButtonEvent(3type)

๐ŸŽ€ SDL_GamepadButtonEvent ๐ŸŽ€

okay bestie, welcome to the SDL3 DATATYPES section of the manual, and today's main character is the SDL_GamepadButtonEvent struct โ€” the lil glow-up that tells you when somebody smashed (or un-smashed) a button on their gamepad. ๐Ÿ’…


โœจ NAME โœจ

SDL_GamepadButtonEvent โ€” the gamepad button event structure, aka event.gbutton.* iykyk ๐ŸŽฎ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <SDL3/SDL_events.h>

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

no cap, that's the whole thing. let's break the members down one by one because every single one of them is doing something ๐Ÿซถ

  • type โ€” it's an SDL_EventType, and it's literally either SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP. those are your only two options, periodt.
  • reserved โ€” a Uint32 just chillin' there. it's reserved, bestie. don't touch.
  • timestamp โ€” a Uint64 measured in nanoseconds, populated using SDL_GetTicksNS(). she knows exactly when it happened. โœจ
  • which โ€” an SDL_JoystickID, holding the joystick instance id. so when you've got three controllers on the couch you know which one is being dramatic. ๐Ÿ‘‘
  • button โ€” a Uint8 for the gamepad button (it's an SDL_GamepadButton). this is the whole point of the event, honestly.
  • down โ€” a bool, and it's true if the button is pressed. true = pressed, that's it, that's the vibe. ๐Ÿ”ฅ
  • padding1 โ€” a Uint8. padding. she's here for structural reasons and we respect her. ๐Ÿ™ˆ
  • padding2 โ€” another Uint8. padding's bestie. same deal. ๐Ÿ™ˆ

๐Ÿ’… AVAILABILITY ๐Ÿ’…

This struct is available since SDL 3.2.0. so if you're on anything older... yeah, no, she's not there yet. ๐Ÿ˜ญ


and that's the page, bestie!! ๐Ÿฆ‹ it's giving Simple Directmedia Layer, SDL 3.4.18, and yes the manual itself calls this page SDL_GamepadButtonEvent(3type). go forth and handle those button presses, you absolute icon. ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from