include/SDL_events.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 20 Oct 2012 00:49:08 -0700
changeset 6595 c6402c811a40
parent 6256 1d905b13b102
child 6596 b00cf2e4835c
permissions -rw-r--r--
Fixed another gcc <-> Visual C++ ABI issue
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_events.h
slouken@3407
    24
 *  
slouken@3407
    25
 *  Include file for SDL event handling.
slouken@1895
    26
 */
slouken@0
    27
slouken@0
    28
#ifndef _SDL_events_h
slouken@0
    29
#define _SDL_events_h
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1358
    32
#include "SDL_error.h"
slouken@1895
    33
#include "SDL_video.h"
slouken@0
    34
#include "SDL_keyboard.h"
slouken@0
    35
#include "SDL_mouse.h"
slouken@0
    36
#include "SDL_joystick.h"
slouken@0
    37
#include "SDL_quit.h"
jim@4659
    38
#include "SDL_gesture.h"
jim@4659
    39
#include "SDL_touch.h"
slouken@0
    40
slouken@0
    41
#include "begin_code.h"
slouken@0
    42
/* Set up for C function definitions, even when using C++ */
slouken@0
    43
#ifdef __cplusplus
slouken@1895
    44
/* *INDENT-OFF* */
slouken@0
    45
extern "C" {
slouken@1895
    46
/* *INDENT-ON* */
slouken@0
    47
#endif
slouken@0
    48
slouken@1330
    49
/* General keyboard/mouse state definitions */
slouken@1330
    50
#define SDL_RELEASED	0
slouken@1330
    51
#define SDL_PRESSED	1
slouken@1330
    52
slouken@1895
    53
/**
slouken@3407
    54
 * \brief The types of events that can be delivered.
slouken@1895
    55
 */
slouken@1895
    56
typedef enum
slouken@1895
    57
{
slouken@4429
    58
    SDL_FIRSTEVENT     = 0,     /**< Unused (do not remove) */
slouken@4429
    59
slouken@4429
    60
    /* Application events */
slouken@4429
    61
    SDL_QUIT           = 0x100, /**< User-requested quit */
slouken@4429
    62
slouken@4429
    63
    /* Window events */
slouken@4429
    64
    SDL_WINDOWEVENT    = 0x200, /**< Window state change */
slouken@4429
    65
    SDL_SYSWMEVENT,             /**< System specific event */
slouken@4429
    66
slouken@4429
    67
    /* Keyboard events */
slouken@4971
    68
    SDL_KEYDOWN        = 0x300, /**< Key pressed */
slouken@4971
    69
    SDL_KEYUP,                  /**< Key released */
slouken@3280
    70
    SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
slouken@1957
    71
    SDL_TEXTINPUT,              /**< Keyboard text input */
slouken@4429
    72
slouken@4429
    73
    /* Mouse events */
slouken@4429
    74
    SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
slouken@1895
    75
    SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
slouken@1895
    76
    SDL_MOUSEBUTTONUP,          /**< Mouse button released */
slouken@1957
    77
    SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
slouken@4429
    78
slouken@4465
    79
    /* Tablet or multiple mice input device events */
slouken@4465
    80
    SDL_INPUTMOTION    = 0x500, /**< Input moved */
slouken@4465
    81
    SDL_INPUTBUTTONDOWN,        /**< Input button pressed */
slouken@4465
    82
    SDL_INPUTBUTTONUP,          /**< Input button released */
slouken@4465
    83
    SDL_INPUTWHEEL,             /**< Input wheel motion */
slouken@4465
    84
    SDL_INPUTPROXIMITYIN,       /**< Input pen entered proximity */
slouken@4465
    85
    SDL_INPUTPROXIMITYOUT,      /**< Input pen left proximity */
slouken@4429
    86
slouken@4429
    87
    /* Joystick events */
slouken@4429
    88
    SDL_JOYAXISMOTION  = 0x600, /**< Joystick axis motion */
slouken@1895
    89
    SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
slouken@1895
    90
    SDL_JOYHATMOTION,           /**< Joystick hat position change */
slouken@1895
    91
    SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
slouken@1895
    92
    SDL_JOYBUTTONUP,            /**< Joystick button released */
slouken@4429
    93
slouken@4661
    94
    /* Touch events */
slouken@4661
    95
    SDL_FINGERDOWN      = 0x700,
jim@4641
    96
    SDL_FINGERUP,
jim@4641
    97
    SDL_FINGERMOTION,
jim@4641
    98
    SDL_TOUCHBUTTONDOWN,
jim@4641
    99
    SDL_TOUCHBUTTONUP,    
jim@4641
   100
slouken@4661
   101
    /* Gesture events */
slouken@4661
   102
    SDL_DOLLARGESTURE   = 0x800,
jim@4659
   103
    SDL_DOLLARRECORD,
jim@4657
   104
    SDL_MULTIGESTURE,
jim@4657
   105
slouken@4503
   106
    /* Clipboard events */
slouken@6091
   107
    SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
jim@4662
   108
slouken@6091
   109
    /* Drag and drop events */
slouken@6091
   110
    SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
slouken@4503
   111
slouken@4429
   112
    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
slouken@4429
   113
     *  and should be allocated with SDL_RegisterEvents()
slouken@4429
   114
     */
slouken@4429
   115
    SDL_USEREVENT    = 0x8000,
slouken@4429
   116
slouken@3407
   117
    /**
slouken@3407
   118
     *  This last event is only for bounding internal arrays
slouken@1895
   119
     */
slouken@4429
   120
    SDL_LASTEVENT    = 0xFFFF
slouken@1294
   121
} SDL_EventType;
slouken@0
   122
slouken@1895
   123
/**
slouken@3407
   124
 *  \brief Window state change event data (event.window.*)
slouken@1895
   125
 */
slouken@1895
   126
typedef struct SDL_WindowEvent
slouken@1895
   127
{
slouken@4429
   128
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
slouken@6114
   129
    Uint32 timestamp;
slouken@4429
   130
    Uint32 windowID;    /**< The associated window */
slouken@4429
   131
    Uint8 event;        /**< ::SDL_WindowEventID */
slouken@4429
   132
    Uint8 padding1;
slouken@4429
   133
    Uint8 padding2;
slouken@4429
   134
    Uint8 padding3;
slouken@4429
   135
    int data1;          /**< event dependent data */
slouken@4429
   136
    int data2;          /**< event dependent data */
slouken@1895
   137
} SDL_WindowEvent;
slouken@0
   138
slouken@1895
   139
/**
slouken@3407
   140
 *  \brief Keyboard button event structure (event.key.*)
slouken@1895
   141
 */
slouken@1895
   142
typedef struct SDL_KeyboardEvent
slouken@1895
   143
{
slouken@4429
   144
    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
slouken@6114
   145
    Uint32 timestamp;
slouken@4429
   146
    Uint32 windowID;    /**< The window with keyboard focus, if any */
slouken@4429
   147
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4560
   148
    Uint8 repeat;       /**< Non-zero if this is a key repeat */
slouken@4429
   149
    Uint8 padding2;
slouken@4465
   150
    Uint8 padding3;
slouken@5218
   151
    SDL_Keysym keysym;  /**< The key that was pressed or released */
slouken@0
   152
} SDL_KeyboardEvent;
slouken@0
   153
slouken@3407
   154
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
slouken@1895
   155
/**
slouken@3407
   156
 *  \brief Keyboard text editing event structure (event.edit.*)
slouken@3280
   157
 */
slouken@3280
   158
typedef struct SDL_TextEditingEvent
slouken@3280
   159
{
slouken@4429
   160
    Uint32 type;                                /**< ::SDL_TEXTEDITING */
slouken@6114
   161
    Uint32 timestamp;
slouken@4434
   162
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
slouken@3280
   163
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
slouken@3280
   164
    int start;                                  /**< The start cursor of selected editing text */
slouken@3280
   165
    int length;                                 /**< The length of selected editing text */
slouken@3280
   166
} SDL_TextEditingEvent;
slouken@3280
   167
slouken@3407
   168
slouken@3407
   169
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
slouken@3280
   170
/**
slouken@3407
   171
 *  \brief Keyboard text input event structure (event.text.*)
slouken@1895
   172
 */
slouken@1895
   173
typedef struct SDL_TextInputEvent
slouken@1895
   174
{
slouken@4429
   175
    Uint32 type;                              /**< ::SDL_TEXTINPUT */
slouken@6114
   176
    Uint32 timestamp;
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@6114
   187
    Uint32 timestamp;
slouken@4429
   188
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   189
    Uint8 state;        /**< The current button state */
slouken@4429
   190
    Uint8 padding1;
slouken@4429
   191
    Uint8 padding2;
slouken@4465
   192
    Uint8 padding3;
slouken@4429
   193
    int x;              /**< X coordinate, relative to window */
slouken@4429
   194
    int y;              /**< Y coordinate, relative to window */
slouken@4429
   195
    int xrel;           /**< The relative motion in the X direction */
slouken@4429
   196
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   197
} SDL_MouseMotionEvent;
slouken@0
   198
slouken@1895
   199
/**
slouken@3407
   200
 *  \brief Mouse button event structure (event.button.*)
slouken@1895
   201
 */
slouken@1895
   202
typedef struct SDL_MouseButtonEvent
slouken@1895
   203
{
slouken@4429
   204
    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
slouken@6114
   205
    Uint32 timestamp;
slouken@4429
   206
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   207
    Uint8 button;       /**< The mouse button index */
slouken@4429
   208
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   209
    Uint8 padding1;
slouken@4465
   210
    Uint8 padding2;
slouken@4429
   211
    int x;              /**< X coordinate, relative to window */
slouken@4429
   212
    int y;              /**< Y coordinate, relative to window */
slouken@0
   213
} SDL_MouseButtonEvent;
slouken@0
   214
slouken@1895
   215
/**
slouken@3407
   216
 *  \brief Mouse wheel event structure (event.wheel.*)
slouken@1895
   217
 */
slouken@1895
   218
typedef struct SDL_MouseWheelEvent
slouken@1895
   219
{
slouken@4429
   220
    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
slouken@6114
   221
    Uint32 timestamp;
slouken@4429
   222
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   223
    int x;              /**< The amount scrolled horizontally */
slouken@4429
   224
    int y;              /**< The amount scrolled vertically */
slouken@1895
   225
} SDL_MouseWheelEvent;
slouken@1895
   226
slouken@1895
   227
/**
slouken@3407
   228
 *  \brief Joystick axis motion event structure (event.jaxis.*)
slouken@1895
   229
 */
slouken@1895
   230
typedef struct SDL_JoyAxisEvent
slouken@1895
   231
{
slouken@4429
   232
    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
slouken@6114
   233
    Uint32 timestamp;
slouken@1895
   234
    Uint8 which;        /**< The joystick device index */
slouken@1895
   235
    Uint8 axis;         /**< The joystick axis index */
slouken@4429
   236
    Uint8 padding1;
slouken@4429
   237
    Uint8 padding2;
slouken@1895
   238
    int value;          /**< The axis value (range: -32768 to 32767) */
slouken@0
   239
} SDL_JoyAxisEvent;
slouken@0
   240
slouken@1895
   241
/**
slouken@3407
   242
 *  \brief Joystick trackball motion event structure (event.jball.*)
slouken@1895
   243
 */
slouken@1895
   244
typedef struct SDL_JoyBallEvent
slouken@1895
   245
{
slouken@4429
   246
    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
slouken@6114
   247
    Uint32 timestamp;
slouken@1895
   248
    Uint8 which;        /**< The joystick device index */
slouken@1895
   249
    Uint8 ball;         /**< The joystick trackball index */
slouken@4429
   250
    Uint8 padding1;
slouken@4429
   251
    Uint8 padding2;
slouken@1895
   252
    int xrel;           /**< The relative motion in the X direction */
slouken@1895
   253
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   254
} SDL_JoyBallEvent;
slouken@0
   255
slouken@1895
   256
/**
slouken@3407
   257
 *  \brief Joystick hat position change event structure (event.jhat.*)
slouken@1895
   258
 */
slouken@1895
   259
typedef struct SDL_JoyHatEvent
slouken@1895
   260
{
slouken@4429
   261
    Uint32 type;        /**< ::SDL_JOYHATMOTION */
slouken@6114
   262
    Uint32 timestamp;
slouken@1895
   263
    Uint8 which;        /**< The joystick device index */
slouken@1895
   264
    Uint8 hat;          /**< The joystick hat index */
slouken@3407
   265
    Uint8 value;        /**< The hat position value.
slouken@3407
   266
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
slouken@3407
   267
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
slouken@3407
   268
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
slouken@3407
   269
                         *   
slouken@3407
   270
                         *   Note that zero means the POV is centered.
slouken@1895
   271
                         */
slouken@4429
   272
    Uint8 padding1;
slouken@0
   273
} SDL_JoyHatEvent;
slouken@0
   274
slouken@1895
   275
/**
slouken@3407
   276
 *  \brief Joystick button event structure (event.jbutton.*)
slouken@1895
   277
 */
slouken@1895
   278
typedef struct SDL_JoyButtonEvent
slouken@1895
   279
{
slouken@4429
   280
    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
slouken@6114
   281
    Uint32 timestamp;
slouken@1895
   282
    Uint8 which;        /**< The joystick device index */
slouken@1895
   283
    Uint8 button;       /**< The joystick button index */
slouken@3407
   284
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   285
    Uint8 padding1;
slouken@0
   286
} SDL_JoyButtonEvent;
slouken@0
   287
jim@4641
   288
jim@4641
   289
/**
slouken@6053
   290
 *  \brief Touch finger motion/finger event structure (event.tfinger.*)
jim@4641
   291
 */
jim@4641
   292
typedef struct SDL_TouchFingerEvent
jim@4641
   293
{
jim@4641
   294
    Uint32 type;        /**< ::SDL_FINGERMOTION OR 
jim@4641
   295
			   SDL_FINGERDOWN OR SDL_FINGERUP*/
slouken@6114
   296
    Uint32 timestamp;
jim@4641
   297
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   298
    SDL_TouchID touchId;        /**< The touch device id */
jimtla@4678
   299
    SDL_FingerID fingerId;
jim@4641
   300
    Uint8 state;        /**< The current button state */
jim@4641
   301
    Uint8 padding1;
jimtla@4676
   302
    Uint8 padding2;
jimtla@4676
   303
    Uint8 padding3;
jimtla@4678
   304
    Uint16 x;
jimtla@4678
   305
    Uint16 y;
jim@4683
   306
    Sint16 dx;
jim@4683
   307
    Sint16 dy;
jimtla@4678
   308
    Uint16 pressure;
jim@4641
   309
} SDL_TouchFingerEvent;
jim@4641
   310
jim@4641
   311
jim@4641
   312
/**
slouken@6053
   313
 *  \brief Touch finger motion/finger event structure (event.tbutton.*)
jim@4641
   314
 */
jim@4641
   315
typedef struct SDL_TouchButtonEvent
jim@4641
   316
{
jim@4641
   317
    Uint32 type;        /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
slouken@6114
   318
    Uint32 timestamp;
jim@4641
   319
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   320
    SDL_TouchID touchId;        /**< The touch device index */
jim@4641
   321
    Uint8 state;        /**< The current button state */
jim@4641
   322
    Uint8 button;        /**< The button changing state */
jim@4641
   323
    Uint8 padding1;
jimtla@4676
   324
    Uint8 padding2;
jim@4641
   325
} SDL_TouchButtonEvent;
jim@4641
   326
jim@4641
   327
jim@4657
   328
/**
slouken@5009
   329
 *  \brief Multiple Finger Gesture Event (event.mgesture.*)
jim@4657
   330
 */
jim@4657
   331
typedef struct SDL_MultiGestureEvent
jim@4657
   332
{
jim@4657
   333
    Uint32 type;        /**< ::SDL_MULTIGESTURE */
slouken@6114
   334
    Uint32 timestamp;
jim@4657
   335
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   336
    SDL_TouchID touchId;        /**< The touch device index */
jim@4657
   337
    float dTheta;
jim@4657
   338
    float dDist;
jim@4657
   339
    float x;  //currently 0...1. Change to screen coords?
jim@4657
   340
    float y;  
jim@4683
   341
    Uint16 numFingers;
jim@4683
   342
    Uint16 padding;
jim@4657
   343
} SDL_MultiGestureEvent;
jim@4657
   344
slouken@5014
   345
/* (event.dgesture.*) */
slouken@5014
   346
typedef struct SDL_DollarGestureEvent
jim@4658
   347
{
jim@4658
   348
    Uint32 type;        /**< ::SDL_DOLLARGESTURE */
slouken@6114
   349
    Uint32 timestamp;
jim@4658
   350
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   351
    SDL_TouchID touchId;        /**< The touch device index */
jimtla@4678
   352
    SDL_GestureID gestureId;
jim@4689
   353
    Uint32 numFingers;
jim@4658
   354
    float error;
jim@4658
   355
  /*
jim@4658
   356
    //TODO: Enable to give location?
jim@4658
   357
    float x;  //currently 0...1. Change to screen coords?
jim@4658
   358
    float y;  
jim@4658
   359
  */
jim@4658
   360
} SDL_DollarGestureEvent;
jim@4658
   361
jim@4657
   362
slouken@1895
   363
/**
slouken@6091
   364
 *  \brief An event used to request a file open by the system (event.drop.*)
slouken@6091
   365
 *         This event is disabled by default, you can enable it with SDL_EventState()
slouken@6091
   366
 *  \note If you enable this event, you must free the filename in the event.
slouken@6091
   367
 */
slouken@6091
   368
typedef struct SDL_DropEvent
slouken@6091
   369
{
slouken@6091
   370
    Uint32 type;        /**< ::SDL_DROPFILE */
slouken@6114
   371
    Uint32 timestamp;
slouken@6091
   372
    char *file;         /**< The file name, which should be freed with SDL_free() */
slouken@6091
   373
} SDL_DropEvent;
slouken@6091
   374
slouken@6091
   375
slouken@6091
   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@6114
   382
    Uint32 timestamp;
slouken@1895
   383
} SDL_QuitEvent;
slouken@1895
   384
slouken@5009
   385
slouken@1895
   386
/**
slouken@3407
   387
 *  \brief A user-defined event type (event.user.*)
slouken@1895
   388
 */
slouken@1895
   389
typedef struct SDL_UserEvent
slouken@1895
   390
{
slouken@4429
   391
    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
slouken@6114
   392
    Uint32 timestamp;
slouken@4429
   393
    Uint32 windowID;    /**< The associated window if any */
slouken@4429
   394
    int code;           /**< User defined event code */
slouken@4429
   395
    void *data1;        /**< User defined data pointer */
slouken@4429
   396
    void *data2;        /**< User defined data pointer */
slouken@1895
   397
} SDL_UserEvent;
slouken@1895
   398
slouken@5009
   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@6091
   405
 *         This event is disabled by default, you can enable it with SDL_EventState()
slouken@6091
   406
 *
slouken@3407
   407
 *  \note If you want to use this event, you should include SDL_syswm.h.
slouken@3407
   408
 */
slouken@1895
   409
typedef struct SDL_SysWMEvent
slouken@1895
   410
{
slouken@4429
   411
    Uint32 type;        /**< ::SDL_SYSWMEVENT */
slouken@6114
   412
    Uint32 timestamp;
slouken@1895
   413
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
slouken@1895
   414
} SDL_SysWMEvent;
slouken@1895
   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 */
slouken@4972
   438
    SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
slouken@4972
   439
    SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
slouken@6091
   440
    SDL_DropEvent drop;             /**< Drag and drop event data */
slouken@6595
   441
slouken@6595
   442
    /* This is necessary for ABI compatibility between Visual C++ and GCC
slouken@6595
   443
       Visual C++ will respect the push pack pragma and use 52 bytes for
slouken@6595
   444
       this structure, and GCC will use the alignment of the largest datatype
slouken@6595
   445
       within the union, which is 8 bytes.
slouken@6595
   446
slouken@6595
   447
       So... we'll add padding to force the size to be 56 bytes for both.
slouken@6595
   448
    */
slouken@6595
   449
    Uint8 padding[56];
slouken@0
   450
} SDL_Event;
slouken@0
   451
slouken@0
   452
slouken@0
   453
/* Function prototypes */
slouken@0
   454
slouken@3407
   455
/**
slouken@3407
   456
 *  Pumps the event loop, gathering events from the input devices.
slouken@3407
   457
 *  
slouken@3407
   458
 *  This function updates the event queue and internal input device state.
slouken@3407
   459
 *  
slouken@3407
   460
 *  This should only be run in the thread that sets the video mode.
slouken@3407
   461
 */
slouken@337
   462
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
slouken@0
   463
slouken@3407
   464
/*@{*/
slouken@1895
   465
typedef enum
slouken@1895
   466
{
slouken@1895
   467
    SDL_ADDEVENT,
slouken@1895
   468
    SDL_PEEKEVENT,
slouken@1895
   469
    SDL_GETEVENT
slouken@0
   470
} SDL_eventaction;
slouken@3407
   471
slouken@3407
   472
/**
slouken@3407
   473
 *  Checks the event queue for messages and optionally returns them.
slouken@3407
   474
 *  
slouken@3407
   475
 *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
slouken@3407
   476
 *  the back of the event queue.
slouken@3407
   477
 *  
slouken@3407
   478
 *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
slouken@4635
   479
 *  of the event queue, within the specified minimum and maximum type,
slouken@4635
   480
 *  will be returned and will not be removed from the queue.
slouken@3407
   481
 *  
slouken@3407
   482
 *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front 
slouken@4635
   483
 *  of the event queue, within the specified minimum and maximum type,
slouken@4635
   484
 *  will be returned and will be removed from the queue.
slouken@3407
   485
 *  
slouken@3407
   486
 *  \return The number of events actually stored, or -1 if there was an error.
slouken@3407
   487
 *  
slouken@3407
   488
 *  This function is thread-safe.
slouken@3407
   489
 */
slouken@1895
   490
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
slouken@1895
   491
                                           SDL_eventaction action,
slouken@4429
   492
                                           Uint32 minType, Uint32 maxType);
slouken@3407
   493
/*@}*/
slouken@1895
   494
slouken@3407
   495
/**
slouken@3407
   496
 *  Checks to see if certain event types are in the event queue.
slouken@1895
   497
 */
slouken@4429
   498
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
slouken@4429
   499
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
slouken@4429
   500
slouken@4429
   501
/**
slouken@4429
   502
 *  This function clears events from the event queue
slouken@4429
   503
 */
slouken@4429
   504
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
slouken@4429
   505
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
slouken@0
   506
slouken@3407
   507
/**
slouken@3407
   508
 *  \brief Polls for currently pending events.
slouken@3407
   509
 *  
slouken@3407
   510
 *  \return 1 if there are any pending events, or 0 if there are none available.
slouken@3407
   511
 *  
slouken@3407
   512
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   513
 *               stored in that area.
slouken@0
   514
 */
slouken@1895
   515
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
slouken@0
   516
slouken@3407
   517
/**
slouken@3407
   518
 *  \brief Waits indefinitely for the next available event.
slouken@3407
   519
 *  
slouken@3407
   520
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   521
 *   
slouken@3407
   522
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   523
 *               stored in that area.
slouken@0
   524
 */
slouken@1895
   525
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
slouken@0
   526
slouken@3407
   527
/**
slouken@3407
   528
 *  \brief Waits until the specified timeout (in milliseconds) for the next 
slouken@3407
   529
 *         available event.
slouken@3407
   530
 *  
slouken@3407
   531
 *  \return 1, or 0 if there was an error while waiting for events.
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@3072
   535
 */
slouken@3072
   536
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
slouken@3072
   537
                                                 int timeout);
slouken@3072
   538
slouken@3407
   539
/**
slouken@3407
   540
 *  \brief Add an event to the event queue.
slouken@3407
   541
 *  
slouken@3407
   542
 *  \return 1 on success, 0 if the event was filtered, or -1 if the event queue 
slouken@3407
   543
 *          was full or there was some other error.
slouken@0
   544
 */
slouken@1895
   545
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
slouken@0
   546
slouken@3407
   547
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
slouken@0
   548
slouken@3407
   549
/**
slouken@3407
   550
 *  Sets up a filter to process all events before they change internal state and
slouken@3407
   551
 *  are posted to the internal event queue.
slouken@3407
   552
 *  
slouken@3407
   553
 *  The filter is protypted as:
slouken@3407
   554
 *  \code
slouken@3407
   555
 *      int SDL_EventFilter(void *userdata, SDL_Event * event);
slouken@3407
   556
 *  \endcode
slouken@3407
   557
 *
slouken@3407
   558
 *  If the filter returns 1, then the event will be added to the internal queue.
slouken@3407
   559
 *  If it returns 0, then the event will be dropped from the queue, but the 
slouken@3407
   560
 *  internal state will still be updated.  This allows selective filtering of
slouken@3407
   561
 *  dynamically arriving events.
slouken@3407
   562
 *  
slouken@3407
   563
 *  \warning  Be very careful of what you do in the event filter function, as 
slouken@3407
   564
 *            it may run in a different thread!
slouken@3407
   565
 *  
slouken@3407
   566
 *  There is one caveat when dealing with the ::SDL_QUITEVENT event type.  The
slouken@3407
   567
 *  event filter is only called when the window manager desires to close the
slouken@3407
   568
 *  application window.  If the event filter returns 1, then the window will
slouken@3407
   569
 *  be closed, otherwise the window will remain open if possible.
slouken@3407
   570
 *
slouken@3407
   571
 *  If the quit event is generated by an interrupt signal, it will bypass the
slouken@3407
   572
 *  internal queue and be delivered to the application at the next event poll.
slouken@3407
   573
 */
slouken@1895
   574
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
slouken@1895
   575
                                                void *userdata);
slouken@0
   576
slouken@3407
   577
/**
slouken@3407
   578
 *  Return the current event filter - can be used to "chain" filters.
slouken@3407
   579
 *  If there is no event filter set, this function returns SDL_FALSE.
slouken@3407
   580
 */
slouken@1895
   581
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
slouken@1895
   582
                                                    void **userdata);
slouken@1895
   583
slouken@3407
   584
/**
slouken@5146
   585
 *  Add a function which is called when an event is added to the queue.
slouken@5146
   586
 */
slouken@5146
   587
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
slouken@5146
   588
                                               void *userdata);
slouken@5146
   589
slouken@5146
   590
/**
slouken@5146
   591
 *  Remove an event watch function added with SDL_AddEventWatch()
slouken@5146
   592
 */
slouken@5146
   593
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
slouken@5146
   594
                                               void *userdata);
slouken@5146
   595
slouken@5146
   596
/**
slouken@3407
   597
 *  Run the filter function on the current event queue, removing any
slouken@3407
   598
 *  events for which the filter returns 0.
slouken@3407
   599
 */
slouken@1895
   600
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
slouken@1895
   601
                                              void *userdata);
slouken@0
   602
slouken@3407
   603
/*@{*/
slouken@0
   604
#define SDL_QUERY	-1
slouken@0
   605
#define SDL_IGNORE	 0
slouken@0
   606
#define SDL_DISABLE	 0
slouken@0
   607
#define SDL_ENABLE	 1
slouken@3407
   608
slouken@3407
   609
/**
slouken@3407
   610
 *  This function allows you to set the state of processing certain events.
slouken@3407
   611
 *   - If \c state is set to ::SDL_IGNORE, that event will be automatically 
slouken@3407
   612
 *     dropped from the event queue and will not event be filtered.
slouken@3407
   613
 *   - If \c state is set to ::SDL_ENABLE, that event will be processed 
slouken@3407
   614
 *     normally.
slouken@3407
   615
 *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 
slouken@3407
   616
 *     current processing state of the specified event.
slouken@3407
   617
 */
slouken@4429
   618
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
slouken@3407
   619
/*@}*/
slouken@4429
   620
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
slouken@4429
   621
slouken@4429
   622
/**
slouken@4429
   623
 *  This function allocates a set of user-defined events, and returns
slouken@4429
   624
 *  the beginning event number for that set of events.
slouken@4429
   625
 *
slouken@4429
   626
 *  If there aren't enough user-defined events left, this function
slouken@4429
   627
 *  returns (Uint32)-1
slouken@4429
   628
 */
slouken@4429
   629
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
slouken@0
   630
slouken@0
   631
/* Ends C function definitions when using C++ */
slouken@0
   632
#ifdef __cplusplus
slouken@1895
   633
/* *INDENT-OFF* */
slouken@0
   634
}
slouken@1895
   635
/* *INDENT-ON* */
slouken@0
   636
#endif
slouken@0
   637
#include "close_code.h"
slouken@0
   638
slouken@0
   639
#endif /* _SDL_events_h */
slouken@1895
   640
slouken@1895
   641
/* vi: set ts=4 sw=4 expandtab: */