include/SDL_events.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 08 Jul 2010 22:54:03 -0700
changeset 4503 524dfefd554c
parent 4465 3e69e077cb95
child 4560 95352c671a6e
child 4661 03dcb795c583
permissions -rw-r--r--
Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
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@4503
    93
    /* Clipboard events */
slouken@4503
    94
    SDL_CLIPBOARDUPDATE = 0x700, /**< The clipboard changed */
slouken@4503
    95
slouken@4429
    96
    /* Obsolete events */
slouken@4429
    97
    SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
slouken@4429
    98
    SDL_EVENT_COMPAT2,
slouken@4429
    99
    SDL_EVENT_COMPAT3,
slouken@4429
   100
slouken@4429
   101
    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
slouken@4429
   102
     *  and should be allocated with SDL_RegisterEvents()
slouken@4429
   103
     */
slouken@4429
   104
    SDL_USEREVENT    = 0x8000,
slouken@4429
   105
slouken@3407
   106
    /**
slouken@3407
   107
     *  This last event is only for bounding internal arrays
slouken@1895
   108
     */
slouken@4429
   109
    SDL_LASTEVENT    = 0xFFFF
slouken@1294
   110
} SDL_EventType;
slouken@0
   111
slouken@1895
   112
/**
slouken@3407
   113
 *  \brief Window state change event data (event.window.*)
slouken@1895
   114
 */
slouken@1895
   115
typedef struct SDL_WindowEvent
slouken@1895
   116
{
slouken@4429
   117
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
slouken@4429
   118
    Uint32 windowID;    /**< The associated window */
slouken@4429
   119
    Uint8 event;        /**< ::SDL_WindowEventID */
slouken@4429
   120
    Uint8 padding1;
slouken@4429
   121
    Uint8 padding2;
slouken@4429
   122
    Uint8 padding3;
slouken@4429
   123
    int data1;          /**< event dependent data */
slouken@4429
   124
    int data2;          /**< event dependent data */
slouken@1895
   125
} SDL_WindowEvent;
slouken@0
   126
slouken@1895
   127
/**
slouken@3407
   128
 *  \brief Keyboard button event structure (event.key.*)
slouken@1895
   129
 */
slouken@1895
   130
typedef struct SDL_KeyboardEvent
slouken@1895
   131
{
slouken@4429
   132
    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
slouken@4429
   133
    Uint32 windowID;    /**< The window with keyboard focus, if any */
slouken@4429
   134
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   135
    Uint8 padding1;
slouken@4429
   136
    Uint8 padding2;
slouken@4465
   137
    Uint8 padding3;
slouken@4429
   138
    SDL_keysym keysym;  /**< The key that was pressed or released */
slouken@0
   139
} SDL_KeyboardEvent;
slouken@0
   140
slouken@3407
   141
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
slouken@1895
   142
/**
slouken@3407
   143
 *  \brief Keyboard text editing event structure (event.edit.*)
slouken@3280
   144
 */
slouken@3280
   145
typedef struct SDL_TextEditingEvent
slouken@3280
   146
{
slouken@4429
   147
    Uint32 type;                                /**< ::SDL_TEXTEDITING */
slouken@4434
   148
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
slouken@3280
   149
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
slouken@3280
   150
    int start;                                  /**< The start cursor of selected editing text */
slouken@3280
   151
    int length;                                 /**< The length of selected editing text */
slouken@3280
   152
} SDL_TextEditingEvent;
slouken@3280
   153
slouken@3407
   154
slouken@3407
   155
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
slouken@3280
   156
/**
slouken@3407
   157
 *  \brief Keyboard text input event structure (event.text.*)
slouken@1895
   158
 */
slouken@1895
   159
typedef struct SDL_TextInputEvent
slouken@1895
   160
{
slouken@4429
   161
    Uint32 type;                              /**< ::SDL_TEXTINPUT */
slouken@3685
   162
    Uint32 windowID;                          /**< The window with keyboard focus, if any */
bob@2300
   163
    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
slouken@1895
   164
} SDL_TextInputEvent;
slouken@1895
   165
slouken@1895
   166
/**
slouken@3407
   167
 *  \brief Mouse motion event structure (event.motion.*)
slouken@1895
   168
 */
slouken@1895
   169
typedef struct SDL_MouseMotionEvent
slouken@1895
   170
{
slouken@4429
   171
    Uint32 type;        /**< ::SDL_MOUSEMOTION */
slouken@4429
   172
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   173
    Uint8 state;        /**< The current button state */
slouken@4429
   174
    Uint8 padding1;
slouken@4429
   175
    Uint8 padding2;
slouken@4465
   176
    Uint8 padding3;
slouken@4429
   177
    int x;              /**< X coordinate, relative to window */
slouken@4429
   178
    int y;              /**< Y coordinate, relative to window */
slouken@4429
   179
    int xrel;           /**< The relative motion in the X direction */
slouken@4429
   180
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   181
} SDL_MouseMotionEvent;
slouken@0
   182
slouken@1895
   183
/**
slouken@3407
   184
 *  \brief Mouse button event structure (event.button.*)
slouken@1895
   185
 */
slouken@1895
   186
typedef struct SDL_MouseButtonEvent
slouken@1895
   187
{
slouken@4429
   188
    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
slouken@4429
   189
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   190
    Uint8 button;       /**< The mouse button index */
slouken@4429
   191
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   192
    Uint8 padding1;
slouken@4465
   193
    Uint8 padding2;
slouken@4429
   194
    int x;              /**< X coordinate, relative to window */
slouken@4429
   195
    int y;              /**< Y coordinate, relative to window */
slouken@0
   196
} SDL_MouseButtonEvent;
slouken@0
   197
slouken@1895
   198
/**
slouken@3407
   199
 *  \brief Mouse wheel event structure (event.wheel.*)
slouken@1895
   200
 */
slouken@1895
   201
typedef struct SDL_MouseWheelEvent
slouken@1895
   202
{
slouken@4429
   203
    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
slouken@4429
   204
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   205
    int x;              /**< The amount scrolled horizontally */
slouken@4429
   206
    int y;              /**< The amount scrolled vertically */
slouken@1895
   207
} SDL_MouseWheelEvent;
slouken@1895
   208
slouken@1895
   209
/**
slouken@3407
   210
 *  \brief Joystick axis motion event structure (event.jaxis.*)
slouken@1895
   211
 */
slouken@1895
   212
typedef struct SDL_JoyAxisEvent
slouken@1895
   213
{
slouken@4429
   214
    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
slouken@1895
   215
    Uint8 which;        /**< The joystick device index */
slouken@1895
   216
    Uint8 axis;         /**< The joystick axis index */
slouken@4429
   217
    Uint8 padding1;
slouken@4429
   218
    Uint8 padding2;
slouken@1895
   219
    int value;          /**< The axis value (range: -32768 to 32767) */
slouken@0
   220
} SDL_JoyAxisEvent;
slouken@0
   221
slouken@1895
   222
/**
slouken@3407
   223
 *  \brief Joystick trackball motion event structure (event.jball.*)
slouken@1895
   224
 */
slouken@1895
   225
typedef struct SDL_JoyBallEvent
slouken@1895
   226
{
slouken@4429
   227
    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
slouken@1895
   228
    Uint8 which;        /**< The joystick device index */
slouken@1895
   229
    Uint8 ball;         /**< The joystick trackball index */
slouken@4429
   230
    Uint8 padding1;
slouken@4429
   231
    Uint8 padding2;
slouken@1895
   232
    int xrel;           /**< The relative motion in the X direction */
slouken@1895
   233
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   234
} SDL_JoyBallEvent;
slouken@0
   235
slouken@1895
   236
/**
slouken@3407
   237
 *  \brief Joystick hat position change event structure (event.jhat.*)
slouken@1895
   238
 */
slouken@1895
   239
typedef struct SDL_JoyHatEvent
slouken@1895
   240
{
slouken@4429
   241
    Uint32 type;        /**< ::SDL_JOYHATMOTION */
slouken@1895
   242
    Uint8 which;        /**< The joystick device index */
slouken@1895
   243
    Uint8 hat;          /**< The joystick hat index */
slouken@3407
   244
    Uint8 value;        /**< The hat position value.
slouken@3407
   245
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
slouken@3407
   246
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
slouken@3407
   247
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
slouken@3407
   248
                         *   
slouken@3407
   249
                         *   Note that zero means the POV is centered.
slouken@1895
   250
                         */
slouken@4429
   251
    Uint8 padding1;
slouken@0
   252
} SDL_JoyHatEvent;
slouken@0
   253
slouken@1895
   254
/**
slouken@3407
   255
 *  \brief Joystick button event structure (event.jbutton.*)
slouken@1895
   256
 */
slouken@1895
   257
typedef struct SDL_JoyButtonEvent
slouken@1895
   258
{
slouken@4429
   259
    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
slouken@1895
   260
    Uint8 which;        /**< The joystick device index */
slouken@1895
   261
    Uint8 button;       /**< The joystick button index */
slouken@3407
   262
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   263
    Uint8 padding1;
slouken@0
   264
} SDL_JoyButtonEvent;
slouken@0
   265
slouken@1895
   266
/**
slouken@3407
   267
 *  \brief The "quit requested" event
slouken@0
   268
 */
slouken@1895
   269
typedef struct SDL_QuitEvent
slouken@1895
   270
{
slouken@4429
   271
    Uint32 type;        /**< ::SDL_QUIT */
slouken@1895
   272
} SDL_QuitEvent;
slouken@1895
   273
slouken@1895
   274
/**
slouken@3407
   275
 *  \brief A user-defined event type (event.user.*)
slouken@1895
   276
 */
slouken@1895
   277
typedef struct SDL_UserEvent
slouken@1895
   278
{
slouken@4429
   279
    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
slouken@4429
   280
    Uint32 windowID;    /**< The associated window if any */
slouken@4429
   281
    int code;           /**< User defined event code */
slouken@4429
   282
    void *data1;        /**< User defined data pointer */
slouken@4429
   283
    void *data2;        /**< User defined data pointer */
slouken@1895
   284
} SDL_UserEvent;
slouken@1895
   285
slouken@1895
   286
struct SDL_SysWMmsg;
slouken@1895
   287
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
slouken@3407
   288
slouken@3407
   289
/**
slouken@3407
   290
 *  \brief A video driver dependent system event (event.syswm.*)
slouken@3407
   291
 *  
slouken@3407
   292
 *  \note If you want to use this event, you should include SDL_syswm.h.
slouken@3407
   293
 */
slouken@1895
   294
typedef struct SDL_SysWMEvent
slouken@1895
   295
{
slouken@4429
   296
    Uint32 type;        /**< ::SDL_SYSWMEVENT */
slouken@1895
   297
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
slouken@1895
   298
} SDL_SysWMEvent;
slouken@1895
   299
bob@3167
   300
#ifndef SDL_NO_COMPAT
slouken@3407
   301
/**
slouken@3407
   302
 *  \addtogroup Compatibility 
slouken@3407
   303
 */
slouken@3407
   304
/*@{*/
slouken@3407
   305
slouken@3407
   306
/**
slouken@3407
   307
 *  \name Typedefs for backwards compatibility
slouken@3407
   308
 */
slouken@3407
   309
/*@{*/
bob@3167
   310
typedef struct SDL_ActiveEvent
bob@3167
   311
{
slouken@4429
   312
    Uint32 type;
bob@3167
   313
    Uint8 gain;
bob@3167
   314
    Uint8 state;
bob@3167
   315
} SDL_ActiveEvent;
bob@3167
   316
bob@3167
   317
typedef struct SDL_ResizeEvent
bob@3167
   318
{
slouken@4429
   319
    Uint32 type;
bob@3167
   320
    int w;
bob@3167
   321
    int h;
bob@3167
   322
} SDL_ResizeEvent;
slouken@3407
   323
/*@}*/
slouken@3407
   324
slouken@3407
   325
/*@}*//*Compatibility*/
bob@3167
   326
#endif
bob@3167
   327
slouken@1895
   328
/**
slouken@3407
   329
 *  \brief General event structure
slouken@1895
   330
 */
slouken@1895
   331
typedef union SDL_Event
slouken@1895
   332
{
slouken@4429
   333
    Uint32 type;                    /**< Event type, shared with all events */
slouken@1895
   334
    SDL_WindowEvent window;         /**< Window event data */
slouken@1895
   335
    SDL_KeyboardEvent key;          /**< Keyboard event data */
slouken@3280
   336
    SDL_TextEditingEvent edit;      /**< Text editing event data */
bob@2300
   337
    SDL_TextInputEvent text;        /**< Text input event data */
slouken@1895
   338
    SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
slouken@1895
   339
    SDL_MouseButtonEvent button;    /**< Mouse button event data */
bob@2300
   340
    SDL_MouseWheelEvent wheel;      /**< Mouse wheel event data */
slouken@1895
   341
    SDL_JoyAxisEvent jaxis;         /**< Joystick axis event data */
slouken@1895
   342
    SDL_JoyBallEvent jball;         /**< Joystick ball event data */
slouken@1895
   343
    SDL_JoyHatEvent jhat;           /**< Joystick hat event data */
slouken@1895
   344
    SDL_JoyButtonEvent jbutton;     /**< Joystick button event data */
slouken@1895
   345
    SDL_QuitEvent quit;             /**< Quit request event data */
slouken@1895
   346
    SDL_UserEvent user;             /**< Custom event data */
slouken@1895
   347
    SDL_SysWMEvent syswm;           /**< System dependent window event data */
slouken@0
   348
slouken@3407
   349
    /** Temporarily here for backwards compatibility */
slouken@3407
   350
    /*@{*/
bob@3167
   351
#ifndef SDL_NO_COMPAT
slouken@1895
   352
    SDL_ActiveEvent active;
slouken@1895
   353
    SDL_ResizeEvent resize;
bob@3167
   354
#endif
slouken@3407
   355
    /*@}*/
slouken@0
   356
} SDL_Event;
slouken@0
   357
slouken@0
   358
slouken@0
   359
/* Function prototypes */
slouken@0
   360
slouken@3407
   361
/**
slouken@3407
   362
 *  Pumps the event loop, gathering events from the input devices.
slouken@3407
   363
 *  
slouken@3407
   364
 *  This function updates the event queue and internal input device state.
slouken@3407
   365
 *  
slouken@3407
   366
 *  This should only be run in the thread that sets the video mode.
slouken@3407
   367
 */
slouken@337
   368
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
slouken@0
   369
slouken@3407
   370
/*@{*/
slouken@1895
   371
typedef enum
slouken@1895
   372
{
slouken@1895
   373
    SDL_ADDEVENT,
slouken@1895
   374
    SDL_PEEKEVENT,
slouken@1895
   375
    SDL_GETEVENT
slouken@0
   376
} SDL_eventaction;
slouken@3407
   377
slouken@3407
   378
/**
slouken@3407
   379
 *  Checks the event queue for messages and optionally returns them.
slouken@3407
   380
 *  
slouken@3407
   381
 *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
slouken@3407
   382
 *  the back of the event queue.
slouken@3407
   383
 *  
slouken@3407
   384
 *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
slouken@3407
   385
 *  of the event queue, matching \c mask, will be returned and will not
slouken@3407
   386
 *  be removed from the queue.
slouken@3407
   387
 *  
slouken@3407
   388
 *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front 
slouken@3407
   389
 *  of the event queue, matching \c mask, will be returned and will be
slouken@3407
   390
 *  removed from the queue.
slouken@3407
   391
 *  
slouken@3407
   392
 *  \return The number of events actually stored, or -1 if there was an error.
slouken@3407
   393
 *  
slouken@3407
   394
 *  This function is thread-safe.
slouken@3407
   395
 */
slouken@1895
   396
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
slouken@1895
   397
                                           SDL_eventaction action,
slouken@4429
   398
                                           Uint32 minType, Uint32 maxType);
slouken@3407
   399
/*@}*/
slouken@1895
   400
slouken@3407
   401
/**
slouken@3407
   402
 *  Checks to see if certain event types are in the event queue.
slouken@1895
   403
 */
slouken@4429
   404
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
slouken@4429
   405
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
slouken@4429
   406
slouken@4429
   407
/**
slouken@4429
   408
 *  This function clears events from the event queue
slouken@4429
   409
 */
slouken@4429
   410
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
slouken@4429
   411
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
slouken@0
   412
slouken@3407
   413
/**
slouken@3407
   414
 *  \brief Polls for currently pending events.
slouken@3407
   415
 *  
slouken@3407
   416
 *  \return 1 if there are any pending events, or 0 if there are none available.
slouken@3407
   417
 *  
slouken@3407
   418
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   419
 *               stored in that area.
slouken@0
   420
 */
slouken@1895
   421
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
slouken@0
   422
slouken@3407
   423
/**
slouken@3407
   424
 *  \brief Waits indefinitely for the next available event.
slouken@3407
   425
 *  
slouken@3407
   426
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   427
 *   
slouken@3407
   428
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   429
 *               stored in that area.
slouken@0
   430
 */
slouken@1895
   431
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
slouken@0
   432
slouken@3407
   433
/**
slouken@3407
   434
 *  \brief Waits until the specified timeout (in milliseconds) for the next 
slouken@3407
   435
 *         available event.
slouken@3407
   436
 *  
slouken@3407
   437
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   438
 *  
slouken@3407
   439
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   440
 *               stored in that area.
slouken@3072
   441
 */
slouken@3072
   442
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
slouken@3072
   443
                                                 int timeout);
slouken@3072
   444
slouken@3407
   445
/**
slouken@3407
   446
 *  \brief Add an event to the event queue.
slouken@3407
   447
 *  
slouken@3407
   448
 *  \return 1 on success, 0 if the event was filtered, or -1 if the event queue 
slouken@3407
   449
 *          was full or there was some other error.
slouken@0
   450
 */
slouken@1895
   451
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
slouken@0
   452
slouken@3407
   453
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
slouken@0
   454
slouken@3407
   455
/**
slouken@3407
   456
 *  Sets up a filter to process all events before they change internal state and
slouken@3407
   457
 *  are posted to the internal event queue.
slouken@3407
   458
 *  
slouken@3407
   459
 *  The filter is protypted as:
slouken@3407
   460
 *  \code
slouken@3407
   461
 *      int SDL_EventFilter(void *userdata, SDL_Event * event);
slouken@3407
   462
 *  \endcode
slouken@3407
   463
 *
slouken@3407
   464
 *  If the filter returns 1, then the event will be added to the internal queue.
slouken@3407
   465
 *  If it returns 0, then the event will be dropped from the queue, but the 
slouken@3407
   466
 *  internal state will still be updated.  This allows selective filtering of
slouken@3407
   467
 *  dynamically arriving events.
slouken@3407
   468
 *  
slouken@3407
   469
 *  \warning  Be very careful of what you do in the event filter function, as 
slouken@3407
   470
 *            it may run in a different thread!
slouken@3407
   471
 *  
slouken@3407
   472
 *  There is one caveat when dealing with the ::SDL_QUITEVENT event type.  The
slouken@3407
   473
 *  event filter is only called when the window manager desires to close the
slouken@3407
   474
 *  application window.  If the event filter returns 1, then the window will
slouken@3407
   475
 *  be closed, otherwise the window will remain open if possible.
slouken@3407
   476
 *
slouken@3407
   477
 *  If the quit event is generated by an interrupt signal, it will bypass the
slouken@3407
   478
 *  internal queue and be delivered to the application at the next event poll.
slouken@3407
   479
 */
slouken@1895
   480
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
slouken@1895
   481
                                                void *userdata);
slouken@0
   482
slouken@3407
   483
/**
slouken@3407
   484
 *  Return the current event filter - can be used to "chain" filters.
slouken@3407
   485
 *  If there is no event filter set, this function returns SDL_FALSE.
slouken@3407
   486
 */
slouken@1895
   487
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
slouken@1895
   488
                                                    void **userdata);
slouken@1895
   489
slouken@3407
   490
/**
slouken@3407
   491
 *  Run the filter function on the current event queue, removing any
slouken@3407
   492
 *  events for which the filter returns 0.
slouken@3407
   493
 */
slouken@1895
   494
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
slouken@1895
   495
                                              void *userdata);
slouken@0
   496
slouken@3407
   497
/*@{*/
slouken@0
   498
#define SDL_QUERY	-1
slouken@0
   499
#define SDL_IGNORE	 0
slouken@0
   500
#define SDL_DISABLE	 0
slouken@0
   501
#define SDL_ENABLE	 1
slouken@3407
   502
slouken@3407
   503
/**
slouken@3407
   504
 *  This function allows you to set the state of processing certain events.
slouken@3407
   505
 *   - If \c state is set to ::SDL_IGNORE, that event will be automatically 
slouken@3407
   506
 *     dropped from the event queue and will not event be filtered.
slouken@3407
   507
 *   - If \c state is set to ::SDL_ENABLE, that event will be processed 
slouken@3407
   508
 *     normally.
slouken@3407
   509
 *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 
slouken@3407
   510
 *     current processing state of the specified event.
slouken@3407
   511
 */
slouken@4429
   512
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
slouken@3407
   513
/*@}*/
slouken@4429
   514
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
slouken@4429
   515
slouken@4429
   516
/**
slouken@4429
   517
 *  This function allocates a set of user-defined events, and returns
slouken@4429
   518
 *  the beginning event number for that set of events.
slouken@4429
   519
 *
slouken@4429
   520
 *  If there aren't enough user-defined events left, this function
slouken@4429
   521
 *  returns (Uint32)-1
slouken@4429
   522
 */
slouken@4429
   523
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
slouken@0
   524
slouken@0
   525
/* Ends C function definitions when using C++ */
slouken@0
   526
#ifdef __cplusplus
slouken@1895
   527
/* *INDENT-OFF* */
slouken@0
   528
}
slouken@1895
   529
/* *INDENT-ON* */
slouken@0
   530
#endif
slouken@0
   531
#include "close_code.h"
slouken@0
   532
slouken@0
   533
#endif /* _SDL_events_h */
slouken@1895
   534
slouken@1895
   535
/* vi: set ts=4 sw=4 expandtab: */