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