SDL_events.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_events.h
  20. *
  21. * Include file for SDL event handling.
  22. */
  23. #ifndef SDL_events_h_
  24. #define SDL_events_h_
  25. #include "SDL_stdinc.h"
  26. #include "SDL_error.h"
  27. #include "SDL_video.h"
  28. #include "SDL_keyboard.h"
  29. #include "SDL_mouse.h"
  30. #include "SDL_joystick.h"
  31. #include "SDL_gamecontroller.h"
  32. #include "SDL_quit.h"
  33. #include "SDL_gesture.h"
  34. #include "SDL_touch.h"
  35. #include "begin_code.h"
  36. /* Set up for C function definitions, even when using C++ */
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /* General keyboard/mouse state definitions */
  41. #define SDL_RELEASED 0
  42. #define SDL_PRESSED 1
  43. /**
  44. * The types of events that can be delivered.
  45. */
  46. typedef enum
  47. {
  48. SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
  49. /* Application events */
  50. SDL_QUIT = 0x100, /**< User-requested quit */
  51. /* These application events have special meaning on iOS, see README-ios.md for details */
  52. SDL_APP_TERMINATING, /**< The application is being terminated by the OS
  53. Called on iOS in applicationWillTerminate()
  54. Called on Android in onDestroy()
  55. */
  56. SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible.
  57. Called on iOS in applicationDidReceiveMemoryWarning()
  58. Called on Android in onLowMemory()
  59. */
  60. SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background
  61. Called on iOS in applicationWillResignActive()
  62. Called on Android in onPause()
  63. */
  64. SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time
  65. Called on iOS in applicationDidEnterBackground()
  66. Called on Android in onPause()
  67. */
  68. SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground
  69. Called on iOS in applicationWillEnterForeground()
  70. Called on Android in onResume()
  71. */
  72. SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive
  73. Called on iOS in applicationDidBecomeActive()
  74. Called on Android in onResume()
  75. */
  76. SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
  77. /* Display events */
  78. SDL_DISPLAYEVENT = 0x150, /**< Display state change */
  79. /* Window events */
  80. SDL_WINDOWEVENT = 0x200, /**< Window state change */
  81. SDL_SYSWMEVENT, /**< System specific event */
  82. /* Keyboard events */
  83. SDL_KEYDOWN = 0x300, /**< Key pressed */
  84. SDL_KEYUP, /**< Key released */
  85. SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
  86. SDL_TEXTINPUT, /**< Keyboard text input */
  87. SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
  88. input language or keyboard layout change.
  89. */
  90. /* Mouse events */
  91. SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
  92. SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
  93. SDL_MOUSEBUTTONUP, /**< Mouse button released */
  94. SDL_MOUSEWHEEL, /**< Mouse wheel motion */
  95. /* Joystick events */
  96. SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
  97. SDL_JOYBALLMOTION, /**< Joystick trackball motion */
  98. SDL_JOYHATMOTION, /**< Joystick hat position change */
  99. SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
  100. SDL_JOYBUTTONUP, /**< Joystick button released */
  101. SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
  102. SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
  103. /* Game controller events */
  104. SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
  105. SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */
  106. SDL_CONTROLLERBUTTONUP, /**< Game controller button released */
  107. SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
  108. SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
  109. SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
  110. SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
  111. SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
  112. SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
  113. SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
  114. /* Touch events */
  115. SDL_FINGERDOWN = 0x700,
  116. SDL_FINGERUP,
  117. SDL_FINGERMOTION,
  118. /* Gesture events */
  119. SDL_DOLLARGESTURE = 0x800,
  120. SDL_DOLLARRECORD,
  121. SDL_MULTIGESTURE,
  122. /* Clipboard events */
  123. SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
  124. /* Drag and drop events */
  125. SDL_DROPFILE = 0x1000, /**< The system requests a file open */
  126. SDL_DROPTEXT, /**< text/plain drag-and-drop event */
  127. SDL_DROPBEGIN, /**< A new set of drops is beginning (NULL filename) */
  128. SDL_DROPCOMPLETE, /**< Current set of drops is now complete (NULL filename) */
  129. /* Audio hotplug events */
  130. SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
  131. SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */
  132. /* Sensor events */
  133. SDL_SENSORUPDATE = 0x1200, /**< A sensor was updated */
  134. /* Render events */
  135. SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
  136. SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
  137. /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
  138. * and should be allocated with SDL_RegisterEvents()
  139. */
  140. SDL_USEREVENT = 0x8000,
  141. /**
  142. * This last event is only for bounding internal arrays
  143. */
  144. SDL_LASTEVENT = 0xFFFF
  145. } SDL_EventType;
  146. /**
  147. * \brief Fields shared by every event
  148. */
  149. typedef struct SDL_CommonEvent
  150. {
  151. Uint32 type;
  152. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  153. } SDL_CommonEvent;
  154. /**
  155. * \brief Display state change event data (event.display.*)
  156. */
  157. typedef struct SDL_DisplayEvent
  158. {
  159. Uint32 type; /**< ::SDL_DISPLAYEVENT */
  160. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  161. Uint32 display; /**< The associated display index */
  162. Uint8 event; /**< ::SDL_DisplayEventID */
  163. Uint8 padding1;
  164. Uint8 padding2;
  165. Uint8 padding3;
  166. Sint32 data1; /**< event dependent data */
  167. } SDL_DisplayEvent;
  168. /**
  169. * \brief Window state change event data (event.window.*)
  170. */
  171. typedef struct SDL_WindowEvent
  172. {
  173. Uint32 type; /**< ::SDL_WINDOWEVENT */
  174. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  175. Uint32 windowID; /**< The associated window */
  176. Uint8 event; /**< ::SDL_WindowEventID */
  177. Uint8 padding1;
  178. Uint8 padding2;
  179. Uint8 padding3;
  180. Sint32 data1; /**< event dependent data */
  181. Sint32 data2; /**< event dependent data */
  182. } SDL_WindowEvent;
  183. /**
  184. * \brief Keyboard button event structure (event.key.*)
  185. */
  186. typedef struct SDL_KeyboardEvent
  187. {
  188. Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
  189. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  190. Uint32 windowID; /**< The window with keyboard focus, if any */
  191. Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
  192. Uint8 repeat; /**< Non-zero if this is a key repeat */
  193. Uint8 padding2;
  194. Uint8 padding3;
  195. SDL_Keysym keysym; /**< The key that was pressed or released */
  196. } SDL_KeyboardEvent;
  197. #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
  198. /**
  199. * \brief Keyboard text editing event structure (event.edit.*)
  200. */
  201. typedef struct SDL_TextEditingEvent
  202. {
  203. Uint32 type; /**< ::SDL_TEXTEDITING */
  204. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  205. Uint32 windowID; /**< The window with keyboard focus, if any */
  206. char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
  207. Sint32 start; /**< The start cursor of selected editing text */
  208. Sint32 length; /**< The length of selected editing text */
  209. } SDL_TextEditingEvent;
  210. #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
  211. /**
  212. * \brief Keyboard text input event structure (event.text.*)
  213. */
  214. typedef struct SDL_TextInputEvent
  215. {
  216. Uint32 type; /**< ::SDL_TEXTINPUT */
  217. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  218. Uint32 windowID; /**< The window with keyboard focus, if any */
  219. char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
  220. } SDL_TextInputEvent;
  221. /**
  222. * \brief Mouse motion event structure (event.motion.*)
  223. */
  224. typedef struct SDL_MouseMotionEvent
  225. {
  226. Uint32 type; /**< ::SDL_MOUSEMOTION */
  227. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  228. Uint32 windowID; /**< The window with mouse focus, if any */
  229. Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
  230. Uint32 state; /**< The current button state */
  231. Sint32 x; /**< X coordinate, relative to window */
  232. Sint32 y; /**< Y coordinate, relative to window */
  233. Sint32 xrel; /**< The relative motion in the X direction */
  234. Sint32 yrel; /**< The relative motion in the Y direction */
  235. } SDL_MouseMotionEvent;
  236. /**
  237. * \brief Mouse button event structure (event.button.*)
  238. */
  239. typedef struct SDL_MouseButtonEvent
  240. {
  241. Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
  242. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  243. Uint32 windowID; /**< The window with mouse focus, if any */
  244. Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
  245. Uint8 button; /**< The mouse button index */
  246. Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
  247. Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
  248. Uint8 padding1;
  249. Sint32 x; /**< X coordinate, relative to window */
  250. Sint32 y; /**< Y coordinate, relative to window */
  251. } SDL_MouseButtonEvent;
  252. /**
  253. * \brief Mouse wheel event structure (event.wheel.*)
  254. */
  255. typedef struct SDL_MouseWheelEvent
  256. {
  257. Uint32 type; /**< ::SDL_MOUSEWHEEL */
  258. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  259. Uint32 windowID; /**< The window with mouse focus, if any */
  260. Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
  261. Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
  262. Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
  263. 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 */
  264. } SDL_MouseWheelEvent;
  265. /**
  266. * \brief Joystick axis motion event structure (event.jaxis.*)
  267. */
  268. typedef struct SDL_JoyAxisEvent
  269. {
  270. Uint32 type; /**< ::SDL_JOYAXISMOTION */
  271. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  272. SDL_JoystickID which; /**< The joystick instance id */
  273. Uint8 axis; /**< The joystick axis index */
  274. Uint8 padding1;
  275. Uint8 padding2;
  276. Uint8 padding3;
  277. Sint16 value; /**< The axis value (range: -32768 to 32767) */
  278. Uint16 padding4;
  279. } SDL_JoyAxisEvent;
  280. /**
  281. * \brief Joystick trackball motion event structure (event.jball.*)
  282. */
  283. typedef struct SDL_JoyBallEvent
  284. {
  285. Uint32 type; /**< ::SDL_JOYBALLMOTION */
  286. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  287. SDL_JoystickID which; /**< The joystick instance id */
  288. Uint8 ball; /**< The joystick trackball index */
  289. Uint8 padding1;
  290. Uint8 padding2;
  291. Uint8 padding3;
  292. Sint16 xrel; /**< The relative motion in the X direction */
  293. Sint16 yrel; /**< The relative motion in the Y direction */
  294. } SDL_JoyBallEvent;
  295. /**
  296. * \brief Joystick hat position change event structure (event.jhat.*)
  297. */
  298. typedef struct SDL_JoyHatEvent
  299. {
  300. Uint32 type; /**< ::SDL_JOYHATMOTION */
  301. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  302. SDL_JoystickID which; /**< The joystick instance id */
  303. Uint8 hat; /**< The joystick hat index */
  304. Uint8 value; /**< The hat position value.
  305. * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
  306. * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
  307. * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
  308. *
  309. * Note that zero means the POV is centered.
  310. */
  311. Uint8 padding1;
  312. Uint8 padding2;
  313. } SDL_JoyHatEvent;
  314. /**
  315. * \brief Joystick button event structure (event.jbutton.*)
  316. */
  317. typedef struct SDL_JoyButtonEvent
  318. {
  319. Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
  320. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  321. SDL_JoystickID which; /**< The joystick instance id */
  322. Uint8 button; /**< The joystick button index */
  323. Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
  324. Uint8 padding1;
  325. Uint8 padding2;
  326. } SDL_JoyButtonEvent;
  327. /**
  328. * \brief Joystick device event structure (event.jdevice.*)
  329. */
  330. typedef struct SDL_JoyDeviceEvent
  331. {
  332. Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
  333. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  334. Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
  335. } SDL_JoyDeviceEvent;
  336. /**
  337. * \brief Game controller axis motion event structure (event.caxis.*)
  338. */
  339. typedef struct SDL_ControllerAxisEvent
  340. {
  341. Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
  342. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  343. SDL_JoystickID which; /**< The joystick instance id */
  344. Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
  345. Uint8 padding1;
  346. Uint8 padding2;
  347. Uint8 padding3;
  348. Sint16 value; /**< The axis value (range: -32768 to 32767) */
  349. Uint16 padding4;
  350. } SDL_ControllerAxisEvent;
  351. /**
  352. * \brief Game controller button event structure (event.cbutton.*)
  353. */
  354. typedef struct SDL_ControllerButtonEvent
  355. {
  356. Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
  357. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  358. SDL_JoystickID which; /**< The joystick instance id */
  359. Uint8 button; /**< The controller button (SDL_GameControllerButton) */
  360. Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
  361. Uint8 padding1;
  362. Uint8 padding2;
  363. } SDL_ControllerButtonEvent;
  364. /**
  365. * \brief Controller device event structure (event.cdevice.*)
  366. */
  367. typedef struct SDL_ControllerDeviceEvent
  368. {
  369. Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
  370. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  371. Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
  372. } SDL_ControllerDeviceEvent;
  373. /**
  374. * \brief Game controller touchpad event structure (event.ctouchpad.*)
  375. */
  376. typedef struct SDL_ControllerTouchpadEvent
  377. {
  378. Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
  379. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  380. SDL_JoystickID which; /**< The joystick instance id */
  381. Sint32 touchpad; /**< The index of the touchpad */
  382. Sint32 finger; /**< The index of the finger on the touchpad */
  383. float x; /**< Normalized in the range 0...1 with 0 being on the left */
  384. float y; /**< Normalized in the range 0...1 with 0 being at the top */
  385. float pressure; /**< Normalized in the range 0...1 */
  386. } SDL_ControllerTouchpadEvent;
  387. /**
  388. * \brief Game controller sensor event structure (event.csensor.*)
  389. */
  390. typedef struct SDL_ControllerSensorEvent
  391. {
  392. Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
  393. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  394. SDL_JoystickID which; /**< The joystick instance id */
  395. Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
  396. float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
  397. } SDL_ControllerSensorEvent;
  398. /**
  399. * \brief Audio device event structure (event.adevice.*)
  400. */
  401. typedef struct SDL_AudioDeviceEvent
  402. {
  403. Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
  404. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  405. Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
  406. Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
  407. Uint8 padding1;
  408. Uint8 padding2;
  409. Uint8 padding3;
  410. } SDL_AudioDeviceEvent;
  411. /**
  412. * \brief Touch finger event structure (event.tfinger.*)
  413. */
  414. typedef struct SDL_TouchFingerEvent
  415. {
  416. Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
  417. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  418. SDL_TouchID touchId; /**< The touch device id */
  419. SDL_FingerID fingerId;
  420. float x; /**< Normalized in the range 0...1 */
  421. float y; /**< Normalized in the range 0...1 */
  422. float dx; /**< Normalized in the range -1...1 */
  423. float dy; /**< Normalized in the range -1...1 */
  424. float pressure; /**< Normalized in the range 0...1 */
  425. Uint32 windowID; /**< The window underneath the finger, if any */
  426. } SDL_TouchFingerEvent;
  427. /**
  428. * \brief Multiple Finger Gesture Event (event.mgesture.*)
  429. */
  430. typedef struct SDL_MultiGestureEvent
  431. {
  432. Uint32 type; /**< ::SDL_MULTIGESTURE */
  433. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  434. SDL_TouchID touchId; /**< The touch device id */
  435. float dTheta;
  436. float dDist;
  437. float x;
  438. float y;
  439. Uint16 numFingers;
  440. Uint16 padding;
  441. } SDL_MultiGestureEvent;
  442. /**
  443. * \brief Dollar Gesture Event (event.dgesture.*)
  444. */
  445. typedef struct SDL_DollarGestureEvent
  446. {
  447. Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
  448. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  449. SDL_TouchID touchId; /**< The touch device id */
  450. SDL_GestureID gestureId;
  451. Uint32 numFingers;
  452. float error;
  453. float x; /**< Normalized center of gesture */
  454. float y; /**< Normalized center of gesture */
  455. } SDL_DollarGestureEvent;
  456. /**
  457. * \brief An event used to request a file open by the system (event.drop.*)
  458. * This event is enabled by default, you can disable it with SDL_EventState().
  459. * \note If this event is enabled, you must free the filename in the event.
  460. */
  461. typedef struct SDL_DropEvent
  462. {
  463. Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
  464. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  465. char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
  466. Uint32 windowID; /**< The window that was dropped on, if any */
  467. } SDL_DropEvent;
  468. /**
  469. * \brief Sensor event structure (event.sensor.*)
  470. */
  471. typedef struct SDL_SensorEvent
  472. {
  473. Uint32 type; /**< ::SDL_SENSORUPDATE */
  474. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  475. Sint32 which; /**< The instance ID of the sensor */
  476. float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
  477. } SDL_SensorEvent;
  478. /**
  479. * \brief The "quit requested" event
  480. */
  481. typedef struct SDL_QuitEvent
  482. {
  483. Uint32 type; /**< ::SDL_QUIT */
  484. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  485. } SDL_QuitEvent;
  486. /**
  487. * \brief OS Specific event
  488. */
  489. typedef struct SDL_OSEvent
  490. {
  491. Uint32 type; /**< ::SDL_QUIT */
  492. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  493. } SDL_OSEvent;
  494. /**
  495. * \brief A user-defined event type (event.user.*)
  496. */
  497. typedef struct SDL_UserEvent
  498. {
  499. Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
  500. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  501. Uint32 windowID; /**< The associated window if any */
  502. Sint32 code; /**< User defined event code */
  503. void *data1; /**< User defined data pointer */
  504. void *data2; /**< User defined data pointer */
  505. } SDL_UserEvent;
  506. struct SDL_SysWMmsg;
  507. typedef struct SDL_SysWMmsg SDL_SysWMmsg;
  508. /**
  509. * \brief A video driver dependent system event (event.syswm.*)
  510. * This event is disabled by default, you can enable it with SDL_EventState()
  511. *
  512. * \note If you want to use this event, you should include SDL_syswm.h.
  513. */
  514. typedef struct SDL_SysWMEvent
  515. {
  516. Uint32 type; /**< ::SDL_SYSWMEVENT */
  517. Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
  518. SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
  519. } SDL_SysWMEvent;
  520. /**
  521. * \brief General event structure
  522. */
  523. typedef union SDL_Event
  524. {
  525. Uint32 type; /**< Event type, shared with all events */
  526. SDL_CommonEvent common; /**< Common event data */
  527. SDL_DisplayEvent display; /**< Display event data */
  528. SDL_WindowEvent window; /**< Window event data */
  529. SDL_KeyboardEvent key; /**< Keyboard event data */
  530. SDL_TextEditingEvent edit; /**< Text editing event data */
  531. SDL_TextInputEvent text; /**< Text input event data */
  532. SDL_MouseMotionEvent motion; /**< Mouse motion event data */
  533. SDL_MouseButtonEvent button; /**< Mouse button event data */
  534. SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
  535. SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
  536. SDL_JoyBallEvent jball; /**< Joystick ball event data */
  537. SDL_JoyHatEvent jhat; /**< Joystick hat event data */
  538. SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
  539. SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
  540. SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
  541. SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
  542. SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
  543. SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
  544. SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
  545. SDL_AudioDeviceEvent adevice; /**< Audio device event data */
  546. SDL_SensorEvent sensor; /**< Sensor event data */
  547. SDL_QuitEvent quit; /**< Quit request event data */
  548. SDL_UserEvent user; /**< Custom event data */
  549. SDL_SysWMEvent syswm; /**< System dependent window event data */
  550. SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
  551. SDL_MultiGestureEvent mgesture; /**< Gesture event data */
  552. SDL_DollarGestureEvent dgesture; /**< Gesture event data */
  553. SDL_DropEvent drop; /**< Drag and drop event data */
  554. /* This is necessary for ABI compatibility between Visual C++ and GCC
  555. Visual C++ will respect the push pack pragma and use 52 bytes for
  556. this structure, and GCC will use the alignment of the largest datatype
  557. within the union, which is 8 bytes.
  558. So... we'll add padding to force the size to be 56 bytes for both.
  559. */
  560. Uint8 padding[56];
  561. } SDL_Event;
  562. /* Make sure we haven't broken binary compatibility */
  563. SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56);
  564. /* Function prototypes */
  565. /**
  566. * Pump the event loop, gathering events from the input devices.
  567. *
  568. * This function updates the event queue and internal input device state.
  569. *
  570. * **WARNING**: This should only be run in the thread that initialized the
  571. * video subsystem, and for extra safety, you should consider only doing those
  572. * things on the main thread in any case.
  573. *
  574. * SDL_PumpEvents() gathers all the pending input information from devices and
  575. * places it in the event queue. Without calls to SDL_PumpEvents() no events
  576. * would ever be placed on the queue. Often the need for calls to
  577. * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
  578. * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
  579. * polling or waiting for events (e.g. you are filtering them), then you must
  580. * call SDL_PumpEvents() to force an event queue update.
  581. *
  582. * \sa SDL_PollEvent
  583. * \sa SDL_WaitEvent
  584. */
  585. extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
  586. /* @{ */
  587. typedef enum
  588. {
  589. SDL_ADDEVENT,
  590. SDL_PEEKEVENT,
  591. SDL_GETEVENT
  592. } SDL_eventaction;
  593. /**
  594. * Check the event queue for messages and optionally return them.
  595. *
  596. * `action` may be any of the following:
  597. *
  598. * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of
  599. * the event queue.
  600. * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
  601. * within the specified minimum and maximum type, will be returned to the
  602. * caller and will _not_ be removed from the queue.
  603. * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
  604. * within the specified minimum and maximum type, will be returned to the
  605. * caller and will be removed from the queue.
  606. *
  607. * You may have to call SDL_PumpEvents() before calling this function.
  608. * Otherwise, the events may not be ready to be filtered when you call
  609. * SDL_PeepEvents().
  610. *
  611. * This function is thread-safe.
  612. *
  613. * \param events destination buffer for the retrieved events
  614. * \param numevents if action is SDL_ADDEVENT, the number of events to add
  615. * back to the event queue; if action is SDL_PEEKEVENT or
  616. * SDL_GETEVENT, the maximum number of events to retrieve
  617. * \param action action to take; see [[#action|Remarks]] for details
  618. * \param minType minimum value of the event type to be considered;
  619. * SDL_FIRSTEVENT is a safe choice
  620. * \param maxType maximum value of the event type to be considered;
  621. * SDL_LASTEVENT is a safe choice
  622. * \returns the number of events actually stored or a negative error code on
  623. * failure; call SDL_GetError() for more information.
  624. *
  625. * \sa SDL_PollEvent
  626. * \sa SDL_PumpEvents
  627. * \sa SDL_PushEvent
  628. */
  629. extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
  630. SDL_eventaction action,
  631. Uint32 minType, Uint32 maxType);
  632. /* @} */
  633. /**
  634. * Check for the existence of a certain event type in the event queue.
  635. *
  636. * If you need to check for a range of event types, use SDL_HasEvents()
  637. * instead.
  638. *
  639. * \param type the type of event to be queried; see SDL_EventType for details
  640. * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
  641. * events matching `type` are not present.
  642. *
  643. * \sa SDL_HasEvents
  644. */
  645. extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
  646. /**
  647. * Check for the existence of certain event types in the event queue.
  648. *
  649. * If you need to check for a single event type, use SDL_HasEvent() instead.
  650. *
  651. * \param minType the low end of event type to be queried, inclusive; see
  652. * SDL_EventType for details
  653. * \param maxType the high end of event type to be queried, inclusive; see
  654. * SDL_EventType for details
  655. * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
  656. * present, or SDL_FALSE if not.
  657. *
  658. * \sa SDL_HasEvents
  659. */
  660. extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
  661. /**
  662. * Clear events of a specific type from the event queue.
  663. *
  664. * This will unconditionally remove any events from the queue that match
  665. * `type`. If you need to remove a range of event types, use SDL_FlushEvents()
  666. * instead.
  667. *
  668. * It's also normal to just ignore events you don't care about in your event
  669. * loop without calling this function.
  670. *
  671. * This function only affects currently queued events. If you want to make
  672. * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
  673. * on the main thread immediately before the flush call.
  674. *
  675. * \param type the type of event to be cleared; see SDL_EventType for details
  676. *
  677. * \sa SDL_FlushEvents
  678. */
  679. extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
  680. /**
  681. * Clear events of a range of types from the event queue.
  682. *
  683. * This will unconditionally remove any events from the queue that are in the
  684. * range of `minType` to `maxType`, inclusive. If you need to remove a single
  685. * event type, use SDL_FlushEvent() instead.
  686. *
  687. * It's also normal to just ignore events you don't care about in your event
  688. * loop without calling this function.
  689. *
  690. * This function only affects currently queued events. If you want to make
  691. * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
  692. * on the main thread immediately before the flush call.
  693. *
  694. * \param minType the low end of event type to be cleared, inclusive; see
  695. * SDL_EventType for details
  696. * \param maxType the high end of event type to be cleared, inclusive; see
  697. * SDL_EventType for details
  698. *
  699. * \sa SDL_FlushEvent
  700. */
  701. extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
  702. /**
  703. * Poll for currently pending events.
  704. *
  705. * If `event` is not NULL, the next event is removed from the queue and
  706. * stored in the SDL_Event structure pointed to by `event`. The 1 returned
  707. * refers to this event, immediately stored in the SDL Event structure -- not
  708. * an event to follow.
  709. *
  710. * If `event` is NULL, it simply returns 1 if there is an event in the queue,
  711. * but will not remove it from the queue.
  712. *
  713. * As this function implicitly calls SDL_PumpEvents(), you can only call this
  714. * function in the thread that set the video mode.
  715. *
  716. * SDL_PollEvent() is the favored way of receiving system events since it can
  717. * be done from the main loop and does not suspend the main loop while waiting
  718. * on an event to be posted.
  719. *
  720. * The common practice is to fully process the event queue once every frame,
  721. * usually as a first step before updating the game's state:
  722. *
  723. * ```c
  724. * while (game_is_still_running) {
  725. * SDL_Event event;
  726. * while (SDL_PollEvent(&event)) { // poll until all events are handled!
  727. * // decide what to do with this event.
  728. * }
  729. *
  730. * // update game state, draw the current frame
  731. * }
  732. * ```
  733. *
  734. * \param event the SDL_Event structure to be filled with the next event from
  735. * the queue, or NULL
  736. * \returns 1 if there is a pending event or 0 if there are none available.
  737. *
  738. * \sa SDL_GetEventFilter
  739. * \sa SDL_PeepEvents
  740. * \sa SDL_PushEvent
  741. * \sa SDL_SetEventFilter
  742. * \sa SDL_WaitEvent
  743. * \sa SDL_WaitEventTimeout
  744. */
  745. extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
  746. /**
  747. * Wait indefinitely for the next available event.
  748. *
  749. * If `event` is not NULL, the next event is removed from the queue and
  750. * stored in the SDL_Event structure pointed to by `event`.
  751. *
  752. * As this function implicitly calls SDL_PumpEvents(), you can only call this
  753. * function in the thread that initialized the video subsystem.
  754. *
  755. * \param event the SDL_Event structure to be filled in with the next event
  756. * from the queue, or NULL
  757. * \returns 1 on success or 0 if there was an error while waiting for events;
  758. * call SDL_GetError() for more information.
  759. *
  760. * \sa SDL_PollEvent
  761. * \sa SDL_PumpEvents
  762. * \sa SDL_WaitEventTimeout
  763. */
  764. extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
  765. /**
  766. * Wait until the specified timeout (in milliseconds) for
  767. * the next available event.
  768. *
  769. * If `event` is not NULL, the next event is removed from the queue and
  770. * stored in the SDL_Event structure pointed to by `event`.
  771. *
  772. * As this function implicitly calls SDL_PumpEvents(), you can only call this
  773. * function in the thread that initialized the video subsystem.
  774. *
  775. * \param event the SDL_Event structure to be filled in with the next event
  776. * from the queue, or NULL
  777. * \param timeout the maximum number of milliseconds to wait for the next
  778. * available event
  779. * \returns 1 on success or 0 if there was an error while waiting for events;
  780. * call SDL_GetError() for more information. This also returns 0 if
  781. * the timeout elapsed without an event arriving.
  782. *
  783. * \sa SDL_PollEvent
  784. * \sa SDL_PumpEvents
  785. * \sa SDL_WaitEvent
  786. */
  787. extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
  788. int timeout);
  789. /**
  790. * Add an event to the event queue.
  791. *
  792. * The event queue can actually be used as a two way communication channel.
  793. * Not only can events be read from the queue, but the user can also push
  794. * their own events onto it. `event` is a pointer to the event structure you
  795. * wish to push onto the queue. The event is copied into the queue, and the
  796. * caller may dispose of the memory pointed to after SDL_PushEvent() returns.
  797. *
  798. * Note: Pushing device input events onto the queue doesn't modify the state
  799. * of the device within SDL.
  800. *
  801. * This function is thread-safe, and can be called from other threads safely.
  802. *
  803. * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
  804. * the event filter but events added with SDL_PeepEvents() do not.
  805. *
  806. * For pushing application-specific events, please use SDL_RegisterEvents() to
  807. * get an event type that does not conflict with other code that also wants
  808. * its own custom event types.
  809. *
  810. * \param event the SDL_Event to be added to the queue
  811. * \returns 1 on success, 0 if the event was filtered, or a negative error
  812. * code on failure; call SDL_GetError() for more information. A
  813. * common reason for error is the event queue being full.
  814. *
  815. * \sa SDL_PeepEvents
  816. * \sa SDL_PollEvent
  817. * \sa SDL_RegisterEvents
  818. */
  819. extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
  820. /**
  821. * A function pointer used for callbacks that watch the event queue.
  822. *
  823. * \param userdata what was passed as `userdata` to SDL_SetEventFilter()
  824. * or SDL_AddEventWatch, etc
  825. * \param event the event that triggered the callback
  826. * \returns Filters return 1 to permit event to be added to the queue, and
  827. * 0 to disallow it. When used with SDL_AddEventWatch, the return
  828. * value is ignored.
  829. *
  830. * \sa SDL_SetEventFilter
  831. * \sa SDL_AddEventWatch
  832. */
  833. typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
  834. /**
  835. * Set up a filter to process all events before they change internal state and
  836. * are posted to the internal event queue.
  837. *
  838. * If the filter function returns 1 when called, then the event will be added
  839. * to the internal queue. If it returns 0, then the event will be dropped from
  840. * the queue, but the internal state will still be updated. This allows
  841. * selective filtering of dynamically arriving events.
  842. *
  843. * **WARNING**: Be very careful of what you do in the event filter function,
  844. * as it may run in a different thread!
  845. *
  846. * On platforms that support it, if the quit event is generated by an
  847. * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
  848. * application at the next event poll.
  849. *
  850. * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
  851. * event filter is only called when the window manager desires to close the
  852. * application window. If the event filter returns 1, then the window will
  853. * be closed, otherwise the window will remain open if possible.
  854. *
  855. * Note: Disabled events never make it to the event filter function; see
  856. * SDL_EventState().
  857. *
  858. * Note: If you just want to inspect events without filtering, you should use
  859. * SDL_AddEventWatch() instead.
  860. *
  861. * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
  862. * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
  863. * not.
  864. *
  865. * \param filter An SDL_EventFilter function to call when an event happens
  866. * \param userdata a pointer that is passed to `filter`
  867. *
  868. * \sa SDL_AddEventWatch
  869. * \sa SDL_EventState
  870. * \sa SDL_GetEventFilter
  871. * \sa SDL_PeepEvents
  872. * \sa SDL_PushEvent
  873. */
  874. extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
  875. void *userdata);
  876. /**
  877. * Query the current event filter.
  878. *
  879. * This function can be used to "chain" filters, by saving the existing filter
  880. * before replacing it with a function that will call that saved filter.
  881. *
  882. * \param filter the current callback function will be stored here
  883. * \param userdata the pointer that is passed to the current event filter will
  884. * be stored here
  885. * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
  886. *
  887. * \sa SDL_SetEventFilter
  888. */
  889. extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
  890. void **userdata);
  891. /**
  892. * Add a callback to be triggered when an event is added to the event queue.
  893. *
  894. * `filter` will be called when an event happens, and its return value is
  895. * ignored.
  896. *
  897. * **WARNING**: Be very careful of what you do in the event filter function,
  898. * as it may run in a different thread!
  899. *
  900. * If the quit event is generated by a signal (e.g. SIGINT), it will bypass
  901. * the internal queue and be delivered to the watch callback immediately, and
  902. * arrive at the next event poll.
  903. *
  904. * Note: the callback is called for events posted by the user through
  905. * SDL_PushEvent(), but not for disabled events, nor for events by a filter
  906. * callback set with SDL_SetEventFilter(), nor for events posted by the user
  907. * through SDL_PeepEvents().
  908. *
  909. * \param filter an SDL_EventFilter function to call when an event happens.
  910. * \param userdata a pointer that is passed to `filter`
  911. *
  912. * \sa SDL_DelEventWatch
  913. * \sa SDL_SetEventFilter
  914. */
  915. extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
  916. void *userdata);
  917. /**
  918. * Remove an event watch callback added with
  919. * SDL_AddEventWatch().
  920. *
  921. * This function takes the same input as SDL_AddEventWatch() to identify and
  922. * delete the corresponding callback.
  923. *
  924. * \param filter the function originally passed to SDL_AddEventWatch()
  925. * \param userdata the pointer originally passed to SDL_AddEventWatch()
  926. *
  927. * \sa SDL_AddEventWatch
  928. */
  929. extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
  930. void *userdata);
  931. /**
  932. * Run a specific filter function on the current event
  933. * queue, removing any events for which the filter returns 0.
  934. *
  935. * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
  936. * this function does not change the filter permanently, it only uses the
  937. * supplied filter until this function returns.
  938. *
  939. * \param filter the SDL_EventFilter function to call when an event happens
  940. * \param userdata a pointer that is passed to `filter`
  941. *
  942. * \sa SDL_GetEventFilter
  943. * \sa SDL_SetEventFilter
  944. */
  945. extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
  946. void *userdata);
  947. /* @{ */
  948. #define SDL_QUERY -1
  949. #define SDL_IGNORE 0
  950. #define SDL_DISABLE 0
  951. #define SDL_ENABLE 1
  952. /**
  953. * Set the state of processing events by type.
  954. *
  955. * `state` may be any of the following:
  956. *
  957. * - `SDL_QUERY`: returns the current processing state of the specified event
  958. * - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped
  959. * from the event queue and will not be filtered
  960. * - `SDL_ENABLE`: the event will be processed normally
  961. *
  962. * \param type the type of event; see SDL_EventType for details
  963. * \param state how to process the event
  964. * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
  965. * of the event before this function makes any changes to it.
  966. *
  967. * \sa SDL_GetEventState
  968. */
  969. extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
  970. /* @} */
  971. #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
  972. /**
  973. * Allocate a set of user-defined events, and return the beginning event
  974. * number for that set of events.
  975. *
  976. * Calling this function with `numevents` <= 0 is an error and will return
  977. * (Uint32)-1.
  978. *
  979. * Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
  980. * 0xFFFFFFFF), but is clearer to write.
  981. *
  982. * \param numevents the number of events to be allocated
  983. * \returns The beginning event number, or (Uint32)-1 if there are not enough
  984. * user-defined events left.
  985. *
  986. * \since This function is available since SDL 2.0.0.
  987. *
  988. * \sa SDL_PushEvent
  989. */
  990. extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
  991. /* Ends C function definitions when using C++ */
  992. #ifdef __cplusplus
  993. }
  994. #endif
  995. #include "close_code.h"
  996. #endif /* SDL_events_h_ */
  997. /* vi: set ts=4 sw=4 expandtab: */