SDL Library

Dependents:   H261_decoder

Committer:
miruga27
Date:
Thu Sep 22 00:03:09 2016 +0000
Revision:
0:7fb6877b5d7c
SDL

Who changed what in which revision?

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