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