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 anSDL_EventType, and it's literally eitherSDL_EVENT_GAMEPAD_BUTTON_DOWNorSDL_EVENT_GAMEPAD_BUTTON_UP. those are your only two options, periodt.reservedโ aUint32just chillin' there. it's reserved, bestie. don't touch.timestampโ aUint64measured in nanoseconds, populated usingSDL_GetTicksNS(). she knows exactly when it happened. โจwhichโ anSDL_JoystickID, holding the joystick instance id. so when you've got three controllers on the couch you know which one is being dramatic. ๐buttonโ aUint8for the gamepad button (it's anSDL_GamepadButton). this is the whole point of the event, honestly.downโ abool, and it'strueif the button is pressed.true= pressed, that's it, that's the vibe. ๐ฅpadding1โ aUint8. padding. she's here for structural reasons and we respect her. ๐padding2โ anotherUint8. 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
- 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