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