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