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