SDL_Event(3type)
π SDL_Event π
okay bestie, welcome to the SDL3 DATATYPES corner of the manual, where we're talking about SDL_Event β literally the structure for all events in SDL. like, all of them. every single one. she contains multitudes. π
β¨ NAME β¨
SDL_Event β the structure for all events in SDL. yes, all. she's the whole group chat. π«Ά
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_events.h>
typedef union SDL_Event
{
Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
SDL_CommonEvent common; /**< Common event data */
SDL_DisplayEvent display; /**< Display event data */
SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */
SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextEditingEvent edit; /**< Text editing event data */
SDL_TextEditingCandidatesEvent edit_candidates; /**< Text editing candidates event data */
SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
SDL_JoyBallEvent jball; /**< Joystick ball event data */
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */
SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */
SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */
SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */
SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
SDL_CameraDeviceEvent cdevice; /**< Camera device event data */
SDL_SensorEvent sensor; /**< Sensor event data */
SDL_QuitEvent quit; /**< Quit request event data */
SDL_UserEvent user; /**< Custom event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
SDL_PinchFingerEvent pinch; /**< Pinch event data */
SDL_PenProximityEvent pproximity; /**< Pen proximity event data */
SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */
SDL_PenMotionEvent pmotion; /**< Pen motion event data */
SDL_PenButtonEvent pbutton; /**< Pen button event data */
SDL_PenAxisEvent paxis; /**< Pen axis event data */
SDL_RenderEvent render; /**< Render event data */
SDL_DropEvent drop; /**< Drag and drop event data */
SDL_ClipboardEvent clipboard; /**< Clipboard event data */
/* This is necessary for ABI compatibility between Visual C++ and GCC.
Visual C++ will respect the push pack pragma and use 52 bytes (size of
SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
architectures) for this union, and GCC will use the alignment of the
largest datatype within the union, which is 8 bytes on 64-bit
architectures.
So... we'll add padding to force the size to be the same for both.
On architectures where pointers are 16 bytes, this needs rounding up to
the next multiple of 16, 64, and on architectures where pointers are
even larger the size of SDL_UserEvent will dominate as being 3 pointers.
*/
Uint8 padding[128];
} SDL_Event;
π¦ DESCRIPTION π¦
okay so. the SDL_Event structure is the absolute core of all event handling in SDL. every tap, every keypress, every "bestie why did the window just move" moment β it all funnels through here. π
and here's the tea: SDL_Event is a union of all event structures used in SDL. one type, one union, forty-plus members, zero chill. it's giving main character energy fr fr. β¨
so when you're reading events, you peek at type first to find out which member of the union is the one actually loaded up, then go read that one. it's a whole vibe check. π
ngl that Uint8 padding[128]; at the bottom is not decorative, bestie β it's doing real work. the comment literally explains that it exists for ABI compatibility between Visual C++ and GCC. don't touch it. don't shrink it. don't "clean it up". let her live. π
π AVAILABILITY π
this struct is available since SDL 3.2.0. iconic behavior, honestly. π
and that's the whole page, bestie β go forth and handle some events. you got this. π
mwah π this lil rewrite was brought to you by the Simple Directmedia Layer crew, SDL 3.4.18, and yes she's got a date on her too (the classic SDL_Event(3type) footer energy). stay slay, stay compiled. π¦β¨
π¦ 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