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