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