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