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