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