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