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