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