SDL 3.0
SDL_events.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategoryEvents
24 *
25 * Event queue management.
26 *
27 * It's extremely common--often required--that an app deal with SDL's event
28 * queue. Almost all useful information about interactions with the real world
29 * flow through here: the user interacting with the computer and app, hardware
30 * coming and going, the system changing in some way, etc.
31 *
32 * An app generally takes a moment, perhaps at the start of a new frame, to
33 * examine any events that have occured since the last time and process or
34 * ignore them. This is generally done by calling SDL_PollEvent() in a loop
35 * until it returns false (or, if using the main callbacks, events are
36 * provided one at a time in calls to SDL_AppEvent() before the next call to
37 * SDL_AppIterate(); in this scenario, the app does not call SDL_PollEvent()
38 * at all).
39 *
40 * There is other forms of control, too: SDL_PeepEvents() has more
41 * functionality at the cost of more complexity, and SDL_WaitEvent() can block
42 * the process until something interesting happens, which might be beneficial
43 * for certain types of programs on low-power hardware. One may also call
44 * SDL_AddEventWatch() to set a callback when new events arrive.
45 *
46 * The app is free to generate their own events, too: SDL_PushEvent allows the
47 * app to put events onto the queue for later retrieval; SDL_RegisterEvents
48 * can guarantee that these events have a type that isn't in use by other
49 * parts of the system.
50 */
51
52#ifndef SDL_events_h_
53#define SDL_events_h_
54
55#include <SDL3/SDL_stdinc.h>
56#include <SDL3/SDL_audio.h>
57#include <SDL3/SDL_camera.h>
58#include <SDL3/SDL_error.h>
59#include <SDL3/SDL_gamepad.h>
60#include <SDL3/SDL_joystick.h>
61#include <SDL3/SDL_keyboard.h>
62#include <SDL3/SDL_keycode.h>
63#include <SDL3/SDL_mouse.h>
64#include <SDL3/SDL_pen.h>
65#include <SDL3/SDL_power.h>
66#include <SDL3/SDL_sensor.h>
67#include <SDL3/SDL_scancode.h>
68#include <SDL3/SDL_touch.h>
69#include <SDL3/SDL_video.h>
70
71#include <SDL3/SDL_begin_code.h>
72/* Set up for C function definitions, even when using C++ */
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77/* General keyboard/mouse/pen state definitions */
78
79/**
80 * The types of events that can be delivered.
81 *
82 * \since This enum is available since SDL 3.2.0.
83 */
84typedef enum SDL_EventType
85{
86 SDL_EVENT_FIRST = 0, /**< Unused (do not remove) */
87
88 /* Application events */
89 SDL_EVENT_QUIT = 0x100, /**< User-requested quit */
90
91 /* These application events have special meaning on iOS and Android, see README-ios.md and README-android.md for details */
92 SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch().
93 Called on iOS in applicationWillTerminate()
94 Called on Android in onDestroy()
95 */
96 SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch().
97 Called on iOS in applicationDidReceiveMemoryWarning()
98 Called on Android in onTrimMemory()
99 */
100 SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch().
101 Called on iOS in applicationWillResignActive()
102 Called on Android in onPause()
103 */
104 SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch().
105 Called on iOS in applicationDidEnterBackground()
106 Called on Android in onPause()
107 */
108 SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch().
109 Called on iOS in applicationWillEnterForeground()
110 Called on Android in onResume()
111 */
112 SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch().
113 Called on iOS in applicationDidBecomeActive()
114 Called on Android in onResume()
115 */
116
117 SDL_EVENT_LOCALE_CHANGED, /**< The user's locale preferences have changed. */
118
119 SDL_EVENT_SYSTEM_THEME_CHANGED, /**< The system theme changed */
120
121 /* Display events */
122 /* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */
123 SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */
124 SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */
125 SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */
126 SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */
127 SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */
128 SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */
129 SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */
132
133 /* Window events */
134 /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */
135 /* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */
136 SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */
137 SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */
138 SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event.
139 data1 is 1 for live-resize expose events, 0 otherwise. */
140 SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */
141 SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */
142 SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */
143 SDL_EVENT_WINDOW_METAL_VIEW_RESIZED,/**< The pixel size of a Metal view associated with the window has changed */
144 SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */
145 SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */
146 SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */
147 SDL_EVENT_WINDOW_MOUSE_ENTER, /**< Window has gained mouse focus */
148 SDL_EVENT_WINDOW_MOUSE_LEAVE, /**< Window has lost mouse focus */
149 SDL_EVENT_WINDOW_FOCUS_GAINED, /**< Window has gained keyboard focus */
150 SDL_EVENT_WINDOW_FOCUS_LOST, /**< Window has lost keyboard focus */
151 SDL_EVENT_WINDOW_CLOSE_REQUESTED, /**< The window manager requests that the window be closed */
152 SDL_EVENT_WINDOW_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */
153 SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */
154 SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */
155 SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */
156 SDL_EVENT_WINDOW_SAFE_AREA_CHANGED, /**< The window safe area has been changed */
157 SDL_EVENT_WINDOW_OCCLUDED, /**< The window has been occluded */
158 SDL_EVENT_WINDOW_ENTER_FULLSCREEN, /**< The window has entered fullscreen mode */
159 SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, /**< The window has left fullscreen mode */
160 SDL_EVENT_WINDOW_DESTROYED, /**< The window with the associated ID is being or has been destroyed. If this message is being handled
161 in an event watcher, the window handle is still valid and can still be used to retrieve any properties
162 associated with the window. Otherwise, the handle has already been destroyed and all resources
163 associated with it are invalid */
164 SDL_EVENT_WINDOW_HDR_STATE_CHANGED, /**< Window HDR properties have changed */
167
168 /* Keyboard events */
169 SDL_EVENT_KEY_DOWN = 0x300, /**< Key pressed */
170 SDL_EVENT_KEY_UP, /**< Key released */
171 SDL_EVENT_TEXT_EDITING, /**< Keyboard text editing (composition) */
172 SDL_EVENT_TEXT_INPUT, /**< Keyboard text input */
173 SDL_EVENT_KEYMAP_CHANGED, /**< Keymap changed due to a system event such as an
174 input language or keyboard layout change. */
175 SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */
176 SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */
177 SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */
178
179 /* Mouse events */
180 SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
181 SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */
182 SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */
183 SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */
184 SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */
185 SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */
186
187 /* Joystick events */
188 SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */
189 SDL_EVENT_JOYSTICK_BALL_MOTION, /**< Joystick trackball motion */
190 SDL_EVENT_JOYSTICK_HAT_MOTION, /**< Joystick hat position change */
191 SDL_EVENT_JOYSTICK_BUTTON_DOWN, /**< Joystick button pressed */
192 SDL_EVENT_JOYSTICK_BUTTON_UP, /**< Joystick button released */
193 SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */
194 SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
195 SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */
196 SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */
197
198 /* Gamepad events */
199 SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */
200 SDL_EVENT_GAMEPAD_BUTTON_DOWN, /**< Gamepad button pressed */
201 SDL_EVENT_GAMEPAD_BUTTON_UP, /**< Gamepad button released */
202 SDL_EVENT_GAMEPAD_ADDED, /**< A new gamepad has been inserted into the system */
203 SDL_EVENT_GAMEPAD_REMOVED, /**< A gamepad has been removed */
204 SDL_EVENT_GAMEPAD_REMAPPED, /**< The gamepad mapping was updated */
205 SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN, /**< Gamepad touchpad was touched */
206 SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, /**< Gamepad touchpad finger was moved */
207 SDL_EVENT_GAMEPAD_TOUCHPAD_UP, /**< Gamepad touchpad finger was lifted */
208 SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */
209 SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete */
210 SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED, /**< Gamepad Steam handle has changed */
211
212 /* Touch events */
217
218 /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */
219
220 /* Clipboard events */
221 SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard or primary selection changed */
222
223 /* Drag and drop events */
224 SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */
225 SDL_EVENT_DROP_TEXT, /**< text/plain drag-and-drop event */
226 SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */
227 SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */
228 SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */
229
230 /* Audio hotplug events */
231 SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */
232 SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */
233 SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED, /**< An audio device's format has been changed by the system. */
234
235 /* Sensor events */
236 SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */
237
238 /* Pressure-sensitive pen events */
239 SDL_EVENT_PEN_PROXIMITY_IN = 0x1300, /**< Pressure-sensitive pen has become available */
240 SDL_EVENT_PEN_PROXIMITY_OUT, /**< Pressure-sensitive pen has become unavailable */
241 SDL_EVENT_PEN_DOWN, /**< Pressure-sensitive pen touched drawing surface */
242 SDL_EVENT_PEN_UP, /**< Pressure-sensitive pen stopped touching drawing surface */
243 SDL_EVENT_PEN_BUTTON_DOWN, /**< Pressure-sensitive pen button pressed */
244 SDL_EVENT_PEN_BUTTON_UP, /**< Pressure-sensitive pen button released */
245 SDL_EVENT_PEN_MOTION, /**< Pressure-sensitive pen is moving on the tablet */
246 SDL_EVENT_PEN_AXIS, /**< Pressure-sensitive pen angle/pressure/etc changed */
247
248 /* Camera hotplug events */
249 SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400, /**< A new camera device is available */
250 SDL_EVENT_CAMERA_DEVICE_REMOVED, /**< A camera device has been removed. */
251 SDL_EVENT_CAMERA_DEVICE_APPROVED, /**< A camera device has been approved for use by the user. */
252 SDL_EVENT_CAMERA_DEVICE_DENIED, /**< A camera device has been denied for use by the user. */
253
254 /* Render events */
255 SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
256 SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
257 SDL_EVENT_RENDER_DEVICE_LOST, /**< The device has been lost and can't be recovered. */
258
259 /* Reserved events for private platforms */
264
265 /* Internal events */
266 SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
267
268 /** Events SDL_EVENT_USER through SDL_EVENT_LAST are for your use,
269 * and should be allocated with SDL_RegisterEvents()
270 */
272
273 /**
274 * This last event is only for bounding internal arrays
275 */
277
278 /* This just makes sure the enum is the size of Uint32 */
279 SDL_EVENT_ENUM_PADDING = 0x7FFFFFFF
280
282
283/**
284 * Fields shared by every event
285 *
286 * \since This struct is available since SDL 3.2.0.
287 */
288typedef struct SDL_CommonEvent
289{
290 Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
292 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
294
295/**
296 * Display state change event data (event.display.*)
297 *
298 * \since This struct is available since SDL 3.2.0.
299 */
300typedef struct SDL_DisplayEvent
301{
302 SDL_EventType type; /**< SDL_DISPLAYEVENT_* */
304 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
305 SDL_DisplayID displayID;/**< The associated display */
306 Sint32 data1; /**< event dependent data */
307 Sint32 data2; /**< event dependent data */
309
310/**
311 * Window state change event data (event.window.*)
312 *
313 * \since This struct is available since SDL 3.2.0.
314 */
315typedef struct SDL_WindowEvent
316{
317 SDL_EventType type; /**< SDL_EVENT_WINDOW_* */
319 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
320 SDL_WindowID windowID; /**< The associated window */
321 Sint32 data1; /**< event dependent data */
322 Sint32 data2; /**< event dependent data */
324
325/**
326 * Keyboard device event structure (event.kdevice.*)
327 *
328 * \since This struct is available since SDL 3.2.0.
329 */
331{
332 SDL_EventType type; /**< SDL_EVENT_KEYBOARD_ADDED or SDL_EVENT_KEYBOARD_REMOVED */
334 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
335 SDL_KeyboardID which; /**< The keyboard instance id */
337
338/**
339 * Keyboard button event structure (event.key.*)
340 *
341 * The `key` is the base SDL_Keycode generated by pressing the `scancode`
342 * using the current keyboard layout, applying any options specified in
343 * SDL_HINT_KEYCODE_OPTIONS. You can get the SDL_Keycode corresponding to the
344 * event scancode and modifiers directly from the keyboard layout, bypassing
345 * SDL_HINT_KEYCODE_OPTIONS, by calling SDL_GetKeyFromScancode().
346 *
347 * \since This struct is available since SDL 3.2.0.
348 *
349 * \sa SDL_GetKeyFromScancode
350 * \sa SDL_HINT_KEYCODE_OPTIONS
351 */
352typedef struct SDL_KeyboardEvent
353{
354 SDL_EventType type; /**< SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP */
356 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
357 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
358 SDL_KeyboardID which; /**< The keyboard instance id, or 0 if unknown or virtual */
359 SDL_Scancode scancode; /**< SDL physical key code */
360 SDL_Keycode key; /**< SDL virtual key code */
361 SDL_Keymod mod; /**< current key modifiers */
362 Uint16 raw; /**< The platform dependent scancode for this event */
363 bool down; /**< true if the key is pressed */
364 bool repeat; /**< true if this is a key repeat */
366
367/**
368 * Keyboard text editing event structure (event.edit.*)
369 *
370 * The start cursor is the position, in UTF-8 characters, where new typing
371 * will be inserted into the editing text. The length is the number of UTF-8
372 * characters that will be replaced by new typing.
373 *
374 * \since This struct is available since SDL 3.2.0.
375 */
377{
378 SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING */
380 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
381 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
382 const char *text; /**< The editing text */
383 Sint32 start; /**< The start cursor of selected editing text, or -1 if not set */
384 Sint32 length; /**< The length of selected editing text, or -1 if not set */
386
387/**
388 * Keyboard IME candidates event structure (event.edit_candidates.*)
389 *
390 * \since This struct is available since SDL 3.2.0.
391 */
393{
394 SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING_CANDIDATES */
396 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
397 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
398 const char * const *candidates; /**< The list of candidates, or NULL if there are no candidates available */
399 Sint32 num_candidates; /**< The number of strings in `candidates` */
400 Sint32 selected_candidate; /**< The index of the selected candidate, or -1 if no candidate is selected */
401 bool horizontal; /**< true if the list is horizontal, false if it's vertical */
406
407/**
408 * Keyboard text input event structure (event.text.*)
409 *
410 * This event will never be delivered unless text input is enabled by calling
411 * SDL_StartTextInput(). Text input is disabled by default!
412 *
413 * \since This struct is available since SDL 3.2.0.
414 *
415 * \sa SDL_StartTextInput
416 * \sa SDL_StopTextInput
417 */
418typedef struct SDL_TextInputEvent
419{
420 SDL_EventType type; /**< SDL_EVENT_TEXT_INPUT */
422 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
423 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
424 const char *text; /**< The input text, UTF-8 encoded */
426
427/**
428 * Mouse device event structure (event.mdevice.*)
429 *
430 * \since This struct is available since SDL 3.2.0.
431 */
433{
434 SDL_EventType type; /**< SDL_EVENT_MOUSE_ADDED or SDL_EVENT_MOUSE_REMOVED */
436 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
437 SDL_MouseID which; /**< The mouse instance id */
439
440/**
441 * Mouse motion event structure (event.motion.*)
442 *
443 * \since This struct is available since SDL 3.2.0.
444 */
446{
447 SDL_EventType type; /**< SDL_EVENT_MOUSE_MOTION */
449 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
450 SDL_WindowID windowID; /**< The window with mouse focus, if any */
451 SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */
452 SDL_MouseButtonFlags state; /**< The current button state */
453 float x; /**< X coordinate, relative to window */
454 float y; /**< Y coordinate, relative to window */
455 float xrel; /**< The relative motion in the X direction */
456 float yrel; /**< The relative motion in the Y direction */
458
459/**
460 * Mouse button event structure (event.button.*)
461 *
462 * \since This struct is available since SDL 3.2.0.
463 */
465{
466 SDL_EventType type; /**< SDL_EVENT_MOUSE_BUTTON_DOWN or SDL_EVENT_MOUSE_BUTTON_UP */
468 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
469 SDL_WindowID windowID; /**< The window with mouse focus, if any */
470 SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */
471 Uint8 button; /**< The mouse button index */
472 bool down; /**< true if the button is pressed */
473 Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
475 float x; /**< X coordinate, relative to window */
476 float y; /**< Y coordinate, relative to window */
478
479/**
480 * Mouse wheel event structure (event.wheel.*)
481 *
482 * \since This struct is available since SDL 3.2.0.
483 */
485{
486 SDL_EventType type; /**< SDL_EVENT_MOUSE_WHEEL */
488 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
489 SDL_WindowID windowID; /**< The window with mouse focus, if any */
490 SDL_MouseID which; /**< The mouse instance id in relative mode or 0 */
491 float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
492 float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
493 SDL_MouseWheelDirection direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
494 float mouse_x; /**< X coordinate, relative to window */
495 float mouse_y; /**< Y coordinate, relative to window */
496 Sint32 integer_x; /**< The amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12) */
497 Sint32 integer_y; /**< The amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12) */
499
500/**
501 * Joystick axis motion event structure (event.jaxis.*)
502 *
503 * \since This struct is available since SDL 3.2.0.
504 */
505typedef struct SDL_JoyAxisEvent
506{
507 SDL_EventType type; /**< SDL_EVENT_JOYSTICK_AXIS_MOTION */
509 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
510 SDL_JoystickID which; /**< The joystick instance id */
511 Uint8 axis; /**< The joystick axis index */
515 Sint16 value; /**< The axis value (range: -32768 to 32767) */
518
519/**
520 * Joystick trackball motion event structure (event.jball.*)
521 *
522 * \since This struct is available since SDL 3.2.0.
523 */
524typedef struct SDL_JoyBallEvent
525{
526 SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BALL_MOTION */
528 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
529 SDL_JoystickID which; /**< The joystick instance id */
530 Uint8 ball; /**< The joystick trackball index */
534 Sint16 xrel; /**< The relative motion in the X direction */
535 Sint16 yrel; /**< The relative motion in the Y direction */
537
538/**
539 * Joystick hat position change event structure (event.jhat.*)
540 *
541 * \since This struct is available since SDL 3.2.0.
542 */
543typedef struct SDL_JoyHatEvent
544{
545 SDL_EventType type; /**< SDL_EVENT_JOYSTICK_HAT_MOTION */
547 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
548 SDL_JoystickID which; /**< The joystick instance id */
549 Uint8 hat; /**< The joystick hat index */
550 Uint8 value; /**< The hat position value.
551 * \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
552 * \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
553 * \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
554 *
555 * Note that zero means the POV is centered.
556 */
560
561/**
562 * Joystick button event structure (event.jbutton.*)
563 *
564 * \since This struct is available since SDL 3.2.0.
565 */
566typedef struct SDL_JoyButtonEvent
567{
568 SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP */
570 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
571 SDL_JoystickID which; /**< The joystick instance id */
572 Uint8 button; /**< The joystick button index */
573 bool down; /**< true if the button is pressed */
577
578/**
579 * Joystick device event structure (event.jdevice.*)
580 *
581 * SDL will send JOYSTICK_ADDED events for devices that are already plugged in
582 * during SDL_Init.
583 *
584 * \since This struct is available since SDL 3.2.0.
585 *
586 * \sa SDL_GamepadDeviceEvent
587 */
588typedef struct SDL_JoyDeviceEvent
589{
590 SDL_EventType type; /**< SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE */
592 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
593 SDL_JoystickID which; /**< The joystick instance id */
595
596/**
597 * Joystick battery level change event structure (event.jbattery.*)
598 *
599 * \since This struct is available since SDL 3.2.0.
600 */
602{
603 SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BATTERY_UPDATED */
605 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
606 SDL_JoystickID which; /**< The joystick instance id */
607 SDL_PowerState state; /**< The joystick battery state */
608 int percent; /**< The joystick battery percent charge remaining */
610
611/**
612 * Gamepad axis motion event structure (event.gaxis.*)
613 *
614 * \since This struct is available since SDL 3.2.0.
615 */
617{
618 SDL_EventType type; /**< SDL_EVENT_GAMEPAD_AXIS_MOTION */
620 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
621 SDL_JoystickID which; /**< The joystick instance id */
622 Uint8 axis; /**< The gamepad axis (SDL_GamepadAxis) */
626 Sint16 value; /**< The axis value (range: -32768 to 32767) */
629
630
631/**
632 * Gamepad button event structure (event.gbutton.*)
633 *
634 * \since This struct is available since SDL 3.2.0.
635 */
637{
638 SDL_EventType type; /**< SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP */
640 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
641 SDL_JoystickID which; /**< The joystick instance id */
642 Uint8 button; /**< The gamepad button (SDL_GamepadButton) */
643 bool down; /**< true if the button is pressed */
647
648
649/**
650 * Gamepad device event structure (event.gdevice.*)
651 *
652 * Joysticks that are supported gamepads receive both an SDL_JoyDeviceEvent
653 * and an SDL_GamepadDeviceEvent.
654 *
655 * SDL will send GAMEPAD_ADDED events for joysticks that are already plugged
656 * in during SDL_Init() and are recognized as gamepads. It will also send
657 * events for joysticks that get gamepad mappings at runtime.
658 *
659 * \since This struct is available since SDL 3.2.0.
660 *
661 * \sa SDL_JoyDeviceEvent
662 */
664{
665 SDL_EventType type; /**< SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMOVED, or SDL_EVENT_GAMEPAD_REMAPPED, SDL_EVENT_GAMEPAD_UPDATE_COMPLETE or SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED */
667 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
668 SDL_JoystickID which; /**< The joystick instance id */
670
671/**
672 * Gamepad touchpad event structure (event.gtouchpad.*)
673 *
674 * \since This struct is available since SDL 3.2.0.
675 */
677{
678 SDL_EventType type; /**< SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP */
680 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
681 SDL_JoystickID which; /**< The joystick instance id */
682 Sint32 touchpad; /**< The index of the touchpad */
683 Sint32 finger; /**< The index of the finger on the touchpad */
684 float x; /**< Normalized in the range 0...1 with 0 being on the left */
685 float y; /**< Normalized in the range 0...1 with 0 being at the top */
686 float pressure; /**< Normalized in the range 0...1 */
688
689/**
690 * Gamepad sensor event structure (event.gsensor.*)
691 *
692 * \since This struct is available since SDL 3.2.0.
693 */
695{
696 SDL_EventType type; /**< SDL_EVENT_GAMEPAD_SENSOR_UPDATE */
698 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
699 SDL_JoystickID which; /**< The joystick instance id */
700 Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */
701 float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
702 Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */
704
705/**
706 * Audio device event structure (event.adevice.*)
707 *
708 * Note that SDL will send a SDL_EVENT_AUDIO_DEVICE_ADDED event for every
709 * device it discovers during initialization. After that, this event will only
710 * arrive when a device is hotplugged during the program's run.
711 *
712 * \since This struct is available since SDL 3.2.0.
713 */
715{
716 SDL_EventType type; /**< SDL_EVENT_AUDIO_DEVICE_ADDED, or SDL_EVENT_AUDIO_DEVICE_REMOVED, or SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED */
718 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
719 SDL_AudioDeviceID which; /**< SDL_AudioDeviceID for the device being added or removed or changing */
720 bool recording; /**< false if a playback device, true if a recording device. */
725
726/**
727 * Camera device event structure (event.cdevice.*)
728 *
729 * \since This struct is available since SDL 3.2.0.
730 */
732{
733 SDL_EventType type; /**< SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED */
735 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
736 SDL_CameraID which; /**< SDL_CameraID for the device being added or removed or changing */
738
739
740/**
741 * Renderer event structure (event.render.*)
742 *
743 * \since This struct is available since SDL 3.2.0.
744 */
745typedef struct SDL_RenderEvent
746{
747 SDL_EventType type; /**< SDL_EVENT_RENDER_TARGETS_RESET, SDL_EVENT_RENDER_DEVICE_RESET, SDL_EVENT_RENDER_DEVICE_LOST */
749 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
750 SDL_WindowID windowID; /**< The window containing the renderer in question. */
752
753
754/**
755 * Touch finger event structure (event.tfinger.*)
756 *
757 * Coordinates in this event are normalized. `x` and `y` are normalized to a
758 * range between 0.0f and 1.0f, relative to the window, so (0,0) is the top
759 * left and (1,1) is the bottom right. Delta coordinates `dx` and `dy` are
760 * normalized in the ranges of -1.0f (traversed all the way from the bottom or
761 * right to all the way up or left) to 1.0f (traversed all the way from the
762 * top or left to all the way down or right).
763 *
764 * Note that while the coordinates are _normalized_, they are not _clamped_,
765 * which means in some circumstances you can get a value outside of this
766 * range. For example, a renderer using logical presentation might give a
767 * negative value when the touch is in the letterboxing. Some platforms might
768 * report a touch outside of the window, which will also be outside of the
769 * range.
770 *
771 * \since This struct is available since SDL 3.2.0.
772 */
774{
775 SDL_EventType type; /**< SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED */
777 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
778 SDL_TouchID touchID; /**< The touch device id */
780 float x; /**< Normalized in the range 0...1 */
781 float y; /**< Normalized in the range 0...1 */
782 float dx; /**< Normalized in the range -1...1 */
783 float dy; /**< Normalized in the range -1...1 */
784 float pressure; /**< Normalized in the range 0...1 */
785 SDL_WindowID windowID; /**< The window underneath the finger, if any */
787
788/**
789 * Pressure-sensitive pen proximity event structure (event.pproximity.*)
790 *
791 * When a pen becomes visible to the system (it is close enough to a tablet,
792 * etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's
793 * ID. This ID is valid until the pen leaves proximity again (has been removed
794 * from the tablet's area, the tablet has been unplugged, etc). If the same
795 * pen reenters proximity again, it will be given a new ID.
796 *
797 * Note that "proximity" means "close enough for the tablet to know the tool
798 * is there." The pen touching and lifting off from the tablet while not
799 * leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP.
800 *
801 * \since This struct is available since SDL 3.2.0.
802 */
804{
805 SDL_EventType type; /**< SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT */
807 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
808 SDL_WindowID windowID; /**< The window with pen focus, if any */
809 SDL_PenID which; /**< The pen instance id */
811
812/**
813 * Pressure-sensitive pen motion event structure (event.pmotion.*)
814 *
815 * Depending on the hardware, you may get motion events when the pen is not
816 * touching a tablet, for tracking a pen even when it isn't drawing. You
817 * should listen for SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP events, or check
818 * `pen_state & SDL_PEN_INPUT_DOWN` to decide if a pen is "drawing" when
819 * dealing with pen motion.
820 *
821 * \since This struct is available since SDL 3.2.0.
822 */
823typedef struct SDL_PenMotionEvent
824{
825 SDL_EventType type; /**< SDL_EVENT_PEN_MOTION */
827 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
828 SDL_WindowID windowID; /**< The window with pen focus, if any */
829 SDL_PenID which; /**< The pen instance id */
830 SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */
831 float x; /**< X coordinate, relative to window */
832 float y; /**< Y coordinate, relative to window */
834
835/**
836 * Pressure-sensitive pen touched event structure (event.ptouch.*)
837 *
838 * These events come when a pen touches a surface (a tablet, etc), or lifts
839 * off from one.
840 *
841 * \since This struct is available since SDL 3.2.0.
842 */
843typedef struct SDL_PenTouchEvent
844{
845 SDL_EventType type; /**< SDL_EVENT_PEN_DOWN or SDL_EVENT_PEN_UP */
847 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
848 SDL_WindowID windowID; /**< The window with pen focus, if any */
849 SDL_PenID which; /**< The pen instance id */
850 SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */
851 float x; /**< X coordinate, relative to window */
852 float y; /**< Y coordinate, relative to window */
853 bool eraser; /**< true if eraser end is used (not all pens support this). */
854 bool down; /**< true if the pen is touching or false if the pen is lifted off */
856
857/**
858 * Pressure-sensitive pen button event structure (event.pbutton.*)
859 *
860 * This is for buttons on the pen itself that the user might click. The pen
861 * itself pressing down to draw triggers a SDL_EVENT_PEN_DOWN event instead.
862 *
863 * \since This struct is available since SDL 3.2.0.
864 */
865typedef struct SDL_PenButtonEvent
866{
867 SDL_EventType type; /**< SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP */
869 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
870 SDL_WindowID windowID; /**< The window with mouse focus, if any */
871 SDL_PenID which; /**< The pen instance id */
872 SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */
873 float x; /**< X coordinate, relative to window */
874 float y; /**< Y coordinate, relative to window */
875 Uint8 button; /**< The pen button index (first button is 1). */
876 bool down; /**< true if the button is pressed */
878
879/**
880 * Pressure-sensitive pen pressure / angle event structure (event.paxis.*)
881 *
882 * You might get some of these events even if the pen isn't touching the
883 * tablet.
884 *
885 * \since This struct is available since SDL 3.2.0.
886 */
887typedef struct SDL_PenAxisEvent
888{
889 SDL_EventType type; /**< SDL_EVENT_PEN_AXIS */
891 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
892 SDL_WindowID windowID; /**< The window with pen focus, if any */
893 SDL_PenID which; /**< The pen instance id */
894 SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */
895 float x; /**< X coordinate, relative to window */
896 float y; /**< Y coordinate, relative to window */
897 SDL_PenAxis axis; /**< Axis that has changed */
898 float value; /**< New value of axis */
900
901/**
902 * An event used to drop text or request a file open by the system
903 * (event.drop.*)
904 *
905 * \since This struct is available since SDL 3.2.0.
906 */
907typedef struct SDL_DropEvent
908{
909 SDL_EventType type; /**< SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION */
911 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
912 SDL_WindowID windowID; /**< The window that was dropped on, if any */
913 float x; /**< X coordinate, relative to window (not on begin) */
914 float y; /**< Y coordinate, relative to window (not on begin) */
915 const char *source; /**< The source app that sent this drop event, or NULL if that isn't available */
916 const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */
918
919/**
920 * An event triggered when the clipboard contents have changed
921 * (event.clipboard.*)
922 *
923 * \since This struct is available since SDL 3.2.0.
924 */
925typedef struct SDL_ClipboardEvent
926{
927 SDL_EventType type; /**< SDL_EVENT_CLIPBOARD_UPDATE */
929 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
930 bool owner; /**< are we owning the clipboard (internal update) */
931 Sint32 num_mime_types; /**< number of mime types */
932 const char **mime_types; /**< current mime types */
934
935/**
936 * Sensor event structure (event.sensor.*)
937 *
938 * \since This struct is available since SDL 3.2.0.
939 */
940typedef struct SDL_SensorEvent
941{
942 SDL_EventType type; /**< SDL_EVENT_SENSOR_UPDATE */
944 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
945 SDL_SensorID which; /**< The instance ID of the sensor */
946 float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData() */
947 Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */
949
950/**
951 * The "quit requested" event
952 *
953 * \since This struct is available since SDL 3.2.0.
954 */
955typedef struct SDL_QuitEvent
956{
957 SDL_EventType type; /**< SDL_EVENT_QUIT */
959 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
961
962/**
963 * A user-defined event type (event.user.*)
964 *
965 * This event is unique; it is never created by SDL, but only by the
966 * application. The event can be pushed onto the event queue using
967 * SDL_PushEvent(). The contents of the structure members are completely up to
968 * the programmer; the only requirement is that '''type''' is a value obtained
969 * from SDL_RegisterEvents().
970 *
971 * \since This struct is available since SDL 3.2.0.
972 */
973typedef struct SDL_UserEvent
974{
975 Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */
977 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
978 SDL_WindowID windowID; /**< The associated window if any */
979 Sint32 code; /**< User defined event code */
980 void *data1; /**< User defined data pointer */
981 void *data2; /**< User defined data pointer */
983
984
985/**
986 * The structure for all events in SDL.
987 *
988 * The SDL_Event structure is the core of all event handling in SDL. SDL_Event
989 * is a union of all event structures used in SDL.
990 *
991 * \since This struct is available since SDL 3.2.0.
992 */
993typedef union SDL_Event
994{
995 Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */
996 SDL_CommonEvent common; /**< Common event data */
997 SDL_DisplayEvent display; /**< Display event data */
998 SDL_WindowEvent window; /**< Window event data */
999 SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */
1000 SDL_KeyboardEvent key; /**< Keyboard event data */
1001 SDL_TextEditingEvent edit; /**< Text editing event data */
1002 SDL_TextEditingCandidatesEvent edit_candidates; /**< Text editing candidates event data */
1003 SDL_TextInputEvent text; /**< Text input event data */
1004 SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */
1005 SDL_MouseMotionEvent motion; /**< Mouse motion event data */
1006 SDL_MouseButtonEvent button; /**< Mouse button event data */
1007 SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
1008 SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
1009 SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
1010 SDL_JoyBallEvent jball; /**< Joystick ball event data */
1011 SDL_JoyHatEvent jhat; /**< Joystick hat event data */
1012 SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
1013 SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
1014 SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */
1015 SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */
1016 SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */
1017 SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */
1018 SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */
1019 SDL_AudioDeviceEvent adevice; /**< Audio device event data */
1020 SDL_CameraDeviceEvent cdevice; /**< Camera device event data */
1021 SDL_SensorEvent sensor; /**< Sensor event data */
1022 SDL_QuitEvent quit; /**< Quit request event data */
1023 SDL_UserEvent user; /**< Custom event data */
1024 SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
1025 SDL_PenProximityEvent pproximity; /**< Pen proximity event data */
1026 SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */
1027 SDL_PenMotionEvent pmotion; /**< Pen motion event data */
1028 SDL_PenButtonEvent pbutton; /**< Pen button event data */
1029 SDL_PenAxisEvent paxis; /**< Pen axis event data */
1030 SDL_RenderEvent render; /**< Render event data */
1031 SDL_DropEvent drop; /**< Drag and drop event data */
1032 SDL_ClipboardEvent clipboard; /**< Clipboard event data */
1033
1034 /* This is necessary for ABI compatibility between Visual C++ and GCC.
1035 Visual C++ will respect the push pack pragma and use 52 bytes (size of
1036 SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
1037 architectures) for this union, and GCC will use the alignment of the
1038 largest datatype within the union, which is 8 bytes on 64-bit
1039 architectures.
1040
1041 So... we'll add padding to force the size to be the same for both.
1042
1043 On architectures where pointers are 16 bytes, this needs rounding up to
1044 the next multiple of 16, 64, and on architectures where pointers are
1045 even larger the size of SDL_UserEvent will dominate as being 3 pointers.
1046 */
1048} SDL_Event;
1049
1050/* Make sure we haven't broken binary compatibility */
1051SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
1052
1053
1054/* Function prototypes */
1055
1056/**
1057 * Pump the event loop, gathering events from the input devices.
1058 *
1059 * This function updates the event queue and internal input device state.
1060 *
1061 * SDL_PumpEvents() gathers all the pending input information from devices and
1062 * places it in the event queue. Without calls to SDL_PumpEvents() no events
1063 * would ever be placed on the queue. Often the need for calls to
1064 * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
1065 * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
1066 * polling or waiting for events (e.g. you are filtering them), then you must
1067 * call SDL_PumpEvents() to force an event queue update.
1068 *
1069 * \threadsafety This function should only be called on the main thread.
1070 *
1071 * \since This function is available since SDL 3.2.0.
1072 *
1073 * \sa SDL_PollEvent
1074 * \sa SDL_WaitEvent
1075 */
1076extern SDL_DECLSPEC void SDLCALL SDL_PumpEvents(void);
1077
1078/* @{ */
1079
1080/**
1081 * The type of action to request from SDL_PeepEvents().
1082 *
1083 * \since This enum is available since SDL 3.2.0.
1084 */
1086{
1087 SDL_ADDEVENT, /**< Add events to the back of the queue. */
1088 SDL_PEEKEVENT, /**< Check but don't remove events from the queue front. */
1089 SDL_GETEVENT /**< Retrieve/remove events from the front of the queue. */
1091
1092/**
1093 * Check the event queue for messages and optionally return them.
1094 *
1095 * `action` may be any of the following:
1096 *
1097 * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the
1098 * event queue.
1099 * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
1100 * within the specified minimum and maximum type, will be returned to the
1101 * caller and will _not_ be removed from the queue. If you pass NULL for
1102 * `events`, then `numevents` is ignored and the total number of matching
1103 * events will be returned.
1104 * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
1105 * within the specified minimum and maximum type, will be returned to the
1106 * caller and will be removed from the queue.
1107 *
1108 * You may have to call SDL_PumpEvents() before calling this function.
1109 * Otherwise, the events may not be ready to be filtered when you call
1110 * SDL_PeepEvents().
1111 *
1112 * \param events destination buffer for the retrieved events, may be NULL to
1113 * leave the events in the queue and return the number of events
1114 * that would have been stored.
1115 * \param numevents if action is SDL_ADDEVENT, the number of events to add
1116 * back to the event queue; if action is SDL_PEEKEVENT or
1117 * SDL_GETEVENT, the maximum number of events to retrieve.
1118 * \param action action to take; see [Remarks](#remarks) for details.
1119 * \param minType minimum value of the event type to be considered;
1120 * SDL_EVENT_FIRST is a safe choice.
1121 * \param maxType maximum value of the event type to be considered;
1122 * SDL_EVENT_LAST is a safe choice.
1123 * \returns the number of events actually stored or -1 on failure; call
1124 * SDL_GetError() for more information.
1125 *
1126 * \threadsafety It is safe to call this function from any thread.
1127 *
1128 * \since This function is available since SDL 3.2.0.
1129 *
1130 * \sa SDL_PollEvent
1131 * \sa SDL_PumpEvents
1132 * \sa SDL_PushEvent
1133 */
1134extern SDL_DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType);
1135/* @} */
1136
1137/**
1138 * Check for the existence of a certain event type in the event queue.
1139 *
1140 * If you need to check for a range of event types, use SDL_HasEvents()
1141 * instead.
1142 *
1143 * \param type the type of event to be queried; see SDL_EventType for details.
1144 * \returns true if events matching `type` are present, or false if events
1145 * matching `type` are not present.
1146 *
1147 * \threadsafety It is safe to call this function from any thread.
1148 *
1149 * \since This function is available since SDL 3.2.0.
1150 *
1151 * \sa SDL_HasEvents
1152 */
1153extern SDL_DECLSPEC bool SDLCALL SDL_HasEvent(Uint32 type);
1154
1155
1156/**
1157 * Check for the existence of certain event types in the event queue.
1158 *
1159 * If you need to check for a single event type, use SDL_HasEvent() instead.
1160 *
1161 * \param minType the low end of event type to be queried, inclusive; see
1162 * SDL_EventType for details.
1163 * \param maxType the high end of event type to be queried, inclusive; see
1164 * SDL_EventType for details.
1165 * \returns true if events with type >= `minType` and <= `maxType` are
1166 * present, or false if not.
1167 *
1168 * \threadsafety It is safe to call this function from any thread.
1169 *
1170 * \since This function is available since SDL 3.2.0.
1171 *
1172 * \sa SDL_HasEvents
1173 */
1174extern SDL_DECLSPEC bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
1175
1176/**
1177 * Clear events of a specific type from the event queue.
1178 *
1179 * This will unconditionally remove any events from the queue that match
1180 * `type`. If you need to remove a range of event types, use SDL_FlushEvents()
1181 * instead.
1182 *
1183 * It's also normal to just ignore events you don't care about in your event
1184 * loop without calling this function.
1185 *
1186 * This function only affects currently queued events. If you want to make
1187 * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
1188 * on the main thread immediately before the flush call.
1189 *
1190 * If you have user events with custom data that needs to be freed, you should
1191 * use SDL_PeepEvents() to remove and clean up those events before calling
1192 * this function.
1193 *
1194 * \param type the type of event to be cleared; see SDL_EventType for details.
1195 *
1196 * \threadsafety It is safe to call this function from any thread.
1197 *
1198 * \since This function is available since SDL 3.2.0.
1199 *
1200 * \sa SDL_FlushEvents
1201 */
1202extern SDL_DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
1203
1204/**
1205 * Clear events of a range of types from the event queue.
1206 *
1207 * This will unconditionally remove any events from the queue that are in the
1208 * range of `minType` to `maxType`, inclusive. If you need to remove a single
1209 * event type, use SDL_FlushEvent() instead.
1210 *
1211 * It's also normal to just ignore events you don't care about in your event
1212 * loop without calling this function.
1213 *
1214 * This function only affects currently queued events. If you want to make
1215 * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
1216 * on the main thread immediately before the flush call.
1217 *
1218 * \param minType the low end of event type to be cleared, inclusive; see
1219 * SDL_EventType for details.
1220 * \param maxType the high end of event type to be cleared, inclusive; see
1221 * SDL_EventType for details.
1222 *
1223 * \threadsafety It is safe to call this function from any thread.
1224 *
1225 * \since This function is available since SDL 3.2.0.
1226 *
1227 * \sa SDL_FlushEvent
1228 */
1229extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
1230
1231/**
1232 * Poll for currently pending events.
1233 *
1234 * If `event` is not NULL, the next event is removed from the queue and stored
1235 * in the SDL_Event structure pointed to by `event`. The 1 returned refers to
1236 * this event, immediately stored in the SDL Event structure -- not an event
1237 * to follow.
1238 *
1239 * If `event` is NULL, it simply returns 1 if there is an event in the queue,
1240 * but will not remove it from the queue.
1241 *
1242 * As this function may implicitly call SDL_PumpEvents(), you can only call
1243 * this function in the thread that set the video mode.
1244 *
1245 * SDL_PollEvent() is the favored way of receiving system events since it can
1246 * be done from the main loop and does not suspend the main loop while waiting
1247 * on an event to be posted.
1248 *
1249 * The common practice is to fully process the event queue once every frame,
1250 * usually as a first step before updating the game's state:
1251 *
1252 * ```c
1253 * while (game_is_still_running) {
1254 * SDL_Event event;
1255 * while (SDL_PollEvent(&event)) { // poll until all events are handled!
1256 * // decide what to do with this event.
1257 * }
1258 *
1259 * // update game state, draw the current frame
1260 * }
1261 * ```
1262 *
1263 * \param event the SDL_Event structure to be filled with the next event from
1264 * the queue, or NULL.
1265 * \returns true if this got an event or false if there are none available.
1266 *
1267 * \threadsafety This function should only be called on the main thread.
1268 *
1269 * \since This function is available since SDL 3.2.0.
1270 *
1271 * \sa SDL_PushEvent
1272 * \sa SDL_WaitEvent
1273 * \sa SDL_WaitEventTimeout
1274 */
1275extern SDL_DECLSPEC bool SDLCALL SDL_PollEvent(SDL_Event *event);
1276
1277/**
1278 * Wait indefinitely for the next available event.
1279 *
1280 * If `event` is not NULL, the next event is removed from the queue and stored
1281 * in the SDL_Event structure pointed to by `event`.
1282 *
1283 * As this function may implicitly call SDL_PumpEvents(), you can only call
1284 * this function in the thread that initialized the video subsystem.
1285 *
1286 * \param event the SDL_Event structure to be filled in with the next event
1287 * from the queue, or NULL.
1288 * \returns true on success or false if there was an error while waiting for
1289 * events; call SDL_GetError() for more information.
1290 *
1291 * \threadsafety This function should only be called on the main thread.
1292 *
1293 * \since This function is available since SDL 3.2.0.
1294 *
1295 * \sa SDL_PollEvent
1296 * \sa SDL_PushEvent
1297 * \sa SDL_WaitEventTimeout
1298 */
1299extern SDL_DECLSPEC bool SDLCALL SDL_WaitEvent(SDL_Event *event);
1300
1301/**
1302 * Wait until the specified timeout (in milliseconds) for the next available
1303 * event.
1304 *
1305 * If `event` is not NULL, the next event is removed from the queue and stored
1306 * in the SDL_Event structure pointed to by `event`.
1307 *
1308 * As this function may implicitly call SDL_PumpEvents(), you can only call
1309 * this function in the thread that initialized the video subsystem.
1310 *
1311 * The timeout is not guaranteed, the actual wait time could be longer due to
1312 * system scheduling.
1313 *
1314 * \param event the SDL_Event structure to be filled in with the next event
1315 * from the queue, or NULL.
1316 * \param timeoutMS the maximum number of milliseconds to wait for the next
1317 * available event.
1318 * \returns true if this got an event or false if the timeout elapsed without
1319 * any events available.
1320 *
1321 * \threadsafety This function should only be called on the main thread.
1322 *
1323 * \since This function is available since SDL 3.2.0.
1324 *
1325 * \sa SDL_PollEvent
1326 * \sa SDL_PushEvent
1327 * \sa SDL_WaitEvent
1328 */
1329extern SDL_DECLSPEC bool SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS);
1330
1331/**
1332 * Add an event to the event queue.
1333 *
1334 * The event queue can actually be used as a two way communication channel.
1335 * Not only can events be read from the queue, but the user can also push
1336 * their own events onto it. `event` is a pointer to the event structure you
1337 * wish to push onto the queue. The event is copied into the queue, and the
1338 * caller may dispose of the memory pointed to after SDL_PushEvent() returns.
1339 *
1340 * Note: Pushing device input events onto the queue doesn't modify the state
1341 * of the device within SDL.
1342 *
1343 * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
1344 * the event filter but events added with SDL_PeepEvents() do not.
1345 *
1346 * For pushing application-specific events, please use SDL_RegisterEvents() to
1347 * get an event type that does not conflict with other code that also wants
1348 * its own custom event types.
1349 *
1350 * \param event the SDL_Event to be added to the queue.
1351 * \returns true on success, false if the event was filtered or on failure;
1352 * call SDL_GetError() for more information. A common reason for
1353 * error is the event queue being full.
1354 *
1355 * \threadsafety It is safe to call this function from any thread.
1356 *
1357 * \since This function is available since SDL 3.2.0.
1358 *
1359 * \sa SDL_PeepEvents
1360 * \sa SDL_PollEvent
1361 * \sa SDL_RegisterEvents
1362 */
1363extern SDL_DECLSPEC bool SDLCALL SDL_PushEvent(SDL_Event *event);
1364
1365/**
1366 * A function pointer used for callbacks that watch the event queue.
1367 *
1368 * \param userdata what was passed as `userdata` to SDL_SetEventFilter() or
1369 * SDL_AddEventWatch, etc.
1370 * \param event the event that triggered the callback.
1371 * \returns true to permit event to be added to the queue, and false to
1372 * disallow it. When used with SDL_AddEventWatch, the return value is
1373 * ignored.
1374 *
1375 * \threadsafety SDL may call this callback at any time from any thread; the
1376 * application is responsible for locking resources the callback
1377 * touches that need to be protected.
1378 *
1379 * \since This datatype is available since SDL 3.2.0.
1380 *
1381 * \sa SDL_SetEventFilter
1382 * \sa SDL_AddEventWatch
1383 */
1384typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event);
1385
1386/**
1387 * Set up a filter to process all events before they are added to the internal
1388 * event queue.
1389 *
1390 * If you just want to see events without modifying them or preventing them
1391 * from being queued, you should use SDL_AddEventWatch() instead.
1392 *
1393 * If the filter function returns true when called, then the event will be
1394 * added to the internal queue. If it returns false, then the event will be
1395 * dropped from the queue, but the internal state will still be updated. This
1396 * allows selective filtering of dynamically arriving events.
1397 *
1398 * **WARNING**: Be very careful of what you do in the event filter function,
1399 * as it may run in a different thread!
1400 *
1401 * On platforms that support it, if the quit event is generated by an
1402 * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
1403 * application at the next event poll.
1404 *
1405 * Note: Disabled events never make it to the event filter function; see
1406 * SDL_SetEventEnabled().
1407 *
1408 * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
1409 * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
1410 * not.
1411 *
1412 * \param filter an SDL_EventFilter function to call when an event happens.
1413 * \param userdata a pointer that is passed to `filter`.
1414 *
1415 * \threadsafety It is safe to call this function from any thread.
1416 *
1417 * \since This function is available since SDL 3.2.0.
1418 *
1419 * \sa SDL_AddEventWatch
1420 * \sa SDL_SetEventEnabled
1421 * \sa SDL_GetEventFilter
1422 * \sa SDL_PeepEvents
1423 * \sa SDL_PushEvent
1424 */
1425extern SDL_DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, void *userdata);
1426
1427/**
1428 * Query the current event filter.
1429 *
1430 * This function can be used to "chain" filters, by saving the existing filter
1431 * before replacing it with a function that will call that saved filter.
1432 *
1433 * \param filter the current callback function will be stored here.
1434 * \param userdata the pointer that is passed to the current event filter will
1435 * be stored here.
1436 * \returns true on success or false if there is no event filter set.
1437 *
1438 * \threadsafety It is safe to call this function from any thread.
1439 *
1440 * \since This function is available since SDL 3.2.0.
1441 *
1442 * \sa SDL_SetEventFilter
1443 */
1444extern SDL_DECLSPEC bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata);
1445
1446/**
1447 * Add a callback to be triggered when an event is added to the event queue.
1448 *
1449 * `filter` will be called when an event happens, and its return value is
1450 * ignored.
1451 *
1452 * **WARNING**: Be very careful of what you do in the event filter function,
1453 * as it may run in a different thread!
1454 *
1455 * If the quit event is generated by a signal (e.g. SIGINT), it will bypass
1456 * the internal queue and be delivered to the watch callback immediately, and
1457 * arrive at the next event poll.
1458 *
1459 * Note: the callback is called for events posted by the user through
1460 * SDL_PushEvent(), but not for disabled events, nor for events by a filter
1461 * callback set with SDL_SetEventFilter(), nor for events posted by the user
1462 * through SDL_PeepEvents().
1463 *
1464 * \param filter an SDL_EventFilter function to call when an event happens.
1465 * \param userdata a pointer that is passed to `filter`.
1466 * \returns true on success or false on failure; call SDL_GetError() for more
1467 * information.
1468 *
1469 * \threadsafety It is safe to call this function from any thread.
1470 *
1471 * \since This function is available since SDL 3.2.0.
1472 *
1473 * \sa SDL_RemoveEventWatch
1474 * \sa SDL_SetEventFilter
1475 */
1476extern SDL_DECLSPEC bool SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata);
1477
1478/**
1479 * Remove an event watch callback added with SDL_AddEventWatch().
1480 *
1481 * This function takes the same input as SDL_AddEventWatch() to identify and
1482 * delete the corresponding callback.
1483 *
1484 * \param filter the function originally passed to SDL_AddEventWatch().
1485 * \param userdata the pointer originally passed to SDL_AddEventWatch().
1486 *
1487 * \threadsafety It is safe to call this function from any thread.
1488 *
1489 * \since This function is available since SDL 3.2.0.
1490 *
1491 * \sa SDL_AddEventWatch
1492 */
1493extern SDL_DECLSPEC void SDLCALL SDL_RemoveEventWatch(SDL_EventFilter filter, void *userdata);
1494
1495/**
1496 * Run a specific filter function on the current event queue, removing any
1497 * events for which the filter returns false.
1498 *
1499 * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
1500 * this function does not change the filter permanently, it only uses the
1501 * supplied filter until this function returns.
1502 *
1503 * \param filter the SDL_EventFilter function to call when an event happens.
1504 * \param userdata a pointer that is passed to `filter`.
1505 *
1506 * \threadsafety It is safe to call this function from any thread.
1507 *
1508 * \since This function is available since SDL 3.2.0.
1509 *
1510 * \sa SDL_GetEventFilter
1511 * \sa SDL_SetEventFilter
1512 */
1513extern SDL_DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata);
1514
1515/**
1516 * Set the state of processing events by type.
1517 *
1518 * \param type the type of event; see SDL_EventType for details.
1519 * \param enabled whether to process the event or not.
1520 *
1521 * \threadsafety It is safe to call this function from any thread.
1522 *
1523 * \since This function is available since SDL 3.2.0.
1524 *
1525 * \sa SDL_EventEnabled
1526 */
1527extern SDL_DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, bool enabled);
1528
1529/**
1530 * Query the state of processing events by type.
1531 *
1532 * \param type the type of event; see SDL_EventType for details.
1533 * \returns true if the event is being processed, false otherwise.
1534 *
1535 * \threadsafety It is safe to call this function from any thread.
1536 *
1537 * \since This function is available since SDL 3.2.0.
1538 *
1539 * \sa SDL_SetEventEnabled
1540 */
1541extern SDL_DECLSPEC bool SDLCALL SDL_EventEnabled(Uint32 type);
1542
1543/**
1544 * Allocate a set of user-defined events, and return the beginning event
1545 * number for that set of events.
1546 *
1547 * \param numevents the number of events to be allocated.
1548 * \returns the beginning event number, or 0 if numevents is invalid or if
1549 * there are not enough user-defined events left.
1550 *
1551 * \threadsafety It is safe to call this function from any thread.
1552 *
1553 * \since This function is available since SDL 3.2.0.
1554 *
1555 * \sa SDL_PushEvent
1556 */
1557extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
1558
1559/**
1560 * Get window associated with an event.
1561 *
1562 * \param event an event containing a `windowID`.
1563 * \returns the associated window on success or NULL if there is none.
1564 *
1565 * \threadsafety It is safe to call this function from any thread.
1566 *
1567 * \since This function is available since SDL 3.2.0.
1568 *
1569 * \sa SDL_PollEvent
1570 * \sa SDL_WaitEvent
1571 * \sa SDL_WaitEventTimeout
1572 */
1573extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event);
1574
1575/**
1576 * Generate a human-readable description of an event.
1577 *
1578 * This will fill `buf` with a null-terminated string that might look
1579 * something like this:
1580 *
1581 * ```
1582 * SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6)
1583 * ```
1584 *
1585 * The exact format of the string is not guaranteed; it is intended for
1586 * logging purposes, to be read by a human, and not parsed by a computer.
1587 *
1588 * The returned value follows the same rules as SDL_snprintf(): `buf` will
1589 * always be NULL-terminated (unless `buflen` is zero), and will be truncated
1590 * if `buflen` is too small. The return code is the number of bytes needed for
1591 * the complete string, not counting the NULL-terminator, whether the string
1592 * was truncated or not. Unlike SDL_snprintf(), though, this function never
1593 * returns -1.
1594 *
1595 * \param event an event to describe. May be NULL.
1596 * \param buf the buffer to fill with the description string. May be NULL.
1597 * \param buflen the maximum bytes that can be written to `buf`.
1598 * \returns number of bytes needed for the full string, not counting the
1599 * null-terminator byte.
1600 *
1601 * \threadsafety It is safe to call this function from any thread.
1602 *
1603 * \since This function is available since SDL 3.4.0.
1604 */
1605extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen);
1606
1607/* Ends C function definitions when using C++ */
1608#ifdef __cplusplus
1609}
1610#endif
1611#include <SDL3/SDL_close_code.h>
1612
1613#endif /* SDL_events_h_ */
Uint32 SDL_AudioDeviceID
Definition SDL_audio.h:374
#define NULL
Uint32 SDL_CameraID
Definition SDL_camera.h:95
void SDL_RemoveEventWatch(SDL_EventFilter filter, void *userdata)
bool SDL_PollEvent(SDL_Event *event)
void SDL_SetEventEnabled(Uint32 type, bool enabled)
int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType)
bool SDL_HasEvents(Uint32 minType, Uint32 maxType)
void SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
bool(* SDL_EventFilter)(void *userdata, SDL_Event *event)
bool SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata)
SDL_Window * SDL_GetWindowFromEvent(const SDL_Event *event)
Uint32 SDL_RegisterEvents(int numevents)
SDL_EventType
Definition SDL_events.h:85
@ SDL_EVENT_KEYMAP_CHANGED
Definition SDL_events.h:173
@ SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED
Definition SDL_events.h:129
@ SDL_EVENT_PRIVATE0
Definition SDL_events.h:260
@ SDL_EVENT_PEN_PROXIMITY_OUT
Definition SDL_events.h:240
@ SDL_EVENT_WINDOW_HIT_TEST
Definition SDL_events.h:152
@ SDL_EVENT_GAMEPAD_ADDED
Definition SDL_events.h:202
@ SDL_EVENT_GAMEPAD_TOUCHPAD_UP
Definition SDL_events.h:207
@ SDL_EVENT_WINDOW_RESTORED
Definition SDL_events.h:146
@ SDL_EVENT_GAMEPAD_AXIS_MOTION
Definition SDL_events.h:199
@ SDL_EVENT_WINDOW_LAST
Definition SDL_events.h:166
@ SDL_EVENT_DROP_BEGIN
Definition SDL_events.h:226
@ SDL_EVENT_MOUSE_MOTION
Definition SDL_events.h:180
@ SDL_EVENT_WINDOW_FOCUS_GAINED
Definition SDL_events.h:149
@ SDL_EVENT_WINDOW_SAFE_AREA_CHANGED
Definition SDL_events.h:156
@ SDL_EVENT_MOUSE_WHEEL
Definition SDL_events.h:183
@ SDL_EVENT_JOYSTICK_REMOVED
Definition SDL_events.h:194
@ SDL_EVENT_WINDOW_ENTER_FULLSCREEN
Definition SDL_events.h:158
@ SDL_EVENT_PEN_DOWN
Definition SDL_events.h:241
@ SDL_EVENT_CLIPBOARD_UPDATE
Definition SDL_events.h:221
@ SDL_EVENT_DID_ENTER_FOREGROUND
Definition SDL_events.h:112
@ SDL_EVENT_JOYSTICK_BUTTON_UP
Definition SDL_events.h:192
@ SDL_EVENT_JOYSTICK_BATTERY_UPDATED
Definition SDL_events.h:195
@ SDL_EVENT_WILL_ENTER_FOREGROUND
Definition SDL_events.h:108
@ SDL_EVENT_PEN_MOTION
Definition SDL_events.h:245
@ SDL_EVENT_POLL_SENTINEL
Definition SDL_events.h:266
@ SDL_EVENT_CAMERA_DEVICE_REMOVED
Definition SDL_events.h:250
@ SDL_EVENT_JOYSTICK_UPDATE_COMPLETE
Definition SDL_events.h:196
@ SDL_EVENT_FINGER_UP
Definition SDL_events.h:214
@ SDL_EVENT_DISPLAY_REMOVED
Definition SDL_events.h:125
@ SDL_EVENT_JOYSTICK_ADDED
Definition SDL_events.h:193
@ SDL_EVENT_MOUSE_ADDED
Definition SDL_events.h:184
@ SDL_EVENT_DROP_POSITION
Definition SDL_events.h:228
@ SDL_EVENT_WINDOW_EXPOSED
Definition SDL_events.h:138
@ SDL_EVENT_WINDOW_DISPLAY_CHANGED
Definition SDL_events.h:154
@ SDL_EVENT_WINDOW_RESIZED
Definition SDL_events.h:141
@ SDL_EVENT_ENUM_PADDING
Definition SDL_events.h:279
@ SDL_EVENT_GAMEPAD_REMAPPED
Definition SDL_events.h:204
@ SDL_EVENT_GAMEPAD_REMOVED
Definition SDL_events.h:203
@ SDL_EVENT_WINDOW_HDR_STATE_CHANGED
Definition SDL_events.h:164
@ SDL_EVENT_FINGER_MOTION
Definition SDL_events.h:215
@ SDL_EVENT_WINDOW_MOUSE_ENTER
Definition SDL_events.h:147
@ SDL_EVENT_WINDOW_HIDDEN
Definition SDL_events.h:137
@ SDL_EVENT_RENDER_TARGETS_RESET
Definition SDL_events.h:255
@ SDL_EVENT_MOUSE_REMOVED
Definition SDL_events.h:185
@ SDL_EVENT_DID_ENTER_BACKGROUND
Definition SDL_events.h:104
@ SDL_EVENT_CAMERA_DEVICE_APPROVED
Definition SDL_events.h:251
@ SDL_EVENT_AUDIO_DEVICE_ADDED
Definition SDL_events.h:231
@ SDL_EVENT_RENDER_DEVICE_RESET
Definition SDL_events.h:256
@ SDL_EVENT_LOW_MEMORY
Definition SDL_events.h:96
@ SDL_EVENT_GAMEPAD_UPDATE_COMPLETE
Definition SDL_events.h:209
@ SDL_EVENT_WINDOW_DESTROYED
Definition SDL_events.h:160
@ SDL_EVENT_PEN_UP
Definition SDL_events.h:242
@ SDL_EVENT_GAMEPAD_BUTTON_DOWN
Definition SDL_events.h:200
@ SDL_EVENT_DISPLAY_ADDED
Definition SDL_events.h:124
@ SDL_EVENT_JOYSTICK_AXIS_MOTION
Definition SDL_events.h:188
@ SDL_EVENT_KEY_UP
Definition SDL_events.h:170
@ SDL_EVENT_WINDOW_CLOSE_REQUESTED
Definition SDL_events.h:151
@ SDL_EVENT_TEXT_INPUT
Definition SDL_events.h:172
@ SDL_EVENT_LOCALE_CHANGED
Definition SDL_events.h:117
@ SDL_EVENT_WINDOW_OCCLUDED
Definition SDL_events.h:157
@ SDL_EVENT_DISPLAY_LAST
Definition SDL_events.h:131
@ SDL_EVENT_WILL_ENTER_BACKGROUND
Definition SDL_events.h:100
@ SDL_EVENT_MOUSE_BUTTON_DOWN
Definition SDL_events.h:181
@ SDL_EVENT_USER
Definition SDL_events.h:271
@ SDL_EVENT_WINDOW_FIRST
Definition SDL_events.h:165
@ SDL_EVENT_SENSOR_UPDATE
Definition SDL_events.h:236
@ SDL_EVENT_PEN_BUTTON_DOWN
Definition SDL_events.h:243
@ SDL_EVENT_FIRST
Definition SDL_events.h:86
@ SDL_EVENT_PEN_PROXIMITY_IN
Definition SDL_events.h:239
@ SDL_EVENT_FINGER_CANCELED
Definition SDL_events.h:216
@ SDL_EVENT_DISPLAY_MOVED
Definition SDL_events.h:126
@ SDL_EVENT_JOYSTICK_BUTTON_DOWN
Definition SDL_events.h:191
@ SDL_EVENT_PEN_BUTTON_UP
Definition SDL_events.h:244
@ SDL_EVENT_MOUSE_BUTTON_UP
Definition SDL_events.h:182
@ SDL_EVENT_PRIVATE1
Definition SDL_events.h:261
@ SDL_EVENT_DROP_TEXT
Definition SDL_events.h:225
@ SDL_EVENT_DROP_FILE
Definition SDL_events.h:224
@ SDL_EVENT_KEYBOARD_REMOVED
Definition SDL_events.h:176
@ SDL_EVENT_WINDOW_FOCUS_LOST
Definition SDL_events.h:150
@ SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED
Definition SDL_events.h:210
@ SDL_EVENT_GAMEPAD_BUTTON_UP
Definition SDL_events.h:201
@ SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED
Definition SDL_events.h:128
@ SDL_EVENT_WINDOW_MAXIMIZED
Definition SDL_events.h:145
@ SDL_EVENT_PEN_AXIS
Definition SDL_events.h:246
@ SDL_EVENT_TERMINATING
Definition SDL_events.h:92
@ SDL_EVENT_RENDER_DEVICE_LOST
Definition SDL_events.h:257
@ SDL_EVENT_WINDOW_ICCPROF_CHANGED
Definition SDL_events.h:153
@ SDL_EVENT_SYSTEM_THEME_CHANGED
Definition SDL_events.h:119
@ SDL_EVENT_WINDOW_LEAVE_FULLSCREEN
Definition SDL_events.h:159
@ SDL_EVENT_CAMERA_DEVICE_ADDED
Definition SDL_events.h:249
@ SDL_EVENT_KEYBOARD_ADDED
Definition SDL_events.h:175
@ SDL_EVENT_GAMEPAD_SENSOR_UPDATE
Definition SDL_events.h:208
@ SDL_EVENT_JOYSTICK_HAT_MOTION
Definition SDL_events.h:190
@ SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
Definition SDL_events.h:233
@ SDL_EVENT_JOYSTICK_BALL_MOTION
Definition SDL_events.h:189
@ SDL_EVENT_PRIVATE3
Definition SDL_events.h:263
@ SDL_EVENT_WINDOW_SHOWN
Definition SDL_events.h:136
@ SDL_EVENT_KEY_DOWN
Definition SDL_events.h:169
@ SDL_EVENT_CAMERA_DEVICE_DENIED
Definition SDL_events.h:252
@ SDL_EVENT_TEXT_EDITING_CANDIDATES
Definition SDL_events.h:177
@ SDL_EVENT_WINDOW_MOVED
Definition SDL_events.h:140
@ SDL_EVENT_DISPLAY_FIRST
Definition SDL_events.h:130
@ SDL_EVENT_WINDOW_MINIMIZED
Definition SDL_events.h:144
@ SDL_EVENT_WINDOW_METAL_VIEW_RESIZED
Definition SDL_events.h:143
@ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED
Definition SDL_events.h:142
@ SDL_EVENT_DISPLAY_ORIENTATION
Definition SDL_events.h:123
@ SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED
Definition SDL_events.h:155
@ SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION
Definition SDL_events.h:206
@ SDL_EVENT_LAST
Definition SDL_events.h:276
@ SDL_EVENT_AUDIO_DEVICE_REMOVED
Definition SDL_events.h:232
@ SDL_EVENT_DROP_COMPLETE
Definition SDL_events.h:227
@ SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN
Definition SDL_events.h:205
@ SDL_EVENT_TEXT_EDITING
Definition SDL_events.h:171
@ SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED
Definition SDL_events.h:127
@ SDL_EVENT_WINDOW_MOUSE_LEAVE
Definition SDL_events.h:148
@ SDL_EVENT_QUIT
Definition SDL_events.h:89
@ SDL_EVENT_PRIVATE2
Definition SDL_events.h:262
@ SDL_EVENT_FINGER_DOWN
Definition SDL_events.h:213
bool SDL_WaitEvent(SDL_Event *event)
bool SDL_EventEnabled(Uint32 type)
void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
bool SDL_HasEvent(Uint32 type)
bool SDL_PushEvent(SDL_Event *event)
int SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen)
void SDL_FlushEvents(Uint32 minType, Uint32 maxType)
SDL_EventAction
@ SDL_ADDEVENT
@ SDL_PEEKEVENT
@ SDL_GETEVENT
void SDL_FlushEvent(Uint32 type)
bool SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
void SDL_PumpEvents(void)
bool SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS)
Uint32 SDL_JoystickID
Uint32 SDL_KeyboardID
Uint16 SDL_Keymod
Uint32 SDL_Keycode
Definition SDL_keycode.h:55
Uint32 SDL_MouseID
Definition SDL_mouse.h:81
Uint32 SDL_MouseButtonFlags
Definition SDL_mouse.h:148
SDL_MouseWheelDirection
Definition SDL_mouse.h:128
Uint32 SDL_PenID
Definition SDL_pen.h:71
SDL_PenAxis
Definition SDL_pen.h:119
Uint32 SDL_PenInputFlags
Definition SDL_pen.h:93
SDL_PowerState
Definition SDL_power.h:57
SDL_Scancode
Uint32 SDL_SensorID
Definition SDL_sensor.h:64
uint8_t Uint8
Definition SDL_stdinc.h:425
uint16_t Uint16
Definition SDL_stdinc.h:443
int32_t Sint32
Definition SDL_stdinc.h:452
int16_t Sint16
Definition SDL_stdinc.h:434
#define SDL_COMPILE_TIME_ASSERT(name, x)
Definition SDL_stdinc.h:209
#define bool
Definition SDL_stdinc.h:72
uint64_t Uint64
Definition SDL_stdinc.h:483
uint32_t Uint32
Definition SDL_stdinc.h:461
Uint64 SDL_TouchID
Definition SDL_touch.h:62
Uint64 SDL_FingerID
Definition SDL_touch.h:76
Uint32 SDL_DisplayID
Definition SDL_video.h:75
struct SDL_Window SDL_Window
Definition SDL_video.h:173
Uint32 SDL_WindowID
Definition SDL_video.h:84
SDL_AudioDeviceID which
Definition SDL_events.h:719
SDL_EventType type
Definition SDL_events.h:716
SDL_EventType type
Definition SDL_events.h:733
const char ** mime_types
Definition SDL_events.h:932
SDL_EventType type
Definition SDL_events.h:927
SDL_DisplayID displayID
Definition SDL_events.h:305
SDL_EventType type
Definition SDL_events.h:302
SDL_EventType type
Definition SDL_events.h:909
SDL_WindowID windowID
Definition SDL_events.h:912
Uint64 timestamp
Definition SDL_events.h:911
const char * data
Definition SDL_events.h:916
Uint32 reserved
Definition SDL_events.h:910
const char * source
Definition SDL_events.h:915
SDL_JoystickID which
Definition SDL_events.h:621
SDL_EventType type
Definition SDL_events.h:618
SDL_JoystickID which
Definition SDL_events.h:641
SDL_JoystickID which
Definition SDL_events.h:668
SDL_JoystickID which
Definition SDL_events.h:699
SDL_EventType type
Definition SDL_events.h:507
SDL_JoystickID which
Definition SDL_events.h:510
SDL_EventType type
Definition SDL_events.h:526
SDL_JoystickID which
Definition SDL_events.h:529
SDL_JoystickID which
Definition SDL_events.h:606
SDL_PowerState state
Definition SDL_events.h:607
SDL_EventType type
Definition SDL_events.h:603
SDL_JoystickID which
Definition SDL_events.h:571
SDL_EventType type
Definition SDL_events.h:568
SDL_EventType type
Definition SDL_events.h:590
SDL_JoystickID which
Definition SDL_events.h:593
SDL_JoystickID which
Definition SDL_events.h:548
SDL_EventType type
Definition SDL_events.h:545
SDL_KeyboardID which
Definition SDL_events.h:335
SDL_EventType type
Definition SDL_events.h:354
SDL_Keycode key
Definition SDL_events.h:360
SDL_KeyboardID which
Definition SDL_events.h:358
SDL_WindowID windowID
Definition SDL_events.h:357
SDL_Scancode scancode
Definition SDL_events.h:359
SDL_WindowID windowID
Definition SDL_events.h:469
SDL_EventType type
Definition SDL_events.h:466
SDL_EventType type
Definition SDL_events.h:434
SDL_WindowID windowID
Definition SDL_events.h:450
SDL_EventType type
Definition SDL_events.h:447
SDL_MouseButtonFlags state
Definition SDL_events.h:452
SDL_MouseWheelDirection direction
Definition SDL_events.h:493
SDL_EventType type
Definition SDL_events.h:486
SDL_MouseID which
Definition SDL_events.h:490
SDL_WindowID windowID
Definition SDL_events.h:489
SDL_PenAxis axis
Definition SDL_events.h:897
SDL_PenID which
Definition SDL_events.h:893
SDL_WindowID windowID
Definition SDL_events.h:892
SDL_PenInputFlags pen_state
Definition SDL_events.h:894
SDL_EventType type
Definition SDL_events.h:889
SDL_WindowID windowID
Definition SDL_events.h:870
SDL_EventType type
Definition SDL_events.h:867
SDL_PenInputFlags pen_state
Definition SDL_events.h:872
SDL_WindowID windowID
Definition SDL_events.h:828
SDL_EventType type
Definition SDL_events.h:825
SDL_PenInputFlags pen_state
Definition SDL_events.h:830
SDL_EventType type
Definition SDL_events.h:805
SDL_WindowID windowID
Definition SDL_events.h:808
SDL_EventType type
Definition SDL_events.h:845
SDL_WindowID windowID
Definition SDL_events.h:848
SDL_PenInputFlags pen_state
Definition SDL_events.h:850
SDL_EventType type
Definition SDL_events.h:957
Uint32 reserved
Definition SDL_events.h:958
Uint64 timestamp
Definition SDL_events.h:959
SDL_EventType type
Definition SDL_events.h:747
SDL_WindowID windowID
Definition SDL_events.h:750
Uint64 sensor_timestamp
Definition SDL_events.h:947
SDL_EventType type
Definition SDL_events.h:942
SDL_SensorID which
Definition SDL_events.h:945
const char *const * candidates
Definition SDL_events.h:398
SDL_EventType type
Definition SDL_events.h:378
const char * text
Definition SDL_events.h:382
SDL_WindowID windowID
Definition SDL_events.h:381
const char * text
Definition SDL_events.h:424
SDL_WindowID windowID
Definition SDL_events.h:423
SDL_EventType type
Definition SDL_events.h:420
SDL_FingerID fingerID
Definition SDL_events.h:779
SDL_TouchID touchID
Definition SDL_events.h:778
SDL_EventType type
Definition SDL_events.h:775
SDL_WindowID windowID
Definition SDL_events.h:785
Uint32 reserved
Definition SDL_events.h:976
SDL_WindowID windowID
Definition SDL_events.h:978
Uint64 timestamp
Definition SDL_events.h:977
SDL_EventType type
Definition SDL_events.h:317
SDL_WindowID windowID
Definition SDL_events.h:320
SDL_QuitEvent quit
SDL_AudioDeviceEvent adevice
SDL_PenProximityEvent pproximity
Uint8 padding[128]
SDL_JoyDeviceEvent jdevice
Uint32 type
Definition SDL_events.h:995
SDL_MouseWheelEvent wheel
SDL_PenTouchEvent ptouch
SDL_PenMotionEvent pmotion
SDL_JoyHatEvent jhat
SDL_ClipboardEvent clipboard
SDL_RenderEvent render
SDL_JoyButtonEvent jbutton
SDL_GamepadDeviceEvent gdevice
SDL_GamepadAxisEvent gaxis
SDL_PenAxisEvent paxis
SDL_WindowEvent window
Definition SDL_events.h:998
SDL_CameraDeviceEvent cdevice
SDL_GamepadTouchpadEvent gtouchpad
SDL_KeyboardDeviceEvent kdevice
Definition SDL_events.h:999
SDL_TextEditingEvent edit
SDL_TextInputEvent text
SDL_PenButtonEvent pbutton
SDL_GamepadSensorEvent gsensor
SDL_TouchFingerEvent tfinger
SDL_MouseButtonEvent button
SDL_UserEvent user
SDL_KeyboardEvent key
SDL_CommonEvent common
Definition SDL_events.h:996
SDL_MouseMotionEvent motion
SDL_JoyAxisEvent jaxis
SDL_MouseDeviceEvent mdevice
SDL_DropEvent drop
SDL_JoyBallEvent jball
SDL_JoyBatteryEvent jbattery
SDL_SensorEvent sensor
SDL_GamepadButtonEvent gbutton
SDL_TextEditingCandidatesEvent edit_candidates
SDL_DisplayEvent display
Definition SDL_events.h:997