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