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