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