SDL standard library

Dependents:   H261_encoder

Committer:
miruga27
Date:
Wed Sep 07 18:46:53 2016 +0000
Revision:
0:dda4f4550403
7/09/2016;

Who changed what in which revision?

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