include/SDL_events.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 19 Oct 2009 13:31:58 +0000
changeset 3407 d3baf5ac4e37
parent 3280 00cace2d9080
child 3572 6bb9952d5029
permissions -rw-r--r--
Partial fix for bug #859

Header file update from Ken for improved doxygen output
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 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@1895
    57
    SDL_NOEVENT = 0,            /**< Unused (do not remove) */
slouken@1895
    58
    SDL_WINDOWEVENT,            /**< Window state change */
slouken@1895
    59
    SDL_KEYDOWN,                /**< Keys pressed */
slouken@1895
    60
    SDL_KEYUP,                  /**< Keys released */
slouken@3280
    61
    SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
slouken@1957
    62
    SDL_TEXTINPUT,              /**< Keyboard text input */
slouken@1895
    63
    SDL_MOUSEMOTION,            /**< Mouse moved */
slouken@1895
    64
    SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
slouken@1895
    65
    SDL_MOUSEBUTTONUP,          /**< Mouse button released */
slouken@1957
    66
    SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
slouken@1895
    67
    SDL_JOYAXISMOTION,          /**< Joystick axis motion */
slouken@1895
    68
    SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
slouken@1895
    69
    SDL_JOYHATMOTION,           /**< Joystick hat position change */
slouken@1895
    70
    SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
slouken@1895
    71
    SDL_JOYBUTTONUP,            /**< Joystick button released */
slouken@1895
    72
    SDL_QUIT,                   /**< User-requested quit */
slouken@1895
    73
    SDL_SYSWMEVENT,             /**< System specific event */
slouken@2710
    74
    SDL_PROXIMITYIN,            /**< Proximity In event */
slouken@2710
    75
    SDL_PROXIMITYOUT,           /**< Proximity Out event */
slouken@1895
    76
    SDL_EVENT_RESERVED1,        /**< Reserved for future use... */
slouken@3407
    77
    SDL_EVENT_RESERVED2,        /**< Reserved for future use... */
slouken@3407
    78
    SDL_EVENT_RESERVED3,        /**< Reserved for future use... */
slouken@3407
    79
    /** Events ::SDL_USEREVENT through ::SDL_MAXEVENTS-1 are for your use */
slouken@1895
    80
    SDL_USEREVENT = 24,
slouken@3407
    81
    /**
slouken@3407
    82
     *  This last event is only for bounding internal arrays
slouken@3407
    83
     *  It is the number of bits in the event mask datatype -- Uint32
slouken@1895
    84
     */
slouken@1895
    85
    SDL_NUMEVENTS = 32
slouken@1294
    86
} SDL_EventType;
slouken@0
    87
slouken@3407
    88
/*@{*/
slouken@3407
    89
#define SDL_EVENTMASK(X)	(1<<(X))
slouken@1895
    90
/**
slouken@1895
    91
 * \brief Predefined event masks
slouken@1895
    92
 */
slouken@1895
    93
typedef enum
slouken@1895
    94
{
slouken@1895
    95
    SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT),
slouken@1895
    96
    SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
slouken@1895
    97
    SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
slouken@1895
    98
    SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
slouken@3280
    99
    SDL_TEXTEDITINGMASK = SDL_EVENTMASK(SDL_TEXTEDITING),
slouken@1895
   100
    SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
slouken@1895
   101
    SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
slouken@1895
   102
    SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
slouken@1895
   103
    SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
slouken@1895
   104
    SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
slouken@1895
   105
    SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
slouken@1895
   106
        SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
slouken@1895
   107
    SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
slouken@1895
   108
    SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION),
slouken@1895
   109
    SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION),
slouken@1895
   110
    SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
slouken@1895
   111
    SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP),
slouken@1895
   112
    SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) |
slouken@1895
   113
        SDL_EVENTMASK(SDL_JOYBALLMOTION) |
slouken@1895
   114
        SDL_EVENTMASK(SDL_JOYHATMOTION) |
slouken@1895
   115
        SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP),
slouken@1895
   116
    SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
slouken@2710
   117
    SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT),
slouken@2710
   118
    SDL_PROXIMITYINMASK = SDL_EVENTMASK(SDL_PROXIMITYIN),
slouken@2710
   119
    SDL_PROXIMITYOUTMASK = SDL_EVENTMASK(SDL_PROXIMITYOUT)
slouken@1895
   120
} SDL_EventMask;
slouken@0
   121
#define SDL_ALLEVENTS		0xFFFFFFFF
slouken@3407
   122
/*@}*/
slouken@0
   123
slouken@1895
   124
/**
slouken@3407
   125
 *  \brief Window state change event data (event.window.*)
slouken@1895
   126
 */
slouken@1895
   127
typedef struct SDL_WindowEvent
slouken@1895
   128
{
slouken@3407
   129
    Uint8 type;             /**< ::SDL_WINDOWEVENT */
slouken@3191
   130
    SDL_WindowID windowID;  /**< The associated window */
slouken@3407
   131
    Uint8 event;            /**< ::SDL_WindowEventID */
slouken@1895
   132
    int data1;              /**< event dependent data */
slouken@1895
   133
    int data2;              /**< event dependent data */
slouken@1895
   134
} SDL_WindowEvent;
slouken@0
   135
slouken@1895
   136
/**
slouken@3407
   137
 *  \brief Keyboard button event structure (event.key.*)
slouken@1895
   138
 */
slouken@1895
   139
typedef struct SDL_KeyboardEvent
slouken@1895
   140
{
slouken@3407
   141
    Uint8 type;             /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
slouken@3191
   142
    SDL_WindowID windowID;  /**< The window with keyboard focus, if any */
slouken@1895
   143
    Uint8 which;            /**< The keyboard device index */
slouken@3407
   144
    Uint8 state;            /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@1895
   145
    SDL_keysym keysym;      /**< The key that was pressed or released */
slouken@0
   146
} SDL_KeyboardEvent;
slouken@0
   147
slouken@3407
   148
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
slouken@1895
   149
/**
slouken@3407
   150
 *  \brief Keyboard text editing event structure (event.edit.*)
slouken@3280
   151
 */
slouken@3280
   152
typedef struct SDL_TextEditingEvent
slouken@3280
   153
{
slouken@3407
   154
    Uint8 type;                                 /**< ::SDL_TEXTEDITING */
slouken@3280
   155
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
slouken@3280
   156
    int start;                                  /**< The start cursor of selected editing text */
slouken@3280
   157
    int length;                                 /**< The length of selected editing text */
slouken@3280
   158
} SDL_TextEditingEvent;
slouken@3280
   159
slouken@3407
   160
slouken@3407
   161
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
slouken@3280
   162
/**
slouken@3407
   163
 *  \brief Keyboard text input event structure (event.text.*)
slouken@1895
   164
 */
slouken@1895
   165
typedef struct SDL_TextInputEvent
slouken@1895
   166
{
slouken@3407
   167
    Uint8 type;                               /**< ::SDL_TEXTINPUT */
slouken@3191
   168
    SDL_WindowID windowID;                    /**< The window with keyboard focus, if any */
bob@2300
   169
    Uint8 which;                              /**< The keyboard device index */
bob@2300
   170
    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
slouken@1895
   171
} SDL_TextInputEvent;
slouken@1895
   172
slouken@1895
   173
/**
slouken@3407
   174
 *  \brief Mouse motion event structure (event.motion.*)
slouken@1895
   175
 */
slouken@1895
   176
typedef struct SDL_MouseMotionEvent
slouken@1895
   177
{
slouken@3407
   178
    Uint8 type;             /**< ::SDL_MOUSEMOTION */
slouken@3191
   179
    SDL_WindowID windowID;  /**< The window with mouse focus, if any */
slouken@1895
   180
    Uint8 which;            /**< The mouse device index */
slouken@1895
   181
    Uint8 state;            /**< The current button state */
slouken@1895
   182
    int x;                  /**< X coordinate, relative to window */
slouken@1895
   183
    int y;                  /**< Y coordinate, relative to window */
slouken@2710
   184
    int z;                  /**< Z coordinate, for future use */
slouken@2710
   185
    int pressure;           /**< Pressure reported by tablets */
slouken@2710
   186
    int pressure_max;       /**< Maximum value of the pressure reported by the device */
slouken@2710
   187
    int pressure_min;       /**< Minimum value of the pressure reported by the device */
slouken@2710
   188
    int rotation;           /**< For future use */
slouken@2710
   189
    int tilt;               /**< For future use */
slouken@2710
   190
    int cursor;             /**< The cursor being used in the event */
slouken@1895
   191
    int xrel;               /**< The relative motion in the X direction */
slouken@1895
   192
    int yrel;               /**< The relative motion in the Y direction */
slouken@0
   193
} SDL_MouseMotionEvent;
slouken@0
   194
slouken@1895
   195
/**
slouken@3407
   196
 *  \brief Mouse button event structure (event.button.*)
slouken@1895
   197
 */
slouken@1895
   198
typedef struct SDL_MouseButtonEvent
slouken@1895
   199
{
slouken@3407
   200
    Uint8 type;             /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
slouken@3191
   201
    SDL_WindowID windowID;  /**< The window with mouse focus, if any */
slouken@1895
   202
    Uint8 which;            /**< The mouse device index */
slouken@1895
   203
    Uint8 button;           /**< The mouse button index */
slouken@3407
   204
    Uint8 state;            /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@1895
   205
    int x;                  /**< X coordinate, relative to window */
slouken@1895
   206
    int y;                  /**< Y coordinate, relative to window */
slouken@0
   207
} SDL_MouseButtonEvent;
slouken@0
   208
slouken@1895
   209
/**
slouken@3407
   210
 *  \brief Mouse wheel event structure (event.wheel.*)
slouken@1895
   211
 */
slouken@1895
   212
typedef struct SDL_MouseWheelEvent
slouken@1895
   213
{
slouken@3407
   214
    Uint8 type;             /**< ::SDL_MOUSEWHEEL */
slouken@3191
   215
    SDL_WindowID windowID;  /**< The window with mouse focus, if any */
slouken@1895
   216
    Uint8 which;            /**< The mouse device index */
slouken@2152
   217
    int x;                  /**< The amount scrolled horizontally */
slouken@2152
   218
    int y;                  /**< The amount scrolled vertically */
slouken@1895
   219
} SDL_MouseWheelEvent;
slouken@1895
   220
slouken@1895
   221
/**
slouken@3407
   222
 *  \brief Joystick axis motion event structure (event.jaxis.*)
slouken@1895
   223
 */
slouken@1895
   224
typedef struct SDL_JoyAxisEvent
slouken@1895
   225
{
slouken@3407
   226
    Uint8 type;         /**< ::SDL_JOYAXISMOTION */
slouken@1895
   227
    Uint8 which;        /**< The joystick device index */
slouken@1895
   228
    Uint8 axis;         /**< The joystick axis index */
slouken@1895
   229
    int value;          /**< The axis value (range: -32768 to 32767) */
slouken@0
   230
} SDL_JoyAxisEvent;
slouken@0
   231
slouken@1895
   232
/**
slouken@3407
   233
 *  \brief Joystick trackball motion event structure (event.jball.*)
slouken@1895
   234
 */
slouken@1895
   235
typedef struct SDL_JoyBallEvent
slouken@1895
   236
{
slouken@3407
   237
    Uint8 type;         /**< ::SDL_JOYBALLMOTION */
slouken@1895
   238
    Uint8 which;        /**< The joystick device index */
slouken@1895
   239
    Uint8 ball;         /**< The joystick trackball index */
slouken@1895
   240
    int xrel;           /**< The relative motion in the X direction */
slouken@1895
   241
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   242
} SDL_JoyBallEvent;
slouken@0
   243
slouken@1895
   244
/**
slouken@3407
   245
 *  \brief Joystick hat position change event structure (event.jhat.*)
slouken@1895
   246
 */
slouken@1895
   247
typedef struct SDL_JoyHatEvent
slouken@1895
   248
{
slouken@3407
   249
    Uint8 type;         /**< ::SDL_JOYHATMOTION */
slouken@1895
   250
    Uint8 which;        /**< The joystick device index */
slouken@1895
   251
    Uint8 hat;          /**< The joystick hat index */
slouken@3407
   252
    Uint8 value;        /**< The hat position value.
slouken@3407
   253
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
slouken@3407
   254
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
slouken@3407
   255
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
slouken@3407
   256
                         *   
slouken@3407
   257
                         *   Note that zero means the POV is centered.
slouken@1895
   258
                         */
slouken@0
   259
} SDL_JoyHatEvent;
slouken@0
   260
slouken@1895
   261
/**
slouken@3407
   262
 *  \brief Joystick button event structure (event.jbutton.*)
slouken@1895
   263
 */
slouken@1895
   264
typedef struct SDL_JoyButtonEvent
slouken@1895
   265
{
slouken@3407
   266
    Uint8 type;         /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
slouken@1895
   267
    Uint8 which;        /**< The joystick device index */
slouken@1895
   268
    Uint8 button;       /**< The joystick button index */
slouken@3407
   269
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@0
   270
} SDL_JoyButtonEvent;
slouken@0
   271
slouken@1895
   272
/**
slouken@3407
   273
 *  \brief The "quit requested" event
slouken@0
   274
 */
slouken@1895
   275
typedef struct SDL_QuitEvent
slouken@1895
   276
{
slouken@3407
   277
    Uint8 type;         /**< ::SDL_QUIT */
slouken@1895
   278
} SDL_QuitEvent;
slouken@1895
   279
slouken@1895
   280
/**
slouken@3407
   281
 *  \brief A user-defined event type (event.user.*)
slouken@1895
   282
 */
slouken@1895
   283
typedef struct SDL_UserEvent
slouken@1895
   284
{
slouken@3407
   285
    Uint8 type;             /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
slouken@3191
   286
    SDL_WindowID windowID;  /**< The associated window if any*/
bob@2131
   287
    int code;               /**< User defined event code */
bob@2131
   288
    void *data1;            /**< User defined data pointer */
bob@2131
   289
    void *data2;            /**< User defined data pointer */
slouken@1895
   290
} SDL_UserEvent;
slouken@1895
   291
slouken@1895
   292
struct SDL_SysWMmsg;
slouken@1895
   293
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
slouken@3407
   294
slouken@3407
   295
/**
slouken@3407
   296
 *  \brief A video driver dependent system event (event.syswm.*)
slouken@3407
   297
 *  
slouken@3407
   298
 *  \note If you want to use this event, you should include SDL_syswm.h.
slouken@3407
   299
 */
slouken@1895
   300
typedef struct SDL_SysWMEvent
slouken@1895
   301
{
slouken@3407
   302
    Uint8 type;         /**< ::SDL_SYSWMEVENT */
slouken@1895
   303
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
slouken@1895
   304
} SDL_SysWMEvent;
slouken@1895
   305
slouken@2710
   306
typedef struct SDL_ProximityEvent
slouken@2710
   307
{
slouken@2710
   308
    Uint8 type;
slouken@3191
   309
    SDL_WindowID windowID;  /**< The associated window */
slouken@2710
   310
    Uint8 which;
slouken@2710
   311
    int cursor;
slouken@2710
   312
    int x;
slouken@2710
   313
    int y;
slouken@2710
   314
} SDL_ProximityEvent;
slouken@2710
   315
bob@3167
   316
#ifndef SDL_NO_COMPAT
slouken@3407
   317
/**
slouken@3407
   318
 *  \addtogroup Compatibility 
slouken@3407
   319
 */
slouken@3407
   320
/*@{*/
slouken@3407
   321
slouken@3407
   322
/**
slouken@3407
   323
 *  \name Typedefs for backwards compatibility
slouken@3407
   324
 */
slouken@3407
   325
/*@{*/
bob@3167
   326
typedef struct SDL_ActiveEvent
bob@3167
   327
{
bob@3167
   328
    Uint8 type;
bob@3167
   329
    Uint8 gain;
bob@3167
   330
    Uint8 state;
bob@3167
   331
} SDL_ActiveEvent;
bob@3167
   332
bob@3167
   333
typedef struct SDL_ResizeEvent
bob@3167
   334
{
bob@3167
   335
    Uint8 type;
bob@3167
   336
    int w;
bob@3167
   337
    int h;
bob@3167
   338
} SDL_ResizeEvent;
slouken@3407
   339
/*@}*/
slouken@3407
   340
slouken@3407
   341
/*@}*//*Compatibility*/
bob@3167
   342
#endif
bob@3167
   343
slouken@1895
   344
/**
slouken@3407
   345
 *  \brief General event structure
slouken@1895
   346
 */
slouken@1895
   347
typedef union SDL_Event
slouken@1895
   348
{
slouken@1895
   349
    Uint8 type;                     /**< Event type, shared with all events */
slouken@1895
   350
    SDL_WindowEvent window;         /**< Window event data */
slouken@1895
   351
    SDL_KeyboardEvent key;          /**< Keyboard event data */
slouken@3280
   352
    SDL_TextEditingEvent edit;      /**< Text editing event data */
bob@2300
   353
    SDL_TextInputEvent text;        /**< Text input event data */
slouken@1895
   354
    SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
slouken@1895
   355
    SDL_MouseButtonEvent button;    /**< Mouse button event data */
bob@2300
   356
    SDL_MouseWheelEvent wheel;      /**< Mouse wheel event data */
slouken@1895
   357
    SDL_JoyAxisEvent jaxis;         /**< Joystick axis event data */
slouken@1895
   358
    SDL_JoyBallEvent jball;         /**< Joystick ball event data */
slouken@1895
   359
    SDL_JoyHatEvent jhat;           /**< Joystick hat event data */
slouken@1895
   360
    SDL_JoyButtonEvent jbutton;     /**< Joystick button event data */
slouken@1895
   361
    SDL_QuitEvent quit;             /**< Quit request event data */
slouken@1895
   362
    SDL_UserEvent user;             /**< Custom event data */
slouken@1895
   363
    SDL_SysWMEvent syswm;           /**< System dependent window event data */
slouken@2710
   364
    SDL_ProximityEvent proximity;   /**< Proximity In or Out event */
slouken@0
   365
slouken@3407
   366
    /** Temporarily here for backwards compatibility */
slouken@3407
   367
    /*@{*/
bob@3167
   368
#ifndef SDL_NO_COMPAT
slouken@1895
   369
    SDL_ActiveEvent active;
slouken@1895
   370
    SDL_ResizeEvent resize;
bob@3167
   371
#endif
slouken@3407
   372
    /*@}*/
slouken@0
   373
} SDL_Event;
slouken@0
   374
slouken@0
   375
slouken@0
   376
/* Function prototypes */
slouken@0
   377
slouken@3407
   378
/**
slouken@3407
   379
 *  Pumps the event loop, gathering events from the input devices.
slouken@3407
   380
 *  
slouken@3407
   381
 *  This function updates the event queue and internal input device state.
slouken@3407
   382
 *  
slouken@3407
   383
 *  This should only be run in the thread that sets the video mode.
slouken@3407
   384
 */
slouken@337
   385
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
slouken@0
   386
slouken@3407
   387
/*@{*/
slouken@1895
   388
typedef enum
slouken@1895
   389
{
slouken@1895
   390
    SDL_ADDEVENT,
slouken@1895
   391
    SDL_PEEKEVENT,
slouken@1895
   392
    SDL_GETEVENT
slouken@0
   393
} SDL_eventaction;
slouken@3407
   394
slouken@3407
   395
/**
slouken@3407
   396
 *  Checks the event queue for messages and optionally returns them.
slouken@3407
   397
 *  
slouken@3407
   398
 *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
slouken@3407
   399
 *  the back of the event queue.
slouken@3407
   400
 *  
slouken@3407
   401
 *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
slouken@3407
   402
 *  of the event queue, matching \c mask, will be returned and will not
slouken@3407
   403
 *  be removed from the queue.
slouken@3407
   404
 *  
slouken@3407
   405
 *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front 
slouken@3407
   406
 *  of the event queue, matching \c mask, will be returned and will be
slouken@3407
   407
 *  removed from the queue.
slouken@3407
   408
 *  
slouken@3407
   409
 *  \return The number of events actually stored, or -1 if there was an error.
slouken@3407
   410
 *  
slouken@3407
   411
 *  This function is thread-safe.
slouken@3407
   412
 */
slouken@1895
   413
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
slouken@1895
   414
                                           SDL_eventaction action,
slouken@1895
   415
                                           Uint32 mask);
slouken@3407
   416
/*@}*/
slouken@1895
   417
slouken@3407
   418
/**
slouken@3407
   419
 *  Checks to see if certain event types are in the event queue.
slouken@1895
   420
 */
slouken@1895
   421
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask);
slouken@0
   422
slouken@3407
   423
/**
slouken@3407
   424
 *  \brief Polls for currently pending events.
slouken@3407
   425
 *  
slouken@3407
   426
 *  \return 1 if there are any pending events, or 0 if there are none available.
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_PollEvent(SDL_Event * event);
slouken@0
   432
slouken@3407
   433
/**
slouken@3407
   434
 *  \brief Waits indefinitely for the next available event.
slouken@3407
   435
 *  
slouken@3407
   436
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   437
 *   
slouken@3407
   438
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   439
 *               stored in that area.
slouken@0
   440
 */
slouken@1895
   441
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
slouken@0
   442
slouken@3407
   443
/**
slouken@3407
   444
 *  \brief Waits until the specified timeout (in milliseconds) for the next 
slouken@3407
   445
 *         available event.
slouken@3407
   446
 *  
slouken@3407
   447
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   448
 *  
slouken@3407
   449
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   450
 *               stored in that area.
slouken@3072
   451
 */
slouken@3072
   452
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
slouken@3072
   453
                                                 int timeout);
slouken@3072
   454
slouken@3407
   455
/**
slouken@3407
   456
 *  \brief Add an event to the event queue.
slouken@3407
   457
 *  
slouken@3407
   458
 *  \return 1 on success, 0 if the event was filtered, or -1 if the event queue 
slouken@3407
   459
 *          was full or there was some other error.
slouken@0
   460
 */
slouken@1895
   461
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
slouken@0
   462
slouken@3407
   463
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
slouken@0
   464
slouken@3407
   465
/**
slouken@3407
   466
 *  Sets up a filter to process all events before they change internal state and
slouken@3407
   467
 *  are posted to the internal event queue.
slouken@3407
   468
 *  
slouken@3407
   469
 *  The filter is protypted as:
slouken@3407
   470
 *  \code
slouken@3407
   471
 *      int SDL_EventFilter(void *userdata, SDL_Event * event);
slouken@3407
   472
 *  \endcode
slouken@3407
   473
 *
slouken@3407
   474
 *  If the filter returns 1, then the event will be added to the internal queue.
slouken@3407
   475
 *  If it returns 0, then the event will be dropped from the queue, but the 
slouken@3407
   476
 *  internal state will still be updated.  This allows selective filtering of
slouken@3407
   477
 *  dynamically arriving events.
slouken@3407
   478
 *  
slouken@3407
   479
 *  \warning  Be very careful of what you do in the event filter function, as 
slouken@3407
   480
 *            it may run in a different thread!
slouken@3407
   481
 *  
slouken@3407
   482
 *  There is one caveat when dealing with the ::SDL_QUITEVENT event type.  The
slouken@3407
   483
 *  event filter is only called when the window manager desires to close the
slouken@3407
   484
 *  application window.  If the event filter returns 1, then the window will
slouken@3407
   485
 *  be closed, otherwise the window will remain open if possible.
slouken@3407
   486
 *
slouken@3407
   487
 *  If the quit event is generated by an interrupt signal, it will bypass the
slouken@3407
   488
 *  internal queue and be delivered to the application at the next event poll.
slouken@3407
   489
 */
slouken@1895
   490
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
slouken@1895
   491
                                                void *userdata);
slouken@0
   492
slouken@3407
   493
/**
slouken@3407
   494
 *  Return the current event filter - can be used to "chain" filters.
slouken@3407
   495
 *  If there is no event filter set, this function returns SDL_FALSE.
slouken@3407
   496
 */
slouken@1895
   497
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
slouken@1895
   498
                                                    void **userdata);
slouken@1895
   499
slouken@3407
   500
/**
slouken@3407
   501
 *  Run the filter function on the current event queue, removing any
slouken@3407
   502
 *  events for which the filter returns 0.
slouken@3407
   503
 */
slouken@1895
   504
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
slouken@1895
   505
                                              void *userdata);
slouken@0
   506
slouken@3407
   507
/*@{*/
slouken@0
   508
#define SDL_QUERY	-1
slouken@0
   509
#define SDL_IGNORE	 0
slouken@0
   510
#define SDL_DISABLE	 0
slouken@0
   511
#define SDL_ENABLE	 1
slouken@3407
   512
slouken@3407
   513
/**
slouken@3407
   514
 *  This function allows you to set the state of processing certain events.
slouken@3407
   515
 *   - If \c state is set to ::SDL_IGNORE, that event will be automatically 
slouken@3407
   516
 *     dropped from the event queue and will not event be filtered.
slouken@3407
   517
 *   - If \c state is set to ::SDL_ENABLE, that event will be processed 
slouken@3407
   518
 *     normally.
slouken@3407
   519
 *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 
slouken@3407
   520
 *     current processing state of the specified event.
slouken@3407
   521
 */
slouken@337
   522
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
slouken@3407
   523
/*@}*/
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: */