SDL  2.0
SDL_events.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 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  * \brief 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  /* Window events */
89  SDL_WINDOWEVENT = 0x200, /**< Window state change */
90  SDL_SYSWMEVENT, /**< System specific event */
91 
92  /* Keyboard events */
93  SDL_KEYDOWN = 0x300, /**< Key pressed */
94  SDL_KEYUP, /**< Key released */
95  SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
96  SDL_TEXTINPUT, /**< Keyboard text input */
97  SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
98  input language or keyboard layout change.
99  */
100 
101  /* Mouse events */
102  SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
103  SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
104  SDL_MOUSEBUTTONUP, /**< Mouse button released */
105  SDL_MOUSEWHEEL, /**< Mouse wheel motion */
106 
107  /* Joystick events */
108  SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
109  SDL_JOYBALLMOTION, /**< Joystick trackball motion */
110  SDL_JOYHATMOTION, /**< Joystick hat position change */
111  SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
112  SDL_JOYBUTTONUP, /**< Joystick button released */
113  SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
114  SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
115 
116  /* Game controller events */
117  SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
118  SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */
119  SDL_CONTROLLERBUTTONUP, /**< Game controller button released */
120  SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
121  SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
122  SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
123 
124  /* Touch events */
125  SDL_FINGERDOWN = 0x700,
128 
129  /* Gesture events */
133 
134  /* Clipboard events */
135  SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
136 
137  /* Drag and drop events */
138  SDL_DROPFILE = 0x1000, /**< The system requests a file open */
139 
140  /* Audio hotplug events */
141  SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
142  SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */
143 
144  /* Render events */
145  SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
146  SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
147 
148  /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
149  * and should be allocated with SDL_RegisterEvents()
150  */
151  SDL_USEREVENT = 0x8000,
152 
153  /**
154  * This last event is only for bounding internal arrays
155  */
156  SDL_LASTEVENT = 0xFFFF
157 } SDL_EventType;
158 
159 /**
160  * \brief Fields shared by every event
161  */
162 typedef struct SDL_CommonEvent
163 {
167 
168 /**
169  * \brief Window state change event data (event.window.*)
170  */
171 typedef struct SDL_WindowEvent
172 {
173  Uint32 type; /**< ::SDL_WINDOWEVENT */
175  Uint32 windowID; /**< The associated window */
176  Uint8 event; /**< ::SDL_WindowEventID */
180  Sint32 data1; /**< event dependent data */
181  Sint32 data2; /**< event dependent data */
183 
184 /**
185  * \brief Keyboard button event structure (event.key.*)
186  */
187 typedef struct SDL_KeyboardEvent
188 {
189  Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
191  Uint32 windowID; /**< The window with keyboard focus, if any */
192  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
193  Uint8 repeat; /**< Non-zero if this is a key repeat */
196  SDL_Keysym keysym; /**< The key that was pressed or released */
198 
199 #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
200 /**
201  * \brief Keyboard text editing event structure (event.edit.*)
202  */
203 typedef struct SDL_TextEditingEvent
204 {
205  Uint32 type; /**< ::SDL_TEXTEDITING */
207  Uint32 windowID; /**< The window with keyboard focus, if any */
208  char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
209  Sint32 start; /**< The start cursor of selected editing text */
210  Sint32 length; /**< The length of selected editing text */
212 
213 
214 #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
215 /**
216  * \brief Keyboard text input event structure (event.text.*)
217  */
218 typedef struct SDL_TextInputEvent
219 {
220  Uint32 type; /**< ::SDL_TEXTINPUT */
222  Uint32 windowID; /**< The window with keyboard focus, if any */
223  char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
225 
226 /**
227  * \brief Mouse motion event structure (event.motion.*)
228  */
229 typedef struct SDL_MouseMotionEvent
230 {
231  Uint32 type; /**< ::SDL_MOUSEMOTION */
233  Uint32 windowID; /**< The window with mouse focus, if any */
234  Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
235  Uint32 state; /**< The current button state */
236  Sint32 x; /**< X coordinate, relative to window */
237  Sint32 y; /**< Y coordinate, relative to window */
238  Sint32 xrel; /**< The relative motion in the X direction */
239  Sint32 yrel; /**< The relative motion in the Y direction */
241 
242 /**
243  * \brief Mouse button event structure (event.button.*)
244  */
245 typedef struct SDL_MouseButtonEvent
246 {
247  Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
249  Uint32 windowID; /**< The window with mouse focus, if any */
250  Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
251  Uint8 button; /**< The mouse button index */
252  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
253  Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
255  Sint32 x; /**< X coordinate, relative to window */
256  Sint32 y; /**< Y coordinate, relative to window */
258 
259 /**
260  * \brief Mouse wheel event structure (event.wheel.*)
261  */
262 typedef struct SDL_MouseWheelEvent
263 {
264  Uint32 type; /**< ::SDL_MOUSEWHEEL */
266  Uint32 windowID; /**< The window with mouse focus, if any */
267  Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
268  Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
269  Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
270  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 */
272 
273 /**
274  * \brief Joystick axis motion event structure (event.jaxis.*)
275  */
276 typedef struct SDL_JoyAxisEvent
277 {
278  Uint32 type; /**< ::SDL_JOYAXISMOTION */
280  SDL_JoystickID which; /**< The joystick instance id */
281  Uint8 axis; /**< The joystick axis index */
285  Sint16 value; /**< The axis value (range: -32768 to 32767) */
288 
289 /**
290  * \brief Joystick trackball motion event structure (event.jball.*)
291  */
292 typedef struct SDL_JoyBallEvent
293 {
294  Uint32 type; /**< ::SDL_JOYBALLMOTION */
296  SDL_JoystickID which; /**< The joystick instance id */
297  Uint8 ball; /**< The joystick trackball index */
301  Sint16 xrel; /**< The relative motion in the X direction */
302  Sint16 yrel; /**< The relative motion in the Y direction */
304 
305 /**
306  * \brief Joystick hat position change event structure (event.jhat.*)
307  */
308 typedef struct SDL_JoyHatEvent
309 {
310  Uint32 type; /**< ::SDL_JOYHATMOTION */
312  SDL_JoystickID which; /**< The joystick instance id */
313  Uint8 hat; /**< The joystick hat index */
314  Uint8 value; /**< The hat position value.
315  * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
316  * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
317  * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
318  *
319  * Note that zero means the POV is centered.
320  */
324 
325 /**
326  * \brief Joystick button event structure (event.jbutton.*)
327  */
328 typedef struct SDL_JoyButtonEvent
329 {
330  Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
332  SDL_JoystickID which; /**< The joystick instance id */
333  Uint8 button; /**< The joystick button index */
334  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
338 
339 /**
340  * \brief Joystick device event structure (event.jdevice.*)
341  */
342 typedef struct SDL_JoyDeviceEvent
343 {
344  Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
346  Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
348 
349 
350 /**
351  * \brief Game controller axis motion event structure (event.caxis.*)
352  */
354 {
355  Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
357  SDL_JoystickID which; /**< The joystick instance id */
358  Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
362  Sint16 value; /**< The axis value (range: -32768 to 32767) */
365 
366 
367 /**
368  * \brief Game controller button event structure (event.cbutton.*)
369  */
371 {
372  Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
374  SDL_JoystickID which; /**< The joystick instance id */
375  Uint8 button; /**< The controller button (SDL_GameControllerButton) */
376  Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
380 
381 
382 /**
383  * \brief Controller device event structure (event.cdevice.*)
384  */
386 {
387  Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
389  Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
391 
392 /**
393  * \brief Audio device event structure (event.adevice.*)
394  */
395 typedef struct SDL_AudioDeviceEvent
396 {
397  Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
399  Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
400  Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
405 
406 
407 /**
408  * \brief Touch finger event structure (event.tfinger.*)
409  */
410 typedef struct SDL_TouchFingerEvent
411 {
412  Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
414  SDL_TouchID touchId; /**< The touch device id */
416  float x; /**< Normalized in the range 0...1 */
417  float y; /**< Normalized in the range 0...1 */
418  float dx; /**< Normalized in the range -1...1 */
419  float dy; /**< Normalized in the range -1...1 */
420  float pressure; /**< Normalized in the range 0...1 */
422 
423 
424 /**
425  * \brief Multiple Finger Gesture Event (event.mgesture.*)
426  */
427 typedef struct SDL_MultiGestureEvent
428 {
429  Uint32 type; /**< ::SDL_MULTIGESTURE */
431  SDL_TouchID touchId; /**< The touch device index */
432  float dTheta;
433  float dDist;
434  float x;
435  float y;
439 
440 
441 /**
442  * \brief Dollar Gesture Event (event.dgesture.*)
443  */
445 {
446  Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
448  SDL_TouchID touchId; /**< The touch device id */
451  float error;
452  float x; /**< Normalized center of gesture */
453  float y; /**< Normalized center of gesture */
455 
456 
457 /**
458  * \brief An event used to request a file open by the system (event.drop.*)
459  * This event is enabled by default, you can disable it with SDL_EventState().
460  * \note If this event is enabled, you must free the filename in the event.
461  */
462 typedef struct SDL_DropEvent
463 {
464  Uint32 type; /**< ::SDL_DROPFILE */
466  char *file; /**< The file name, which should be freed with SDL_free() */
467 } SDL_DropEvent;
468 
469 
470 /**
471  * \brief The "quit requested" event
472  */
473 typedef struct SDL_QuitEvent
474 {
475  Uint32 type; /**< ::SDL_QUIT */
477 } SDL_QuitEvent;
478 
479 /**
480  * \brief OS Specific event
481  */
482 typedef struct SDL_OSEvent
483 {
484  Uint32 type; /**< ::SDL_QUIT */
486 } SDL_OSEvent;
487 
488 /**
489  * \brief A user-defined event type (event.user.*)
490  */
491 typedef struct SDL_UserEvent
492 {
493  Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
495  Uint32 windowID; /**< The associated window if any */
496  Sint32 code; /**< User defined event code */
497  void *data1; /**< User defined data pointer */
498  void *data2; /**< User defined data pointer */
499 } SDL_UserEvent;
500 
501 
502 struct SDL_SysWMmsg;
503 typedef struct SDL_SysWMmsg SDL_SysWMmsg;
504 
505 /**
506  * \brief A video driver dependent system event (event.syswm.*)
507  * This event is disabled by default, you can enable it with SDL_EventState()
508  *
509  * \note If you want to use this event, you should include SDL_syswm.h.
510  */
511 typedef struct SDL_SysWMEvent
512 {
513  Uint32 type; /**< ::SDL_SYSWMEVENT */
515  SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
517 
518 /**
519  * \brief General event structure
520  */
521 typedef union SDL_Event
522 {
523  Uint32 type; /**< Event type, shared with all events */
524  SDL_CommonEvent common; /**< Common event data */
525  SDL_WindowEvent window; /**< Window event data */
526  SDL_KeyboardEvent key; /**< Keyboard event data */
527  SDL_TextEditingEvent edit; /**< Text editing event data */
528  SDL_TextInputEvent text; /**< Text input event data */
529  SDL_MouseMotionEvent motion; /**< Mouse motion event data */
530  SDL_MouseButtonEvent button; /**< Mouse button event data */
531  SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
532  SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
533  SDL_JoyBallEvent jball; /**< Joystick ball event data */
534  SDL_JoyHatEvent jhat; /**< Joystick hat event data */
535  SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
536  SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
537  SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
538  SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
539  SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
540  SDL_AudioDeviceEvent adevice; /**< Audio device event data */
541  SDL_QuitEvent quit; /**< Quit request event data */
542  SDL_UserEvent user; /**< Custom event data */
543  SDL_SysWMEvent syswm; /**< System dependent window event data */
544  SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
545  SDL_MultiGestureEvent mgesture; /**< Gesture event data */
546  SDL_DollarGestureEvent dgesture; /**< Gesture event data */
547  SDL_DropEvent drop; /**< Drag and drop event data */
548 
549  /* This is necessary for ABI compatibility between Visual C++ and GCC
550  Visual C++ will respect the push pack pragma and use 52 bytes for
551  this structure, and GCC will use the alignment of the largest datatype
552  within the union, which is 8 bytes.
553 
554  So... we'll add padding to force the size to be 56 bytes for both.
555  */
556  Uint8 padding[56];
557 } SDL_Event;
558 
559 
560 /* Function prototypes */
561 
562 /**
563  * Pumps the event loop, gathering events from the input devices.
564  *
565  * This function updates the event queue and internal input device state.
566  *
567  * This should only be run in the thread that sets the video mode.
568  */
569 extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
570 
571 /* @{ */
572 typedef enum
573 {
578 
579 /**
580  * Checks the event queue for messages and optionally returns them.
581  *
582  * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
583  * the back of the event queue.
584  *
585  * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
586  * of the event queue, within the specified minimum and maximum type,
587  * will be returned and will not be removed from the queue.
588  *
589  * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front
590  * of the event queue, within the specified minimum and maximum type,
591  * will be returned and will be removed from the queue.
592  *
593  * \return The number of events actually stored, or -1 if there was an error.
594  *
595  * This function is thread-safe.
596  */
597 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
598  SDL_eventaction action,
599  Uint32 minType, Uint32 maxType);
600 /* @} */
601 
602 /**
603  * Checks to see if certain event types are in the event queue.
604  */
606 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
607 
608 /**
609  * This function clears events from the event queue
610  * This function only affects currently queued events. If you want to make
611  * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
612  * on the main thread immediately before the flush call.
613  */
615 extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
616 
617 /**
618  * \brief Polls for currently pending events.
619  *
620  * \return 1 if there are any pending events, or 0 if there are none available.
621  *
622  * \param event If not NULL, the next event is removed from the queue and
623  * stored in that area.
624  */
626 
627 /**
628  * \brief Waits indefinitely for the next available event.
629  *
630  * \return 1, or 0 if there was an error while waiting for events.
631  *
632  * \param event If not NULL, the next event is removed from the queue and
633  * stored in that area.
634  */
636 
637 /**
638  * \brief Waits until the specified timeout (in milliseconds) for the next
639  * available event.
640  *
641  * \return 1, or 0 if there was an error while waiting for events.
642  *
643  * \param event If not NULL, the next event is removed from the queue and
644  * stored in that area.
645  * \param timeout The timeout (in milliseconds) to wait for next event.
646  */
648  int timeout);
649 
650 /**
651  * \brief Add an event to the event queue.
652  *
653  * \return 1 on success, 0 if the event was filtered, or -1 if the event queue
654  * was full or there was some other error.
655  */
657 
658 typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
659 
660 /**
661  * Sets up a filter to process all events before they change internal state and
662  * are posted to the internal event queue.
663  *
664  * The filter is prototyped as:
665  * \code
666  * int SDL_EventFilter(void *userdata, SDL_Event * event);
667  * \endcode
668  *
669  * If the filter returns 1, then the event will be added to the internal queue.
670  * If it returns 0, then the event will be dropped from the queue, but the
671  * internal state will still be updated. This allows selective filtering of
672  * dynamically arriving events.
673  *
674  * \warning Be very careful of what you do in the event filter function, as
675  * it may run in a different thread!
676  *
677  * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
678  * event filter is only called when the window manager desires to close the
679  * application window. If the event filter returns 1, then the window will
680  * be closed, otherwise the window will remain open if possible.
681  *
682  * If the quit event is generated by an interrupt signal, it will bypass the
683  * internal queue and be delivered to the application at the next event poll.
684  */
686  void *userdata);
687 
688 /**
689  * Return the current event filter - can be used to "chain" filters.
690  * If there is no event filter set, this function returns SDL_FALSE.
691  */
693  void **userdata);
694 
695 /**
696  * Add a function which is called when an event is added to the queue.
697  */
699  void *userdata);
700 
701 /**
702  * Remove an event watch function added with SDL_AddEventWatch()
703  */
705  void *userdata);
706 
707 /**
708  * Run the filter function on the current event queue, removing any
709  * events for which the filter returns 0.
710  */
712  void *userdata);
713 
714 /* @{ */
715 #define SDL_QUERY -1
716 #define SDL_IGNORE 0
717 #define SDL_DISABLE 0
718 #define SDL_ENABLE 1
719 
720 /**
721  * This function allows you to set the state of processing certain events.
722  * - If \c state is set to ::SDL_IGNORE, that event will be automatically
723  * dropped from the event queue and will not event be filtered.
724  * - If \c state is set to ::SDL_ENABLE, that event will be processed
725  * normally.
726  * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the
727  * current processing state of the specified event.
728  */
730 /* @} */
731 #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
732 
733 /**
734  * This function allocates a set of user-defined events, and returns
735  * the beginning event number for that set of events.
736  *
737  * If there aren't enough user-defined events left, this function
738  * returns (Uint32)-1
739  */
740 extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
741 
742 /* Ends C function definitions when using C++ */
743 #ifdef __cplusplus
744 }
745 #endif
746 #include "close_code.h"
747 
748 #endif /* _SDL_events_h */
749 
750 /* vi: set ts=4 sw=4 expandtab: */
void * data1
Definition: SDL_events.h:497
SDL_JoystickID which
Definition: SDL_events.h:357
SDL_eventaction
Definition: SDL_events.h:572
SDL_MouseMotionEvent motion
Definition: SDL_events.h:529
SDL_JoystickID which
Definition: SDL_events.h:332
SDL_ControllerAxisEvent caxis
Definition: SDL_events.h:537
SDL_JoyDeviceEvent jdevice
Definition: SDL_events.h:536
The "quit requested" event.
Definition: SDL_events.h:473
Controller device event structure (event.cdevice.*)
Definition: SDL_events.h:385
int SDL_PollEvent(SDL_Event *event)
Polls for currently pending events.
Definition: SDL_events.c:416
SDL_DollarGestureEvent dgesture
Definition: SDL_events.h:546
Joystick button event structure (event.jbutton.*)
Definition: SDL_events.h:328
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
SDL_bool SDL_HasEvents(Uint32 minType, Uint32 maxType)
Definition: SDL_events.c:351
int SDL_WaitEvent(SDL_Event *event)
Waits indefinitely for the next available event.
Definition: SDL_events.c:422
void * data2
Definition: SDL_events.h:498
SDL_ControllerDeviceEvent cdevice
Definition: SDL_events.h:539
SDL_JoyButtonEvent jbutton
Definition: SDL_events.h:535
void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
Definition: SDL_events.c:533
Sint64 SDL_FingerID
Definition: SDL_touch.h:42
void SDL_FlushEvent(Uint32 type)
Definition: SDL_events.c:357
Joystick axis motion event structure (event.jaxis.*)
Definition: SDL_events.h:276
SDL_SysWMmsg * msg
Definition: SDL_events.h:515
struct xkb_state * state
static SDL_Event events[EVENT_BUF_SIZE]
Definition: testgesture.c:36
SDL_JoyBallEvent jball
Definition: SDL_events.h:533
SDL_JoystickID which
Definition: SDL_events.h:280
SDL_TouchID touchId
Definition: SDL_events.h:414
Uint32 timestamp
Definition: SDL_events.h:476
int(* SDL_EventFilter)(void *userdata, SDL_Event *event)
Definition: SDL_events.h:658
Keyboard text editing event structure (event.edit.*)
Definition: SDL_events.h:203
The SDL keysym structure, used in key events.
Definition: SDL_keyboard.h:47
int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType)
Definition: SDL_events.c:265
Game controller axis motion event structure (event.caxis.*)
Definition: SDL_events.h:353
SDL_QuitEvent quit
Definition: SDL_events.h:541
SDL_GestureID gestureId
Definition: SDL_events.h:449
Uint32 timestamp
Definition: SDL_events.h:494
Dollar Gesture Event (event.dgesture.*)
Definition: SDL_events.h:444
SDL_JoystickID which
Definition: SDL_events.h:374
OS Specific event.
Definition: SDL_events.h:482
Keyboard text input event structure (event.text.*)
Definition: SDL_events.h:218
SDL_MouseWheelEvent wheel
Definition: SDL_events.h:531
int SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
Definition: SDL_events.c:458
Joystick trackball motion event structure (event.jball.*)
Definition: SDL_events.h:292
void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
Definition: SDL_events.c:482
SDL_bool
Definition: SDL_stdinc.h:126
SDL_WindowEvent window
Definition: SDL_events.h:525
Uint32 timestamp
Definition: SDL_events.h:514
A user-defined event type (event.user.*)
Definition: SDL_events.h:491
An event used to request a file open by the system (event.drop.*) This event is enabled by default...
Definition: SDL_events.h:462
Fields shared by every event.
Definition: SDL_events.h:162
SDL_JoystickID which
Definition: SDL_events.h:296
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1564
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:187
SDL_TextInputEvent text
Definition: SDL_events.h:528
#define DECLSPEC
Definition: SDL_internal.h:30
Uint32 timestamp
Definition: SDL_events.h:465
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:72
SDL_JoyAxisEvent jaxis
Definition: SDL_events.h:532
Touch finger event structure (event.tfinger.*)
Definition: SDL_events.h:410
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_MultiGestureEvent mgesture
Definition: SDL_events.h:545
Sint64 SDL_GestureID
Definition: SDL_gesture.h:44
struct _cl_event * event
SDL_EventType
The types of events that can be delivered.
Definition: SDL_events.h:55
Uint32 SDL_RegisterEvents(int numevents)
Definition: SDL_events.c:608
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
Uint32 windowID
Definition: SDL_events.h:495
Uint32 timestamp
Definition: SDL_events.h:311
Audio device event structure (event.adevice.*)
Definition: SDL_events.h:395
SDL_Keysym keysym
Definition: SDL_events.h:196
int32_t Sint32
A signed 32-bit integer type.
Definition: SDL_stdinc.h:151
void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
Definition: SDL_events.c:505
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:262
void SDL_PumpEvents(void)
Definition: SDL_events.c:395
void SDL_FlushEvents(Uint32 minType, Uint32 maxType)
Definition: SDL_events.c:363
Window state change event data (event.window.*)
Definition: SDL_events.h:171
Uint32 timestamp
Definition: SDL_events.h:174
Uint32 timestamp
Definition: SDL_events.h:485
SDL_TextEditingEvent edit
Definition: SDL_events.h:527
SDL_AudioDeviceEvent adevice
Definition: SDL_events.h:540
SDL_SysWMEvent syswm
Definition: SDL_events.h:543
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:229
Game controller button event structure (event.cbutton.*)
Definition: SDL_events.h:370
SDL_KeyboardEvent key
Definition: SDL_events.h:526
Joystick hat position change event structure (event.jhat.*)
Definition: SDL_events.h:308
SDL_ControllerButtonEvent cbutton
Definition: SDL_events.h:538
Mouse button event structure (event.button.*)
Definition: SDL_events.h:245
GLbitfield GLuint64 timeout
A video driver dependent system event (event.syswm.*) This event is disabled by default, you can enable it with SDL_EventState()
Definition: SDL_events.h:511
Uint32 timestamp
Definition: SDL_events.h:165
SDL_FingerID fingerId
Definition: SDL_events.h:415
int SDL_WaitEventTimeout(SDL_Event *event, int timeout)
Waits until the specified timeout (in milliseconds) for the next available event. ...
Definition: SDL_events.c:428
SDL_MouseButtonEvent button
Definition: SDL_events.h:530
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
SDL_bool SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata)
Definition: SDL_events.c:492
General event structure.
Definition: SDL_events.h:521
SDL_UserEvent user
Definition: SDL_events.h:542
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
Definition: SDL_events.h:214
Uint32 type
Definition: SDL_events.h:484
Uint8 SDL_EventState(Uint32 type, int state)
Definition: SDL_events.c:567
SDL_JoyHatEvent jhat
Definition: SDL_events.h:534
SDL_CommonEvent common
Definition: SDL_events.h:524
SDL_bool SDL_HasEvent(Uint32 type)
Definition: SDL_events.c:345
#define SDLCALL
Definition: SDL_internal.h:31
Joystick device event structure (event.jdevice.*)
Definition: SDL_events.h:342
SDL_JoystickID which
Definition: SDL_events.h:312
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
int16_t Sint16
A signed 16-bit integer type.
Definition: SDL_stdinc.h:143
SDL_TouchID touchId
Definition: SDL_events.h:431
SDL_DropEvent drop
Definition: SDL_events.h:547
Uint32 type
Definition: SDL_events.h:523
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE
Definition: SDL_events.h:199
Multiple Finger Gesture Event (event.mgesture.*)
Definition: SDL_events.h:427
SDL_TouchFingerEvent tfinger
Definition: SDL_events.h:544
void SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
Definition: SDL_events.c:552