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