🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1150 lines
45 KiB

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