include/SDL_events.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 09 May 2010 20:47:22 -0700
changeset 4465 3e69e077cb95
parent 4435 e953700da4ca
child 4503 524dfefd554c
permissions -rw-r--r--
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.

Plus, this lets me start implementing cursor support.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@1895
    23
/**
slouken@3407
    24
 *  \file SDL_events.h
slouken@3407
    25
 *  
slouken@3407
    26
 *  Include file for SDL event handling.
slouken@1895
    27
 */
slouken@0
    28
slouken@0
    29
#ifndef _SDL_events_h
slouken@0
    30
#define _SDL_events_h
slouken@0
    31
slouken@1356
    32
#include "SDL_stdinc.h"
slouken@1358
    33
#include "SDL_error.h"
slouken@1895
    34
#include "SDL_video.h"
slouken@0
    35
#include "SDL_keyboard.h"
slouken@0
    36
#include "SDL_mouse.h"
slouken@0
    37
#include "SDL_joystick.h"
slouken@0
    38
#include "SDL_quit.h"
slouken@0
    39
slouken@0
    40
#include "begin_code.h"
slouken@0
    41
/* Set up for C function definitions, even when using C++ */
slouken@0
    42
#ifdef __cplusplus
slouken@1895
    43
/* *INDENT-OFF* */
slouken@0
    44
extern "C" {
slouken@1895
    45
/* *INDENT-ON* */
slouken@0
    46
#endif
slouken@0
    47
slouken@1330
    48
/* General keyboard/mouse state definitions */
slouken@1330
    49
#define SDL_RELEASED	0
slouken@1330
    50
#define SDL_PRESSED	1
slouken@1330
    51
slouken@1895
    52
/**
slouken@3407
    53
 * \brief The types of events that can be delivered.
slouken@1895
    54
 */
slouken@1895
    55
typedef enum
slouken@1895
    56
{
slouken@4429
    57
    SDL_FIRSTEVENT     = 0,     /**< Unused (do not remove) */
slouken@4429
    58
slouken@4429
    59
    /* Application events */
slouken@4429
    60
    SDL_QUIT           = 0x100, /**< User-requested quit */
slouken@4429
    61
slouken@4429
    62
    /* Window events */
slouken@4429
    63
    SDL_WINDOWEVENT    = 0x200, /**< Window state change */
slouken@4429
    64
    SDL_SYSWMEVENT,             /**< System specific event */
slouken@4429
    65
slouken@4429
    66
    /* Keyboard events */
slouken@4429
    67
    SDL_KEYDOWN        = 0x300, /**< Keys pressed */
slouken@1895
    68
    SDL_KEYUP,                  /**< Keys released */
slouken@3280
    69
    SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
slouken@1957
    70
    SDL_TEXTINPUT,              /**< Keyboard text input */
slouken@4429
    71
slouken@4429
    72
    /* Mouse events */
slouken@4429
    73
    SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
slouken@1895
    74
    SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
slouken@1895
    75
    SDL_MOUSEBUTTONUP,          /**< Mouse button released */
slouken@1957
    76
    SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
slouken@4429
    77
slouken@4465
    78
    /* Tablet or multiple mice input device events */
slouken@4465
    79
    SDL_INPUTMOTION    = 0x500, /**< Input moved */
slouken@4465
    80
    SDL_INPUTBUTTONDOWN,        /**< Input button pressed */
slouken@4465
    81
    SDL_INPUTBUTTONUP,          /**< Input button released */
slouken@4465
    82
    SDL_INPUTWHEEL,             /**< Input wheel motion */
slouken@4465
    83
    SDL_INPUTPROXIMITYIN,       /**< Input pen entered proximity */
slouken@4465
    84
    SDL_INPUTPROXIMITYOUT,      /**< Input pen left proximity */
slouken@4429
    85
slouken@4429
    86
    /* Joystick events */
slouken@4429
    87
    SDL_JOYAXISMOTION  = 0x600, /**< Joystick axis motion */
slouken@1895
    88
    SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
slouken@1895
    89
    SDL_JOYHATMOTION,           /**< Joystick hat position change */
slouken@1895
    90
    SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
slouken@1895
    91
    SDL_JOYBUTTONUP,            /**< Joystick button released */
slouken@4429
    92
slouken@4429
    93
    /* Obsolete events */
slouken@4429
    94
    SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
slouken@4429
    95
    SDL_EVENT_COMPAT2,
slouken@4429
    96
    SDL_EVENT_COMPAT3,
slouken@4429
    97
slouken@4429
    98
    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
slouken@4429
    99
     *  and should be allocated with SDL_RegisterEvents()
slouken@4429
   100
     */
slouken@4429
   101
    SDL_USEREVENT    = 0x8000,
slouken@4429
   102
slouken@3407
   103
    /**
slouken@3407
   104
     *  This last event is only for bounding internal arrays
slouken@1895
   105
     */
slouken@4429
   106
    SDL_LASTEVENT    = 0xFFFF
slouken@1294
   107
} SDL_EventType;
slouken@0
   108
slouken@1895
   109
/**
slouken@3407
   110
 *  \brief Window state change event data (event.window.*)
slouken@1895
   111
 */
slouken@1895
   112
typedef struct SDL_WindowEvent
slouken@1895
   113
{
slouken@4429
   114
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
slouken@4429
   115
    Uint32 windowID;    /**< The associated window */
slouken@4429
   116
    Uint8 event;        /**< ::SDL_WindowEventID */
slouken@4429
   117
    Uint8 padding1;
slouken@4429
   118
    Uint8 padding2;
slouken@4429
   119
    Uint8 padding3;
slouken@4429
   120
    int data1;          /**< event dependent data */
slouken@4429
   121
    int data2;          /**< event dependent data */
slouken@1895
   122
} SDL_WindowEvent;
slouken@0
   123
slouken@1895
   124
/**
slouken@3407
   125
 *  \brief Keyboard button event structure (event.key.*)
slouken@1895
   126
 */
slouken@1895
   127
typedef struct SDL_KeyboardEvent
slouken@1895
   128
{
slouken@4429
   129
    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
slouken@4429
   130
    Uint32 windowID;    /**< The window with keyboard focus, if any */
slouken@4429
   131
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   132
    Uint8 padding1;
slouken@4429
   133
    Uint8 padding2;
slouken@4465
   134
    Uint8 padding3;
slouken@4429
   135
    SDL_keysym keysym;  /**< The key that was pressed or released */
slouken@0
   136
} SDL_KeyboardEvent;
slouken@0
   137
slouken@3407
   138
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
slouken@1895
   139
/**
slouken@3407
   140
 *  \brief Keyboard text editing event structure (event.edit.*)
slouken@3280
   141
 */
slouken@3280
   142
typedef struct SDL_TextEditingEvent
slouken@3280
   143
{
slouken@4429
   144
    Uint32 type;                                /**< ::SDL_TEXTEDITING */
slouken@4434
   145
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
slouken@3280
   146
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
slouken@3280
   147
    int start;                                  /**< The start cursor of selected editing text */
slouken@3280
   148
    int length;                                 /**< The length of selected editing text */
slouken@3280
   149
} SDL_TextEditingEvent;
slouken@3280
   150
slouken@3407
   151
slouken@3407
   152
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
slouken@3280
   153
/**
slouken@3407
   154
 *  \brief Keyboard text input event structure (event.text.*)
slouken@1895
   155
 */
slouken@1895
   156
typedef struct SDL_TextInputEvent
slouken@1895
   157
{
slouken@4429
   158
    Uint32 type;                              /**< ::SDL_TEXTINPUT */
slouken@3685
   159
    Uint32 windowID;                          /**< The window with keyboard focus, if any */
bob@2300
   160
    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
slouken@1895
   161
} SDL_TextInputEvent;
slouken@1895
   162
slouken@1895
   163
/**
slouken@3407
   164
 *  \brief Mouse motion event structure (event.motion.*)
slouken@1895
   165
 */
slouken@1895
   166
typedef struct SDL_MouseMotionEvent
slouken@1895
   167
{
slouken@4429
   168
    Uint32 type;        /**< ::SDL_MOUSEMOTION */
slouken@4429
   169
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   170
    Uint8 state;        /**< The current button state */
slouken@4429
   171
    Uint8 padding1;
slouken@4429
   172
    Uint8 padding2;
slouken@4465
   173
    Uint8 padding3;
slouken@4429
   174
    int x;              /**< X coordinate, relative to window */
slouken@4429
   175
    int y;              /**< Y coordinate, relative to window */
slouken@4429
   176
    int xrel;           /**< The relative motion in the X direction */
slouken@4429
   177
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   178
} SDL_MouseMotionEvent;
slouken@0
   179
slouken@1895
   180
/**
slouken@3407
   181
 *  \brief Mouse button event structure (event.button.*)
slouken@1895
   182
 */
slouken@1895
   183
typedef struct SDL_MouseButtonEvent
slouken@1895
   184
{
slouken@4429
   185
    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
slouken@4429
   186
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   187
    Uint8 button;       /**< The mouse button index */
slouken@4429
   188
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   189
    Uint8 padding1;
slouken@4465
   190
    Uint8 padding2;
slouken@4429
   191
    int x;              /**< X coordinate, relative to window */
slouken@4429
   192
    int y;              /**< Y coordinate, relative to window */
slouken@0
   193
} SDL_MouseButtonEvent;
slouken@0
   194
slouken@1895
   195
/**
slouken@3407
   196
 *  \brief Mouse wheel event structure (event.wheel.*)
slouken@1895
   197
 */
slouken@1895
   198
typedef struct SDL_MouseWheelEvent
slouken@1895
   199
{
slouken@4429
   200
    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
slouken@4429
   201
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   202
    int x;              /**< The amount scrolled horizontally */
slouken@4429
   203
    int y;              /**< The amount scrolled vertically */
slouken@1895
   204
} SDL_MouseWheelEvent;
slouken@1895
   205
slouken@1895
   206
/**
slouken@3407
   207
 *  \brief Joystick axis motion event structure (event.jaxis.*)
slouken@1895
   208
 */
slouken@1895
   209
typedef struct SDL_JoyAxisEvent
slouken@1895
   210
{
slouken@4429
   211
    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
slouken@1895
   212
    Uint8 which;        /**< The joystick device index */
slouken@1895
   213
    Uint8 axis;         /**< The joystick axis index */
slouken@4429
   214
    Uint8 padding1;
slouken@4429
   215
    Uint8 padding2;
slouken@1895
   216
    int value;          /**< The axis value (range: -32768 to 32767) */
slouken@0
   217
} SDL_JoyAxisEvent;
slouken@0
   218
slouken@1895
   219
/**
slouken@3407
   220
 *  \brief Joystick trackball motion event structure (event.jball.*)
slouken@1895
   221
 */
slouken@1895
   222
typedef struct SDL_JoyBallEvent
slouken@1895
   223
{
slouken@4429
   224
    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
slouken@1895
   225
    Uint8 which;        /**< The joystick device index */
slouken@1895
   226
    Uint8 ball;         /**< The joystick trackball index */
slouken@4429
   227
    Uint8 padding1;
slouken@4429
   228
    Uint8 padding2;
slouken@1895
   229
    int xrel;           /**< The relative motion in the X direction */
slouken@1895
   230
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   231
} SDL_JoyBallEvent;
slouken@0
   232
slouken@1895
   233
/**
slouken@3407
   234
 *  \brief Joystick hat position change event structure (event.jhat.*)
slouken@1895
   235
 */
slouken@1895
   236
typedef struct SDL_JoyHatEvent
slouken@1895
   237
{
slouken@4429
   238
    Uint32 type;        /**< ::SDL_JOYHATMOTION */
slouken@1895
   239
    Uint8 which;        /**< The joystick device index */
slouken@1895
   240
    Uint8 hat;          /**< The joystick hat index */
slouken@3407
   241
    Uint8 value;        /**< The hat position value.
slouken@3407
   242
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
slouken@3407
   243
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
slouken@3407
   244
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
slouken@3407
   245
                         *   
slouken@3407
   246
                         *   Note that zero means the POV is centered.
slouken@1895
   247
                         */
slouken@4429
   248
    Uint8 padding1;
slouken@0
   249
} SDL_JoyHatEvent;
slouken@0
   250
slouken@1895
   251
/**
slouken@3407
   252
 *  \brief Joystick button event structure (event.jbutton.*)
slouken@1895
   253
 */
slouken@1895
   254
typedef struct SDL_JoyButtonEvent
slouken@1895
   255
{
slouken@4429
   256
    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
slouken@1895
   257
    Uint8 which;        /**< The joystick device index */
slouken@1895
   258
    Uint8 button;       /**< The joystick button index */
slouken@3407
   259
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   260
    Uint8 padding1;
slouken@0
   261
} SDL_JoyButtonEvent;
slouken@0
   262
slouken@1895
   263
/**
slouken@3407
   264
 *  \brief The "quit requested" event
slouken@0
   265
 */
slouken@1895
   266
typedef struct SDL_QuitEvent
slouken@1895
   267
{
slouken@4429
   268
    Uint32 type;        /**< ::SDL_QUIT */
slouken@1895
   269
} SDL_QuitEvent;
slouken@1895
   270
slouken@1895
   271
/**
slouken@3407
   272
 *  \brief A user-defined event type (event.user.*)
slouken@1895
   273
 */
slouken@1895
   274
typedef struct SDL_UserEvent
slouken@1895
   275
{
slouken@4429
   276
    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
slouken@4429
   277
    Uint32 windowID;    /**< The associated window if any */
slouken@4429
   278
    int code;           /**< User defined event code */
slouken@4429
   279
    void *data1;        /**< User defined data pointer */
slouken@4429
   280
    void *data2;        /**< User defined data pointer */
slouken@1895
   281
} SDL_UserEvent;
slouken@1895
   282
slouken@1895
   283
struct SDL_SysWMmsg;
slouken@1895
   284
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
slouken@3407
   285
slouken@3407
   286
/**
slouken@3407
   287
 *  \brief A video driver dependent system event (event.syswm.*)
slouken@3407
   288
 *  
slouken@3407
   289
 *  \note If you want to use this event, you should include SDL_syswm.h.
slouken@3407
   290
 */
slouken@1895
   291
typedef struct SDL_SysWMEvent
slouken@1895
   292
{
slouken@4429
   293
    Uint32 type;        /**< ::SDL_SYSWMEVENT */
slouken@1895
   294
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
slouken@1895
   295
} SDL_SysWMEvent;
slouken@1895
   296
bob@3167
   297
#ifndef SDL_NO_COMPAT
slouken@3407
   298
/**
slouken@3407
   299
 *  \addtogroup Compatibility 
slouken@3407
   300
 */
slouken@3407
   301
/*@{*/
slouken@3407
   302
slouken@3407
   303
/**
slouken@3407
   304
 *  \name Typedefs for backwards compatibility
slouken@3407
   305
 */
slouken@3407
   306
/*@{*/
bob@3167
   307
typedef struct SDL_ActiveEvent
bob@3167
   308
{
slouken@4429
   309
    Uint32 type;
bob@3167
   310
    Uint8 gain;
bob@3167
   311
    Uint8 state;
bob@3167
   312
} SDL_ActiveEvent;
bob@3167
   313
bob@3167
   314
typedef struct SDL_ResizeEvent
bob@3167
   315
{
slouken@4429
   316
    Uint32 type;
bob@3167
   317
    int w;
bob@3167
   318
    int h;
bob@3167
   319
} SDL_ResizeEvent;
slouken@3407
   320
/*@}*/
slouken@3407
   321
slouken@3407
   322
/*@}*//*Compatibility*/
bob@3167
   323
#endif
bob@3167
   324
slouken@1895
   325
/**
slouken@3407
   326
 *  \brief General event structure
slouken@1895
   327
 */
slouken@1895
   328
typedef union SDL_Event
slouken@1895
   329
{
slouken@4429
   330
    Uint32 type;                    /**< Event type, shared with all events */
slouken@1895
   331
    SDL_WindowEvent window;         /**< Window event data */
slouken@1895
   332
    SDL_KeyboardEvent key;          /**< Keyboard event data */
slouken@3280
   333
    SDL_TextEditingEvent edit;      /**< Text editing event data */
bob@2300
   334
    SDL_TextInputEvent text;        /**< Text input event data */
slouken@1895
   335
    SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
slouken@1895
   336
    SDL_MouseButtonEvent button;    /**< Mouse button event data */
bob@2300
   337
    SDL_MouseWheelEvent wheel;      /**< Mouse wheel event data */
slouken@1895
   338
    SDL_JoyAxisEvent jaxis;         /**< Joystick axis event data */
slouken@1895
   339
    SDL_JoyBallEvent jball;         /**< Joystick ball event data */
slouken@1895
   340
    SDL_JoyHatEvent jhat;           /**< Joystick hat event data */
slouken@1895
   341
    SDL_JoyButtonEvent jbutton;     /**< Joystick button event data */
slouken@1895
   342
    SDL_QuitEvent quit;             /**< Quit request event data */
slouken@1895
   343
    SDL_UserEvent user;             /**< Custom event data */
slouken@1895
   344
    SDL_SysWMEvent syswm;           /**< System dependent window event data */
slouken@0
   345
slouken@3407
   346
    /** Temporarily here for backwards compatibility */
slouken@3407
   347
    /*@{*/
bob@3167
   348
#ifndef SDL_NO_COMPAT
slouken@1895
   349
    SDL_ActiveEvent active;
slouken@1895
   350
    SDL_ResizeEvent resize;
bob@3167
   351
#endif
slouken@3407
   352
    /*@}*/
slouken@0
   353
} SDL_Event;
slouken@0
   354
slouken@0
   355
slouken@0
   356
/* Function prototypes */
slouken@0
   357
slouken@3407
   358
/**
slouken@3407
   359
 *  Pumps the event loop, gathering events from the input devices.
slouken@3407
   360
 *  
slouken@3407
   361
 *  This function updates the event queue and internal input device state.
slouken@3407
   362
 *  
slouken@3407
   363
 *  This should only be run in the thread that sets the video mode.
slouken@3407
   364
 */
slouken@337
   365
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
slouken@0
   366
slouken@3407
   367
/*@{*/
slouken@1895
   368
typedef enum
slouken@1895
   369
{
slouken@1895
   370
    SDL_ADDEVENT,
slouken@1895
   371
    SDL_PEEKEVENT,
slouken@1895
   372
    SDL_GETEVENT
slouken@0
   373
} SDL_eventaction;
slouken@3407
   374
slouken@3407
   375
/**
slouken@3407
   376
 *  Checks the event queue for messages and optionally returns them.
slouken@3407
   377
 *  
slouken@3407
   378
 *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
slouken@3407
   379
 *  the back of the event queue.
slouken@3407
   380
 *  
slouken@3407
   381
 *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
slouken@3407
   382
 *  of the event queue, matching \c mask, will be returned and will not
slouken@3407
   383
 *  be removed from the queue.
slouken@3407
   384
 *  
slouken@3407
   385
 *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front 
slouken@3407
   386
 *  of the event queue, matching \c mask, will be returned and will be
slouken@3407
   387
 *  removed from the queue.
slouken@3407
   388
 *  
slouken@3407
   389
 *  \return The number of events actually stored, or -1 if there was an error.
slouken@3407
   390
 *  
slouken@3407
   391
 *  This function is thread-safe.
slouken@3407
   392
 */
slouken@1895
   393
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
slouken@1895
   394
                                           SDL_eventaction action,
slouken@4429
   395
                                           Uint32 minType, Uint32 maxType);
slouken@3407
   396
/*@}*/
slouken@1895
   397
slouken@3407
   398
/**
slouken@3407
   399
 *  Checks to see if certain event types are in the event queue.
slouken@1895
   400
 */
slouken@4429
   401
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
slouken@4429
   402
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
slouken@4429
   403
slouken@4429
   404
/**
slouken@4429
   405
 *  This function clears events from the event queue
slouken@4429
   406
 */
slouken@4429
   407
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
slouken@4429
   408
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
slouken@0
   409
slouken@3407
   410
/**
slouken@3407
   411
 *  \brief Polls for currently pending events.
slouken@3407
   412
 *  
slouken@3407
   413
 *  \return 1 if there are any pending events, or 0 if there are none available.
slouken@3407
   414
 *  
slouken@3407
   415
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   416
 *               stored in that area.
slouken@0
   417
 */
slouken@1895
   418
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
slouken@0
   419
slouken@3407
   420
/**
slouken@3407
   421
 *  \brief Waits indefinitely for the next available event.
slouken@3407
   422
 *  
slouken@3407
   423
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   424
 *   
slouken@3407
   425
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   426
 *               stored in that area.
slouken@0
   427
 */
slouken@1895
   428
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
slouken@0
   429
slouken@3407
   430
/**
slouken@3407
   431
 *  \brief Waits until the specified timeout (in milliseconds) for the next 
slouken@3407
   432
 *         available event.
slouken@3407
   433
 *  
slouken@3407
   434
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   435
 *  
slouken@3407
   436
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   437
 *               stored in that area.
slouken@3072
   438
 */
slouken@3072
   439
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
slouken@3072
   440
                                                 int timeout);
slouken@3072
   441
slouken@3407
   442
/**
slouken@3407
   443
 *  \brief Add an event to the event queue.
slouken@3407
   444
 *  
slouken@3407
   445
 *  \return 1 on success, 0 if the event was filtered, or -1 if the event queue 
slouken@3407
   446
 *          was full or there was some other error.
slouken@0
   447
 */
slouken@1895
   448
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
slouken@0
   449
slouken@3407
   450
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
slouken@0
   451
slouken@3407
   452
/**
slouken@3407
   453
 *  Sets up a filter to process all events before they change internal state and
slouken@3407
   454
 *  are posted to the internal event queue.
slouken@3407
   455
 *  
slouken@3407
   456
 *  The filter is protypted as:
slouken@3407
   457
 *  \code
slouken@3407
   458
 *      int SDL_EventFilter(void *userdata, SDL_Event * event);
slouken@3407
   459
 *  \endcode
slouken@3407
   460
 *
slouken@3407
   461
 *  If the filter returns 1, then the event will be added to the internal queue.
slouken@3407
   462
 *  If it returns 0, then the event will be dropped from the queue, but the 
slouken@3407
   463
 *  internal state will still be updated.  This allows selective filtering of
slouken@3407
   464
 *  dynamically arriving events.
slouken@3407
   465
 *  
slouken@3407
   466
 *  \warning  Be very careful of what you do in the event filter function, as 
slouken@3407
   467
 *            it may run in a different thread!
slouken@3407
   468
 *  
slouken@3407
   469
 *  There is one caveat when dealing with the ::SDL_QUITEVENT event type.  The
slouken@3407
   470
 *  event filter is only called when the window manager desires to close the
slouken@3407
   471
 *  application window.  If the event filter returns 1, then the window will
slouken@3407
   472
 *  be closed, otherwise the window will remain open if possible.
slouken@3407
   473
 *
slouken@3407
   474
 *  If the quit event is generated by an interrupt signal, it will bypass the
slouken@3407
   475
 *  internal queue and be delivered to the application at the next event poll.
slouken@3407
   476
 */
slouken@1895
   477
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
slouken@1895
   478
                                                void *userdata);
slouken@0
   479
slouken@3407
   480
/**
slouken@3407
   481
 *  Return the current event filter - can be used to "chain" filters.
slouken@3407
   482
 *  If there is no event filter set, this function returns SDL_FALSE.
slouken@3407
   483
 */
slouken@1895
   484
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
slouken@1895
   485
                                                    void **userdata);
slouken@1895
   486
slouken@3407
   487
/**
slouken@3407
   488
 *  Run the filter function on the current event queue, removing any
slouken@3407
   489
 *  events for which the filter returns 0.
slouken@3407
   490
 */
slouken@1895
   491
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
slouken@1895
   492
                                              void *userdata);
slouken@0
   493
slouken@3407
   494
/*@{*/
slouken@0
   495
#define SDL_QUERY	-1
slouken@0
   496
#define SDL_IGNORE	 0
slouken@0
   497
#define SDL_DISABLE	 0
slouken@0
   498
#define SDL_ENABLE	 1
slouken@3407
   499
slouken@3407
   500
/**
slouken@3407
   501
 *  This function allows you to set the state of processing certain events.
slouken@3407
   502
 *   - If \c state is set to ::SDL_IGNORE, that event will be automatically 
slouken@3407
   503
 *     dropped from the event queue and will not event be filtered.
slouken@3407
   504
 *   - If \c state is set to ::SDL_ENABLE, that event will be processed 
slouken@3407
   505
 *     normally.
slouken@3407
   506
 *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 
slouken@3407
   507
 *     current processing state of the specified event.
slouken@3407
   508
 */
slouken@4429
   509
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
slouken@3407
   510
/*@}*/
slouken@4429
   511
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
slouken@4429
   512
slouken@4429
   513
/**
slouken@4429
   514
 *  This function allocates a set of user-defined events, and returns
slouken@4429
   515
 *  the beginning event number for that set of events.
slouken@4429
   516
 *
slouken@4429
   517
 *  If there aren't enough user-defined events left, this function
slouken@4429
   518
 *  returns (Uint32)-1
slouken@4429
   519
 */
slouken@4429
   520
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
slouken@0
   521
slouken@0
   522
/* Ends C function definitions when using C++ */
slouken@0
   523
#ifdef __cplusplus
slouken@1895
   524
/* *INDENT-OFF* */
slouken@0
   525
}
slouken@1895
   526
/* *INDENT-ON* */
slouken@0
   527
#endif
slouken@0
   528
#include "close_code.h"
slouken@0
   529
slouken@0
   530
#endif /* _SDL_events_h */
slouken@1895
   531
slouken@1895
   532
/* vi: set ts=4 sw=4 expandtab: */