include/SDL_events.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 18 May 2013 14:17:52 -0700
changeset 7191 75360622e65f
parent 7190 11612d544fcd
child 7203 c74f5dbcfd23
permissions -rw-r--r--
File style cleanup for the SDL 2.0 release
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 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@7191
    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@6690
    37
#include "SDL_gamecontroller.h"
slouken@0
    38
#include "SDL_quit.h"
jim@4659
    39
#include "SDL_gesture.h"
jim@4659
    40
#include "SDL_touch.h"
slouken@0
    41
slouken@0
    42
#include "begin_code.h"
slouken@0
    43
/* Set up for C function definitions, even when using C++ */
slouken@0
    44
#ifdef __cplusplus
slouken@0
    45
extern "C" {
slouken@0
    46
#endif
slouken@0
    47
slouken@1330
    48
/* General keyboard/mouse state definitions */
slouken@7191
    49
#define SDL_RELEASED    0
slouken@7191
    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@7190
    62
    /* These application events have special meaning on iOS, see README.iOS for details */
slouken@7191
    63
    SDL_APP_TERMINATING,        /**< The application is being terminated by the OS
slouken@7190
    64
                                     Called on iOS in applicationWillTerminate()
slouken@7190
    65
                                     Called on Android in onDestroy()
slouken@7190
    66
                                */
slouken@7191
    67
    SDL_APP_LOWMEMORY,          /**< The application is low on memory, free memory if possible.
slouken@7190
    68
                                     Called on iOS in applicationDidReceiveMemoryWarning()
slouken@7190
    69
                                     Called on Android in onLowMemory()
slouken@7190
    70
                                */
slouken@7191
    71
    SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background
slouken@7190
    72
                                     Called on iOS in applicationWillResignActive()
slouken@7190
    73
                                     Called on Android in onPause()
slouken@7190
    74
                                */
slouken@7191
    75
    SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time
slouken@7190
    76
                                     Called on iOS in applicationDidEnterBackground()
slouken@7190
    77
                                     Called on Android in onPause()
slouken@7190
    78
                                */
slouken@7191
    79
    SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground
slouken@7190
    80
                                     Called on iOS in applicationWillEnterForeground()
slouken@7190
    81
                                     Called on Android in onResume()
slouken@7190
    82
                                */
slouken@7191
    83
    SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive
slouken@7190
    84
                                     Called on iOS in applicationDidBecomeActive()
slouken@7190
    85
                                     Called on Android in onResume()
slouken@7190
    86
                                */
slouken@7190
    87
slouken@4429
    88
    /* Window events */
slouken@4429
    89
    SDL_WINDOWEVENT    = 0x200, /**< Window state change */
slouken@4429
    90
    SDL_SYSWMEVENT,             /**< System specific event */
slouken@4429
    91
slouken@4429
    92
    /* Keyboard events */
slouken@4971
    93
    SDL_KEYDOWN        = 0x300, /**< Key pressed */
slouken@4971
    94
    SDL_KEYUP,                  /**< Key released */
slouken@3280
    95
    SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
slouken@1957
    96
    SDL_TEXTINPUT,              /**< Keyboard text input */
slouken@4429
    97
slouken@4429
    98
    /* Mouse events */
slouken@4429
    99
    SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
slouken@1895
   100
    SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
slouken@1895
   101
    SDL_MOUSEBUTTONUP,          /**< Mouse button released */
slouken@1957
   102
    SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
slouken@4429
   103
slouken@4429
   104
    /* Joystick events */
slouken@4429
   105
    SDL_JOYAXISMOTION  = 0x600, /**< Joystick axis motion */
slouken@1895
   106
    SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
slouken@1895
   107
    SDL_JOYHATMOTION,           /**< Joystick hat position change */
slouken@1895
   108
    SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
slouken@1895
   109
    SDL_JOYBUTTONUP,            /**< Joystick button released */
slouken@6690
   110
    SDL_JOYDEVICEADDED,         /**< A new joystick has been inserted into the system */
slouken@6690
   111
    SDL_JOYDEVICEREMOVED,       /**< An opened joystick has been removed */
slouken@6690
   112
slouken@7191
   113
    /* Game controller events */
slouken@7191
   114
    SDL_CONTROLLERAXISMOTION  = 0x650, /**< Game controller axis motion */
slouken@7191
   115
    SDL_CONTROLLERBUTTONDOWN,          /**< Game controller button pressed */
slouken@7191
   116
    SDL_CONTROLLERBUTTONUP,            /**< Game controller button released */
slouken@7191
   117
    SDL_CONTROLLERDEVICEADDED,         /**< A new Game controller has been inserted into the system */
slouken@7191
   118
    SDL_CONTROLLERDEVICEREMOVED,       /**< An opened Game controller has been removed */
slouken@7191
   119
    SDL_CONTROLLERDEVICEREMAPPED,      /**< The controller mapping was updated */
slouken@4429
   120
slouken@4661
   121
    /* Touch events */
slouken@4661
   122
    SDL_FINGERDOWN      = 0x700,
jim@4641
   123
    SDL_FINGERUP,
jim@4641
   124
    SDL_FINGERMOTION,
jim@4641
   125
slouken@4661
   126
    /* Gesture events */
slouken@4661
   127
    SDL_DOLLARGESTURE   = 0x800,
jim@4659
   128
    SDL_DOLLARRECORD,
jim@4657
   129
    SDL_MULTIGESTURE,
jim@4657
   130
slouken@4503
   131
    /* Clipboard events */
slouken@6091
   132
    SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
jim@4662
   133
slouken@6091
   134
    /* Drag and drop events */
slouken@6091
   135
    SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
slouken@7191
   136
slouken@4429
   137
    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
slouken@4429
   138
     *  and should be allocated with SDL_RegisterEvents()
slouken@4429
   139
     */
slouken@4429
   140
    SDL_USEREVENT    = 0x8000,
slouken@4429
   141
slouken@3407
   142
    /**
slouken@3407
   143
     *  This last event is only for bounding internal arrays
slouken@1895
   144
     */
slouken@4429
   145
    SDL_LASTEVENT    = 0xFFFF
slouken@1294
   146
} SDL_EventType;
slouken@0
   147
slouken@1895
   148
/**
slouken@6949
   149
 *  \brief Fields shared by every event
slouken@6949
   150
 */
dludwig@7082
   151
typedef struct SDL_CommonEvent
slouken@6949
   152
{
slouken@6949
   153
    Uint32 type;
slouken@6949
   154
    Uint32 timestamp;
dludwig@7082
   155
} SDL_CommonEvent;
slouken@7191
   156
slouken@6949
   157
/**
slouken@3407
   158
 *  \brief Window state change event data (event.window.*)
slouken@1895
   159
 */
slouken@1895
   160
typedef struct SDL_WindowEvent
slouken@1895
   161
{
slouken@4429
   162
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
slouken@6114
   163
    Uint32 timestamp;
slouken@4429
   164
    Uint32 windowID;    /**< The associated window */
slouken@4429
   165
    Uint8 event;        /**< ::SDL_WindowEventID */
slouken@4429
   166
    Uint8 padding1;
slouken@4429
   167
    Uint8 padding2;
slouken@4429
   168
    Uint8 padding3;
slouken@6950
   169
    Sint32 data1;       /**< event dependent data */
slouken@6950
   170
    Sint32 data2;       /**< event dependent data */
slouken@1895
   171
} SDL_WindowEvent;
slouken@0
   172
slouken@1895
   173
/**
slouken@3407
   174
 *  \brief Keyboard button event structure (event.key.*)
slouken@1895
   175
 */
slouken@1895
   176
typedef struct SDL_KeyboardEvent
slouken@1895
   177
{
slouken@4429
   178
    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
slouken@6114
   179
    Uint32 timestamp;
slouken@4429
   180
    Uint32 windowID;    /**< The window with keyboard focus, if any */
slouken@4429
   181
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4560
   182
    Uint8 repeat;       /**< Non-zero if this is a key repeat */
slouken@4429
   183
    Uint8 padding2;
slouken@4465
   184
    Uint8 padding3;
slouken@5218
   185
    SDL_Keysym keysym;  /**< The key that was pressed or released */
slouken@0
   186
} SDL_KeyboardEvent;
slouken@0
   187
slouken@3407
   188
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
slouken@1895
   189
/**
slouken@3407
   190
 *  \brief Keyboard text editing event structure (event.edit.*)
slouken@3280
   191
 */
slouken@3280
   192
typedef struct SDL_TextEditingEvent
slouken@3280
   193
{
slouken@4429
   194
    Uint32 type;                                /**< ::SDL_TEXTEDITING */
slouken@6114
   195
    Uint32 timestamp;
slouken@4434
   196
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
slouken@3280
   197
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
slouken@6950
   198
    Sint32 start;                               /**< The start cursor of selected editing text */
slouken@6950
   199
    Sint32 length;                              /**< The length of selected editing text */
slouken@3280
   200
} SDL_TextEditingEvent;
slouken@3280
   201
slouken@3407
   202
slouken@3407
   203
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
slouken@3280
   204
/**
slouken@3407
   205
 *  \brief Keyboard text input event structure (event.text.*)
slouken@1895
   206
 */
slouken@1895
   207
typedef struct SDL_TextInputEvent
slouken@1895
   208
{
slouken@4429
   209
    Uint32 type;                              /**< ::SDL_TEXTINPUT */
slouken@6114
   210
    Uint32 timestamp;
slouken@3685
   211
    Uint32 windowID;                          /**< The window with keyboard focus, if any */
bob@2300
   212
    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
slouken@1895
   213
} SDL_TextInputEvent;
slouken@1895
   214
slouken@1895
   215
/**
slouken@3407
   216
 *  \brief Mouse motion event structure (event.motion.*)
slouken@1895
   217
 */
slouken@1895
   218
typedef struct SDL_MouseMotionEvent
slouken@1895
   219
{
slouken@4429
   220
    Uint32 type;        /**< ::SDL_MOUSEMOTION */
slouken@6114
   221
    Uint32 timestamp;
slouken@4429
   222
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@6950
   223
    Uint32 which;       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
slouken@4429
   224
    Uint8 state;        /**< The current button state */
slouken@4429
   225
    Uint8 padding1;
slouken@4429
   226
    Uint8 padding2;
slouken@4465
   227
    Uint8 padding3;
slouken@6950
   228
    Sint32 x;           /**< X coordinate, relative to window */
slouken@6950
   229
    Sint32 y;           /**< Y coordinate, relative to window */
slouken@6950
   230
    Sint32 xrel;        /**< The relative motion in the X direction */
slouken@6950
   231
    Sint32 yrel;        /**< The relative motion in the Y direction */
slouken@0
   232
} SDL_MouseMotionEvent;
slouken@0
   233
slouken@1895
   234
/**
slouken@3407
   235
 *  \brief Mouse button event structure (event.button.*)
slouken@1895
   236
 */
slouken@1895
   237
typedef struct SDL_MouseButtonEvent
slouken@1895
   238
{
slouken@4429
   239
    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
slouken@6114
   240
    Uint32 timestamp;
slouken@4429
   241
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@6950
   242
    Uint32 which;       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
slouken@4429
   243
    Uint8 button;       /**< The mouse button index */
slouken@4429
   244
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   245
    Uint8 padding1;
slouken@4465
   246
    Uint8 padding2;
slouken@6950
   247
    Sint32 x;           /**< X coordinate, relative to window */
slouken@6950
   248
    Sint32 y;           /**< Y coordinate, relative to window */
slouken@0
   249
} SDL_MouseButtonEvent;
slouken@0
   250
slouken@1895
   251
/**
slouken@3407
   252
 *  \brief Mouse wheel event structure (event.wheel.*)
slouken@1895
   253
 */
slouken@1895
   254
typedef struct SDL_MouseWheelEvent
slouken@1895
   255
{
slouken@4429
   256
    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
slouken@6114
   257
    Uint32 timestamp;
slouken@4429
   258
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@6950
   259
    Uint32 which;       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
slouken@6950
   260
    Sint32 x;           /**< The amount scrolled horizontally */
slouken@6950
   261
    Sint32 y;           /**< The amount scrolled vertically */
slouken@1895
   262
} SDL_MouseWheelEvent;
slouken@1895
   263
slouken@1895
   264
/**
slouken@3407
   265
 *  \brief Joystick axis motion event structure (event.jaxis.*)
slouken@1895
   266
 */
slouken@1895
   267
typedef struct SDL_JoyAxisEvent
slouken@1895
   268
{
slouken@4429
   269
    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
slouken@6114
   270
    Uint32 timestamp;
slouken@6974
   271
    SDL_JoystickID which; /**< The joystick instance id */
slouken@1895
   272
    Uint8 axis;         /**< The joystick axis index */
slouken@4429
   273
    Uint8 padding1;
slouken@4429
   274
    Uint8 padding2;
slouken@6949
   275
    Uint8 padding3;
slouken@6949
   276
    Sint16 value;       /**< The axis value (range: -32768 to 32767) */
slouken@6949
   277
    Uint16 padding4;
slouken@0
   278
} SDL_JoyAxisEvent;
slouken@0
   279
slouken@1895
   280
/**
slouken@3407
   281
 *  \brief Joystick trackball motion event structure (event.jball.*)
slouken@1895
   282
 */
slouken@1895
   283
typedef struct SDL_JoyBallEvent
slouken@1895
   284
{
slouken@4429
   285
    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
slouken@7191
   286
    Uint32 timestamp;
slouken@6974
   287
    SDL_JoystickID which; /**< The joystick instance id */
slouken@1895
   288
    Uint8 ball;         /**< The joystick trackball index */
slouken@4429
   289
    Uint8 padding1;
slouken@4429
   290
    Uint8 padding2;
slouken@6949
   291
    Uint8 padding3;
slouken@6949
   292
    Sint16 xrel;        /**< The relative motion in the X direction */
slouken@6949
   293
    Sint16 yrel;        /**< The relative motion in the Y direction */
slouken@0
   294
} SDL_JoyBallEvent;
slouken@0
   295
slouken@1895
   296
/**
slouken@3407
   297
 *  \brief Joystick hat position change event structure (event.jhat.*)
slouken@1895
   298
 */
slouken@1895
   299
typedef struct SDL_JoyHatEvent
slouken@1895
   300
{
slouken@4429
   301
    Uint32 type;        /**< ::SDL_JOYHATMOTION */
slouken@7191
   302
    Uint32 timestamp;
slouken@6974
   303
    SDL_JoystickID which; /**< The joystick instance id */
slouken@1895
   304
    Uint8 hat;          /**< The joystick hat index */
slouken@3407
   305
    Uint8 value;        /**< The hat position value.
slouken@3407
   306
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
slouken@3407
   307
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
slouken@3407
   308
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
slouken@7191
   309
                         *
slouken@3407
   310
                         *   Note that zero means the POV is centered.
slouken@1895
   311
                         */
slouken@4429
   312
    Uint8 padding1;
slouken@6949
   313
    Uint8 padding2;
slouken@0
   314
} SDL_JoyHatEvent;
slouken@0
   315
slouken@1895
   316
/**
slouken@3407
   317
 *  \brief Joystick button event structure (event.jbutton.*)
slouken@1895
   318
 */
slouken@1895
   319
typedef struct SDL_JoyButtonEvent
slouken@1895
   320
{
slouken@4429
   321
    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
slouken@7191
   322
    Uint32 timestamp;
slouken@6974
   323
    SDL_JoystickID which; /**< The joystick instance id */
slouken@1895
   324
    Uint8 button;       /**< The joystick button index */
slouken@3407
   325
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   326
    Uint8 padding1;
slouken@6949
   327
    Uint8 padding2;
slouken@0
   328
} SDL_JoyButtonEvent;
slouken@0
   329
slouken@6690
   330
/**
slouken@6690
   331
 *  \brief Joystick device event structure (event.jdevice.*)
slouken@6690
   332
 */
slouken@6690
   333
typedef struct SDL_JoyDeviceEvent
slouken@6690
   334
{
slouken@7191
   335
    Uint32 type;        /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
slouken@7191
   336
    Uint32 timestamp;
slouken@7191
   337
    Sint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
slouken@6690
   338
} SDL_JoyDeviceEvent;
slouken@6690
   339
slouken@6690
   340
slouken@6690
   341
/**
slouken@6690
   342
 *  \brief Game controller axis motion event structure (event.caxis.*)
slouken@6690
   343
 */
slouken@6690
   344
typedef struct SDL_ControllerAxisEvent
slouken@6690
   345
{
slouken@6690
   346
    Uint32 type;        /**< ::SDL_CONTROLLERAXISMOTION */
slouken@7191
   347
    Uint32 timestamp;
slouken@6974
   348
    SDL_JoystickID which; /**< The joystick instance id */
slouken@6949
   349
    Uint8 axis;         /**< The controller axis (SDL_GameControllerAxis) */
slouken@6949
   350
    Uint8 padding1;
slouken@6949
   351
    Uint8 padding2;
slouken@6949
   352
    Uint8 padding3;
slouken@6949
   353
    Sint16 value;       /**< The axis value (range: -32768 to 32767) */
slouken@6949
   354
    Uint16 padding4;
slouken@6690
   355
} SDL_ControllerAxisEvent;
slouken@6690
   356
slouken@6690
   357
slouken@6690
   358
/**
slouken@6690
   359
 *  \brief Game controller button event structure (event.cbutton.*)
slouken@6690
   360
 */
slouken@6690
   361
typedef struct SDL_ControllerButtonEvent
slouken@6690
   362
{
slouken@6690
   363
    Uint32 type;        /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
slouken@7191
   364
    Uint32 timestamp;
slouken@6974
   365
    SDL_JoystickID which; /**< The joystick instance id */
slouken@6949
   366
    Uint8 button;       /**< The controller button (SDL_GameControllerButton) */
slouken@6690
   367
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@6949
   368
    Uint8 padding1;
slouken@6949
   369
    Uint8 padding2;
slouken@6690
   370
} SDL_ControllerButtonEvent;
slouken@6690
   371
slouken@6690
   372
slouken@6690
   373
/**
slouken@6690
   374
 *  \brief Controller device event structure (event.cdevice.*)
slouken@6690
   375
 */
slouken@6690
   376
typedef struct SDL_ControllerDeviceEvent
slouken@6690
   377
{
slouken@7191
   378
    Uint32 type;        /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
slouken@7191
   379
    Uint32 timestamp;
slouken@7191
   380
    Sint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
slouken@6690
   381
} SDL_ControllerDeviceEvent;
slouken@6690
   382
jim@4641
   383
jim@4641
   384
/**
slouken@6951
   385
 *  \brief Touch finger event structure (event.tfinger.*)
jim@4641
   386
 */
jim@4641
   387
typedef struct SDL_TouchFingerEvent
jim@4641
   388
{
slouken@6949
   389
    Uint32 type;        /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
slouken@6114
   390
    Uint32 timestamp;
slouken@6949
   391
    SDL_TouchID touchId; /**< The touch device id */
jimtla@4678
   392
    SDL_FingerID fingerId;
slouken@6951
   393
    float x;            /**< Normalized in the range 0...1 */
slouken@6951
   394
    float y;            /**< Normalized in the range 0...1 */
slouken@6951
   395
    float dx;           /**< Normalized in the range 0...1 */
slouken@6951
   396
    float dy;           /**< Normalized in the range 0...1 */
slouken@6951
   397
    float pressure;     /**< Normalized in the range 0...1 */
jim@4641
   398
} SDL_TouchFingerEvent;
jim@4641
   399
jim@4641
   400
jim@4641
   401
/**
slouken@5009
   402
 *  \brief Multiple Finger Gesture Event (event.mgesture.*)
jim@4657
   403
 */
jim@4657
   404
typedef struct SDL_MultiGestureEvent
jim@4657
   405
{
jim@4657
   406
    Uint32 type;        /**< ::SDL_MULTIGESTURE */
slouken@6114
   407
    Uint32 timestamp;
slouken@6951
   408
    SDL_TouchID touchId; /**< The touch device index */
jim@4657
   409
    float dTheta;
jim@4657
   410
    float dDist;
slouken@6951
   411
    float x;
slouken@7191
   412
    float y;
jim@4683
   413
    Uint16 numFingers;
jim@4683
   414
    Uint16 padding;
jim@4657
   415
} SDL_MultiGestureEvent;
jim@4657
   416
slouken@6951
   417
slouken@5014
   418
/* (event.dgesture.*) */
slouken@5014
   419
typedef struct SDL_DollarGestureEvent
jim@4658
   420
{
jim@4658
   421
    Uint32 type;        /**< ::SDL_DOLLARGESTURE */
slouken@6114
   422
    Uint32 timestamp;
slouken@6951
   423
    SDL_TouchID touchId; /**< The touch device id */
jimtla@4678
   424
    SDL_GestureID gestureId;
jim@4689
   425
    Uint32 numFingers;
jim@4658
   426
    float error;
slouken@6951
   427
    float x;            /**< Normalized center of gesture */
slouken@6951
   428
    float y;            /**< Normalized center of gesture */
jim@4658
   429
} SDL_DollarGestureEvent;
jim@4658
   430
jim@4657
   431
slouken@1895
   432
/**
slouken@6091
   433
 *  \brief An event used to request a file open by the system (event.drop.*)
slouken@6091
   434
 *         This event is disabled by default, you can enable it with SDL_EventState()
slouken@6091
   435
 *  \note If you enable this event, you must free the filename in the event.
slouken@6091
   436
 */
slouken@6091
   437
typedef struct SDL_DropEvent
slouken@6091
   438
{
slouken@6091
   439
    Uint32 type;        /**< ::SDL_DROPFILE */
slouken@6114
   440
    Uint32 timestamp;
slouken@6091
   441
    char *file;         /**< The file name, which should be freed with SDL_free() */
slouken@6091
   442
} SDL_DropEvent;
slouken@6091
   443
slouken@6091
   444
slouken@6091
   445
/**
slouken@3407
   446
 *  \brief The "quit requested" event
slouken@0
   447
 */
slouken@1895
   448
typedef struct SDL_QuitEvent
slouken@1895
   449
{
slouken@4429
   450
    Uint32 type;        /**< ::SDL_QUIT */
slouken@6114
   451
    Uint32 timestamp;
slouken@1895
   452
} SDL_QuitEvent;
slouken@1895
   453
slouken@7190
   454
/**
slouken@7190
   455
 *  \brief OS Specific event
slouken@7190
   456
 */
slouken@7190
   457
typedef struct SDL_OSEvent
slouken@7190
   458
{
slouken@7190
   459
    Uint32 type;        /**< ::SDL_QUIT */
slouken@7190
   460
    Uint32 timestamp;
slouken@7190
   461
} SDL_OSEvent;
slouken@5009
   462
slouken@1895
   463
/**
slouken@3407
   464
 *  \brief A user-defined event type (event.user.*)
slouken@1895
   465
 */
slouken@1895
   466
typedef struct SDL_UserEvent
slouken@1895
   467
{
slouken@4429
   468
    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
slouken@6114
   469
    Uint32 timestamp;
slouken@4429
   470
    Uint32 windowID;    /**< The associated window if any */
slouken@6950
   471
    Sint32 code;        /**< User defined event code */
slouken@4429
   472
    void *data1;        /**< User defined data pointer */
slouken@4429
   473
    void *data2;        /**< User defined data pointer */
slouken@1895
   474
} SDL_UserEvent;
slouken@1895
   475
slouken@5009
   476
slouken@1895
   477
struct SDL_SysWMmsg;
slouken@1895
   478
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
slouken@3407
   479
slouken@3407
   480
/**
slouken@3407
   481
 *  \brief A video driver dependent system event (event.syswm.*)
slouken@6091
   482
 *         This event is disabled by default, you can enable it with SDL_EventState()
slouken@6091
   483
 *
slouken@3407
   484
 *  \note If you want to use this event, you should include SDL_syswm.h.
slouken@3407
   485
 */
slouken@1895
   486
typedef struct SDL_SysWMEvent
slouken@1895
   487
{
slouken@4429
   488
    Uint32 type;        /**< ::SDL_SYSWMEVENT */
slouken@6114
   489
    Uint32 timestamp;
slouken@1895
   490
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
slouken@1895
   491
} SDL_SysWMEvent;
slouken@1895
   492
slouken@1895
   493
/**
slouken@3407
   494
 *  \brief General event structure
slouken@1895
   495
 */
slouken@1895
   496
typedef union SDL_Event
slouken@1895
   497
{
slouken@4429
   498
    Uint32 type;                    /**< Event type, shared with all events */
dludwig@7082
   499
    SDL_CommonEvent common;         /**< Common event data */
slouken@1895
   500
    SDL_WindowEvent window;         /**< Window event data */
slouken@1895
   501
    SDL_KeyboardEvent key;          /**< Keyboard event data */
slouken@3280
   502
    SDL_TextEditingEvent edit;      /**< Text editing event data */
bob@2300
   503
    SDL_TextInputEvent text;        /**< Text input event data */
slouken@1895
   504
    SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
slouken@1895
   505
    SDL_MouseButtonEvent button;    /**< Mouse button event data */
bob@2300
   506
    SDL_MouseWheelEvent wheel;      /**< Mouse wheel event data */
slouken@1895
   507
    SDL_JoyAxisEvent jaxis;         /**< Joystick axis event data */
slouken@1895
   508
    SDL_JoyBallEvent jball;         /**< Joystick ball event data */
slouken@1895
   509
    SDL_JoyHatEvent jhat;           /**< Joystick hat event data */
slouken@1895
   510
    SDL_JoyButtonEvent jbutton;     /**< Joystick button event data */
slouken@6690
   511
    SDL_JoyDeviceEvent jdevice;     /**< Joystick device change event data */
slouken@7191
   512
    SDL_ControllerAxisEvent caxis;      /**< Game Controller axis event data */
slouken@7191
   513
    SDL_ControllerButtonEvent cbutton;  /**< Game Controller button event data */
slouken@7191
   514
    SDL_ControllerDeviceEvent cdevice;  /**< Game Controller device event data */
slouken@1895
   515
    SDL_QuitEvent quit;             /**< Quit request event data */
slouken@1895
   516
    SDL_UserEvent user;             /**< Custom event data */
slouken@1895
   517
    SDL_SysWMEvent syswm;           /**< System dependent window event data */
jim@4641
   518
    SDL_TouchFingerEvent tfinger;   /**< Touch finger event data */
slouken@6951
   519
    SDL_MultiGestureEvent mgesture; /**< Gesture event data */
slouken@6951
   520
    SDL_DollarGestureEvent dgesture; /**< Gesture event data */
slouken@6091
   521
    SDL_DropEvent drop;             /**< Drag and drop event data */
slouken@6595
   522
slouken@6595
   523
    /* This is necessary for ABI compatibility between Visual C++ and GCC
slouken@6595
   524
       Visual C++ will respect the push pack pragma and use 52 bytes for
slouken@6595
   525
       this structure, and GCC will use the alignment of the largest datatype
slouken@6595
   526
       within the union, which is 8 bytes.
slouken@6595
   527
slouken@6595
   528
       So... we'll add padding to force the size to be 56 bytes for both.
slouken@6595
   529
    */
slouken@6595
   530
    Uint8 padding[56];
slouken@0
   531
} SDL_Event;
slouken@0
   532
slouken@0
   533
slouken@0
   534
/* Function prototypes */
slouken@0
   535
slouken@3407
   536
/**
slouken@3407
   537
 *  Pumps the event loop, gathering events from the input devices.
slouken@7191
   538
 *
slouken@3407
   539
 *  This function updates the event queue and internal input device state.
slouken@7191
   540
 *
slouken@3407
   541
 *  This should only be run in the thread that sets the video mode.
slouken@3407
   542
 */
slouken@337
   543
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
slouken@0
   544
slouken@3407
   545
/*@{*/
slouken@1895
   546
typedef enum
slouken@1895
   547
{
slouken@1895
   548
    SDL_ADDEVENT,
slouken@1895
   549
    SDL_PEEKEVENT,
slouken@1895
   550
    SDL_GETEVENT
slouken@0
   551
} SDL_eventaction;
slouken@3407
   552
slouken@3407
   553
/**
slouken@3407
   554
 *  Checks the event queue for messages and optionally returns them.
slouken@7191
   555
 *
slouken@3407
   556
 *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
slouken@3407
   557
 *  the back of the event queue.
slouken@7191
   558
 *
slouken@3407
   559
 *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
slouken@4635
   560
 *  of the event queue, within the specified minimum and maximum type,
slouken@4635
   561
 *  will be returned and will not be removed from the queue.
slouken@7191
   562
 *
slouken@7191
   563
 *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front
slouken@4635
   564
 *  of the event queue, within the specified minimum and maximum type,
slouken@4635
   565
 *  will be returned and will be removed from the queue.
slouken@7191
   566
 *
slouken@3407
   567
 *  \return The number of events actually stored, or -1 if there was an error.
slouken@7191
   568
 *
slouken@3407
   569
 *  This function is thread-safe.
slouken@3407
   570
 */
slouken@1895
   571
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
slouken@1895
   572
                                           SDL_eventaction action,
slouken@4429
   573
                                           Uint32 minType, Uint32 maxType);
slouken@3407
   574
/*@}*/
slouken@1895
   575
slouken@3407
   576
/**
slouken@3407
   577
 *  Checks to see if certain event types are in the event queue.
slouken@1895
   578
 */
slouken@4429
   579
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
slouken@4429
   580
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
slouken@4429
   581
slouken@4429
   582
/**
slouken@4429
   583
 *  This function clears events from the event queue
slouken@4429
   584
 */
slouken@4429
   585
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
slouken@4429
   586
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
slouken@0
   587
slouken@3407
   588
/**
slouken@3407
   589
 *  \brief Polls for currently pending events.
slouken@7191
   590
 *
slouken@3407
   591
 *  \return 1 if there are any pending events, or 0 if there are none available.
slouken@7191
   592
 *
slouken@7191
   593
 *  \param event If not NULL, the next event is removed from the queue and
slouken@3407
   594
 *               stored in that area.
slouken@0
   595
 */
slouken@1895
   596
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
slouken@0
   597
slouken@3407
   598
/**
slouken@3407
   599
 *  \brief Waits indefinitely for the next available event.
slouken@7191
   600
 *
slouken@3407
   601
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@7191
   602
 *
slouken@7191
   603
 *  \param event If not NULL, the next event is removed from the queue and
slouken@3407
   604
 *               stored in that area.
slouken@0
   605
 */
slouken@1895
   606
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
slouken@0
   607
slouken@3407
   608
/**
slouken@7191
   609
 *  \brief Waits until the specified timeout (in milliseconds) for the next
slouken@3407
   610
 *         available event.
slouken@7191
   611
 *
slouken@3407
   612
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@7191
   613
 *
slouken@7191
   614
 *  \param event If not NULL, the next event is removed from the queue and
slouken@3407
   615
 *               stored in that area.
philipp@7188
   616
 *  \param timeout The timeout (in milliseconds) to wait for next event.
slouken@3072
   617
 */
slouken@3072
   618
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
slouken@3072
   619
                                                 int timeout);
slouken@3072
   620
slouken@3407
   621
/**
slouken@3407
   622
 *  \brief Add an event to the event queue.
slouken@7191
   623
 *
slouken@7191
   624
 *  \return 1 on success, 0 if the event was filtered, or -1 if the event queue
slouken@3407
   625
 *          was full or there was some other error.
slouken@0
   626
 */
slouken@1895
   627
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
slouken@0
   628
slouken@3407
   629
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
slouken@0
   630
slouken@3407
   631
/**
slouken@3407
   632
 *  Sets up a filter to process all events before they change internal state and
slouken@3407
   633
 *  are posted to the internal event queue.
slouken@7191
   634
 *
philipp@7125
   635
 *  The filter is prototyped as:
slouken@3407
   636
 *  \code
slouken@3407
   637
 *      int SDL_EventFilter(void *userdata, SDL_Event * event);
slouken@3407
   638
 *  \endcode
slouken@3407
   639
 *
slouken@3407
   640
 *  If the filter returns 1, then the event will be added to the internal queue.
slouken@7191
   641
 *  If it returns 0, then the event will be dropped from the queue, but the
slouken@3407
   642
 *  internal state will still be updated.  This allows selective filtering of
slouken@3407
   643
 *  dynamically arriving events.
slouken@7191
   644
 *
slouken@7191
   645
 *  \warning  Be very careful of what you do in the event filter function, as
slouken@3407
   646
 *            it may run in a different thread!
slouken@7191
   647
 *
slouken@3407
   648
 *  There is one caveat when dealing with the ::SDL_QUITEVENT event type.  The
slouken@3407
   649
 *  event filter is only called when the window manager desires to close the
slouken@3407
   650
 *  application window.  If the event filter returns 1, then the window will
slouken@3407
   651
 *  be closed, otherwise the window will remain open if possible.
slouken@3407
   652
 *
slouken@3407
   653
 *  If the quit event is generated by an interrupt signal, it will bypass the
slouken@3407
   654
 *  internal queue and be delivered to the application at the next event poll.
slouken@3407
   655
 */
slouken@1895
   656
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
slouken@1895
   657
                                                void *userdata);
slouken@0
   658
slouken@3407
   659
/**
slouken@3407
   660
 *  Return the current event filter - can be used to "chain" filters.
slouken@3407
   661
 *  If there is no event filter set, this function returns SDL_FALSE.
slouken@3407
   662
 */
slouken@1895
   663
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
slouken@1895
   664
                                                    void **userdata);
slouken@1895
   665
slouken@3407
   666
/**
slouken@5146
   667
 *  Add a function which is called when an event is added to the queue.
slouken@5146
   668
 */
slouken@5146
   669
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
slouken@5146
   670
                                               void *userdata);
slouken@5146
   671
slouken@5146
   672
/**
slouken@5146
   673
 *  Remove an event watch function added with SDL_AddEventWatch()
slouken@5146
   674
 */
slouken@5146
   675
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
slouken@5146
   676
                                               void *userdata);
slouken@5146
   677
slouken@5146
   678
/**
slouken@3407
   679
 *  Run the filter function on the current event queue, removing any
slouken@3407
   680
 *  events for which the filter returns 0.
slouken@3407
   681
 */
slouken@1895
   682
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
slouken@1895
   683
                                              void *userdata);
slouken@0
   684
slouken@3407
   685
/*@{*/
slouken@7191
   686
#define SDL_QUERY   -1
slouken@7191
   687
#define SDL_IGNORE   0
slouken@7191
   688
#define SDL_DISABLE  0
slouken@7191
   689
#define SDL_ENABLE   1
slouken@3407
   690
slouken@3407
   691
/**
slouken@3407
   692
 *  This function allows you to set the state of processing certain events.
slouken@7191
   693
 *   - If \c state is set to ::SDL_IGNORE, that event will be automatically
slouken@3407
   694
 *     dropped from the event queue and will not event be filtered.
slouken@7191
   695
 *   - If \c state is set to ::SDL_ENABLE, that event will be processed
slouken@3407
   696
 *     normally.
slouken@7191
   697
 *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the
slouken@3407
   698
 *     current processing state of the specified event.
slouken@3407
   699
 */
slouken@4429
   700
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
slouken@3407
   701
/*@}*/
slouken@4429
   702
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
slouken@4429
   703
slouken@4429
   704
/**
slouken@4429
   705
 *  This function allocates a set of user-defined events, and returns
slouken@4429
   706
 *  the beginning event number for that set of events.
slouken@4429
   707
 *
slouken@4429
   708
 *  If there aren't enough user-defined events left, this function
slouken@4429
   709
 *  returns (Uint32)-1
slouken@4429
   710
 */
slouken@4429
   711
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
slouken@0
   712
slouken@0
   713
/* Ends C function definitions when using C++ */
slouken@0
   714
#ifdef __cplusplus
slouken@0
   715
}
slouken@0
   716
#endif
slouken@0
   717
#include "close_code.h"
slouken@0
   718
slouken@0
   719
#endif /* _SDL_events_h */
slouken@1895
   720
slouken@1895
   721
/* vi: set ts=4 sw=4 expandtab: */