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