sdlevents.inc 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  1. //from "sdl_events.h"
  2. type
  3. PPSDL_EventType = ^PSDL_EventType;
  4. PSDL_EventType = ^TSDL_EventType;
  5. TSDL_EventType = type cuint32;
  6. {**
  7. * The types of events that can be delivered.
  8. *}
  9. const
  10. { General keyboard/mouse state definitions }
  11. SDL_RELEASED = 0;
  12. SDL_PRESSED = 1;
  13. SDL_FIRSTEVENT = TSDL_EventType(0); // Unused (do not remove) (needed in pascal?)
  14. SDL_COMMONEVENT = TSDL_EventType(1); //added for pascal-compatibility
  15. { Application events }
  16. SDL_QUITEV = TSDL_EventType($100); // User-requested quit (originally SDL_QUIT, but changed, cause theres a method called SDL_QUIT)
  17. { These application events have special meaning on iOS, see README.iOS for details *}
  18. {* The application is being terminated by the OS. *
  19. * Called on iOS in applicationWillTerminate() *
  20. * Called on Android in onDestroy() *}
  21. SDL_APP_TERMINATING = TSDL_EventType($101);
  22. {* The application is low on memory, free memory if possible. *
  23. * Called on iOS in applicationDidReceiveMemoryWarning() *
  24. * Called on Android in onLowMemory() *}
  25. SDL_APP_LOWMEMORY = TSDL_EventType($102);
  26. {* The application is about to enter the background. *
  27. * Called on iOS in applicationWillResignActive() *
  28. * Called on Android in onPause() *}
  29. SDL_APP_WILLENTERBACKGROUND = TSDL_EventType($103);
  30. {* The application did enter the background and may not get CPU for some time. *
  31. * Called on iOS in applicationDidEnterBackground() *
  32. * Called on Android in onPause() *}
  33. SDL_APP_DIDENTERBACKGROUND = TSDL_EventType($104);
  34. {* The application is about to enter the foreground. *
  35. * Called on iOS in applicationWillEnterForeground() *
  36. * Called on Android in onResume() *}
  37. SDL_APP_WILLENTERFOREGROUND = TSDL_EventType($105);
  38. {* The application is now interactive. *
  39. * Called on iOS in applicationDidBecomeActive() *
  40. * Called on Android in onResume() *}
  41. SDL_APP_DIDENTERFOREGROUND = TSDL_EventType($106);
  42. {* The user's locale preferences have changed. *}
  43. SDL_LOCALECHANGED = TSDL_EventType($107);
  44. { Display events }
  45. SDL_DISPLAYEVENT = TSDL_EventType($150); // Display state change
  46. { Window events }
  47. SDL_WINDOWEVENT = TSDL_EventType($200); // Window state change
  48. SDL_SYSWMEVENT = TSDL_EventType($201); // System specific event
  49. { Keyboard events }
  50. SDL_KEYDOWN = TSDL_EventType($300); // Key pressed
  51. SDL_KEYUP = TSDL_EventType($301); // Key released
  52. SDL_TEXTEDITING = TSDL_EventType($302); // Keyboard text editing (composition)
  53. SDL_TEXTINPUT = TSDL_EventType($303); // Keyboard text input
  54. SDL_KEYMAPCHANGED = TSDL_EventType($304); // Keymap changed due to a system event such as an input language or keyboard layout change.
  55. SDL_TEXTEDITING_EXT = TSDL_EventType($305); // Extended keyboard text editing (composition)
  56. { Mouse events }
  57. SDL_MOUSEMOTION = TSDL_EventType($400); // Mouse moved
  58. SDL_MOUSEBUTTONDOWN = TSDL_EventType($401); // Mouse button pressed
  59. SDL_MOUSEBUTTONUP = TSDL_EventType($402); // Mouse button released
  60. SDL_MOUSEWHEEL = TSDL_EventType($403); // Mouse wheel motion
  61. { Joystick events }
  62. SDL_JOYAXISMOTION = TSDL_EventType($600); // Joystick axis motion
  63. SDL_JOYBALLMOTION = TSDL_EventType($601); // Joystick trackball motion
  64. SDL_JOYHATMOTION = TSDL_EventType($602); // Joystick hat position change
  65. SDL_JOYBUTTONDOWN = TSDL_EventType($603); // Joystick button pressed
  66. SDL_JOYBUTTONUP = TSDL_EventType($604); // Joystick button released
  67. SDL_JOYDEVICEADDED = TSDL_EventType($605); // A new joystick has been inserted into the system
  68. SDL_JOYDEVICEREMOVED = TSDL_EventType($606); // An opened joystick has been removed
  69. SDL_JOYBATTERYUPDATED = TSDL_EventType($607); // Joystick battery level change
  70. { Game controller events }
  71. SDL_CONTROLLERAXISMOTION = TSDL_EventType($650); // Game controller axis motion
  72. SDL_CONTROLLERBUTTONDOWN = TSDL_EventType($651); // Game controller button pressed
  73. SDL_CONTROLLERBUTTONUP = TSDL_EventType($652); // Game controller button released
  74. SDL_CONTROLLERDEVICEADDED = TSDL_EventType($653); // A new Game controller has been inserted into the system
  75. SDL_CONTROLLERDEVICEREMOVED = TSDL_EventType($654); // An opened Game controller has been removed
  76. SDL_CONTROLLERDEVICEREMAPPED = TSDL_EventType($655); // The controller mapping was updated
  77. SDL_CONTROLLERTOUCHPADDOWN = TSDL_EventType($666); // Game controller touchpad was touched
  78. SDL_CONTROLLERTOUCHPADMOTION = TSDL_EventType($667); // Game controller touchpad finger was moved
  79. SDL_CONTROLLERTOUCHPADUP = TSDL_EventType($668); // Game controller touchpad finger was lifted
  80. SDL_CONTROLLERSENSORUPDATE = TSDL_EventType($669); // Game controller sensor was updated
  81. { Touch events }
  82. SDL_FINGERDOWN = TSDL_EventType($700);
  83. SDL_FINGERUP = TSDL_EventType($701);
  84. SDL_FINGERMOTION = TSDL_EventType($702);
  85. { Gesture events }
  86. SDL_DOLLARGESTURE = TSDL_EventType($800);
  87. SDL_DOLLARRECORD = TSDL_EventType($801);
  88. SDL_MULTIGESTURE = TSDL_EventType($802);
  89. { Clipboard events }
  90. SDL_CLIPBOARDUPDATE = TSDL_EventType($900); // The clipboard changed
  91. { Drag and drop events }
  92. SDL_DROPFILE = TSDL_EventType($1000); // The system requests a file open
  93. SDL_DROPTEXT = TSDL_EventType($1001); // text/plain drag-and-drop event
  94. SDL_DROPBEGIN = TSDL_EventType($1002); // A new set of drops is beginning (NULL filename)
  95. SDL_DROPCOMPLETE = TSDL_EventType($1003); // Current set of drops is now complete (NULL filename)
  96. { Audio hotplug events }
  97. SDL_AUDIODEVICEADDED = TSDL_EventType($1100); // A new audio device is available
  98. SDL_AUDIODEVICEREMOVED = TSDL_EventType($1101); // An audio device has been removed.
  99. { Sensor events }
  100. SDL_SENSORUPDATED = TSDL_EventType($1200); // A sensor was updated
  101. { Render events }
  102. SDL_RENDER_TARGETS_RESET = TSDL_EventType($2000); // The render targets have been reset
  103. SDL_RENDER_DEVICE_RESET = TSDL_EventType($2001); // The device has been reset and all textures need to be recreated
  104. { Internal events }
  105. SDL_POLLSENTINEL = TSDL_EventType($7F00); // Signals the end of an event poll cycle
  106. {** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
  107. * and should be allocated with SDL_RegisterEvents()
  108. *}
  109. SDL_USEREVENT = TSDL_EventType($8000);
  110. {**
  111. * This last event is only for bounding internal arrays (needed in pascal ??)
  112. *}
  113. SDL_LASTEVENT = TSDL_EventType($FFFF);
  114. type
  115. {**
  116. * Fields shared by every event
  117. *}
  118. PPSDL_CommonEvent = ^PSDL_CommonEvent;
  119. PSDL_CommonEvent = ^TSDL_CommonEvent;
  120. TSDL_CommonEvent = record
  121. type_: cuint32;
  122. timestamp: cuint32;
  123. end;
  124. {**
  125. * Display state change event data (event.display.*)
  126. *}
  127. PPSDL_DisplayEvent = ^PSDL_DisplayEvent;
  128. PSDL_DisplayEvent = ^TSDL_DisplayEvent;
  129. TSDL_DisplayEvent = record
  130. type_: cuint32; // SDL_DISPLAYEVENT
  131. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  132. display: cuint32; // The associated display index
  133. event: cuint8; // SDL_DisplayEventID
  134. padding1: cuint8;
  135. padding2: cuint8;
  136. padding3: cuint8;
  137. data1: cint32; // event dependent data
  138. end;
  139. {**
  140. * Window state change event data (event.window.*)
  141. *}
  142. PPSDL_WindowEvent = ^PSDL_WindowEvent;
  143. PSDL_WindowEvent = ^TSDL_WindowEvent;
  144. TSDL_WindowEvent = record
  145. type_: cuint32; // SDL_WINDOWEVENT
  146. timestamp: cuint32;
  147. windowID: cuint32; // The associated window
  148. event: cuint8; // SDL_WindowEventID
  149. padding1: cuint8;
  150. padding2: cuint8;
  151. padding3: cuint8;
  152. data1: cint32; // event dependent data
  153. data2: cint32; // event dependent data
  154. end;
  155. {**
  156. * Keyboard button event structure (event.key.*)
  157. *}
  158. PPSDL_KeyboardEvent = ^PSDL_KeyboardEvent;
  159. PSDL_KeyboardEvent = ^TSDL_KeyboardEvent;
  160. TSDL_KeyboardEvent = record
  161. type_: cuint32; // SDL_KEYDOWN or SDL_KEYUP
  162. timestamp: cuint32;
  163. windowID: cuint32; // The window with keyboard focus, if any
  164. state: cuint8; // SDL_PRESSED or SDL_RELEASED
  165. repeat_: cuint8; // Non-zero if this is a key repeat
  166. padding2: cuint8;
  167. padding3: cuint8;
  168. keysym: TSDL_KeySym; // The key that was pressed or released
  169. end;
  170. const
  171. SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
  172. type
  173. {**
  174. * Keyboard text editing event structure (event.edit.*)
  175. *}
  176. PPSDL_TextEditingEvent = ^PSDL_TextEditingEvent;
  177. PSDL_TextEditingEvent = ^TSDL_TextEditingEvent;
  178. TSDL_TextEditingEvent = record
  179. type_: cuint32; // SDL_TEXTEDITING
  180. timestamp: cuint32;
  181. windowID: cuint32; // The window with keyboard focus, if any
  182. text: array[0..SDL_TEXTEDITINGEVENT_TEXT_SIZE] of Char; // The editing text
  183. start: cint32; // The start cursor of selected editing text
  184. length: cint32; // The length of selected editing text
  185. end;
  186. {**
  187. * Extended keyboard text editing event structure (event.editExt.*) when text would be
  188. * truncated if stored in the text buffer SDL_TextEditingEvent
  189. *}
  190. PPSDL_TextEditingExtEvent = ^PSDL_TextEditingExtEvent;
  191. PSDL_TextEditingExtEvent = ^TSDL_TextEditingExtEvent;
  192. TSDL_TextEditingExtEvent = record
  193. type_: cuint32; // SDL_TEXTEDITING_EXT
  194. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  195. windowID: cuint32; // The window with keyboard focus, if any
  196. text: PAnsiChar; // The editing text, which should be freed with SDL_free(), and will not be NIL
  197. start: cint32; // The start cursor of selected editing text
  198. length: cint32; // The length of selected editing text
  199. end;
  200. const
  201. SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
  202. type
  203. {**
  204. * Keyboard text input event structure (event.text.*)
  205. *}
  206. PPSDL_TextInputEvent = ^PSDL_TextInputEvent;
  207. PSDL_TextInputEvent = ^TSDL_TextInputEvent;
  208. TSDL_TextInputEvent = record
  209. type_: cuint32; // SDL_TEXTINPUT
  210. timestamp: cuint32;
  211. windowID: cuint32; // The window with keyboard focus, if any
  212. text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char; // The input text
  213. end;
  214. {**
  215. * Mouse motion event structure (event.motion.*)
  216. *}
  217. PPSDL_MouseMotionEvent = ^PSDL_MouseMotionEvent;
  218. PSDL_MouseMotionEvent = ^TSDL_MouseMotionEvent;
  219. TSDL_MouseMotionEvent = record
  220. type_: cuint32; // SDL_MOUSEMOTION
  221. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  222. windowID: cuint32; // The window with mouse focus, if any
  223. which: cuint32; // The mouse instance id, or SDL_TOUCH_MOUSEID
  224. state: cuint32; // The current button state
  225. x: cint32; // X coordinate, relative to window
  226. y: cint32; // Y coordinate, relative to window
  227. xrel: cint32; // The relative motion in the X direction
  228. yrel: cint32; // The relative motion in the Y direction
  229. end;
  230. {**
  231. * Mouse button event structure (event.button.*)
  232. *}
  233. PPSDL_MouseButtonEvent = ^PSDL_MouseButtonEvent;
  234. PSDL_MouseButtonEvent = ^TSDL_MouseButtonEvent;
  235. TSDL_MouseButtonEvent = record
  236. type_: cuint32; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
  237. timestamp: cuint32;
  238. windowID: cuint32; // The window with mouse focus, if any
  239. which: cuint32; // The mouse instance id, or SDL_TOUCH_MOUSEID
  240. button: cuint8; // The mouse button index
  241. state: cuint8; // SDL_PRESSED or SDL_RELEASED
  242. clicks: cuint8; // 1 for single-click, 2 for double-click, etc.
  243. padding1: cuint8;
  244. x: cint32; // X coordinate, relative to window
  245. y: cint32; // Y coordinate, relative to window
  246. end;
  247. {**
  248. * Mouse wheel event structure (event.wheel.*)
  249. *}
  250. PPSDL_MouseWheelEvent = ^PSDL_MouseWheelEvent;
  251. PSDL_MouseWheelEvent = ^TSDL_MouseWheelEvent;
  252. TSDL_MouseWheelEvent = record
  253. type_: cuint32; // SDL_MOUSEWHEEL
  254. timestamp: cuint32;
  255. windowID: cuint32; // The window with mouse focus, if any
  256. which: cuint32; // The mouse instance id, or SDL_TOUCH_MOUSEID
  257. x: cint32; // The amount scrolled horizontally
  258. y: cint32; // The amount scrolled vertically
  259. direction: cuint32; // 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
  260. preciseX: cfloat; // The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18)
  261. preciseY: cfloat; // The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18)
  262. mouseX: cint32; // X coordinate, relative to window (added in 2.26.0)
  263. mouseY: cint32; // Y coordinate, relative to window (added in 2.26.0)
  264. end;
  265. {**
  266. * Joystick axis motion event structure (event.jaxis.*)
  267. *}
  268. PPSDL_JoyAxisEvent = ^PSDL_JoyAxisEvent;
  269. PSDL_JoyAxisEvent = ^TSDL_JoyAxisEvent;
  270. TSDL_JoyAxisEvent = record
  271. type_: cuint32; // SDL_JOYAXISMOTION
  272. timestamp: cuint32;
  273. which: TSDL_JoystickID; // The joystick instance id
  274. axis: cuint8; // The joystick axis index
  275. padding1: cuint8;
  276. padding2: cuint8;
  277. padding3: cuint8;
  278. value: cint16; // The axis value (range: -32768 to 32767)
  279. padding4: cuint16;
  280. end;
  281. {**
  282. * Joystick trackball motion event structure (event.jball.*)
  283. *}
  284. PPSDL_JoyBallEvent = ^PSDL_JoyBallEvent;
  285. PSDL_JoyBallEvent = ^TSDL_JoyBallEvent;
  286. TSDL_JoyBallEvent = record
  287. type_: cuint32; // SDL_JOYBALLMOTION
  288. timestamp: cuint32;
  289. which: TSDL_JoystickID; // The joystick instance id
  290. ball: cuint8; // The joystick trackball index
  291. padding1: cuint8;
  292. padding2: cuint8;
  293. padding3: cuint8;
  294. xrel: cint16; // The relative motion in the X direction
  295. yrel: cint16; // The relative motion in the Y direction
  296. end;
  297. {**
  298. * Joystick hat position change event structure (event.jhat.*)
  299. *}
  300. PPSDL_JoyHatEvent = ^PSDL_JoyHatEvent;
  301. PSDL_JoyHatEvent = ^TSDL_JoyHatEvent;
  302. TSDL_JoyHatEvent = record
  303. type_: cuint32; // SDL_JOYHATMOTION
  304. timestamp: cuint32;
  305. which: TSDL_JoystickID; // The joystick instance id
  306. hat: cuint8; // The joystick hat index
  307. value: cuint8; {* The hat position value.
  308. * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
  309. * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
  310. * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
  311. *
  312. * Note that zero means the POV is centered.
  313. *}
  314. padding1: cuint8;
  315. padding2: cuint8;
  316. end;
  317. {**
  318. * Joystick button event structure (event.jbutton.*)
  319. *}
  320. PPSDL_JoyButtonEvent = ^PSDL_JoyButtonEvent;
  321. PSDL_JoyButtonEvent = ^TSDL_JoyButtonEvent;
  322. TSDL_JoyButtonEvent = record
  323. type_: cuint32; // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
  324. timestamp: cuint32;
  325. which: TSDL_JoystickID; // The joystick instance id
  326. button: cuint8; // The joystick button index
  327. state: cuint8; // SDL_PRESSED or SDL_RELEASED
  328. padding1: cuint8;
  329. padding2: cuint8;
  330. end;
  331. {**
  332. * Joystick device event structure (event.jdevice.*)
  333. *}
  334. PPSDL_JoyDeviceEvent = ^PSDL_JoyDeviceEvent;
  335. PSDL_JoyDeviceEvent = ^TSDL_JoyDeviceEvent;
  336. TSDL_JoyDeviceEvent = record
  337. type_: cuint32; // SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED
  338. timestamp: cuint32;
  339. which: cint32; // The joystick device index for the ADDED event, instance id for the REMOVED event
  340. end;
  341. {**
  342. * Joysick battery level change event structure (event.jbattery.*)
  343. *}
  344. PPSDL_JoyBatteryEvent = ^PSDL_JoyBatteryEvent;
  345. PSDL_JoyBatteryEvent = ^TSDL_JoyBatteryEvent;
  346. TSDL_JoyBatteryEvent = record
  347. type_: cuint32; // SDL_JOYBATTERYUPDATED
  348. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  349. which: TSDL_JoystickID; // The joystick instance id
  350. level: TSDL_JoystickPowerLevel; // The joystick battery level
  351. end;
  352. {**
  353. * Game controller axis motion event structure (event.caxis.*)
  354. *}
  355. PPSDL_ControllerAxisEvent = ^PSDL_ControllerAxisEvent;
  356. PSDL_ControllerAxisEvent = ^TSDL_ControllerAxisEvent;
  357. TSDL_ControllerAxisEvent = record
  358. type_: cuint32; // SDL_CONTROLLERAXISMOTION
  359. timestamp: cuint32;
  360. which: TSDL_JoystickID; // The joystick instance id
  361. axis: cuint8; // The controller axis (SDL_GameControllerAxis)
  362. padding1: cuint8;
  363. padding2: cuint8;
  364. padding3: cuint8;
  365. value: cint16; // The axis value (range: -32768 to 32767)
  366. padding4: cuint16;
  367. end;
  368. {**
  369. * Game controller button event structure (event.cbutton.*)
  370. *}
  371. PPSDL_ControllerButtonEvent = ^PSDL_ControllerButtonEvent;
  372. PSDL_ControllerButtonEvent = ^TSDL_ControllerButtonEvent;
  373. TSDL_ControllerButtonEvent = record
  374. type_: cuint32; // SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP
  375. timestamp: cuint32;
  376. which: TSDL_JoystickID; // The joystick instance id
  377. button: cuint8; // The controller button (SDL_GameControllerButton)
  378. state: cuint8; // SDL_PRESSED or SDL_RELEASED
  379. padding1: cuint8;
  380. padding2: cuint8;
  381. end;
  382. {**
  383. * Controller device event structure (event.cdevice.*)
  384. *}
  385. PPSDL_ControllerDeviceEvent = ^PSDL_ControllerDeviceEvent;
  386. PSDL_ControllerDeviceEvent = ^TSDL_ControllerDeviceEvent;
  387. TSDL_ControllerDeviceEvent = record
  388. type_: cuint32; // SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, or SDL_CONTROLLERDEVICEREMAPPED
  389. timestamp: cuint32;
  390. which: cint32; // The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event
  391. end;
  392. {**
  393. * Game controller touchpad event structure (event.ctouchpad.*)
  394. *}
  395. PPSDL_ControllerTouchpadEvent = ^PSDL_ControllerTouchpadEvent;
  396. PSDL_ControllerTouchpadEvent = ^TSDL_ControllerTouchpadEvent;
  397. TSDL_ControllerTouchpadEvent = record
  398. type_: cuint32; // SDL_CONTROLLERTOUCHPADDOWN or SDL_CONTROLLERTOUCHPADMOTION or SDL_CONTROLLERTOUCHPADUP
  399. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  400. which: TSDL_JoystickID; // The joystick instance id
  401. touchpad: cint32; // The index of the touchpad
  402. finger: cint32; // The index of the finger on the touchpad
  403. x: cfloat; // Normalized in the range 0...1 with 0 being on the left
  404. y: cfloat; // Normalized in the range 0...1 with 0 being at the top
  405. pressure: cfloat; // Normalized in the range 0...1
  406. end;
  407. {**
  408. * Game controller sensor event structure (event.csensor.*)
  409. *}
  410. PPSDL_ControllerSensorEvent = ^PSDL_ControllerSensorEvent;
  411. PSDL_ControllerSensorEvent = ^TSDL_ControllerSensorEvent;
  412. TSDL_ControllerSensorEvent = record
  413. type_: cuint32; // SDL_CONTROLLERSENSORUPDATE
  414. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  415. which: TSDL_JoystickID; // The joystick instance id
  416. sensor: cint32; // The type of the sensor, one of the values of SDL_SensorType
  417. data: array[0..2] of cfloat; // Up to 3 values from the sensor, as defined in SDL_sensor.h
  418. end;
  419. {**
  420. * Audio device event structure (event.adevice.*)
  421. *}
  422. PPSDL_AudioDeviceEvent = ^PSDL_AudioDeviceEvent;
  423. PSDL_AudioDeviceEvent = ^TSDL_AudioDeviceEvent;
  424. TSDL_AudioDeviceEvent = record
  425. type_: cuint32; // ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED
  426. timestamp: cuint32;
  427. which: cuint32; // The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event
  428. iscapture: cuint8; // zero if an output device, non-zero if a capture device.
  429. padding1: cuint8;
  430. padding2: cuint8;
  431. padding3: cuint8;
  432. end;
  433. {**
  434. * Touch finger event structure (event.tfinger.*)
  435. *}
  436. PPSDL_TouchFingerEvent = ^PSDL_TouchFingerEvent;
  437. PSDL_TouchFingerEvent = ^TSDL_TouchFingerEvent;
  438. TSDL_TouchFingerEvent = record
  439. type_: cuint32; // SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP
  440. timestamp: cuint32;
  441. touchId: TSDL_TouchID; // The touch device id
  442. fingerId: TSDL_FingerID;
  443. x: cfloat; // Normalized in the range 0...1
  444. y: cfloat; // Normalized in the range 0...1
  445. dx: cfloat; // Normalized in the range 0...1
  446. dy: cfloat; // Normalized in the range 0...1
  447. pressure: cfloat; // Normalized in the range 0...1
  448. window: cuint32; // The window underneath the finger, if any
  449. end;
  450. {**
  451. * Multiple Finger Gesture Event (event.mgesture.*)
  452. *}
  453. PPSDL_MultiGestureEvent = ^PSDL_MultiGestureEvent;
  454. PSDL_MultiGestureEvent = ^TSDL_MultiGestureEvent;
  455. TSDL_MultiGestureEvent = record
  456. type_: cuint32; // SDL_MULTIGESTURE
  457. timestamp: cuint32;
  458. touchId: TSDL_TouchID; // The touch device index
  459. dTheta: cfloat;
  460. dDist: cfloat;
  461. x: cfloat;
  462. y: cfloat;
  463. numFingers: cuint16;
  464. padding: cuint16;
  465. end;
  466. {* (event.dgesture.*) *}
  467. PPSDL_DollarGestureEvent = ^PSDL_DollarGestureEvent;
  468. PSDL_DollarGestureEvent = ^TSDL_DollarGestureEvent;
  469. TSDL_DollarGestureEvent = record
  470. type_: cuint32; // SDL_DOLLARGESTURE
  471. timestamp: cuint32;
  472. touchId: TSDL_TouchID; // The touch device id
  473. gestureId: TSDL_GestureID;
  474. numFingers: cuint32;
  475. error: cfloat;
  476. x: cfloat; // Normalized center of gesture
  477. y: cfloat; // Normalized center of gesture
  478. end;
  479. {**
  480. * An event used to request a file open by the system (event.drop.*)
  481. * This event is disabled by default, you can enable it with SDL_EventState()
  482. * If you enable this event, you must free the filename in the event.
  483. *}
  484. PPSDL_DropEvent = ^PSDL_DropEvent;
  485. PSDL_DropEvent = ^TSDL_DropEvent;
  486. TSDL_DropEvent = record
  487. type_: cuint32; // SDL_DROPBEGIN or SDL_DROPFILE or SDL_DROPTEXT or SDL_DROPCOMPLETE
  488. timestamp: cuint32;
  489. file_: PAnsiChar; // The file name, which should be freed with SDL_free(), is NIL on begin/complete
  490. windowID: cuint32; // The window that was dropped on, if any
  491. end;
  492. {**
  493. * Sensor event structure (event.sensor.*)
  494. *}
  495. PPSDL_SensorEvent = ^PSDL_SensorEvent;
  496. PSDL_SensorEvent = ^TSDL_SensorEvent;
  497. TSDL_SensorEvent = record
  498. type_: cuint32; // SDL_SENSORUPDATED
  499. timestamp: cuint32; // In milliseconds, populated using SDL_GetTicks()
  500. which: cint32; // The instance ID of the sensor
  501. data: array[0..5] of cfloat; // Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData()
  502. end;
  503. {**
  504. * The "quit requested" event
  505. *}
  506. PPSDL_QuitEvent = ^PSDL_QuitEvent;
  507. PSDL_QuitEvent = ^TSDL_QuitEvent;
  508. TSDL_QuitEvent = record
  509. type_: cuint32; // SDL_QUIT
  510. timestamp: cuint32;
  511. end;
  512. {**
  513. * A user-defined event type (event.user.*)
  514. *}
  515. PPSDL_UserEvent = ^PSDL_UserEvent;
  516. PSDL_UserEvent = ^TSDL_UserEvent;
  517. TSDL_UserEvent = record
  518. type_: cuint32; // SDL_USEREVENT through SDL_NUMEVENTS-1
  519. timestamp: cuint32;
  520. windowID: cuint32; // The associated window if any
  521. code: cint32; // User defined event code
  522. data1: Pointer; // User defined data pointer
  523. data2: Pointer; // User defined data pointer
  524. end;
  525. {**
  526. * A video driver dependent system event (event.syswm.*)
  527. * This event is disabled by default, you can enable it with SDL_EventState()
  528. *
  529. * If you want to use this event, you should include SDL_syswm.h.
  530. *}
  531. PPSDL_SysWMEvent = ^PSDL_SysWMEvent;
  532. PSDL_SysWMEvent = ^TSDL_SysWMEvent;
  533. TSDL_SysWMEvent = record
  534. type_: cuint32; // SDL_SYSWMEVENT
  535. timestamp: cuint32;
  536. msg: PSDL_SysWMmsg; // driver dependent data (defined in SDL_syswm.h)
  537. end;
  538. {**
  539. * General event structure
  540. *}
  541. PPSDL_Event = ^PSDL_Event;
  542. PSDL_Event = ^TSDL_Event;
  543. TSDL_Event = record
  544. case cint of
  545. 0: (type_: cuint32);
  546. SDL_COMMONEVENT: (common: TSDL_CommonEvent);
  547. SDL_DISPLAYEVENT: (display: TSDL_DisplayEvent);
  548. SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
  549. SDL_KEYUP,
  550. SDL_KEYDOWN: (key: TSDL_KeyboardEvent);
  551. SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
  552. SDL_TEXTEDITING_EXT: (exitExt: TSDL_TextEditingExtEvent);
  553. SDL_TEXTINPUT: (text: TSDL_TextInputEvent);
  554. SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
  555. SDL_MOUSEBUTTONUP,
  556. SDL_MOUSEBUTTONDOWN: (button: TSDL_MouseButtonEvent);
  557. SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
  558. SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
  559. SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
  560. SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
  561. SDL_JOYBUTTONDOWN,
  562. SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
  563. SDL_JOYDEVICEADDED,
  564. SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
  565. SDL_JOYBATTERYUPDATED: (jbattery: TSDL_JoyBatteryEvent);
  566. SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
  567. SDL_CONTROLLERBUTTONUP,
  568. SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
  569. SDL_CONTROLLERDEVICEADDED,
  570. SDL_CONTROLLERDEVICEREMOVED,
  571. SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent);
  572. SDL_CONTROLLERTOUCHPADDOWN,
  573. SDL_CONTROLLERTOUCHPADMOTION,
  574. SDL_CONTROLLERTOUCHPADUP: (ctouchpad: TSDL_ControllerTouchpadEvent);
  575. SDL_CONTROLLERSENSORUPDATE: (csensor: TSDL_ControllerSensorEvent);
  576. SDL_AUDIODEVICEADDED,
  577. SDL_AUDIODEVICEREMOVED: (adevice: TSDL_AudioDeviceEvent);
  578. SDL_SENSORUPDATED: (sensor: TSDL_SensorEvent);
  579. SDL_QUITEV: (quit: TSDL_QuitEvent);
  580. SDL_USEREVENT: (user: TSDL_UserEvent);
  581. SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
  582. SDL_FINGERDOWN,
  583. SDL_FINGERUP,
  584. SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
  585. SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
  586. SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent);
  587. SDL_DROPFILE: (drop: TSDL_DropEvent);
  588. end;
  589. {* Function prototypes *}
  590. {**
  591. * Pumps the event loop, gathering events from the input devices.
  592. *
  593. * This function updates the event queue and internal input device state.
  594. *
  595. * This should only be run in the thread that sets the video mode.
  596. *}
  597. procedure SDL_PumpEvents cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF} {$ENDIF};
  598. const
  599. SDL_ADDEVENT = 0;
  600. SDL_PEEKEVENT = 1;
  601. SDL_GETEVENT = 2;
  602. type
  603. PPSDL_EventAction = ^PSDL_EventAction;
  604. PSDL_EventAction = ^TSDL_EventAction;
  605. TSDL_EventAction = Word;
  606. {**
  607. * Checks the event queue for messages and optionally returns them.
  608. *
  609. * If action is SDL_ADDEVENT, up to numevents events will be added to
  610. * the back of the event queue.
  611. *
  612. * If action is SDL_PEEKEVENT, up to numevents events at the front
  613. * of the event queue, within the specified minimum and maximum type,
  614. * will be returned and will not be removed from the queue.
  615. *
  616. * If action is SDL_GETEVENT, up to numevents events at the front
  617. * of the event queue, within the specified minimum and maximum type,
  618. * will be returned and will be removed from the queue.
  619. *
  620. * Result: The number of events actually stored, or -1 if there was an error.
  621. *
  622. * This function is thread-safe.
  623. *}
  624. function SDL_PeepEvents(events: PSDL_Event; numevents: cint32; action: TSDL_EventAction; minType, maxType: TSDL_EventType): cint32 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PeepEvents' {$ENDIF} {$ENDIF};
  625. {**
  626. * Checks to see if certain event types are in the event queue.
  627. *}
  628. function SDL_HasEvent(type_: TSDL_EventType): TSDL_Bool cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvent' {$ENDIF} {$ENDIF};
  629. function SDL_HasEvents(minType, maxType: TSDL_EventType): TSDL_Bool cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvents' {$ENDIF} {$ENDIF};
  630. {**
  631. * This function clears events from the event queue
  632. *}
  633. procedure SDL_FlushEvent(type_: TSDL_EventType) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvent' {$ENDIF} {$ENDIF};
  634. procedure SDL_FlushEvents(minType, maxType: TSDL_EventType) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvents' {$ENDIF} {$ENDIF};
  635. {**
  636. * Polls for currently pending events.
  637. *
  638. * 1 if there are any pending events, or 0 if there are none available.
  639. *
  640. * event - If not nil, the next event is removed from the queue and
  641. * stored in that area.
  642. *}
  643. function SDL_PollEvent(event: PSDL_Event): cint32 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PollEvent' {$ENDIF} {$ENDIF};
  644. {**
  645. * Waits indefinitely for the next available event.
  646. *
  647. * 1, or 0 if there was an error while waiting for events.
  648. *
  649. * event - If not nil, the next event is removed from the queue and
  650. * stored in that area.
  651. *}
  652. function SDL_WaitEvent(event: PSDL_Event): cint32 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WaitEvent' {$ENDIF} {$ENDIF};
  653. {**
  654. * Waits until the specified timeout (in milliseconds) for the next
  655. * available event.
  656. *
  657. * 1, or 0 if there was an error while waiting for events.
  658. *
  659. * event - If not nil, the next event is removed from the queue and
  660. * stored in that area.
  661. *}
  662. function SDL_WaitEventTimeout(event: PSDL_Event; timeout: cint32): cint32 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WaitEventTimeout' {$ENDIF} {$ENDIF};
  663. {**
  664. * Add an event to the event queue.
  665. *
  666. * 1 on success, 0 if the event was filtered, or -1 if the event queue
  667. * was full or there was some other error.
  668. *}
  669. function SDL_PushEvent(event: PSDL_Event): cint32 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF} {$ENDIF};
  670. type
  671. PPSDL_EventFilter = ^PSDL_EventFilter;
  672. PSDL_EventFilter = ^TSDL_EventFilter;
  673. {$IFNDEF GPC}
  674. TSDL_EventFilter = function(userdata: Pointer; event: PSDL_Event): cint; cdecl;
  675. {$ELSE}
  676. TSDL_EventFilter = function( userdata: Pointer; event: PSDL_Event ): cint;
  677. {$ENDIF}
  678. {**
  679. * Sets up a filter to process all events before they change internal state and
  680. * are posted to the internal event queue.
  681. *
  682. * If the filter returns 1, then the event will be added to the internal queue.
  683. * If it returns 0, then the event will be dropped from the queue, but the
  684. * internal state will still be updated. This allows selective filtering of
  685. * dynamically arriving events.
  686. *
  687. * Be very careful of what you do in the event filter function, as
  688. * it may run in a different thread!
  689. *
  690. * There is one caveat when dealing with the SDL_QUITEVENT event type. The
  691. * event filter is only called when the window manager desires to close the
  692. * application window. If the event filter returns 1, then the window will
  693. * be closed, otherwise the window will remain open if possible.
  694. *
  695. * If the quit event is generated by an interrupt signal, it will bypass the
  696. * internal queue and be delivered to the application at the next event poll.
  697. *}
  698. procedure SDL_SetEventFilter(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetEventFilter' {$ENDIF} {$ENDIF};
  699. {**
  700. * Return the current event filter - can be used to "chain" filters.
  701. * If there is no event filter set, this function returns SDL_FALSE.
  702. *}
  703. function SDL_GetEventFilter(var filter: PSDL_EventFilter; var userdata: PPointer): TSDL_Bool cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetEventFilter' {$ENDIF} {$ENDIF};
  704. {**
  705. * Add a function which is called when an event is added to the queue.
  706. *}
  707. procedure SDL_AddEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AddEventWatch' {$ENDIF} {$ENDIF};
  708. {**
  709. * Remove an event watch function added with SDL_AddEventWatch()
  710. *}
  711. procedure SDL_DelEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_DelEventWatch' {$ENDIF} {$ENDIF};
  712. {**
  713. * Run the filter function on the current event queue, removing any
  714. * events for which the filter returns 0.
  715. *}
  716. procedure SDL_FilterEvents(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FilterEvents' {$ENDIF} {$ENDIF};
  717. const
  718. SDL_QUERY = -1;
  719. SDL_IGNORE = 0;
  720. SDL_DISABLE = 0;
  721. SDL_ENABLE = 1;
  722. {**
  723. * This function allows you to set the state of processing certain events.
  724. * - If state is set to SDL_IGNORE, that event will be automatically
  725. * dropped from the event queue and will not event be filtered.
  726. * - If state is set to SDL_ENABLE, that event will be processed
  727. * normally.
  728. * - If state is set to SDL_QUERY, SDL_EventState() will return the
  729. * current processing state of the specified event.
  730. *}
  731. function SDL_EventState(type_: TSDL_EventType; state: cint32): cuint8 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EventState' {$ENDIF} {$ENDIF};
  732. function SDL_GetEventState(type_: TSDL_EventType): cuint8;
  733. {**
  734. * This function allocates a set of user-defined events, and returns
  735. * the beginning event number for that set of events.
  736. *
  737. * If there aren't enough user-defined events left, this function
  738. * returns (Uint32)-1
  739. *}
  740. function SDL_RegisterEvents(numevents: cint32): cuint32 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RegisterEvents' {$ENDIF} {$ENDIF};