Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

789 rindas
30 KiB

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