SDL 3.0
SDL_events.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 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 * \file SDL_events.h
24 *
25 * Include file for SDL event handling.
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_quit.h>
38#include <SDL3/SDL_stdinc.h>
39#include <SDL3/SDL_touch.h>
40#include <SDL3/SDL_video.h>
41
42#include <SDL3/SDL_begin_code.h>
43/* Set up for C function definitions, even when using C++ */
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* General keyboard/mouse state definitions */
49#define SDL_RELEASED 0
50#define SDL_PRESSED 1
51
52/**
53 * The types of events that can be delivered.
54 */
55typedef enum
56{
57 SDL_EVENT_FIRST = 0, /**< Unused (do not remove) */
58
59 /* Application events */
60 SDL_EVENT_QUIT = 0x100, /**< User-requested quit */
61
62 /* These application events have special meaning on iOS, see README-ios.md for details */
63 SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS
64 Called on iOS in applicationWillTerminate()
65 Called on Android in onDestroy()
66 */
67 SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible.
68 Called on iOS in applicationDidReceiveMemoryWarning()
69 Called on Android in onLowMemory()
70 */
71 SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background
72 Called on iOS in applicationWillResignActive()
73 Called on Android in onPause()
74 */
75 SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time
76 Called on iOS in applicationDidEnterBackground()
77 Called on Android in onPause()
78 */
79 SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground
80 Called on iOS in applicationWillEnterForeground()
81 Called on Android in onResume()
82 */
83 SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive
84 Called on iOS in applicationDidBecomeActive()
85 Called on Android in onResume()
86 */
87
88 SDL_EVENT_LOCALE_CHANGED, /**< The user's locale preferences have changed. */
89
90 SDL_EVENT_SYSTEM_THEME_CHANGED, /**< The system theme changed */
91
92 /* Display events */
93 /* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */
94 SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */
95 SDL_EVENT_DISPLAY_CONNECTED, /**< Display has been added to the system */
96 SDL_EVENT_DISPLAY_DISCONNECTED, /**< Display has been removed from the system */
97 SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */
98 SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */
101
102 /* Window events */
103 /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */
104 SDL_EVENT_SYSWM = 0x201, /**< System specific event */
105 SDL_EVENT_WINDOW_SHOWN, /**< Window has been shown */
106 SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */
107 SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn */
108 SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */
109 SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */
110 SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */
111 SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */
112 SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */
113 SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */
114 SDL_EVENT_WINDOW_MOUSE_ENTER, /**< Window has gained mouse focus */
115 SDL_EVENT_WINDOW_MOUSE_LEAVE, /**< Window has lost mouse focus */
116 SDL_EVENT_WINDOW_FOCUS_GAINED, /**< Window has gained keyboard focus */
117 SDL_EVENT_WINDOW_FOCUS_LOST, /**< Window has lost keyboard focus */
118 SDL_EVENT_WINDOW_CLOSE_REQUESTED, /**< The window manager requests that the window be closed */
119 SDL_EVENT_WINDOW_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
120 SDL_EVENT_WINDOW_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */
121 SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */
122 SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */
123 SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */
124 SDL_EVENT_WINDOW_DESTROYED, /**< The window with the associated ID is being or has been destroyed. If this message is being handled
125 in an event watcher, the window handle is still valid and can still be used to retrieve any userdata
126 associated with the window. Otherwise, the handle has already been destroyed and all resources
127 associated with it are invalid */
130
131 /* Keyboard events */
132 SDL_EVENT_KEY_DOWN = 0x300, /**< Key pressed */
133 SDL_EVENT_KEY_UP, /**< Key released */
134 SDL_EVENT_TEXT_EDITING, /**< Keyboard text editing (composition) */
135 SDL_EVENT_TEXT_INPUT, /**< Keyboard text input */
136 SDL_EVENT_KEYMAP_CHANGED, /**< Keymap changed due to a system event such as an
137 input language or keyboard layout change. */
138 SDL_EVENT_TEXT_EDITING_EXT, /**< Extended keyboard text editing (composition) */
139
140 /* Mouse events */
141 SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
142 SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */
143 SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */
144 SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */
145
146 /* Joystick events */
147 SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */
148 SDL_EVENT_JOYSTICK_HAT_MOTION = 0x602, /**< Joystick hat position change */
149 SDL_EVENT_JOYSTICK_BUTTON_DOWN, /**< Joystick button pressed */
150 SDL_EVENT_JOYSTICK_BUTTON_UP, /**< Joystick button released */
151 SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */
152 SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
153 SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */
154
155 /* Gamepad events */
156 SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */
157 SDL_EVENT_GAMEPAD_BUTTON_DOWN, /**< Gamepad button pressed */
158 SDL_EVENT_GAMEPAD_BUTTON_UP, /**< Gamepad button released */
159 SDL_EVENT_GAMEPAD_ADDED, /**< A new gamepad has been inserted into the system */
160 SDL_EVENT_GAMEPAD_REMOVED, /**< An opened gamepad has been removed */
161 SDL_EVENT_GAMEPAD_REMAPPED, /**< The gamepad mapping was updated */
162 SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN, /**< Gamepad touchpad was touched */
163 SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, /**< Gamepad touchpad finger was moved */
164 SDL_EVENT_GAMEPAD_TOUCHPAD_UP, /**< Gamepad touchpad finger was lifted */
165 SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */
166
167 /* Touch events */
171
172 /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */
173
174 /* Clipboard events */
175 SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard or primary selection changed */
176 SDL_EVENT_CLIPBOARD_CANCELLED, /**< The clipboard or primary selection cancelled */
177
178 /* Drag and drop events */
179 SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */
180 SDL_EVENT_DROP_TEXT, /**< text/plain drag-and-drop event */
181 SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */
182 SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */
183 SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */
184
185 /* Audio hotplug events */
186 SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */
187 SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */
188
189 /* Sensor events */
190 SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */
191
192 /* Render events */
193 SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
194 SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
195
196 /* Internal events */
197 SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
198
199 /** Events ::SDL_EVENT_USER through ::SDL_EVENT_LAST are for your use,
200 * and should be allocated with SDL_RegisterEvents()
201 */
203
204 /**
205 * This last event is only for bounding internal arrays
206 */
207 SDL_EVENT_LAST = 0xFFFF
209
210/**
211 * \brief Fields shared by every event
212 */
213typedef struct SDL_CommonEvent
214{
216 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
218
219/**
220 * \brief Display state change event data (event.display.*)
221 */
222typedef struct SDL_DisplayEvent
223{
224 Uint32 type; /**< ::SDL_DISPLAYEVENT_* */
225 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
226 SDL_DisplayID displayID;/**< The associated display */
227 Sint32 data1; /**< event dependent data */
229
230/**
231 * \brief Window state change event data (event.window.*)
232 */
233typedef struct SDL_WindowEvent
234{
235 Uint32 type; /**< ::SDL_WINDOWEVENT_* */
236 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
237 SDL_WindowID windowID;/**< The associated window */
238 Sint32 data1; /**< event dependent data */
239 Sint32 data2; /**< event dependent data */
241
242/**
243 * \brief Keyboard button event structure (event.key.*)
244 */
245typedef struct SDL_KeyboardEvent
246{
247 Uint32 type; /**< ::SDL_EVENT_KEY_DOWN or ::SDL_EVENT_KEY_UP */
248 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
249 SDL_WindowID windowID;/**< The window with keyboard focus, if any */
250 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
251 Uint8 repeat; /**< Non-zero if this is a key repeat */
254 SDL_Keysym keysym; /**< The key that was pressed or released */
256
257#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
258/**
259 * \brief Keyboard text editing event structure (event.edit.*)
260 */
262{
263 Uint32 type; /**< ::SDL_EVENT_TEXT_EDITING */
264 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
265 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
266 char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
267 Sint32 start; /**< The start cursor of selected editing text */
268 Sint32 length; /**< The length of selected editing text */
270
271/**
272 * \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
273 * truncated if stored in the text buffer SDL_TextEditingEvent
274 */
276{
277 Uint32 type; /**< ::SDL_EVENT_TEXT_EDITING_EXT */
278 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
279 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
280 char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
281 Sint32 start; /**< The start cursor of selected editing text */
282 Sint32 length; /**< The length of selected editing text */
284
285#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
286/**
287 * \brief Keyboard text input event structure (event.text.*)
288 */
289typedef struct SDL_TextInputEvent
290{
291 Uint32 type; /**< ::SDL_EVENT_TEXT_INPUT */
292 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
293 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
294 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
296
297/**
298 * \brief Mouse motion event structure (event.motion.*)
299 */
301{
302 Uint32 type; /**< ::SDL_EVENT_MOUSE_MOTION */
303 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
304 SDL_WindowID windowID;/**< The window with mouse focus, if any */
305 SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
306 Uint32 state; /**< The current button state */
307 float x; /**< X coordinate, relative to window */
308 float y; /**< Y coordinate, relative to window */
309 float xrel; /**< The relative motion in the X direction */
310 float yrel; /**< The relative motion in the Y direction */
312
313/**
314 * \brief Mouse button event structure (event.button.*)
315 */
317{
318 Uint32 type; /**< ::SDL_EVENT_MOUSE_BUTTON_DOWN or ::SDL_EVENT_MOUSE_BUTTON_UP */
319 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
320 SDL_WindowID windowID;/**< The window with mouse focus, if any */
321 SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
322 Uint8 button; /**< The mouse button index */
323 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
324 Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
326 float x; /**< X coordinate, relative to window */
327 float y; /**< Y coordinate, relative to window */
329
330/**
331 * \brief Mouse wheel event structure (event.wheel.*)
332 */
334{
335 Uint32 type; /**< ::SDL_EVENT_MOUSE_WHEEL */
336 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
337 SDL_WindowID windowID;/**< The window with mouse focus, if any */
338 SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
339 float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
340 float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
341 Uint32 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 */
342 float mouseX; /**< X coordinate, relative to window */
343 float mouseY; /**< Y coordinate, relative to window */
345
346/**
347 * \brief Joystick axis motion event structure (event.jaxis.*)
348 */
349typedef struct SDL_JoyAxisEvent
350{
351 Uint32 type; /**< ::SDL_EVENT_JOYSTICK_AXIS_MOTION */
352 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
353 SDL_JoystickID which; /**< The joystick instance id */
354 Uint8 axis; /**< The joystick axis index */
358 Sint16 value; /**< The axis value (range: -32768 to 32767) */
361
362/**
363 * \brief Joystick hat position change event structure (event.jhat.*)
364 */
365typedef struct SDL_JoyHatEvent
366{
367 Uint32 type; /**< ::SDL_EVENT_JOYSTICK_HAT_MOTION */
368 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
369 SDL_JoystickID which; /**< The joystick instance id */
370 Uint8 hat; /**< The joystick hat index */
371 Uint8 value; /**< The hat position value.
372 * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
373 * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
374 * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
375 *
376 * Note that zero means the POV is centered.
377 */
381
382/**
383 * \brief Joystick button event structure (event.jbutton.*)
384 */
385typedef struct SDL_JoyButtonEvent
386{
387 Uint32 type; /**< ::SDL_EVENT_JOYSTICK_BUTTON_DOWN or ::SDL_EVENT_JOYSTICK_BUTTON_UP */
388 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
389 SDL_JoystickID which; /**< The joystick instance id */
390 Uint8 button; /**< The joystick button index */
391 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
395
396/**
397 * \brief Joystick device event structure (event.jdevice.*)
398 */
399typedef struct SDL_JoyDeviceEvent
400{
401 Uint32 type; /**< ::SDL_EVENT_JOYSTICK_ADDED or ::SDL_EVENT_JOYSTICK_REMOVED */
402 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
403 SDL_JoystickID which; /**< The joystick instance id */
405
406/**
407 * \brief Joysick battery level change event structure (event.jbattery.*)
408 */
410{
411 Uint32 type; /**< ::SDL_EVENT_JOYSTICK_BATTERY_UPDATED */
412 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
413 SDL_JoystickID which; /**< The joystick instance id */
414 SDL_JoystickPowerLevel level; /**< The joystick battery level */
416
417/**
418 * \brief Gamepad axis motion event structure (event.gaxis.*)
419 */
421{
422 Uint32 type; /**< ::SDL_EVENT_GAMEPAD_AXIS_MOTION */
423 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
424 SDL_JoystickID which; /**< The joystick instance id */
425 Uint8 axis; /**< The gamepad axis (SDL_GamepadAxis) */
429 Sint16 value; /**< The axis value (range: -32768 to 32767) */
432
433
434/**
435 * \brief Gamepad button event structure (event.gbutton.*)
436 */
438{
439 Uint32 type; /**< ::SDL_EVENT_GAMEPAD_BUTTON_DOWN or ::SDL_EVENT_GAMEPAD_BUTTON_UP */
440 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
441 SDL_JoystickID which; /**< The joystick instance id */
442 Uint8 button; /**< The gamepad button (SDL_GamepadButton) */
443 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
447
448
449/**
450 * \brief Gamepad device event structure (event.gdevice.*)
451 */
453{
454 Uint32 type; /**< ::SDL_EVENT_GAMEPAD_ADDED, ::SDL_EVENT_GAMEPAD_REMOVED, or ::SDL_EVENT_GAMEPAD_REMAPPED */
455 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
456 SDL_JoystickID which; /**< The joystick instance id */
458
459/**
460 * \brief Gamepad touchpad event structure (event.gtouchpad.*)
461 */
463{
464 Uint32 type; /**< ::SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or ::SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or ::SDL_EVENT_GAMEPAD_TOUCHPAD_UP */
465 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
466 SDL_JoystickID which; /**< The joystick instance id */
467 Sint32 touchpad; /**< The index of the touchpad */
468 Sint32 finger; /**< The index of the finger on the touchpad */
469 float x; /**< Normalized in the range 0...1 with 0 being on the left */
470 float y; /**< Normalized in the range 0...1 with 0 being at the top */
471 float pressure; /**< Normalized in the range 0...1 */
473
474/**
475 * \brief Gamepad sensor event structure (event.gsensor.*)
476 */
478{
479 Uint32 type; /**< ::SDL_EVENT_GAMEPAD_SENSOR_UPDATE */
480 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
481 SDL_JoystickID which; /**< The joystick instance id */
482 Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
483 float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
484 Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */
486
487/**
488 * \brief Audio device event structure (event.adevice.*)
489 */
491{
492 Uint32 type; /**< ::SDL_EVENT_AUDIO_DEVICE_ADDED, or ::SDL_EVENT_AUDIO_DEVICE_REMOVED */
493 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
494 SDL_AudioDeviceID which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
495 Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
500
501
502/**
503 * \brief Touch finger event structure (event.tfinger.*)
504 */
506{
507 Uint32 type; /**< ::SDL_EVENT_FINGER_MOTION or ::SDL_EVENT_FINGER_DOWN or ::SDL_EVENT_FINGER_UP */
508 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
509 SDL_TouchID touchId; /**< The touch device id */
511 float x; /**< Normalized in the range 0...1 */
512 float y; /**< Normalized in the range 0...1 */
513 float dx; /**< Normalized in the range -1...1 */
514 float dy; /**< Normalized in the range -1...1 */
515 float pressure; /**< Normalized in the range 0...1 */
516 SDL_WindowID windowID;/**< The window underneath the finger, if any */
518
519
520/**
521 * \brief An event used to request a file open by the system (event.drop.*)
522 * This event is enabled by default, you can disable it with SDL_SetEventEnabled().
523 * \note If this event is enabled, you must free the filename in the event.
524 */
525typedef struct SDL_DropEvent
526{
527 Uint32 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 */
528 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
529 char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
530 SDL_WindowID windowID; /**< The window that was dropped on, if any */
531 float x; /**< X coordinate, relative to window (not on begin) */
532 float y; /**< Y coordinate, relative to window (not on begin) */
534
535/**
536 * \brief An event triggered when the applications active clipboard content is cancelled by new clipboard content
537 * \note Primary use for this event is to free any userdata you may have provided when setting the clipboard data.
538 *
539 * \sa SDL_SetClipboardData
540 */
541typedef struct SDL_ClipboardCancelled
542{
543 Uint32 type; /**< ::SDL_EVENT_CLIPBOARD_CANCELLED or ::SDL_EVENT_CLIPBOARD_UPDATE */
544 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
545 void *userdata; /**< User data if any has been set. NULL for ::SDL_EVENT_CLIPBOARD_UPDATE */
547
548/**
549 * \brief Sensor event structure (event.sensor.*)
550 */
551typedef struct SDL_SensorEvent
552{
553 Uint32 type; /**< ::SDL_EVENT_SENSOR_UPDATE */
554 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
555 SDL_SensorID which; /**< The instance ID of the sensor */
556 float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData() */
557 Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */
559
560/**
561 * \brief The "quit requested" event
562 */
563typedef struct SDL_QuitEvent
564{
565 Uint32 type; /**< ::SDL_EVENT_QUIT */
566 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
568
569/**
570 * \brief OS Specific event
571 */
572typedef struct SDL_OSEvent
573{
574 Uint32 type; /**< ::SDL_EVENT_QUIT */
575 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
577
578/**
579 * \brief A user-defined event type (event.user.*)
580 */
581typedef struct SDL_UserEvent
582{
583 Uint32 type; /**< ::SDL_EVENT_USER through ::SDL_EVENT_LAST-1 */
584 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
585 SDL_WindowID windowID;/**< The associated window if any */
586 Sint32 code; /**< User defined event code */
587 void *data1; /**< User defined data pointer */
588 void *data2; /**< User defined data pointer */
590
591
592struct SDL_SysWMmsg;
593typedef struct SDL_SysWMmsg SDL_SysWMmsg;
594
595/**
596 * \brief A video driver dependent system event (event.syswm.*)
597 * This event is disabled by default, you can enable it with SDL_SetEventEnabled()
598 *
599 * \note If you want to use this event, you should include SDL_syswm.h.
600 */
601typedef struct SDL_SysWMEvent
602{
603 Uint32 type; /**< ::SDL_EVENT_SYSWM */
604 Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
605 SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
607
608/**
609 * \brief General event structure
610 */
611typedef union SDL_Event
612{
613 Uint32 type; /**< Event type, shared with all events */
614 SDL_CommonEvent common; /**< Common event data */
615 SDL_DisplayEvent display; /**< Display event data */
616 SDL_WindowEvent window; /**< Window event data */
617 SDL_KeyboardEvent key; /**< Keyboard event data */
618 SDL_TextEditingEvent edit; /**< Text editing event data */
619 SDL_TextEditingExtEvent editExt; /**< Extended text editing event data */
620 SDL_TextInputEvent text; /**< Text input event data */
621 SDL_MouseMotionEvent motion; /**< Mouse motion event data */
622 SDL_MouseButtonEvent button; /**< Mouse button event data */
623 SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
624 SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
625 SDL_JoyHatEvent jhat; /**< Joystick hat event data */
626 SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
627 SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
628 SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
629 SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */
630 SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */
631 SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */
632 SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */
633 SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */
634 SDL_AudioDeviceEvent adevice; /**< Audio device event data */
635 SDL_SensorEvent sensor; /**< Sensor event data */
636 SDL_QuitEvent quit; /**< Quit request event data */
637 SDL_UserEvent user; /**< Custom event data */
638 SDL_SysWMEvent syswm; /**< System dependent window event data */
639 SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
640 SDL_DropEvent drop; /**< Drag and drop event data */
641 SDL_ClipboardEvent clipboard; /**< Clipboard cancelled event data */
642
643 /* This is necessary for ABI compatibility between Visual C++ and GCC.
644 Visual C++ will respect the push pack pragma and use 52 bytes (size of
645 SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
646 architectures) for this union, and GCC will use the alignment of the
647 largest datatype within the union, which is 8 bytes on 64-bit
648 architectures.
649
650 So... we'll add padding to force the size to be 56 bytes for both.
651
652 On architectures where pointers are 16 bytes, this needs rounding up to
653 the next multiple of 16, 64, and on architectures where pointers are
654 even larger the size of SDL_UserEvent will dominate as being 3 pointers.
655 */
657} SDL_Event;
658
659/* Make sure we haven't broken binary compatibility */
660SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
661
662
663/* Function prototypes */
664
665/**
666 * Pump the event loop, gathering events from the input devices.
667 *
668 * This function updates the event queue and internal input device state.
669 *
670 * **WARNING**: This should only be run in the thread that initialized the
671 * video subsystem, and for extra safety, you should consider only doing those
672 * things on the main thread in any case.
673 *
674 * SDL_PumpEvents() gathers all the pending input information from devices and
675 * places it in the event queue. Without calls to SDL_PumpEvents() no events
676 * would ever be placed on the queue. Often the need for calls to
677 * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
678 * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
679 * polling or waiting for events (e.g. you are filtering them), then you must
680 * call SDL_PumpEvents() to force an event queue update.
681 *
682 * \since This function is available since SDL 3.0.0.
683 *
684 * \sa SDL_PollEvent
685 * \sa SDL_WaitEvent
686 */
687extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
688
689/* @{ */
690typedef enum
691{
696
697/**
698 * Check the event queue for messages and optionally return them.
699 *
700 * `action` may be any of the following:
701 *
702 * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the
703 * event queue.
704 * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
705 * within the specified minimum and maximum type, will be returned to the
706 * caller and will _not_ be removed from the queue.
707 * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
708 * within the specified minimum and maximum type, will be returned to the
709 * caller and will be removed from the queue.
710 *
711 * You may have to call SDL_PumpEvents() before calling this function.
712 * Otherwise, the events may not be ready to be filtered when you call
713 * SDL_PeepEvents().
714 *
715 * This function is thread-safe.
716 *
717 * \param events destination buffer for the retrieved events
718 * \param numevents if action is SDL_ADDEVENT, the number of events to add
719 * back to the event queue; if action is SDL_PEEKEVENT or
720 * SDL_GETEVENT, the maximum number of events to retrieve
721 * \param action action to take; see [[#action|Remarks]] for details
722 * \param minType minimum value of the event type to be considered;
723 * SDL_EVENT_FIRST is a safe choice
724 * \param maxType maximum value of the event type to be considered;
725 * SDL_EVENT_LAST is a safe choice
726 * \returns the number of events actually stored or a negative error code on
727 * failure; call SDL_GetError() for more information.
728 *
729 * \since This function is available since SDL 3.0.0.
730 *
731 * \sa SDL_PollEvent
732 * \sa SDL_PumpEvents
733 * \sa SDL_PushEvent
734 */
735extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
736 SDL_eventaction action,
737 Uint32 minType, Uint32 maxType);
738/* @} */
739
740/**
741 * Check for the existence of a certain event type in the event queue.
742 *
743 * If you need to check for a range of event types, use SDL_HasEvents()
744 * instead.
745 *
746 * \param type the type of event to be queried; see SDL_EventType for details
747 * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
748 * events matching `type` are not present.
749 *
750 * \since This function is available since SDL 3.0.0.
751 *
752 * \sa SDL_HasEvents
753 */
754extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
755
756
757/**
758 * Check for the existence of certain event types in the event queue.
759 *
760 * If you need to check for a single event type, use SDL_HasEvent() instead.
761 *
762 * \param minType the low end of event type to be queried, inclusive; see
763 * SDL_EventType for details
764 * \param maxType the high end of event type to be queried, inclusive; see
765 * SDL_EventType for details
766 * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
767 * present, or SDL_FALSE if not.
768 *
769 * \since This function is available since SDL 3.0.0.
770 *
771 * \sa SDL_HasEvents
772 */
773extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
774
775/**
776 * Clear events of a specific type from the event queue.
777 *
778 * This will unconditionally remove any events from the queue that match
779 * `type`. If you need to remove a range of event types, use SDL_FlushEvents()
780 * instead.
781 *
782 * It's also normal to just ignore events you don't care about in your event
783 * loop without calling this function.
784 *
785 * This function only affects currently queued events. If you want to make
786 * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
787 * on the main thread immediately before the flush call.
788 *
789 * \param type the type of event to be cleared; see SDL_EventType for details
790 *
791 * \since This function is available since SDL 3.0.0.
792 *
793 * \sa SDL_FlushEvents
794 */
795extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
796
797/**
798 * Clear events of a range of types from the event queue.
799 *
800 * This will unconditionally remove any events from the queue that are in the
801 * range of `minType` to `maxType`, inclusive. If you need to remove a single
802 * event type, use SDL_FlushEvent() instead.
803 *
804 * It's also normal to just ignore events you don't care about in your event
805 * loop without calling this function.
806 *
807 * This function only affects currently queued events. If you want to make
808 * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
809 * on the main thread immediately before the flush call.
810 *
811 * \param minType the low end of event type to be cleared, inclusive; see
812 * SDL_EventType for details
813 * \param maxType the high end of event type to be cleared, inclusive; see
814 * SDL_EventType for details
815 *
816 * \since This function is available since SDL 3.0.0.
817 *
818 * \sa SDL_FlushEvent
819 */
820extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
821
822/**
823 * Poll for currently pending events.
824 *
825 * If `event` is not NULL, the next event is removed from the queue and stored
826 * in the SDL_Event structure pointed to by `event`. The 1 returned refers to
827 * this event, immediately stored in the SDL Event structure -- not an event
828 * to follow.
829 *
830 * If `event` is NULL, it simply returns 1 if there is an event in the queue,
831 * but will not remove it from the queue.
832 *
833 * As this function may implicitly call SDL_PumpEvents(), you can only call
834 * this function in the thread that set the video mode.
835 *
836 * SDL_PollEvent() is the favored way of receiving system events since it can
837 * be done from the main loop and does not suspend the main loop while waiting
838 * on an event to be posted.
839 *
840 * The common practice is to fully process the event queue once every frame,
841 * usually as a first step before updating the game's state:
842 *
843 * ```c
844 * while (game_is_still_running) {
845 * SDL_Event event;
846 * while (SDL_PollEvent(&event)) { // poll until all events are handled!
847 * // decide what to do with this event.
848 * }
849 *
850 * // update game state, draw the current frame
851 * }
852 * ```
853 *
854 * \param event the SDL_Event structure to be filled with the next event from
855 * the queue, or NULL
856 * \returns 1 if there is a pending event or 0 if there are none available.
857 *
858 * \since This function is available since SDL 3.0.0.
859 *
860 * \sa SDL_GetEventFilter
861 * \sa SDL_PeepEvents
862 * \sa SDL_PushEvent
863 * \sa SDL_SetEventFilter
864 * \sa SDL_WaitEvent
865 * \sa SDL_WaitEventTimeout
866 */
867extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
868
869/**
870 * Wait indefinitely for the next available event.
871 *
872 * If `event` is not NULL, the next event is removed from the queue and stored
873 * in the SDL_Event structure pointed to by `event`.
874 *
875 * As this function may implicitly call SDL_PumpEvents(), you can only call
876 * this function in the thread that initialized the video subsystem.
877 *
878 * \param event the SDL_Event structure to be filled in with the next event
879 * from the queue, or NULL
880 * \returns 1 on success or 0 if there was an error while waiting for events;
881 * call SDL_GetError() for more information.
882 *
883 * \since This function is available since SDL 3.0.0.
884 *
885 * \sa SDL_PollEvent
886 * \sa SDL_PumpEvents
887 * \sa SDL_WaitEventTimeout
888 */
889extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event);
890
891/**
892 * Wait until the specified timeout (in milliseconds) for the next available
893 * event.
894 *
895 * If `event` is not NULL, the next event is removed from the queue and stored
896 * in the SDL_Event structure pointed to by `event`.
897 *
898 * As this function may implicitly call SDL_PumpEvents(), you can only call
899 * this function in the thread that initialized the video subsystem.
900 *
901 * The timeout is not guaranteed, the actual wait time could be longer due to
902 * system scheduling.
903 *
904 * \param event the SDL_Event structure to be filled in with the next event
905 * from the queue, or NULL
906 * \param timeoutMS the maximum number of milliseconds to wait for the next
907 * available event
908 * \returns 1 on success or 0 if there was an error while waiting for events;
909 * call SDL_GetError() for more information. This also returns 0 if
910 * the timeout elapsed without an event arriving.
911 *
912 * \since This function is available since SDL 3.0.0.
913 *
914 * \sa SDL_PollEvent
915 * \sa SDL_PumpEvents
916 * \sa SDL_WaitEvent
917 */
918extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS);
919
920/**
921 * Add an event to the event queue.
922 *
923 * The event queue can actually be used as a two way communication channel.
924 * Not only can events be read from the queue, but the user can also push
925 * their own events onto it. `event` is a pointer to the event structure you
926 * wish to push onto the queue. The event is copied into the queue, and the
927 * caller may dispose of the memory pointed to after SDL_PushEvent() returns.
928 *
929 * Note: Pushing device input events onto the queue doesn't modify the state
930 * of the device within SDL.
931 *
932 * This function is thread-safe, and can be called from other threads safely.
933 *
934 * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
935 * the event filter but events added with SDL_PeepEvents() do not.
936 *
937 * For pushing application-specific events, please use SDL_RegisterEvents() to
938 * get an event type that does not conflict with other code that also wants
939 * its own custom event types.
940 *
941 * \param event the SDL_Event to be added to the queue
942 * \returns 1 on success, 0 if the event was filtered, or a negative error
943 * code on failure; call SDL_GetError() for more information. A
944 * common reason for error is the event queue being full.
945 *
946 * \since This function is available since SDL 3.0.0.
947 *
948 * \sa SDL_PeepEvents
949 * \sa SDL_PollEvent
950 * \sa SDL_RegisterEvents
951 */
952extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
953
954/**
955 * A function pointer used for callbacks that watch the event queue.
956 *
957 * \param userdata what was passed as `userdata` to SDL_SetEventFilter()
958 * or SDL_AddEventWatch, etc
959 * \param event the event that triggered the callback
960 * \returns 1 to permit event to be added to the queue, and 0 to disallow
961 * it. When used with SDL_AddEventWatch, the return value is ignored.
962 *
963 * \sa SDL_SetEventFilter
964 * \sa SDL_AddEventWatch
965 */
966typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
967
968/**
969 * Set up a filter to process all events before they change internal state and
970 * are posted to the internal event queue.
971 *
972 * If the filter function returns 1 when called, then the event will be added
973 * to the internal queue. If it returns 0, then the event will be dropped from
974 * the queue, but the internal state will still be updated. This allows
975 * selective filtering of dynamically arriving events.
976 *
977 * **WARNING**: Be very careful of what you do in the event filter function,
978 * as it may run in a different thread!
979 *
980 * On platforms that support it, if the quit event is generated by an
981 * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
982 * application at the next event poll.
983 *
984 * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
985 * event filter is only called when the window manager desires to close the
986 * application window. If the event filter returns 1, then the window will be
987 * closed, otherwise the window will remain open if possible.
988 *
989 * Note: Disabled events never make it to the event filter function; see
990 * SDL_SetEventEnabled().
991 *
992 * Note: If you just want to inspect events without filtering, you should use
993 * SDL_AddEventWatch() instead.
994 *
995 * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
996 * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
997 * not.
998 *
999 * \param filter An SDL_EventFilter function to call when an event happens
1000 * \param userdata a pointer that is passed to `filter`
1001 *
1002 * \since This function is available since SDL 3.0.0.
1003 *
1004 * \sa SDL_AddEventWatch
1005 * \sa SDL_SetEventEnabled
1006 * \sa SDL_GetEventFilter
1007 * \sa SDL_PeepEvents
1008 * \sa SDL_PushEvent
1009 */
1010extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
1011 void *userdata);
1012
1013/**
1014 * Query the current event filter.
1015 *
1016 * This function can be used to "chain" filters, by saving the existing filter
1017 * before replacing it with a function that will call that saved filter.
1018 *
1019 * \param filter the current callback function will be stored here
1020 * \param userdata the pointer that is passed to the current event filter will
1021 * be stored here
1022 * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
1023 *
1024 * \since This function is available since SDL 3.0.0.
1025 *
1026 * \sa SDL_SetEventFilter
1027 */
1028extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
1029 void **userdata);
1030
1031/**
1032 * Add a callback to be triggered when an event is added to the event queue.
1033 *
1034 * `filter` will be called when an event happens, and its return value is
1035 * ignored.
1036 *
1037 * **WARNING**: Be very careful of what you do in the event filter function,
1038 * as it may run in a different thread!
1039 *
1040 * If the quit event is generated by a signal (e.g. SIGINT), it will bypass
1041 * the internal queue and be delivered to the watch callback immediately, and
1042 * arrive at the next event poll.
1043 *
1044 * Note: the callback is called for events posted by the user through
1045 * SDL_PushEvent(), but not for disabled events, nor for events by a filter
1046 * callback set with SDL_SetEventFilter(), nor for events posted by the user
1047 * through SDL_PeepEvents().
1048 *
1049 * \param filter an SDL_EventFilter function to call when an event happens.
1050 * \param userdata a pointer that is passed to `filter`
1051 *
1052 * \since This function is available since SDL 3.0.0.
1053 *
1054 * \sa SDL_DelEventWatch
1055 * \sa SDL_SetEventFilter
1056 */
1057extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
1058 void *userdata);
1059
1060/**
1061 * Remove an event watch callback added with SDL_AddEventWatch().
1062 *
1063 * This function takes the same input as SDL_AddEventWatch() to identify and
1064 * delete the corresponding callback.
1065 *
1066 * \param filter the function originally passed to SDL_AddEventWatch()
1067 * \param userdata the pointer originally passed to SDL_AddEventWatch()
1068 *
1069 * \since This function is available since SDL 3.0.0.
1070 *
1071 * \sa SDL_AddEventWatch
1072 */
1073extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
1074 void *userdata);
1075
1076/**
1077 * Run a specific filter function on the current event queue, removing any
1078 * events for which the filter returns 0.
1079 *
1080 * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
1081 * this function does not change the filter permanently, it only uses the
1082 * supplied filter until this function returns.
1083 *
1084 * \param filter the SDL_EventFilter function to call when an event happens
1085 * \param userdata a pointer that is passed to `filter`
1086 *
1087 * \since This function is available since SDL 3.0.0.
1088 *
1089 * \sa SDL_GetEventFilter
1090 * \sa SDL_SetEventFilter
1091 */
1092extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
1093 void *userdata);
1094
1095/**
1096 * Set the state of processing events by type.
1097 *
1098 * \param type the type of event; see SDL_EventType for details
1099 * \param enabled whether to process the event or not
1100 *
1101 * \since This function is available since SDL 3.0.0.
1102 *
1103 * \sa SDL_IsEventEnabled
1104 */
1105extern DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, SDL_bool enabled);
1106
1107/**
1108 * Query the state of processing events by type.
1109 *
1110 * \param type the type of event; see SDL_EventType for details
1111 * \returns SDL_TRUE if the event is being processed, SDL_FALSE otherwise.
1112 *
1113 * \since This function is available since SDL 3.0.0.
1114 *
1115 * \sa SDL_SetEventEnabled
1116 */
1117extern DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(Uint32 type);
1118
1119/**
1120 * Allocate a set of user-defined events, and return the beginning event
1121 * number for that set of events.
1122 *
1123 * Calling this function with `numevents` <= 0 is an error and will return
1124 * (Uint32)-1.
1125 *
1126 * Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
1127 * 0xFFFFFFFF), but is clearer to write.
1128 *
1129 * \param numevents the number of events to be allocated
1130 * \returns the beginning event number, or (Uint32)-1 if there are not enough
1131 * user-defined events left.
1132 *
1133 * \since This function is available since SDL 3.0.0.
1134 *
1135 * \sa SDL_PushEvent
1136 */
1137extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
1138
1139/* Ends C function definitions when using C++ */
1140#ifdef __cplusplus
1141}
1142#endif
1143#include <SDL3/SDL_close_code.h>
1144
1145#endif /* SDL_events_h_ */
Access to the raw audio mixing buffer for the SDL library.
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:262
#define NULL
int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType)
void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE
Definition: SDL_events.h:257
void SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
SDL_bool SDL_HasEvent(Uint32 type)
int SDL_PollEvent(SDL_Event *event)
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event)==sizeof(((SDL_Event *) NULL) ->padding))
Uint32 SDL_RegisterEvents(int numevents)
SDL_EventType
Definition: SDL_events.h:56
@ SDL_EVENT_KEYMAP_CHANGED
Definition: SDL_events.h:136
@ SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED
Definition: SDL_events.h:98
@ SDL_EVENT_WINDOW_HIT_TEST
Definition: SDL_events.h:120
@ SDL_EVENT_GAMEPAD_ADDED
Definition: SDL_events.h:159
@ SDL_EVENT_GAMEPAD_TOUCHPAD_UP
Definition: SDL_events.h:164
@ SDL_EVENT_WINDOW_RESTORED
Definition: SDL_events.h:113
@ SDL_EVENT_GAMEPAD_AXIS_MOTION
Definition: SDL_events.h:156
@ SDL_EVENT_WINDOW_LAST
Definition: SDL_events.h:129
@ SDL_EVENT_DROP_BEGIN
Definition: SDL_events.h:181
@ SDL_EVENT_MOUSE_MOTION
Definition: SDL_events.h:141
@ SDL_EVENT_WINDOW_FOCUS_GAINED
Definition: SDL_events.h:116
@ SDL_EVENT_TEXT_EDITING_EXT
Definition: SDL_events.h:138
@ SDL_EVENT_MOUSE_WHEEL
Definition: SDL_events.h:144
@ SDL_EVENT_JOYSTICK_REMOVED
Definition: SDL_events.h:152
@ SDL_EVENT_CLIPBOARD_UPDATE
Definition: SDL_events.h:175
@ SDL_EVENT_DID_ENTER_FOREGROUND
Definition: SDL_events.h:83
@ SDL_EVENT_JOYSTICK_BUTTON_UP
Definition: SDL_events.h:150
@ SDL_EVENT_JOYSTICK_BATTERY_UPDATED
Definition: SDL_events.h:153
@ SDL_EVENT_WILL_ENTER_FOREGROUND
Definition: SDL_events.h:79
@ SDL_EVENT_POLL_SENTINEL
Definition: SDL_events.h:197
@ SDL_EVENT_FINGER_UP
Definition: SDL_events.h:169
@ SDL_EVENT_JOYSTICK_ADDED
Definition: SDL_events.h:151
@ SDL_EVENT_DROP_POSITION
Definition: SDL_events.h:183
@ SDL_EVENT_WINDOW_EXPOSED
Definition: SDL_events.h:107
@ SDL_EVENT_WINDOW_DISPLAY_CHANGED
Definition: SDL_events.h:122
@ SDL_EVENT_WINDOW_RESIZED
Definition: SDL_events.h:109
@ SDL_EVENT_GAMEPAD_REMAPPED
Definition: SDL_events.h:161
@ SDL_EVENT_GAMEPAD_REMOVED
Definition: SDL_events.h:160
@ SDL_EVENT_FINGER_MOTION
Definition: SDL_events.h:170
@ SDL_EVENT_WINDOW_MOUSE_ENTER
Definition: SDL_events.h:114
@ SDL_EVENT_WINDOW_HIDDEN
Definition: SDL_events.h:106
@ SDL_EVENT_RENDER_TARGETS_RESET
Definition: SDL_events.h:193
@ SDL_EVENT_DID_ENTER_BACKGROUND
Definition: SDL_events.h:75
@ SDL_EVENT_AUDIO_DEVICE_ADDED
Definition: SDL_events.h:186
@ SDL_EVENT_RENDER_DEVICE_RESET
Definition: SDL_events.h:194
@ SDL_EVENT_LOW_MEMORY
Definition: SDL_events.h:67
@ SDL_EVENT_DISPLAY_DISCONNECTED
Definition: SDL_events.h:96
@ SDL_EVENT_WINDOW_DESTROYED
Definition: SDL_events.h:124
@ SDL_EVENT_GAMEPAD_BUTTON_DOWN
Definition: SDL_events.h:157
@ SDL_EVENT_JOYSTICK_AXIS_MOTION
Definition: SDL_events.h:147
@ SDL_EVENT_KEY_UP
Definition: SDL_events.h:133
@ SDL_EVENT_WINDOW_CLOSE_REQUESTED
Definition: SDL_events.h:118
@ SDL_EVENT_TEXT_INPUT
Definition: SDL_events.h:135
@ SDL_EVENT_CLIPBOARD_CANCELLED
Definition: SDL_events.h:176
@ SDL_EVENT_SYSWM
Definition: SDL_events.h:104
@ SDL_EVENT_LOCALE_CHANGED
Definition: SDL_events.h:88
@ SDL_EVENT_DISPLAY_LAST
Definition: SDL_events.h:100
@ SDL_EVENT_WILL_ENTER_BACKGROUND
Definition: SDL_events.h:71
@ SDL_EVENT_MOUSE_BUTTON_DOWN
Definition: SDL_events.h:142
@ SDL_EVENT_USER
Definition: SDL_events.h:202
@ SDL_EVENT_WINDOW_FIRST
Definition: SDL_events.h:128
@ SDL_EVENT_SENSOR_UPDATE
Definition: SDL_events.h:190
@ SDL_EVENT_FIRST
Definition: SDL_events.h:57
@ SDL_EVENT_DISPLAY_MOVED
Definition: SDL_events.h:97
@ SDL_EVENT_JOYSTICK_BUTTON_DOWN
Definition: SDL_events.h:149
@ SDL_EVENT_MOUSE_BUTTON_UP
Definition: SDL_events.h:143
@ SDL_EVENT_DROP_TEXT
Definition: SDL_events.h:180
@ SDL_EVENT_DROP_FILE
Definition: SDL_events.h:179
@ SDL_EVENT_WINDOW_FOCUS_LOST
Definition: SDL_events.h:117
@ SDL_EVENT_GAMEPAD_BUTTON_UP
Definition: SDL_events.h:158
@ SDL_EVENT_WINDOW_MAXIMIZED
Definition: SDL_events.h:112
@ SDL_EVENT_TERMINATING
Definition: SDL_events.h:63
@ SDL_EVENT_WINDOW_ICCPROF_CHANGED
Definition: SDL_events.h:121
@ SDL_EVENT_SYSTEM_THEME_CHANGED
Definition: SDL_events.h:90
@ SDL_EVENT_GAMEPAD_SENSOR_UPDATE
Definition: SDL_events.h:165
@ SDL_EVENT_JOYSTICK_HAT_MOTION
Definition: SDL_events.h:148
@ SDL_EVENT_WINDOW_TAKE_FOCUS
Definition: SDL_events.h:119
@ SDL_EVENT_WINDOW_SHOWN
Definition: SDL_events.h:105
@ SDL_EVENT_KEY_DOWN
Definition: SDL_events.h:132
@ SDL_EVENT_WINDOW_MOVED
Definition: SDL_events.h:108
@ SDL_EVENT_DISPLAY_FIRST
Definition: SDL_events.h:99
@ SDL_EVENT_WINDOW_MINIMIZED
Definition: SDL_events.h:111
@ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED
Definition: SDL_events.h:110
@ SDL_EVENT_DISPLAY_ORIENTATION
Definition: SDL_events.h:94
@ SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED
Definition: SDL_events.h:123
@ SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION
Definition: SDL_events.h:163
@ SDL_EVENT_LAST
Definition: SDL_events.h:207
@ SDL_EVENT_DISPLAY_CONNECTED
Definition: SDL_events.h:95
@ SDL_EVENT_AUDIO_DEVICE_REMOVED
Definition: SDL_events.h:187
@ SDL_EVENT_DROP_COMPLETE
Definition: SDL_events.h:182
@ SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN
Definition: SDL_events.h:162
@ SDL_EVENT_TEXT_EDITING
Definition: SDL_events.h:134
@ SDL_EVENT_WINDOW_MOUSE_LEAVE
Definition: SDL_events.h:115
@ SDL_EVENT_QUIT
Definition: SDL_events.h:60
@ SDL_EVENT_FINGER_DOWN
Definition: SDL_events.h:168
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
Definition: SDL_events.h:285
int(* SDL_EventFilter)(void *userdata, SDL_Event *event)
Definition: SDL_events.h:966
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_AddEventWatch(SDL_EventFilter filter, void *userdata)
SDL_eventaction
Definition: SDL_events.h:691
@ SDL_ADDEVENT
Definition: SDL_events.h:692
@ SDL_PEEKEVENT
Definition: SDL_events.h:693
@ SDL_GETEVENT
Definition: SDL_events.h:694
void SDL_FlushEvents(Uint32 minType, Uint32 maxType)
int SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS)
void SDL_FlushEvent(Uint32 type)
int SDL_WaitEvent(SDL_Event *event)
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)
Include file for SDL gamepad event handling.
Include file for SDL joystick event handling.
Uint32 SDL_JoystickID
Definition: SDL_joystick.h:83
SDL_JoystickPowerLevel
Definition: SDL_joystick.h:100
Include file for SDL keyboard event handling.
Include file for SDL mouse event handling.
Uint32 SDL_MouseID
Definition: SDL_mouse.h:41
Include file for SDL quit event handling.
Uint32 SDL_SensorID
Definition: SDL_sensor.h:59
This is a general header that includes C language support.
uint8_t Uint8
Definition: SDL_stdinc.h:147
uint16_t Uint16
Definition: SDL_stdinc.h:159
int32_t Sint32
Definition: SDL_stdinc.h:165
SDL_bool
Definition: SDL_stdinc.h:130
int16_t Sint16
Definition: SDL_stdinc.h:153
uint64_t Uint64
Definition: SDL_stdinc.h:184
uint32_t Uint32
Definition: SDL_stdinc.h:171
Include file for SDL touch event handling.
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
Sint64 SDL_FingerID
Definition: SDL_touch.h:42
Header file for SDL video functions.
Uint32 SDL_DisplayID
Definition: SDL_video.h:43
Uint32 SDL_WindowID
Definition: SDL_video.h:44
Audio device event structure (event.adevice.*)
Definition: SDL_events.h:491
SDL_AudioDeviceID which
Definition: SDL_events.h:494
An event triggered when the applications active clipboard content is cancelled by new clipboard conte...
Definition: SDL_events.h:542
Fields shared by every event.
Definition: SDL_events.h:214
Uint64 timestamp
Definition: SDL_events.h:216
Display state change event data (event.display.*)
Definition: SDL_events.h:223
SDL_DisplayID displayID
Definition: SDL_events.h:226
An event used to request a file open by the system (event.drop.*) This event is enabled by default,...
Definition: SDL_events.h:526
SDL_WindowID windowID
Definition: SDL_events.h:530
Uint64 timestamp
Definition: SDL_events.h:528
Gamepad axis motion event structure (event.gaxis.*)
Definition: SDL_events.h:421
SDL_JoystickID which
Definition: SDL_events.h:424
Gamepad button event structure (event.gbutton.*)
Definition: SDL_events.h:438
SDL_JoystickID which
Definition: SDL_events.h:441
Gamepad device event structure (event.gdevice.*)
Definition: SDL_events.h:453
SDL_JoystickID which
Definition: SDL_events.h:456
Gamepad sensor event structure (event.gsensor.*)
Definition: SDL_events.h:478
SDL_JoystickID which
Definition: SDL_events.h:481
Gamepad touchpad event structure (event.gtouchpad.*)
Definition: SDL_events.h:463
SDL_JoystickID which
Definition: SDL_events.h:466
Joystick axis motion event structure (event.jaxis.*)
Definition: SDL_events.h:350
SDL_JoystickID which
Definition: SDL_events.h:353
Joysick battery level change event structure (event.jbattery.*)
Definition: SDL_events.h:410
SDL_JoystickPowerLevel level
Definition: SDL_events.h:414
SDL_JoystickID which
Definition: SDL_events.h:413
Joystick button event structure (event.jbutton.*)
Definition: SDL_events.h:386
SDL_JoystickID which
Definition: SDL_events.h:389
Joystick device event structure (event.jdevice.*)
Definition: SDL_events.h:400
SDL_JoystickID which
Definition: SDL_events.h:403
Joystick hat position change event structure (event.jhat.*)
Definition: SDL_events.h:366
Uint64 timestamp
Definition: SDL_events.h:368
SDL_JoystickID which
Definition: SDL_events.h:369
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:246
SDL_Keysym keysym
Definition: SDL_events.h:254
SDL_WindowID windowID
Definition: SDL_events.h:249
The SDL keysym structure, used in key events.
Definition: SDL_keyboard.h:48
Mouse button event structure (event.button.*)
Definition: SDL_events.h:317
SDL_WindowID windowID
Definition: SDL_events.h:320
SDL_MouseID which
Definition: SDL_events.h:321
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:301
SDL_MouseID which
Definition: SDL_events.h:305
SDL_WindowID windowID
Definition: SDL_events.h:304
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:334
SDL_MouseID which
Definition: SDL_events.h:338
SDL_WindowID windowID
Definition: SDL_events.h:337
OS Specific event.
Definition: SDL_events.h:573
Uint32 type
Definition: SDL_events.h:574
Uint64 timestamp
Definition: SDL_events.h:575
The "quit requested" event.
Definition: SDL_events.h:564
Uint64 timestamp
Definition: SDL_events.h:566
Sensor event structure (event.sensor.*)
Definition: SDL_events.h:552
Uint64 timestamp
Definition: SDL_events.h:554
float data[6]
Definition: SDL_events.h:556
Uint64 sensor_timestamp
Definition: SDL_events.h:557
SDL_SensorID which
Definition: SDL_events.h:555
A video driver dependent system event (event.syswm.*) This event is disabled by default,...
Definition: SDL_events.h:602
Uint64 timestamp
Definition: SDL_events.h:604
SDL_SysWMmsg * msg
Definition: SDL_events.h:605
Keyboard text editing event structure (event.edit.*)
Definition: SDL_events.h:262
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]
Definition: SDL_events.h:266
SDL_WindowID windowID
Definition: SDL_events.h:265
Extended keyboard text editing event structure (event.editExt.*) when text would be truncated if stor...
Definition: SDL_events.h:276
SDL_WindowID windowID
Definition: SDL_events.h:279
Keyboard text input event structure (event.text.*)
Definition: SDL_events.h:290
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]
Definition: SDL_events.h:294
SDL_WindowID windowID
Definition: SDL_events.h:293
Touch finger event structure (event.tfinger.*)
Definition: SDL_events.h:506
SDL_FingerID fingerId
Definition: SDL_events.h:510
SDL_WindowID windowID
Definition: SDL_events.h:516
SDL_TouchID touchId
Definition: SDL_events.h:509
A user-defined event type (event.user.*)
Definition: SDL_events.h:582
void * data2
Definition: SDL_events.h:588
void * data1
Definition: SDL_events.h:587
SDL_WindowID windowID
Definition: SDL_events.h:585
Uint64 timestamp
Definition: SDL_events.h:584
Window state change event data (event.window.*)
Definition: SDL_events.h:234
Uint64 timestamp
Definition: SDL_events.h:236
SDL_WindowID windowID
Definition: SDL_events.h:237
General event structure.
Definition: SDL_events.h:612
SDL_QuitEvent quit
Definition: SDL_events.h:636
SDL_AudioDeviceEvent adevice
Definition: SDL_events.h:634
Uint8 padding[128]
Definition: SDL_events.h:656
SDL_JoyDeviceEvent jdevice
Definition: SDL_events.h:627
Uint32 type
Definition: SDL_events.h:613
SDL_MouseWheelEvent wheel
Definition: SDL_events.h:623
SDL_JoyHatEvent jhat
Definition: SDL_events.h:625
SDL_ClipboardEvent clipboard
Definition: SDL_events.h:641
SDL_JoyButtonEvent jbutton
Definition: SDL_events.h:626
SDL_GamepadDeviceEvent gdevice
Definition: SDL_events.h:631
SDL_GamepadAxisEvent gaxis
Definition: SDL_events.h:629
SDL_WindowEvent window
Definition: SDL_events.h:616
SDL_GamepadTouchpadEvent gtouchpad
Definition: SDL_events.h:632
SDL_TextEditingEvent edit
Definition: SDL_events.h:618
SDL_TextInputEvent text
Definition: SDL_events.h:620
SDL_GamepadSensorEvent gsensor
Definition: SDL_events.h:633
SDL_TouchFingerEvent tfinger
Definition: SDL_events.h:639
SDL_SysWMEvent syswm
Definition: SDL_events.h:638
SDL_MouseButtonEvent button
Definition: SDL_events.h:622
SDL_UserEvent user
Definition: SDL_events.h:637
SDL_KeyboardEvent key
Definition: SDL_events.h:617
SDL_TextEditingExtEvent editExt
Definition: SDL_events.h:619
SDL_CommonEvent common
Definition: SDL_events.h:614
SDL_MouseMotionEvent motion
Definition: SDL_events.h:621
SDL_JoyAxisEvent jaxis
Definition: SDL_events.h:624
SDL_DropEvent drop
Definition: SDL_events.h:640
SDL_JoyBatteryEvent jbattery
Definition: SDL_events.h:628
SDL_SensorEvent sensor
Definition: SDL_events.h:635
SDL_GamepadButtonEvent gbutton
Definition: SDL_events.h:630
SDL_DisplayEvent display
Definition: SDL_events.h:615