SDL  2.0
SDL_events.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2022 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 "SDL_stdinc.h"
32 #include "SDL_error.h"
33 #include "SDL_video.h"
34 #include "SDL_keyboard.h"
35 #include "SDL_mouse.h"
36 #include "SDL_joystick.h"
37 #include "SDL_gamecontroller.h"
38 #include "SDL_quit.h"
39 #include "SDL_gesture.h"
40 #include "SDL_touch.h"
41 
42 #include "begin_code.h"
43 /* Set up for C function definitions, even when using C++ */
44 #ifdef __cplusplus
45 extern "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  */
55 typedef enum
56 {
57  SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
58 
59  /* Application events */
60  SDL_QUIT = 0x100, /**< User-requested quit */
61 
62  /* These application events have special meaning on iOS, see README-ios.md for details */
63  SDL_APP_TERMINATING, /**< The application is being terminated by the OS
64  Called on iOS in applicationWillTerminate()
65  Called on Android in onDestroy()
66  */
67  SDL_APP_LOWMEMORY, /**< 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_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background
72  Called on iOS in applicationWillResignActive()
73  Called on Android in onPause()
74  */
75  SDL_APP_DIDENTERBACKGROUND, /**< 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_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground
80  Called on iOS in applicationWillEnterForeground()
81  Called on Android in onResume()
82  */
83  SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive
84  Called on iOS in applicationDidBecomeActive()
85  Called on Android in onResume()
86  */
87 
88  SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
89 
90  /* Display events */
91  SDL_DISPLAYEVENT = 0x150, /**< Display state change */
92 
93  /* Window events */
94  SDL_WINDOWEVENT = 0x200, /**< Window state change */
95  SDL_SYSWMEVENT, /**< System specific event */
96 
97  /* Keyboard events */
98  SDL_KEYDOWN = 0x300, /**< Key pressed */
99  SDL_KEYUP, /**< Key released */
100  SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
101  SDL_TEXTINPUT, /**< Keyboard text input */
102  SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
103  input language or keyboard layout change.
104  */
105  SDL_TEXTEDITING_EXT, /**< Extended keyboard text editing (composition) */
106 
107  /* Mouse events */
108  SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
109  SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
110  SDL_MOUSEBUTTONUP, /**< Mouse button released */
111  SDL_MOUSEWHEEL, /**< Mouse wheel motion */
112 
113  /* Joystick events */
114  SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
115  SDL_JOYBALLMOTION, /**< Joystick trackball motion */
116  SDL_JOYHATMOTION, /**< Joystick hat position change */
117  SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
118  SDL_JOYBUTTONUP, /**< Joystick button released */
119  SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
120  SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
121  SDL_JOYBATTERYUPDATED, /**< Joystick battery level change */
122 
123  /* Game controller events */
124  SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
125  SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */
126  SDL_CONTROLLERBUTTONUP, /**< Game controller button released */
127  SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
128  SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
129  SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
130  SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
131  SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
132  SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
133  SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
134 
135  /* Touch events */
136  SDL_FINGERDOWN = 0x700,
139 
140  /* Gesture events */
144 
145  /* Clipboard events */
146  SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
147 
148  /* Drag and drop events */
149  SDL_DROPFILE = 0x1000, /**< The system requests a file open */
150  SDL_DROPTEXT, /**< text/plain drag-and-drop event */
151  SDL_DROPBEGIN, /**< A new set of drops is beginning (NULL filename) */
152  SDL_DROPCOMPLETE, /**< Current set of drops is now complete (NULL filename) */
153 
154  /* Audio hotplug events */
155  SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
156  SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */
157 
158  /* Sensor events */
159  SDL_SENSORUPDATE = 0x1200, /**< A sensor was updated */
160 
161  /* Render events */
162  SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
163  SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
164 
165  /* Internal events */
166  SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
167 
168  /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
169  * and should be allocated with SDL_RegisterEvents()
170  */
171  SDL_USEREVENT = 0x8000,
172 
173  /**
174  * This last event is only for bounding internal arrays
175  */
176  SDL_LASTEVENT = 0xFFFF
178 
179 /**
180  * \brief Fields shared by every event
181  */
182 typedef struct SDL_CommonEvent
183 {
185  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
187 
188 /**
189  * \brief Display state change event data (event.display.*)
190  */
191 typedef struct SDL_DisplayEvent
192 {
193  Uint32 type; /**< ::SDL_DISPLAYEVENT */
194  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
195  Uint32 display; /**< The associated display index */
196  Uint8 event; /**< ::SDL_DisplayEventID */
200  Sint32 data1; /**< event dependent data */
202 
203 /**
204  * \brief Window state change event data (event.window.*)
205  */
206 typedef struct SDL_WindowEvent
207 {
208  Uint32 type; /**< ::SDL_WINDOWEVENT */
209  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
210  Uint32 windowID; /**< The associated window */
211  Uint8 event; /**< ::SDL_WindowEventID */
215  Sint32 data1; /**< event dependent data */
216  Sint32 data2; /**< event dependent data */
218 
219 /**
220  * \brief Keyboard button event structure (event.key.*)
221  */
222 typedef struct SDL_KeyboardEvent
223 {
224  Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
225  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
226  Uint32 windowID; /**< The window with keyboard focus, if any */
227  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
228  Uint8 repeat; /**< Non-zero if this is a key repeat */
231  SDL_Keysym keysym; /**< The key that was pressed or released */
233 
234 #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
235 /**
236  * \brief Keyboard text editing event structure (event.edit.*)
237  */
238 typedef struct SDL_TextEditingEvent
239 {
240  Uint32 type; /**< ::SDL_TEXTEDITING */
241  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
242  Uint32 windowID; /**< The window with keyboard focus, if any */
243  char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
244  Sint32 start; /**< The start cursor of selected editing text */
245  Sint32 length; /**< The length of selected editing text */
247 
248 /**
249  * \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
250  * truncated if stored in the text buffer SDL_TextEditingEvent
251  */
253 {
254  Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
255  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
256  Uint32 windowID; /**< The window with keyboard focus, if any */
257  char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
258  Sint32 start; /**< The start cursor of selected editing text */
259  Sint32 length; /**< The length of selected editing text */
261 
262 #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
263 /**
264  * \brief Keyboard text input event structure (event.text.*)
265  */
266 typedef struct SDL_TextInputEvent
267 {
268  Uint32 type; /**< ::SDL_TEXTINPUT */
269  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
270  Uint32 windowID; /**< The window with keyboard focus, if any */
271  char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
273 
274 /**
275  * \brief Mouse motion event structure (event.motion.*)
276  */
277 typedef struct SDL_MouseMotionEvent
278 {
279  Uint32 type; /**< ::SDL_MOUSEMOTION */
280  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
281  Uint32 windowID; /**< The window with mouse focus, if any */
282  Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
283  Uint32 state; /**< The current button state */
284  Sint32 x; /**< X coordinate, relative to window */
285  Sint32 y; /**< Y coordinate, relative to window */
286  Sint32 xrel; /**< The relative motion in the X direction */
287  Sint32 yrel; /**< The relative motion in the Y direction */
289 
290 /**
291  * \brief Mouse button event structure (event.button.*)
292  */
293 typedef struct SDL_MouseButtonEvent
294 {
295  Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
296  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
297  Uint32 windowID; /**< The window with mouse focus, if any */
298  Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
299  Uint8 button; /**< The mouse button index */
300  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
301  Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
303  Sint32 x; /**< X coordinate, relative to window */
304  Sint32 y; /**< Y coordinate, relative to window */
306 
307 /**
308  * \brief Mouse wheel event structure (event.wheel.*)
309  */
310 typedef struct SDL_MouseWheelEvent
311 {
312  Uint32 type; /**< ::SDL_MOUSEWHEEL */
313  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
314  Uint32 windowID; /**< The window with mouse focus, if any */
315  Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
316  Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
317  Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
318  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 */
319  float preciseX; /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
320  float preciseY; /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
322 
323 /**
324  * \brief Joystick axis motion event structure (event.jaxis.*)
325  */
326 typedef struct SDL_JoyAxisEvent
327 {
328  Uint32 type; /**< ::SDL_JOYAXISMOTION */
329  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
330  SDL_JoystickID which; /**< The joystick instance id */
331  Uint8 axis; /**< The joystick axis index */
335  Sint16 value; /**< The axis value (range: -32768 to 32767) */
338 
339 /**
340  * \brief Joystick trackball motion event structure (event.jball.*)
341  */
342 typedef struct SDL_JoyBallEvent
343 {
344  Uint32 type; /**< ::SDL_JOYBALLMOTION */
345  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
346  SDL_JoystickID which; /**< The joystick instance id */
347  Uint8 ball; /**< The joystick trackball index */
351  Sint16 xrel; /**< The relative motion in the X direction */
352  Sint16 yrel; /**< The relative motion in the Y direction */
354 
355 /**
356  * \brief Joystick hat position change event structure (event.jhat.*)
357  */
358 typedef struct SDL_JoyHatEvent
359 {
360  Uint32 type; /**< ::SDL_JOYHATMOTION */
361  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
362  SDL_JoystickID which; /**< The joystick instance id */
363  Uint8 hat; /**< The joystick hat index */
364  Uint8 value; /**< The hat position value.
365  * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
366  * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
367  * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
368  *
369  * Note that zero means the POV is centered.
370  */
374 
375 /**
376  * \brief Joystick button event structure (event.jbutton.*)
377  */
378 typedef struct SDL_JoyButtonEvent
379 {
380  Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
381  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
382  SDL_JoystickID which; /**< The joystick instance id */
383  Uint8 button; /**< The joystick button index */
384  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
388 
389 /**
390  * \brief Joystick device event structure (event.jdevice.*)
391  */
392 typedef struct SDL_JoyDeviceEvent
393 {
394  Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
395  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
396  Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
398 
399 /**
400  * \brief Joysick battery level change event structure (event.jbattery.*)
401  */
402 typedef struct SDL_JoyBatteryEvent
403 {
404  Uint32 type; /**< ::SDL_JOYBATTERYUPDATED */
405  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
406  SDL_JoystickID which; /**< The joystick instance id */
407  SDL_JoystickPowerLevel level; /**< The joystick battery level */
409 
410 /**
411  * \brief Game controller axis motion event structure (event.caxis.*)
412  */
414 {
415  Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
416  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
417  SDL_JoystickID which; /**< The joystick instance id */
418  Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
422  Sint16 value; /**< The axis value (range: -32768 to 32767) */
425 
426 
427 /**
428  * \brief Game controller button event structure (event.cbutton.*)
429  */
431 {
432  Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
433  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
434  SDL_JoystickID which; /**< The joystick instance id */
435  Uint8 button; /**< The controller button (SDL_GameControllerButton) */
436  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
440 
441 
442 /**
443  * \brief Controller device event structure (event.cdevice.*)
444  */
446 {
447  Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
448  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
449  Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
451 
452 /**
453  * \brief Game controller touchpad event structure (event.ctouchpad.*)
454  */
456 {
457  Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
458  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
459  SDL_JoystickID which; /**< The joystick instance id */
460  Sint32 touchpad; /**< The index of the touchpad */
461  Sint32 finger; /**< The index of the finger on the touchpad */
462  float x; /**< Normalized in the range 0...1 with 0 being on the left */
463  float y; /**< Normalized in the range 0...1 with 0 being at the top */
464  float pressure; /**< Normalized in the range 0...1 */
466 
467 /**
468  * \brief Game controller sensor event structure (event.csensor.*)
469  */
471 {
472  Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
473  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
474  SDL_JoystickID which; /**< The joystick instance id */
475  Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
476  float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
478 
479 /**
480  * \brief Audio device event structure (event.adevice.*)
481  */
482 typedef struct SDL_AudioDeviceEvent
483 {
484  Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
485  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
486  Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
487  Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
492 
493 
494 /**
495  * \brief Touch finger event structure (event.tfinger.*)
496  */
497 typedef struct SDL_TouchFingerEvent
498 {
499  Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
500  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
501  SDL_TouchID touchId; /**< The touch device id */
503  float x; /**< Normalized in the range 0...1 */
504  float y; /**< Normalized in the range 0...1 */
505  float dx; /**< Normalized in the range -1...1 */
506  float dy; /**< Normalized in the range -1...1 */
507  float pressure; /**< Normalized in the range 0...1 */
508  Uint32 windowID; /**< The window underneath the finger, if any */
510 
511 
512 /**
513  * \brief Multiple Finger Gesture Event (event.mgesture.*)
514  */
515 typedef struct SDL_MultiGestureEvent
516 {
517  Uint32 type; /**< ::SDL_MULTIGESTURE */
518  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
519  SDL_TouchID touchId; /**< The touch device id */
520  float dTheta;
521  float dDist;
522  float x;
523  float y;
527 
528 
529 /**
530  * \brief Dollar Gesture Event (event.dgesture.*)
531  */
533 {
534  Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
535  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
536  SDL_TouchID touchId; /**< The touch device id */
539  float error;
540  float x; /**< Normalized center of gesture */
541  float y; /**< Normalized center of gesture */
543 
544 
545 /**
546  * \brief An event used to request a file open by the system (event.drop.*)
547  * This event is enabled by default, you can disable it with SDL_EventState().
548  * \note If this event is enabled, you must free the filename in the event.
549  */
550 typedef struct SDL_DropEvent
551 {
552  Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
553  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
554  char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
555  Uint32 windowID; /**< The window that was dropped on, if any */
556 } SDL_DropEvent;
557 
558 
559 /**
560  * \brief Sensor event structure (event.sensor.*)
561  */
562 typedef struct SDL_SensorEvent
563 {
564  Uint32 type; /**< ::SDL_SENSORUPDATE */
565  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
566  Sint32 which; /**< The instance ID of the sensor */
567  float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
569 
570 /**
571  * \brief The "quit requested" event
572  */
573 typedef struct SDL_QuitEvent
574 {
575  Uint32 type; /**< ::SDL_QUIT */
576  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
577 } SDL_QuitEvent;
578 
579 /**
580  * \brief OS Specific event
581  */
582 typedef struct SDL_OSEvent
583 {
584  Uint32 type; /**< ::SDL_QUIT */
585  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
586 } SDL_OSEvent;
587 
588 /**
589  * \brief A user-defined event type (event.user.*)
590  */
591 typedef struct SDL_UserEvent
592 {
593  Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
594  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
595  Uint32 windowID; /**< The associated window if any */
596  Sint32 code; /**< User defined event code */
597  void *data1; /**< User defined data pointer */
598  void *data2; /**< User defined data pointer */
599 } SDL_UserEvent;
600 
601 
602 struct SDL_SysWMmsg;
603 typedef struct SDL_SysWMmsg SDL_SysWMmsg;
604 
605 /**
606  * \brief A video driver dependent system event (event.syswm.*)
607  * This event is disabled by default, you can enable it with SDL_EventState()
608  *
609  * \note If you want to use this event, you should include SDL_syswm.h.
610  */
611 typedef struct SDL_SysWMEvent
612 {
613  Uint32 type; /**< ::SDL_SYSWMEVENT */
614  Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
615  SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
617 
618 /**
619  * \brief General event structure
620  */
621 typedef union SDL_Event
622 {
623  Uint32 type; /**< Event type, shared with all events */
624  SDL_CommonEvent common; /**< Common event data */
625  SDL_DisplayEvent display; /**< Display event data */
626  SDL_WindowEvent window; /**< Window event data */
627  SDL_KeyboardEvent key; /**< Keyboard event data */
628  SDL_TextEditingEvent edit; /**< Text editing event data */
629  SDL_TextEditingExtEvent editExt; /**< Extended text editing event data */
630  SDL_TextInputEvent text; /**< Text input event data */
631  SDL_MouseMotionEvent motion; /**< Mouse motion event data */
632  SDL_MouseButtonEvent button; /**< Mouse button event data */
633  SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
634  SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
635  SDL_JoyBallEvent jball; /**< Joystick ball event data */
636  SDL_JoyHatEvent jhat; /**< Joystick hat event data */
637  SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
638  SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
639  SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
640  SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
641  SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
642  SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
643  SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
644  SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
645  SDL_AudioDeviceEvent adevice; /**< Audio device event data */
646  SDL_SensorEvent sensor; /**< Sensor event data */
647  SDL_QuitEvent quit; /**< Quit request event data */
648  SDL_UserEvent user; /**< Custom event data */
649  SDL_SysWMEvent syswm; /**< System dependent window event data */
650  SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
651  SDL_MultiGestureEvent mgesture; /**< Gesture event data */
652  SDL_DollarGestureEvent dgesture; /**< Gesture event data */
653  SDL_DropEvent drop; /**< Drag and drop event data */
654 
655  /* This is necessary for ABI compatibility between Visual C++ and GCC.
656  Visual C++ will respect the push pack pragma and use 52 bytes (size of
657  SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
658  architectures) for this union, and GCC will use the alignment of the
659  largest datatype within the union, which is 8 bytes on 64-bit
660  architectures.
661 
662  So... we'll add padding to force the size to be 56 bytes for both.
663 
664  On architectures where pointers are 16 bytes, this needs rounding up to
665  the next multiple of 16, 64, and on architectures where pointers are
666  even larger the size of SDL_UserEvent will dominate as being 3 pointers.
667  */
668  Uint8 padding[sizeof(void *) <= 8 ? 56 : sizeof(void *) == 16 ? 64 : 3 * sizeof(void *)];
669 } SDL_Event;
670 
671 /* Make sure we haven't broken binary compatibility */
672 SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
673 
674 
675 /* Function prototypes */
676 
677 /**
678  * Pump the event loop, gathering events from the input devices.
679  *
680  * This function updates the event queue and internal input device state.
681  *
682  * **WARNING**: This should only be run in the thread that initialized the
683  * video subsystem, and for extra safety, you should consider only doing those
684  * things on the main thread in any case.
685  *
686  * SDL_PumpEvents() gathers all the pending input information from devices and
687  * places it in the event queue. Without calls to SDL_PumpEvents() no events
688  * would ever be placed on the queue. Often the need for calls to
689  * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
690  * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
691  * polling or waiting for events (e.g. you are filtering them), then you must
692  * call SDL_PumpEvents() to force an event queue update.
693  *
694  * \since This function is available since SDL 2.0.0.
695  *
696  * \sa SDL_PollEvent
697  * \sa SDL_WaitEvent
698  */
699 extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
700 
701 /* @{ */
702 typedef enum
703 {
708 
709 /**
710  * Check the event queue for messages and optionally return them.
711  *
712  * `action` may be any of the following:
713  *
714  * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the
715  * event queue.
716  * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
717  * within the specified minimum and maximum type, will be returned to the
718  * caller and will _not_ be removed from the queue.
719  * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
720  * within the specified minimum and maximum type, will be returned to the
721  * caller and will be removed from the queue.
722  *
723  * You may have to call SDL_PumpEvents() before calling this function.
724  * Otherwise, the events may not be ready to be filtered when you call
725  * SDL_PeepEvents().
726  *
727  * This function is thread-safe.
728  *
729  * \param events destination buffer for the retrieved events
730  * \param numevents if action is SDL_ADDEVENT, the number of events to add
731  * back to the event queue; if action is SDL_PEEKEVENT or
732  * SDL_GETEVENT, the maximum number of events to retrieve
733  * \param action action to take; see [[#action|Remarks]] for details
734  * \param minType minimum value of the event type to be considered;
735  * SDL_FIRSTEVENT is a safe choice
736  * \param maxType maximum value of the event type to be considered;
737  * SDL_LASTEVENT is a safe choice
738  * \returns the number of events actually stored or a negative error code on
739  * failure; call SDL_GetError() for more information.
740  *
741  * \since This function is available since SDL 2.0.0.
742  *
743  * \sa SDL_PollEvent
744  * \sa SDL_PumpEvents
745  * \sa SDL_PushEvent
746  */
747 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
748  SDL_eventaction action,
749  Uint32 minType, Uint32 maxType);
750 /* @} */
751 
752 /**
753  * Check for the existence of a certain event type in the event queue.
754  *
755  * If you need to check for a range of event types, use SDL_HasEvents()
756  * instead.
757  *
758  * \param type the type of event to be queried; see SDL_EventType for details
759  * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
760  * events matching `type` are not present.
761  *
762  * \since This function is available since SDL 2.0.0.
763  *
764  * \sa SDL_HasEvents
765  */
766 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
767 
768 
769 /**
770  * Check for the existence of certain event types in the event queue.
771  *
772  * If you need to check for a single event type, use SDL_HasEvent() instead.
773  *
774  * \param minType the low end of event type to be queried, inclusive; see
775  * SDL_EventType for details
776  * \param maxType the high end of event type to be queried, inclusive; see
777  * SDL_EventType for details
778  * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
779  * present, or SDL_FALSE if not.
780  *
781  * \since This function is available since SDL 2.0.0.
782  *
783  * \sa SDL_HasEvents
784  */
785 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
786 
787 /**
788  * Clear events of a specific type from the event queue.
789  *
790  * This will unconditionally remove any events from the queue that match
791  * `type`. If you need to remove a range of event types, use SDL_FlushEvents()
792  * instead.
793  *
794  * It's also normal to just ignore events you don't care about in your event
795  * loop without calling this function.
796  *
797  * This function only affects currently queued events. If you want to make
798  * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
799  * on the main thread immediately before the flush call.
800  *
801  * \param type the type of event to be cleared; see SDL_EventType for details
802  *
803  * \since This function is available since SDL 2.0.0.
804  *
805  * \sa SDL_FlushEvents
806  */
807 extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
808 
809 /**
810  * Clear events of a range of types from the event queue.
811  *
812  * This will unconditionally remove any events from the queue that are in the
813  * range of `minType` to `maxType`, inclusive. If you need to remove a single
814  * event type, use SDL_FlushEvent() instead.
815  *
816  * It's also normal to just ignore events you don't care about in your event
817  * loop without calling this function.
818  *
819  * This function only affects currently queued events. If you want to make
820  * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
821  * on the main thread immediately before the flush call.
822  *
823  * \param minType the low end of event type to be cleared, inclusive; see
824  * SDL_EventType for details
825  * \param maxType the high end of event type to be cleared, inclusive; see
826  * SDL_EventType for details
827  *
828  * \since This function is available since SDL 2.0.0.
829  *
830  * \sa SDL_FlushEvent
831  */
832 extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
833 
834 /**
835  * Poll for currently pending events.
836  *
837  * If `event` is not NULL, the next event is removed from the queue and stored
838  * in the SDL_Event structure pointed to by `event`. The 1 returned refers to
839  * this event, immediately stored in the SDL Event structure -- not an event
840  * to follow.
841  *
842  * If `event` is NULL, it simply returns 1 if there is an event in the queue,
843  * but will not remove it from the queue.
844  *
845  * As this function may implicitly call SDL_PumpEvents(), you can only call
846  * this function in the thread that set the video mode.
847  *
848  * SDL_PollEvent() is the favored way of receiving system events since it can
849  * be done from the main loop and does not suspend the main loop while waiting
850  * on an event to be posted.
851  *
852  * The common practice is to fully process the event queue once every frame,
853  * usually as a first step before updating the game's state:
854  *
855  * ```c
856  * while (game_is_still_running) {
857  * SDL_Event event;
858  * while (SDL_PollEvent(&event)) { // poll until all events are handled!
859  * // decide what to do with this event.
860  * }
861  *
862  * // update game state, draw the current frame
863  * }
864  * ```
865  *
866  * \param event the SDL_Event structure to be filled with the next event from
867  * the queue, or NULL
868  * \returns 1 if there is a pending event or 0 if there are none available.
869  *
870  * \since This function is available since SDL 2.0.0.
871  *
872  * \sa SDL_GetEventFilter
873  * \sa SDL_PeepEvents
874  * \sa SDL_PushEvent
875  * \sa SDL_SetEventFilter
876  * \sa SDL_WaitEvent
877  * \sa SDL_WaitEventTimeout
878  */
879 extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
880 
881 /**
882  * Wait indefinitely for the next available event.
883  *
884  * If `event` is not NULL, the next event is removed from the queue and stored
885  * in the SDL_Event structure pointed to by `event`.
886  *
887  * As this function may implicitly call SDL_PumpEvents(), you can only call
888  * this function in the thread that initialized the video subsystem.
889  *
890  * \param event the SDL_Event structure to be filled in with the next event
891  * from the queue, or NULL
892  * \returns 1 on success or 0 if there was an error while waiting for events;
893  * call SDL_GetError() for more information.
894  *
895  * \since This function is available since SDL 2.0.0.
896  *
897  * \sa SDL_PollEvent
898  * \sa SDL_PumpEvents
899  * \sa SDL_WaitEventTimeout
900  */
901 extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
902 
903 /**
904  * Wait until the specified timeout (in milliseconds) for the next available
905  * event.
906  *
907  * If `event` is not NULL, the next event is removed from the queue and stored
908  * in the SDL_Event structure pointed to by `event`.
909  *
910  * As this function may implicitly call SDL_PumpEvents(), you can only call
911  * this function in the thread that initialized the video subsystem.
912  *
913  * \param event the SDL_Event structure to be filled in with the next event
914  * from the queue, or NULL
915  * \param timeout the maximum number of milliseconds to wait for the next
916  * available event
917  * \returns 1 on success or 0 if there was an error while waiting for events;
918  * call SDL_GetError() for more information. This also returns 0 if
919  * the timeout elapsed without an event arriving.
920  *
921  * \since This function is available since SDL 2.0.0.
922  *
923  * \sa SDL_PollEvent
924  * \sa SDL_PumpEvents
925  * \sa SDL_WaitEvent
926  */
927 extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
928  int timeout);
929 
930 /**
931  * Add an event to the event queue.
932  *
933  * The event queue can actually be used as a two way communication channel.
934  * Not only can events be read from the queue, but the user can also push
935  * their own events onto it. `event` is a pointer to the event structure you
936  * wish to push onto the queue. The event is copied into the queue, and the
937  * caller may dispose of the memory pointed to after SDL_PushEvent() returns.
938  *
939  * Note: Pushing device input events onto the queue doesn't modify the state
940  * of the device within SDL.
941  *
942  * This function is thread-safe, and can be called from other threads safely.
943  *
944  * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
945  * the event filter but events added with SDL_PeepEvents() do not.
946  *
947  * For pushing application-specific events, please use SDL_RegisterEvents() to
948  * get an event type that does not conflict with other code that also wants
949  * its own custom event types.
950  *
951  * \param event the SDL_Event to be added to the queue
952  * \returns 1 on success, 0 if the event was filtered, or a negative error
953  * code on failure; call SDL_GetError() for more information. A
954  * common reason for error is the event queue being full.
955  *
956  * \since This function is available since SDL 2.0.0.
957  *
958  * \sa SDL_PeepEvents
959  * \sa SDL_PollEvent
960  * \sa SDL_RegisterEvents
961  */
962 extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
963 
964 /**
965  * A function pointer used for callbacks that watch the event queue.
966  *
967  * \param userdata what was passed as `userdata` to SDL_SetEventFilter()
968  * or SDL_AddEventWatch, etc
969  * \param event the event that triggered the callback
970  * \returns 1 to permit event to be added to the queue, and 0 to disallow
971  * it. When used with SDL_AddEventWatch, the return value is ignored.
972  *
973  * \sa SDL_SetEventFilter
974  * \sa SDL_AddEventWatch
975  */
976 typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
977 
978 /**
979  * Set up a filter to process all events before they change internal state and
980  * are posted to the internal event queue.
981  *
982  * If the filter function returns 1 when called, then the event will be added
983  * to the internal queue. If it returns 0, then the event will be dropped from
984  * the queue, but the internal state will still be updated. This allows
985  * selective filtering of dynamically arriving events.
986  *
987  * **WARNING**: Be very careful of what you do in the event filter function,
988  * as it may run in a different thread!
989  *
990  * On platforms that support it, if the quit event is generated by an
991  * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
992  * application at the next event poll.
993  *
994  * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
995  * event filter is only called when the window manager desires to close the
996  * application window. If the event filter returns 1, then the window will be
997  * closed, otherwise the window will remain open if possible.
998  *
999  * Note: Disabled events never make it to the event filter function; see
1000  * SDL_EventState().
1001  *
1002  * Note: If you just want to inspect events without filtering, you should use
1003  * SDL_AddEventWatch() instead.
1004  *
1005  * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
1006  * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
1007  * not.
1008  *
1009  * \param filter An SDL_EventFilter function to call when an event happens
1010  * \param userdata a pointer that is passed to `filter`
1011  *
1012  * \since This function is available since SDL 2.0.0.
1013  *
1014  * \sa SDL_AddEventWatch
1015  * \sa SDL_EventState
1016  * \sa SDL_GetEventFilter
1017  * \sa SDL_PeepEvents
1018  * \sa SDL_PushEvent
1019  */
1020 extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
1021  void *userdata);
1022 
1023 /**
1024  * Query the current event filter.
1025  *
1026  * This function can be used to "chain" filters, by saving the existing filter
1027  * before replacing it with a function that will call that saved filter.
1028  *
1029  * \param filter the current callback function will be stored here
1030  * \param userdata the pointer that is passed to the current event filter will
1031  * be stored here
1032  * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
1033  *
1034  * \since This function is available since SDL 2.0.0.
1035  *
1036  * \sa SDL_SetEventFilter
1037  */
1038 extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
1039  void **userdata);
1040 
1041 /**
1042  * Add a callback to be triggered when an event is added to the event queue.
1043  *
1044  * `filter` will be called when an event happens, and its return value is
1045  * ignored.
1046  *
1047  * **WARNING**: Be very careful of what you do in the event filter function,
1048  * as it may run in a different thread!
1049  *
1050  * If the quit event is generated by a signal (e.g. SIGINT), it will bypass
1051  * the internal queue and be delivered to the watch callback immediately, and
1052  * arrive at the next event poll.
1053  *
1054  * Note: the callback is called for events posted by the user through
1055  * SDL_PushEvent(), but not for disabled events, nor for events by a filter
1056  * callback set with SDL_SetEventFilter(), nor for events posted by the user
1057  * through SDL_PeepEvents().
1058  *
1059  * \param filter an 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 2.0.0.
1063  *
1064  * \sa SDL_DelEventWatch
1065  * \sa SDL_SetEventFilter
1066  */
1067 extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
1068  void *userdata);
1069 
1070 /**
1071  * Remove an event watch callback added with SDL_AddEventWatch().
1072  *
1073  * This function takes the same input as SDL_AddEventWatch() to identify and
1074  * delete the corresponding callback.
1075  *
1076  * \param filter the function originally passed to SDL_AddEventWatch()
1077  * \param userdata the pointer originally passed to SDL_AddEventWatch()
1078  *
1079  * \since This function is available since SDL 2.0.0.
1080  *
1081  * \sa SDL_AddEventWatch
1082  */
1083 extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
1084  void *userdata);
1085 
1086 /**
1087  * Run a specific filter function on the current event queue, removing any
1088  * events for which the filter returns 0.
1089  *
1090  * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
1091  * this function does not change the filter permanently, it only uses the
1092  * supplied filter until this function returns.
1093  *
1094  * \param filter the SDL_EventFilter function to call when an event happens
1095  * \param userdata a pointer that is passed to `filter`
1096  *
1097  * \since This function is available since SDL 2.0.0.
1098  *
1099  * \sa SDL_GetEventFilter
1100  * \sa SDL_SetEventFilter
1101  */
1102 extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
1103  void *userdata);
1104 
1105 /* @{ */
1106 #define SDL_QUERY -1
1107 #define SDL_IGNORE 0
1108 #define SDL_DISABLE 0
1109 #define SDL_ENABLE 1
1110 
1111 /**
1112  * Set the state of processing events by type.
1113  *
1114  * `state` may be any of the following:
1115  *
1116  * - `SDL_QUERY`: returns the current processing state of the specified event
1117  * - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped
1118  * from the event queue and will not be filtered
1119  * - `SDL_ENABLE`: the event will be processed normally
1120  *
1121  * \param type the type of event; see SDL_EventType for details
1122  * \param state how to process the event
1123  * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
1124  * of the event before this function makes any changes to it.
1125  *
1126  * \since This function is available since SDL 2.0.0.
1127  *
1128  * \sa SDL_GetEventState
1129  */
1130 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
1131 /* @} */
1132 #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
1133 
1134 /**
1135  * Allocate a set of user-defined events, and return the beginning event
1136  * number for that set of events.
1137  *
1138  * Calling this function with `numevents` <= 0 is an error and will return
1139  * (Uint32)-1.
1140  *
1141  * Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
1142  * 0xFFFFFFFF), but is clearer to write.
1143  *
1144  * \param numevents the number of events to be allocated
1145  * \returns the beginning event number, or (Uint32)-1 if there are not enough
1146  * user-defined events left.
1147  *
1148  * \since This function is available since SDL 2.0.0.
1149  *
1150  * \sa SDL_PushEvent
1151  */
1152 extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
1153 
1154 /* Ends C function definitions when using C++ */
1155 #ifdef __cplusplus
1156 }
1157 #endif
1158 #include "close_code.h"
1159 
1160 #endif /* SDL_events_h_ */
1161 
1162 /* vi: set ts=4 sw=4 expandtab: */
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:234
void SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
SDL_bool SDL_HasEvent(Uint32 type)
int(* SDL_EventFilter)(void *userdata, SDL_Event *event)
Definition: SDL_events.h:976
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_MOUSEMOTION
Definition: SDL_events.h:108
@ SDL_JOYDEVICEADDED
Definition: SDL_events.h:119
@ SDL_DROPBEGIN
Definition: SDL_events.h:151
@ SDL_SENSORUPDATE
Definition: SDL_events.h:159
@ SDL_CONTROLLERTOUCHPADDOWN
Definition: SDL_events.h:130
@ SDL_FINGERMOTION
Definition: SDL_events.h:138
@ SDL_TEXTEDITING
Definition: SDL_events.h:100
@ SDL_DROPTEXT
Definition: SDL_events.h:150
@ SDL_QUIT
Definition: SDL_events.h:60
@ SDL_APP_LOWMEMORY
Definition: SDL_events.h:67
@ SDL_JOYBUTTONDOWN
Definition: SDL_events.h:117
@ SDL_POLLSENTINEL
Definition: SDL_events.h:166
@ SDL_APP_WILLENTERFOREGROUND
Definition: SDL_events.h:79
@ SDL_USEREVENT
Definition: SDL_events.h:171
@ SDL_MOUSEBUTTONUP
Definition: SDL_events.h:110
@ SDL_JOYDEVICEREMOVED
Definition: SDL_events.h:120
@ SDL_TEXTINPUT
Definition: SDL_events.h:101
@ SDL_WINDOWEVENT
Definition: SDL_events.h:94
@ SDL_MOUSEWHEEL
Definition: SDL_events.h:111
@ SDL_CONTROLLERTOUCHPADMOTION
Definition: SDL_events.h:131
@ SDL_CLIPBOARDUPDATE
Definition: SDL_events.h:146
@ SDL_SYSWMEVENT
Definition: SDL_events.h:95
@ SDL_LOCALECHANGED
Definition: SDL_events.h:88
@ SDL_JOYBUTTONUP
Definition: SDL_events.h:118
@ SDL_JOYBALLMOTION
Definition: SDL_events.h:115
@ SDL_DISPLAYEVENT
Definition: SDL_events.h:91
@ SDL_FINGERUP
Definition: SDL_events.h:137
@ SDL_TEXTEDITING_EXT
Definition: SDL_events.h:105
@ SDL_RENDER_DEVICE_RESET
Definition: SDL_events.h:163
@ SDL_CONTROLLERBUTTONUP
Definition: SDL_events.h:126
@ SDL_MOUSEBUTTONDOWN
Definition: SDL_events.h:109
@ SDL_CONTROLLERDEVICEADDED
Definition: SDL_events.h:127
@ SDL_APP_DIDENTERFOREGROUND
Definition: SDL_events.h:83
@ SDL_DOLLARRECORD
Definition: SDL_events.h:142
@ SDL_APP_WILLENTERBACKGROUND
Definition: SDL_events.h:71
@ SDL_MULTIGESTURE
Definition: SDL_events.h:143
@ SDL_FINGERDOWN
Definition: SDL_events.h:136
@ SDL_DROPCOMPLETE
Definition: SDL_events.h:152
@ SDL_DOLLARGESTURE
Definition: SDL_events.h:141
@ SDL_CONTROLLERBUTTONDOWN
Definition: SDL_events.h:125
@ SDL_APP_DIDENTERBACKGROUND
Definition: SDL_events.h:75
@ SDL_JOYBATTERYUPDATED
Definition: SDL_events.h:121
@ SDL_APP_TERMINATING
Definition: SDL_events.h:63
@ SDL_CONTROLLERAXISMOTION
Definition: SDL_events.h:124
@ SDL_KEYDOWN
Definition: SDL_events.h:98
@ SDL_KEYMAPCHANGED
Definition: SDL_events.h:102
@ SDL_AUDIODEVICEREMOVED
Definition: SDL_events.h:156
@ SDL_DROPFILE
Definition: SDL_events.h:149
@ SDL_AUDIODEVICEADDED
Definition: SDL_events.h:155
@ SDL_KEYUP
Definition: SDL_events.h:99
@ SDL_CONTROLLERDEVICEREMOVED
Definition: SDL_events.h:128
@ SDL_RENDER_TARGETS_RESET
Definition: SDL_events.h:162
@ SDL_CONTROLLERTOUCHPADUP
Definition: SDL_events.h:132
@ SDL_CONTROLLERDEVICEREMAPPED
Definition: SDL_events.h:129
@ SDL_JOYAXISMOTION
Definition: SDL_events.h:114
@ SDL_CONTROLLERSENSORUPDATE
Definition: SDL_events.h:133
@ SDL_JOYHATMOTION
Definition: SDL_events.h:116
@ SDL_FIRSTEVENT
Definition: SDL_events.h:57
@ SDL_LASTEVENT
Definition: SDL_events.h:176
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
Definition: SDL_events.h:262
void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
SDL_bool SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata)
void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
int SDL_WaitEventTimeout(SDL_Event *event, int timeout)
SDL_eventaction
Definition: SDL_events.h:703
@ SDL_ADDEVENT
Definition: SDL_events.h:704
@ SDL_PEEKEVENT
Definition: SDL_events.h:705
@ SDL_GETEVENT
Definition: SDL_events.h:706
void SDL_FlushEvents(Uint32 minType, Uint32 maxType)
void SDL_FlushEvent(Uint32 type)
int SDL_WaitEvent(SDL_Event *event)
Uint8 SDL_EventState(Uint32 type, int state)
int SDL_PushEvent(SDL_Event *event)
SDL_bool SDL_HasEvents(Uint32 minType, Uint32 maxType)
void SDL_PumpEvents(void)
Sint64 SDL_GestureID
Definition: SDL_gesture.h:44
SDL_JoystickPowerLevel
Definition: SDL_joystick.h:100
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:83
uint8_t Uint8
Definition: SDL_stdinc.h:196
uint16_t Uint16
Definition: SDL_stdinc.h:208
int32_t Sint32
Definition: SDL_stdinc.h:214
SDL_bool
Definition: SDL_stdinc.h:179
int16_t Sint16
Definition: SDL_stdinc.h:202
uint32_t Uint32
Definition: SDL_stdinc.h:220
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
Sint64 SDL_FingerID
Definition: SDL_touch.h:42
#define NULL
Definition: begin_code.h:163
Audio device event structure (event.adevice.*)
Definition: SDL_events.h:483
Fields shared by every event.
Definition: SDL_events.h:183
Uint32 timestamp
Definition: SDL_events.h:185
Game controller axis motion event structure (event.caxis.*)
Definition: SDL_events.h:414
SDL_JoystickID which
Definition: SDL_events.h:417
Game controller button event structure (event.cbutton.*)
Definition: SDL_events.h:431
SDL_JoystickID which
Definition: SDL_events.h:434
Controller device event structure (event.cdevice.*)
Definition: SDL_events.h:446
Game controller sensor event structure (event.csensor.*)
Definition: SDL_events.h:471
SDL_JoystickID which
Definition: SDL_events.h:474
Game controller touchpad event structure (event.ctouchpad.*)
Definition: SDL_events.h:456
Display state change event data (event.display.*)
Definition: SDL_events.h:192
Dollar Gesture Event (event.dgesture.*)
Definition: SDL_events.h:533
SDL_GestureID gestureId
Definition: SDL_events.h:537
An event used to request a file open by the system (event.drop.*) This event is enabled by default,...
Definition: SDL_events.h:551
Uint32 timestamp
Definition: SDL_events.h:553
Uint32 windowID
Definition: SDL_events.h:555
Joystick axis motion event structure (event.jaxis.*)
Definition: SDL_events.h:327
SDL_JoystickID which
Definition: SDL_events.h:330
Joystick trackball motion event structure (event.jball.*)
Definition: SDL_events.h:343
SDL_JoystickID which
Definition: SDL_events.h:346
Joysick battery level change event structure (event.jbattery.*)
Definition: SDL_events.h:403
SDL_JoystickPowerLevel level
Definition: SDL_events.h:407
SDL_JoystickID which
Definition: SDL_events.h:406
Joystick button event structure (event.jbutton.*)
Definition: SDL_events.h:379
SDL_JoystickID which
Definition: SDL_events.h:382
Joystick device event structure (event.jdevice.*)
Definition: SDL_events.h:393
Joystick hat position change event structure (event.jhat.*)
Definition: SDL_events.h:359
SDL_JoystickID which
Definition: SDL_events.h:362
Uint32 timestamp
Definition: SDL_events.h:361
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:223
SDL_Keysym keysym
Definition: SDL_events.h:231
The SDL keysym structure, used in key events.
Definition: SDL_keyboard.h:48
Mouse button event structure (event.button.*)
Definition: SDL_events.h:294
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:278
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:311
Multiple Finger Gesture Event (event.mgesture.*)
Definition: SDL_events.h:516
SDL_TouchID touchId
Definition: SDL_events.h:519
OS Specific event.
Definition: SDL_events.h:583
Uint32 type
Definition: SDL_events.h:584
Uint32 timestamp
Definition: SDL_events.h:585
The "quit requested" event.
Definition: SDL_events.h:574
Uint32 timestamp
Definition: SDL_events.h:576
Sensor event structure (event.sensor.*)
Definition: SDL_events.h:563
Uint32 timestamp
Definition: SDL_events.h:565
float data[6]
Definition: SDL_events.h:567
A video driver dependent system event (event.syswm.*) This event is disabled by default,...
Definition: SDL_events.h:612
Uint32 timestamp
Definition: SDL_events.h:614
SDL_SysWMmsg * msg
Definition: SDL_events.h:615
Keyboard text editing event structure (event.edit.*)
Definition: SDL_events.h:239
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]
Definition: SDL_events.h:243
Extended keyboard text editing event structure (event.editExt.*) when text would be truncated if stor...
Definition: SDL_events.h:253
Keyboard text input event structure (event.text.*)
Definition: SDL_events.h:267
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]
Definition: SDL_events.h:271
Touch finger event structure (event.tfinger.*)
Definition: SDL_events.h:498
SDL_FingerID fingerId
Definition: SDL_events.h:502
SDL_TouchID touchId
Definition: SDL_events.h:501
A user-defined event type (event.user.*)
Definition: SDL_events.h:592
void * data2
Definition: SDL_events.h:598
void * data1
Definition: SDL_events.h:597
Uint32 windowID
Definition: SDL_events.h:595
Uint32 timestamp
Definition: SDL_events.h:594
Window state change event data (event.window.*)
Definition: SDL_events.h:207
Uint32 timestamp
Definition: SDL_events.h:209
General event structure.
Definition: SDL_events.h:622
SDL_QuitEvent quit
Definition: SDL_events.h:647
SDL_AudioDeviceEvent adevice
Definition: SDL_events.h:645
SDL_JoyDeviceEvent jdevice
Definition: SDL_events.h:638
Uint32 type
Definition: SDL_events.h:623
SDL_MouseWheelEvent wheel
Definition: SDL_events.h:633
SDL_JoyHatEvent jhat
Definition: SDL_events.h:636
SDL_DollarGestureEvent dgesture
Definition: SDL_events.h:652
SDL_JoyButtonEvent jbutton
Definition: SDL_events.h:637
SDL_WindowEvent window
Definition: SDL_events.h:626
SDL_TextEditingEvent edit
Definition: SDL_events.h:628
SDL_TextInputEvent text
Definition: SDL_events.h:630
SDL_ControllerAxisEvent caxis
Definition: SDL_events.h:640
SDL_TouchFingerEvent tfinger
Definition: SDL_events.h:650
SDL_SysWMEvent syswm
Definition: SDL_events.h:649
SDL_MouseButtonEvent button
Definition: SDL_events.h:632
SDL_UserEvent user
Definition: SDL_events.h:648
SDL_KeyboardEvent key
Definition: SDL_events.h:627
SDL_TextEditingExtEvent editExt
Definition: SDL_events.h:629
SDL_CommonEvent common
Definition: SDL_events.h:624
SDL_MultiGestureEvent mgesture
Definition: SDL_events.h:651
SDL_MouseMotionEvent motion
Definition: SDL_events.h:631
SDL_JoyAxisEvent jaxis
Definition: SDL_events.h:634
SDL_DropEvent drop
Definition: SDL_events.h:653
SDL_ControllerDeviceEvent cdevice
Definition: SDL_events.h:642
SDL_ControllerSensorEvent csensor
Definition: SDL_events.h:644
Uint8 padding[sizeof(void *)<=8 ? 56 :sizeof(void *)==16 ? 64 :3 *sizeof(void *)]
Definition: SDL_events.h:668
SDL_JoyBallEvent jball
Definition: SDL_events.h:635
SDL_JoyBatteryEvent jbattery
Definition: SDL_events.h:639
SDL_ControllerButtonEvent cbutton
Definition: SDL_events.h:641
SDL_SensorEvent sensor
Definition: SDL_events.h:646
SDL_ControllerTouchpadEvent ctouchpad
Definition: SDL_events.h:643
SDL_DisplayEvent display
Definition: SDL_events.h:625