include/SDL_events.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 05 Jan 2016 01:42:00 -0500
changeset 10022 30807689ca1b
parent 10020 08b9e569e1ce
child 10638 d11daa346140
permissions -rw-r--r--
Added SDL_DROPBEGIN and SDL_DROPCOMPLETE events, plus window IDs for drops.

This allows an app to know when a set of drops are coming in a grouping of
some sort (for example, a user selected multiple files and dropped them all
on the window with a single drag), and when that set is complete.

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