sdljoystick.inc 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. {**
  2. * \file SDL_joystick.h
  3. *
  4. * Include file for SDL joystick event handling
  5. *
  6. * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick
  7. * behind a device_index changing as joysticks are plugged and unplugged.
  8. *
  9. * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
  10. * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
  11. *
  12. * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
  13. * the device (a X360 wired controller for example). This identifier is platform dependent.
  14. *
  15. *
  16. *}
  17. {**
  18. * \file SDL_joystick.h
  19. *
  20. * In order to use these functions, SDL_Init() must have been called
  21. * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
  22. * for joysticks, and load appropriate drivers.
  23. *
  24. * If you would like to receive joystick updates while the application
  25. * is in the background, you should set the following hint before calling
  26. * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
  27. *}
  28. type
  29. {* The joystick structure used to identify an SDL joystick *}
  30. PPSDL_Joystick = ^PSDL_Joystick;
  31. PSDL_Joystick = ^TSDL_Joystick;
  32. TSDL_Joystick = record end;
  33. {* A structure that encodes the stable unique id for a joystick device *}
  34. PPSDL_JoystickGUID = ^PSDL_JoystickGUID;
  35. PSDL_JoystickGUID = ^TSDL_JoystickGUID;
  36. TSDL_JoystickGUID = type TSDL_GUID;
  37. {**
  38. * This is a unique ID for a joystick for the time it is connected to the system,
  39. * and is never reused for the lifetime of the application. If the joystick is
  40. * disconnected and reconnected, it will get a new ID.
  41. *
  42. * The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
  43. *}
  44. PPSDL_JoystickID = ^PSDL_JoystickID;
  45. PSDL_JoystickID = ^TSDL_JoystickID;
  46. TSDL_JoystickID = type cint32;
  47. type
  48. PPSDL_JoystickType = ^PSDL_JoystickType;
  49. PSDL_JoystickType = ^TSDL_JoystickType;
  50. TSDL_JoystickType = type Integer;
  51. const
  52. SDL_JOYSTICK_TYPE_UNKNOWN = TSDL_JoystickType(0);
  53. SDL_JOYSTICK_TYPE_GAMECONTROLLER = TSDL_JoystickType(1);
  54. SDL_JOYSTICK_TYPE_WHEEL = TSDL_JoystickType(2);
  55. SDL_JOYSTICK_TYPE_ARCADE_STICK = TSDL_JoystickType(3);
  56. SDL_JOYSTICK_TYPE_FLIGHT_STICK = TSDL_JoystickType(4);
  57. SDL_JOYSTICK_TYPE_DANCE_PAD = TSDL_JoystickType(5);
  58. SDL_JOYSTICK_TYPE_GUITAR = TSDL_JoystickType(6);
  59. SDL_JOYSTICK_TYPE_DRUM_KIT = TSDL_JoystickType(7);
  60. SDL_JOYSTICK_TYPE_ARCADE_PAD = TSDL_JoystickType(8);
  61. SDL_JOYSTICK_TYPE_THROTTLE = TSDL_JoystickType(9);
  62. type
  63. PPSDL_JoystickPowerLevel = ^PSDL_JoystickPowerLevel;
  64. PSDL_JoystickPowerLevel = ^TSDL_JoystickPowerLevel;
  65. TSDL_JoystickPowerLevel = type Integer;
  66. const
  67. SDL_JOYSTICK_POWER_UNKNOWN = TSDL_JoystickPowerLevel(-1);
  68. SDL_JOYSTICK_POWER_EMPTY = TSDL_JoystickPowerLevel(0); {* <= 5% *}
  69. SDL_JOYSTICK_POWER_LOW = TSDL_JoystickPowerLevel(1); {* <= 20% *}
  70. SDL_JOYSTICK_POWER_MEDIUM = TSDL_JoystickPowerLevel(2); {* <= 70% *}
  71. SDL_JOYSTICK_POWER_FULL = TSDL_JoystickPowerLevel(3); {* <= 100% *}
  72. SDL_JOYSTICK_POWER_WIRED = TSDL_JoystickPowerLevel(4);
  73. SDL_JOYSTICK_POWER_MAX = TSDL_JoystickPowerLevel(5);
  74. {* Set max recognized G-force from accelerometer
  75. See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
  76. *}
  77. const
  78. SDL_IPHONE_MAX_GFORCE = 5.0;
  79. {* Function prototypes *}
  80. {**
  81. * Locking for multi-threaded access to the joystick API
  82. *
  83. * If you are using the joystick API or handling events from multiple threads
  84. * you should use these locking functions to protect access to the joysticks.
  85. *
  86. * In particular, you are guaranteed that the joystick list won't change, so
  87. * the API functions that take a joystick index will be valid, and joystick
  88. * and game controller events will not be delivered.
  89. *
  90. * As of SDL 2.26.0, you can take the joystick lock around reinitializing the
  91. * joystick subsystem, to prevent other threads from seeing joysticks in an
  92. * uninitialized state. However, all open joysticks will be closed and SDL
  93. * functions called with them will fail.
  94. *
  95. * \since This function is available since SDL 2.0.7.
  96. *}
  97. procedure SDL_LockJoysticks(); cdecl;
  98. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockJoysticks' {$ENDIF} {$ENDIF};
  99. {**
  100. * Unlocking for multi-threaded access to the joystick API
  101. *
  102. * If you are using the joystick API or handling events from multiple threads
  103. * you should use these locking functions to protect access to the joysticks.
  104. *
  105. * In particular, you are guaranteed that the joystick list won't change, so
  106. * the API functions that take a joystick index will be valid, and joystick
  107. * and game controller events will not be delivered.
  108. *
  109. * \since This function is available since SDL 2.0.7.
  110. *}
  111. procedure SDL_UnlockJoysticks(); cdecl;
  112. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockJoysticks' {$ENDIF} {$ENDIF};
  113. {**
  114. * Count the number of joysticks attached to the system.
  115. *
  116. * \returns the number of attached joysticks on success or a negative error
  117. * code on failure; call SDL_GetError() for more information.
  118. *
  119. * \since This function is available since SDL 2.0.0.
  120. *
  121. * \sa SDL_JoystickName
  122. * \sa SDL_JoystickPath
  123. * \sa SDL_JoystickOpen
  124. *}
  125. function SDL_NumJoysticks(): cint; cdecl;
  126. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NumJoysticks' {$ENDIF} {$ENDIF};
  127. {**
  128. * Get the implementation dependent name of a joystick.
  129. *
  130. * This can be called before any joysticks are opened.
  131. *
  132. * \param device_index the index of the joystick to query (the N'th joystick
  133. * on the system)
  134. * \returns the name of the selected joystick. If no name can be found, this
  135. * function returns NULL; call SDL_GetError() for more information.
  136. *
  137. * \since This function is available since SDL 2.0.0.
  138. *
  139. * \sa SDL_JoystickName
  140. * \sa SDL_JoystickOpen
  141. *}
  142. function SDL_JoystickNameForIndex(device_index: cint): PAnsiChar; cdecl;
  143. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNameForIndex' {$ENDIF} {$ENDIF};
  144. {**
  145. * Get the implementation dependent path of a joystick.
  146. *
  147. * This can be called before any joysticks are opened.
  148. *
  149. * \param device_index the index of the joystick to query (the N'th joystick
  150. * on the system)
  151. * \returns the path of the selected joystick. If no path can be found, this
  152. * function returns NULL; call SDL_GetError() for more information.
  153. *
  154. * \since This function is available since SDL 2.24.0.
  155. *
  156. * \sa SDL_JoystickPath
  157. * \sa SDL_JoystickOpen
  158. *}
  159. function SDL_JoystickPathForIndex(device_index: cint): PAnsiChar; cdecl;
  160. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickPathForIndex' {$ENDIF} {$ENDIF};
  161. {**
  162. * Get the player index of a joystick, or -1 if it's not available This can be
  163. * called before any joysticks are opened.
  164. *
  165. * \since This function is available since SDL 2.0.9.
  166. *}
  167. function SDL_JoystickGetDevicePlayerIndex(device_index: cint): cint; cdecl;
  168. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDevicePlayerIndex' {$ENDIF} {$ENDIF};
  169. {**
  170. * Return the GUID for the joystick at this index
  171. * This can be called before any joysticks are opened.
  172. *}
  173. function SDL_JoystickGetDeviceGUID(device_index: cint): TSDL_JoystickGUID; cdecl;
  174. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceGUID' {$ENDIF} {$ENDIF};
  175. {**
  176. * Get the USB vendor ID of a joystick, if available.
  177. *
  178. * This can be called before any joysticks are opened. If the vendor ID isn't
  179. * available this function returns 0.
  180. *
  181. * \param device_index the index of the joystick to query (the N'th joystick
  182. * on the system
  183. * \returns the USB vendor ID of the selected joystick. If called on an
  184. * invalid index, this function returns zero
  185. *
  186. * \since This function is available since SDL 2.0.6.
  187. *}
  188. function SDL_JoystickGetDeviceVendor(device_index: cint): cuint16; cdecl;
  189. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceVendor' {$ENDIF} {$ENDIF};
  190. {**
  191. * Get the USB product ID of a joystick, if available.
  192. *
  193. * This can be called before any joysticks are opened. If the product ID isn't
  194. * available this function returns 0.
  195. *
  196. * \param device_index the index of the joystick to query (the N'th joystick
  197. * on the system
  198. * \returns the USB product ID of the selected joystick. If called on an
  199. * invalid index, this function returns zero
  200. *
  201. * \since This function is available since SDL 2.0.6.
  202. *}
  203. function SDL_JoystickGetDeviceProduct(device_index: cint): cuint16; cdecl;
  204. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceProduct' {$ENDIF} {$ENDIF};
  205. {**
  206. * Get the product version of a joystick, if available.
  207. *
  208. * This can be called before any joysticks are opened. If the product version
  209. * isn't available this function returns 0.
  210. *
  211. * \param device_index the index of the joystick to query (the N'th joystick
  212. * on the system
  213. * \returns the product version of the selected joystick. If called on an
  214. * invalid index, this function returns zero
  215. *
  216. * \since This function is available since SDL 2.0.6.
  217. *}
  218. function SDL_JoystickGetDeviceProductVersion(device_index: cint): cuint16; cdecl;
  219. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceProductVersion' {$ENDIF} {$ENDIF};
  220. {**
  221. * Get the type of a joystick, if available.
  222. *
  223. * This can be called before any joysticks are opened.
  224. *
  225. * \param device_index the index of the joystick to query (the N'th joystick
  226. * on the system
  227. * \returns the SDL_JoystickType of the selected joystick. If called on an
  228. * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
  229. *
  230. * \since This function is available since SDL 2.0.6.
  231. *}
  232. function SDL_JoystickGetDeviceType(device_index: cint): TSDL_JoystickType; cdecl;
  233. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceType' {$ENDIF} {$ENDIF};
  234. {**
  235. * Get the instance ID of a joystick.
  236. *
  237. * This can be called before any joysticks are opened. If the index is out of
  238. * range, this function will return -1.
  239. *
  240. * \param device_index the index of the joystick to query (the N'th joystick
  241. * on the system
  242. * \returns the instance id of the selected joystick. If called on an invalid
  243. * index, this function returns zero
  244. *
  245. * \since This function is available since SDL 2.0.6.
  246. *}
  247. function SDL_JoystickGetDeviceInstanceID(device_index: cint): TSDL_JoystickID; cdecl;
  248. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetDeviceInstanceID' {$ENDIF} {$ENDIF};
  249. {**
  250. * Open a joystick for use.
  251. *
  252. * The `device_index` argument refers to the N'th joystick presently
  253. * recognized by SDL on the system. It is **NOT** the same as the instance ID
  254. * used to identify the joystick in future events. See
  255. * SDL_JoystickInstanceID() for more details about instance IDs.
  256. *
  257. * The joystick subsystem must be initialized before a joystick can be opened
  258. * for use.
  259. *
  260. * \param device_index the index of the joystick to query
  261. * \returns a joystick identifier or NULL if an error occurred; call
  262. * SDL_GetError() for more information.
  263. *
  264. * \since This function is available since SDL 2.0.0.
  265. *
  266. * \sa SDL_JoystickClose
  267. * \sa SDL_JoystickInstanceID
  268. *}
  269. function SDL_JoystickOpen(device_index: cint): PSDL_Joystick; cdecl;
  270. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickOpen' {$ENDIF} {$ENDIF};
  271. {**
  272. * Get the SDL_Joystick associated with an instance id.
  273. *
  274. * \param instance_id the instance id to get the SDL_Joystick for
  275. * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
  276. * for more information.
  277. *
  278. * \since This function is available since SDL 2.0.4.
  279. *}
  280. function SDL_JoystickFromInstanceID(instance_id: TSDL_JoystickID): PSDL_Joystick; cdecl;
  281. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickFromInstanceID' {$ENDIF} {$ENDIF};
  282. {**
  283. * Get the SDL_Joystick associated with a player index.
  284. *
  285. * \param player_index the player index to get the SDL_Joystick for
  286. * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
  287. * for more information.
  288. *
  289. * \since This function is available since SDL 2.0.12.
  290. *}
  291. function SDL_JoystickFromPlayerIndex(player_index: cint): PSDL_Joystick; cdecl;
  292. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickFromPlayerIndex' {$ENDIF} {$ENDIF};
  293. {**
  294. * Attach a new virtual joystick.
  295. *
  296. * \returns the joystick's device index, or -1 if an error occurred.
  297. *
  298. * \since This function is available since SDL 2.0.14.
  299. *}
  300. function SDL_JoystickAttachVirtual(type_: TSDL_JoystickType; naxes: cint; nbuttons: cint; nhats: cint): cint; cdecl;
  301. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickAttachVirtual' {$ENDIF} {$ENDIF};
  302. type
  303. {**
  304. * The structure that defines an extended virtual joystick description
  305. *
  306. * The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()
  307. * All other elements of this structure are optional and can be left 0.
  308. *
  309. * \sa SDL_JoystickAttachVirtualEx
  310. *}
  311. TUpdateProc = procedure(userdata: Pointer); cdecl;
  312. TSetPlayerIndexProc = procedure(userdata: Pointer; player_index: cint); cdecl;
  313. TRumbleFunc = function(userdata: Pointer; low_frequency_rumble: cuint16; high_frequency_rumble: cuint16): cint; cdecl;
  314. TRumbleTriggersFunc = function(userdata: Pointer; left_rumble: cuint16; right_rumble: cuint16): cint; cdecl;
  315. TSetLEDFunc = function(userdata: Pointer; red: cuint8; green: cuint8; blue: cuint8): cint; cdecl;
  316. TSendEffectFunc = function(userdata: Pointer; const data: Pointer; size: cint): cint; cdecl;
  317. PPSDL_VirtualJoystickDesc = ^PSDL_VirtualJoystickDesc;
  318. PSDL_VirtualJoystickDesc = ^TSDL_VirtualJoystickDesc;
  319. TSDL_VirtualJoystickDesc = record
  320. version: cuint16; {**< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` *}
  321. type_: cuint16; {**< `SDL_JoystickType` }
  322. naxes: cuint16; {**< the number of axes on this joystick *}
  323. nbuttons: cuint16; {**< the number of buttons on this joystick *}
  324. nhats: cuint16; {**< the number of hats on this joystick *}
  325. vendor_id: cuint16; {**< the USB vendor ID of this joystick *}
  326. product_id: cuint16; {**< the USB product ID of this joystick *}
  327. padding: cuint16; {**< unused *}
  328. button_mask: cuint16; {**< A mask of which buttons are valid for this controller
  329. e.g. (1 << SDL_CONTROLLER_BUTTON_A) *}
  330. axis_mask: cuint32; {**< A mask of which axes are valid for this controller
  331. e.g. (1 << SDL_CONTROLLER_AXIS_LEFTX) *}
  332. name: PAnsiChar; {**< the name of the joystick *}
  333. userdata: Pointer; {**< User data pointer passed to callbacks *}
  334. Update: TUpdateProc; {**< Called when the joystick state should be updated *}
  335. SetPlayerIndex: TSetPlayerIndexProc; {**< Called when the player index is set *}
  336. Rumble: TRumbleFunc; {**< Implements SDL_JoystickRumble() *}
  337. RumbleTriggers: TRumbleTriggersFunc; {**< Implements SDL_JoystickRumbleTriggers() *}
  338. SetLED: TSetLEDFunc; {**< Implements SDL_JoystickSetLED() *}
  339. SendEffect: TSendEffectFunc; {**< Implements SDL_JoystickSendEffect() *}
  340. end;
  341. {**
  342. * \brief The current version of the SDL_VirtualJoystickDesc structure
  343. *}
  344. const
  345. SDL_VIRTUAL_JOYSTICK_DESC_VERSION = 1;
  346. {/**
  347. * Attach a new virtual joystick with extended properties.
  348. *
  349. * \returns the joystick's device index, or -1 if an error occurred.
  350. *
  351. * \since This function is available since SDL 2.24.0.
  352. */}
  353. function SDL_JoystickAttachVirtualEx(const desc: PSDL_VirtualJoystickDesc): cint; cdecl;
  354. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickAttachVirtualEx' {$ENDIF} {$ENDIF};
  355. {**
  356. * Detach a virtual joystick.
  357. *
  358. * \param device_index a value previously returned from
  359. * SDL_JoystickAttachVirtual()
  360. * \returns 0 on success, or -1 if an error occurred.
  361. *
  362. * \since This function is available since SDL 2.0.14.
  363. *}
  364. function SDL_JoystickDetachVirtual(device_index: cint): cint; cdecl;
  365. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickDetachVirtual' {$ENDIF} {$ENDIF};
  366. {**
  367. * Query whether or not the joystick at a given device index is virtual.
  368. *
  369. * \param device_index a joystick device index.
  370. * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
  371. *
  372. * \since This function is available since SDL 2.0.14.
  373. *}
  374. function SDL_JoystickIsVirtual(device_index: cint): TSDL_Bool; cdecl;
  375. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickIsVirtual' {$ENDIF} {$ENDIF};
  376. {**
  377. * Set values on an opened, virtual-joystick's axis.
  378. *
  379. * Please note that values set here will not be applied until the next call to
  380. * SDL_JoystickUpdate, which can either be called directly, or can be called
  381. * indirectly through various other SDL APIs, including, but not limited to
  382. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  383. * SDL_WaitEvent.
  384. *
  385. * Note that when sending trigger axes, you should scale the value to the full
  386. * range of Sint16. For example, a trigger at rest would have the value of
  387. * `SDL_JOYSTICK_AXIS_MIN`.
  388. *
  389. * \param joystick the virtual joystick on which to set state.
  390. * \param axis the specific axis on the virtual joystick to set.
  391. * \param value the new value for the specified axis.
  392. * \returns 0 on success, -1 on error.
  393. *
  394. * \since This function is available since SDL 2.0.14.
  395. *}
  396. function SDL_JoystickSetVirtualAxis(joystick: PSDL_Joystick; axis: cint; value: cint16): cint; cdecl;
  397. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickSetVirtualAxis' {$ENDIF} {$ENDIF};
  398. {**
  399. * Set values on an opened, virtual-joystick's button.
  400. *
  401. * Please note that values set here will not be applied until the next call to
  402. * SDL_JoystickUpdate, which can either be called directly, or can be called
  403. * indirectly through various other SDL APIs, including, but not limited to
  404. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  405. * SDL_WaitEvent.
  406. *
  407. * \param joystick the virtual joystick on which to set state.
  408. * \param button the specific button on the virtual joystick to set.
  409. * \param value the new value for the specified button.
  410. * \returns 0 on success, -1 on error.
  411. *
  412. * \since This function is available since SDL 2.0.14.
  413. *}
  414. function SDL_JoystickSetVirtualButton(joystick: PSDL_Joystick; button: cint; value: cuint8): cint; cdecl;
  415. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickSetVirtualButton' {$ENDIF} {$ENDIF};
  416. {**
  417. * Set values on an opened, virtual-joystick's hat.
  418. *
  419. * Please note that values set here will not be applied until the next call to
  420. * SDL_JoystickUpdate, which can either be called directly, or can be called
  421. * indirectly through various other SDL APIs, including, but not limited to
  422. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  423. * SDL_WaitEvent.
  424. *
  425. * \param joystick the virtual joystick on which to set state.
  426. * \param hat the specific hat on the virtual joystick to set.
  427. * \param value the new value for the specified hat.
  428. * \returns 0 on success, -1 on error.
  429. *
  430. * \since This function is available since SDL 2.0.14.
  431. *}
  432. function SDL_JoystickSetVirtualHat(joystick: PSDL_Joystick; hat: cint; value: cuint8): cint; cdecl;
  433. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickSetVirtualHat' {$ENDIF} {$ENDIF};
  434. {**
  435. * Get the implementation dependent name of a joystick.
  436. *
  437. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  438. * \returns the name of the selected joystick. If no name can be found, this
  439. * function returns NULL; call SDL_GetError() for more information.
  440. *
  441. * \since This function is available since SDL 2.0.0.
  442. *
  443. * \sa SDL_JoystickNameForIndex
  444. * \sa SDL_JoystickOpen
  445. *}
  446. function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar; cdecl;
  447. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickName' {$ENDIF} {$ENDIF};
  448. {**
  449. * Get the implementation dependent path of a joystick.
  450. *
  451. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  452. * \returns the path of the selected joystick. If no path can be found, this
  453. * function returns NULL; call SDL_GetError() for more information.
  454. *
  455. * \since This function is available since SDL 2.24.0.
  456. *
  457. * \sa SDL_JoystickPathForIndex
  458. *}
  459. function SDL_JoystickPath(joystick: PSDL_Joystick): PAnsiChar; cdecl;
  460. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickPath' {$ENDIF} {$ENDIF};
  461. {**
  462. * Get the player index of an opened joystick.
  463. *
  464. * For XInput controllers this returns the XInput user index. Many joysticks
  465. * will not be able to supply this information.
  466. *
  467. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  468. * \returns the player index, or -1 if it's not available.
  469. *
  470. * \since This function is available since SDL 2.0.9.
  471. *}
  472. function SDL_JoystickGetPlayerIndex(joystick: PSDL_Joystick): cint; cdecl;
  473. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetPlayerIndex' {$ENDIF} {$ENDIF};
  474. {**
  475. * Set the player index of an opened joystick.
  476. *
  477. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  478. * \param player_index Player index to assign to this joystick, or -1 to clear
  479. * the player index and turn off player LEDs.
  480. *
  481. * \since This function is available since SDL 2.0.12.
  482. *}
  483. procedure SDL_JoystickSetPlayerIndex(joystick: PSDL_Joystick; player_index: cint); cdecl;
  484. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickSetPlayerIndex' {$ENDIF} {$ENDIF};
  485. {**
  486. * Get the implementation-dependent GUID for the joystick.
  487. *
  488. * This function requires an open joystick.
  489. *
  490. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  491. * \returns the GUID of the given joystick. If called on an invalid index,
  492. * this function returns a zero GUID; call SDL_GetError() for more
  493. * information.
  494. *
  495. * \since This function is available since SDL 2.0.0.
  496. *
  497. * \sa SDL_JoystickGetDeviceGUID
  498. * \sa SDL_JoystickGetGUIDString
  499. *}
  500. function SDL_JoystickGetGUID(joystick: PSDL_Joystick): TSDL_JoystickGUID; cdecl;
  501. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUID' {$ENDIF} {$ENDIF};
  502. {**
  503. * Get the USB vendor ID of an opened joystick, if available.
  504. *
  505. * If the vendor ID isn't available this function returns 0.
  506. *
  507. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  508. * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
  509. *
  510. * \since This function is available since SDL 2.0.6.
  511. *}
  512. function SDL_JoystickGetVendor(joystick: PSDL_Joystick): cuint16; cdecl;
  513. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetVendor' {$ENDIF} {$ENDIF};
  514. {**
  515. * Get the USB product ID of an opened joystick, if available.
  516. *
  517. * If the product ID isn't available this function returns 0.
  518. *
  519. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  520. * \returns the USB product ID of the selected joystick, or 0 if unavailable.
  521. *
  522. * \since This function is available since SDL 2.0.6.
  523. *}
  524. function SDL_JoystickGetProduct(joystick: PSDL_Joystick): cuint16; cdecl;
  525. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetProduct' {$ENDIF} {$ENDIF};
  526. {**
  527. * Get the product version of an opened joystick, if available.
  528. *
  529. * If the product version isn't available this function returns 0.
  530. *
  531. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  532. * \returns the product version of the selected joystick, or 0 if unavailable.
  533. *
  534. * \since This function is available since SDL 2.0.6.
  535. *}
  536. function SDL_JoystickGetProductVersion(joystick: PSDL_Joystick): cuint16; cdecl;
  537. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetProductVersion' {$ENDIF} {$ENDIF};
  538. {**
  539. * Get the firmware version of an opened joystick, if available.
  540. *
  541. * If the firmware version isn't available this function returns 0.
  542. *
  543. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  544. * \returns the firmware version of the selected joystick, or 0 if
  545. * unavailable.
  546. *
  547. * \since This function is available since SDL 2.24.0.
  548. *}
  549. function SDL_JoystickGetFirmwareVersion(joystick: PSDL_Joystick): cuint16; cdecl;
  550. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetFirmwareVersion' {$ENDIF} {$ENDIF};
  551. {**
  552. * Get the serial number of an opened joystick, if available.
  553. *
  554. * Returns the serial number of the joystick, or NULL if it is not available.
  555. *
  556. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  557. * \returns the serial number of the selected joystick, or NULL if
  558. * unavailable.
  559. *
  560. * \since This function is available since SDL 2.0.14.
  561. *}
  562. function SDL_JoystickGetSerial(joystick: PSDL_Joystick): PAnsiChar; cdecl;
  563. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetSerial' {$ENDIF} {$ENDIF};
  564. {**
  565. * Get the type of an opened joystick.
  566. *
  567. * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
  568. * \returns the SDL_JoystickType of the selected joystick.
  569. *
  570. * \since This function is available since SDL 2.0.6.
  571. *}
  572. function SDL_JoystickGetType(joystick: PSDL_Joystick): TSDL_JoystickType; cdecl;
  573. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetType' {$ENDIF} {$ENDIF};
  574. {**
  575. * Get an ASCII string representation for a given SDL_JoystickGUID.
  576. *
  577. * You should supply at least 33 bytes for pszGUID.
  578. *
  579. * \param guid the SDL_JoystickGUID you wish to convert to string
  580. * \param pszGUID buffer in which to write the ASCII string
  581. * \param cbGUID the size of pszGUID
  582. *
  583. * \since This function is available since SDL 2.0.0.
  584. *
  585. * \sa SDL_JoystickGetDeviceGUID
  586. * \sa SDL_JoystickGetGUID
  587. * \sa SDL_JoystickGetGUIDFromString
  588. *}
  589. procedure SDL_JoystickGetGUIDString(guid: TSDL_JoystickGUID; pszGUID: PAnsiChar; cbGUID: cint); cdecl;
  590. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUIDString' {$ENDIF} {$ENDIF};
  591. {**
  592. * Convert a GUID string into a SDL_JoystickGUID structure.
  593. *
  594. * Performs no error checking. If this function is given a string containing
  595. * an invalid GUID, the function will silently succeed, but the GUID generated
  596. * will not be useful.
  597. *
  598. * \param pchGUID string containing an ASCII representation of a GUID
  599. * \returns a SDL_JoystickGUID structure.
  600. *
  601. * \since This function is available since SDL 2.0.0.
  602. *
  603. * \sa SDL_JoystickGetGUIDString
  604. *}
  605. function SDL_JoystickGetGUIDFromString(const pchGUID: PAnsiChar): TSDL_JoystickGUID; cdecl;
  606. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetGUIDFromString' {$ENDIF} {$ENDIF};
  607. {**
  608. * Get the device information encoded in a SDL_JoystickGUID structure
  609. *
  610. * \param guid the SDL_JoystickGUID you wish to get info about
  611. * \param vendor A pointer filled in with the device VID, or 0 if not
  612. * available
  613. * \param product A pointer filled in with the device PID, or 0 if not
  614. * available
  615. * \param version A pointer filled in with the device version, or 0 if not
  616. * available
  617. * \param crc16 A pointer filled in with a CRC used to distinguish different
  618. * products with the same VID/PID, or 0 if not available
  619. *
  620. * \since This function is available since SDL 2.26.0.
  621. *
  622. * \sa SDL_JoystickGetDeviceGUID
  623. *}
  624. procedure SDL_GetJoystickGUIDInfo(guid: TSDL_JoystickGUID; vendor: pcuint16; product: pcuint16; version: pcuint16; crc16: pcuint16); cdecl;
  625. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetJoystickGUIDInfo' {$ENDIF} {$ENDIF};
  626. {**
  627. * Get the status of a specified joystick.
  628. *
  629. * \param joystick the joystick to query
  630. * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
  631. * call SDL_GetError() for more information.
  632. *
  633. * \since This function is available since SDL 2.0.0.
  634. *
  635. * \sa SDL_JoystickClose
  636. * \sa SDL_JoystickOpen
  637. *}
  638. function SDL_JoystickGetAttached(joystick: PSDL_Joystick): TSDL_Bool; cdecl;
  639. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAttached' {$ENDIF} {$ENDIF};
  640. {**
  641. * Get the instance ID of an opened joystick.
  642. *
  643. * \param joystick an SDL_Joystick structure containing joystick information
  644. * \returns the instance ID of the specified joystick on success or a negative
  645. * error code on failure; call SDL_GetError() for more information.
  646. *
  647. * \since This function is available since SDL 2.0.0.
  648. *
  649. * \sa SDL_JoystickOpen
  650. *}
  651. function SDL_JoystickInstanceID(joystick: PSDL_Joystick): TSDL_JoystickID; cdecl;
  652. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickInstanceID' {$ENDIF} {$ENDIF};
  653. {**
  654. * Get the number of general axis controls on a joystick.
  655. *
  656. * Often, the directional pad on a game controller will either look like 4
  657. * separate buttons or a POV hat, and not axes, but all of this is up to the
  658. * device and platform.
  659. *
  660. * \param joystick an SDL_Joystick structure containing joystick information
  661. * \returns the number of axis controls/number of axes on success or a
  662. * negative error code on failure; call SDL_GetError() for more
  663. * information.
  664. *
  665. * \since This function is available since SDL 2.0.0.
  666. *
  667. * \sa SDL_JoystickGetAxis
  668. * \sa SDL_JoystickOpen
  669. *}
  670. function SDL_JoystickNumAxes(joystick: PSDL_Joystick): cint; cdecl;
  671. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumAxes' {$ENDIF} {$ENDIF};
  672. {**
  673. * Get the number of trackballs on a joystick.
  674. *
  675. * Joystick trackballs have only relative motion events associated with them
  676. * and their state cannot be polled.
  677. *
  678. * Most joysticks do not have trackballs.
  679. *
  680. * \param joystick an SDL_Joystick structure containing joystick information
  681. * \returns the number of trackballs on success or a negative error code on
  682. * failure; call SDL_GetError() for more information.
  683. *
  684. * \since This function is available since SDL 2.0.0.
  685. *
  686. * \sa SDL_JoystickGetBall
  687. *}
  688. function SDL_JoystickNumBalls(joystick: PSDL_Joystick): cint; cdecl;
  689. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumBalls' {$ENDIF} {$ENDIF};
  690. {**
  691. * Get the number of POV hats on a joystick.
  692. *
  693. * \param joystick an SDL_Joystick structure containing joystick information
  694. * \returns the number of POV hats on success or a negative error code on
  695. * failure; call SDL_GetError() for more information.
  696. *
  697. * \since This function is available since SDL 2.0.0.
  698. *
  699. * \sa SDL_JoystickGetHat
  700. * \sa SDL_JoystickOpen
  701. *}
  702. function SDL_JoystickNumHats(joystick: PSDL_Joystick): cint; cdecl;
  703. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumHats' {$ENDIF} {$ENDIF};
  704. {**
  705. * Get the number of buttons on a joystick.
  706. *
  707. * \param joystick an SDL_Joystick structure containing joystick information
  708. * \returns the number of buttons on success or a negative error code on
  709. * failure; call SDL_GetError() for more information.
  710. *
  711. * \since This function is available since SDL 2.0.0.
  712. *
  713. * \sa SDL_JoystickGetButton
  714. * \sa SDL_JoystickOpen
  715. *}
  716. function SDL_JoystickNumButtons(joystick: PSDL_Joystick): cint; cdecl;
  717. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickNumButtons' {$ENDIF} {$ENDIF};
  718. {**
  719. * Update the current state of the open joysticks.
  720. *
  721. * This is called automatically by the event loop if any joystick events are
  722. * enabled.
  723. *
  724. * \since This function is available since SDL 2.0.0.
  725. *
  726. * \sa SDL_JoystickEventState
  727. *}
  728. procedure SDL_JoystickUpdate(); cdecl;
  729. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickUpdate' {$ENDIF} {$ENDIF};
  730. {**
  731. * Enable/disable joystick event polling.
  732. *
  733. * If joystick events are disabled, you must call SDL_JoystickUpdate()
  734. * yourself and manually check the state of the joystick when you want
  735. * joystick information.
  736. *
  737. * It is recommended that you leave joystick event handling enabled.
  738. *
  739. * **WARNING**: Calling this function may delete all events currently in SDL's
  740. * event queue.
  741. *
  742. * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
  743. * \returns 1 if enabled, 0 if disabled, or a negative error code on failure;
  744. * call SDL_GetError() for more information.
  745. *
  746. * If `state` is `SDL_QUERY` then the current state is returned,
  747. * otherwise the new processing state is returned.
  748. *
  749. * \since This function is available since SDL 2.0.0.
  750. *
  751. * \sa SDL_GameControllerEventState
  752. *}
  753. function SDL_JoystickEventState(state: cint): cint; cdecl;
  754. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickEventState' {$ENDIF} {$ENDIF};
  755. const
  756. SDL_JOYSTICK_AXIS_MAX = 32767;
  757. SDL_JOYSTICK_AXIS_MIN = -32768;
  758. {**
  759. * Get the current state of an axis control on a joystick.
  760. *
  761. * SDL makes no promises about what part of the joystick any given axis refers
  762. * to. Your game should have some sort of configuration UI to let users
  763. * specify what each axis should be bound to. Alternately, SDL's higher-level
  764. * Game Controller API makes a great effort to apply order to this lower-level
  765. * interface, so you know that a specific axis is the "left thumb stick," etc.
  766. *
  767. * The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to
  768. * 32767) representing the current position of the axis. It may be necessary
  769. * to impose certain tolerances on these values to account for jitter.
  770. *
  771. * \param joystick an SDL_Joystick structure containing joystick information
  772. * \param axis the axis to query; the axis indices start at index 0
  773. * \returns a 16-bit signed integer representing the current position of the
  774. * axis or 0 on failure; call SDL_GetError() for more information.
  775. *
  776. * \since This function is available since SDL 2.0.0.
  777. *
  778. * \sa SDL_JoystickNumAxes
  779. *}
  780. function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: cint): cint16; cdecl;
  781. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAxis' {$ENDIF} {$ENDIF};
  782. {**
  783. * Get the initial state of an axis control on a joystick.
  784. *
  785. * The state is a value ranging from -32768 to 32767.
  786. *
  787. * The axis indices start at index 0.
  788. *
  789. * \param joystick an SDL_Joystick structure containing joystick information
  790. * \param axis the axis to query; the axis indices start at index 0
  791. * \param state Upon return, the initial value is supplied here.
  792. * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
  793. *
  794. * \since This function is available since SDL 2.0.6.
  795. *}
  796. function SDL_JoystickGetAxisInitialState(joystick: PSDL_Joystick; axis: cint; state: pcint16): TSDL_Bool; cdecl;
  797. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetAxisInitialState' {$ENDIF} {$ENDIF};
  798. {**
  799. * Hat positions
  800. *}
  801. const
  802. SDL_HAT_CENTERED = $00;
  803. SDL_HAT_UP = $01;
  804. SDL_HAT_RIGHT = $02;
  805. SDL_HAT_DOWN = $04;
  806. SDL_HAT_LEFT = $08;
  807. SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
  808. SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
  809. SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
  810. SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
  811. {**
  812. * Get the current state of a POV hat on a joystick.
  813. *
  814. * The returned value will be one of the following positions:
  815. *
  816. * - `SDL_HAT_CENTERED`
  817. * - `SDL_HAT_UP`
  818. * - `SDL_HAT_RIGHT`
  819. * - `SDL_HAT_DOWN`
  820. * - `SDL_HAT_LEFT`
  821. * - `SDL_HAT_RIGHTUP`
  822. * - `SDL_HAT_RIGHTDOWN`
  823. * - `SDL_HAT_LEFTUP`
  824. * - `SDL_HAT_LEFTDOWN`
  825. *
  826. * \param joystick an SDL_Joystick structure containing joystick information
  827. * \param hat the hat index to get the state from; indices start at index 0
  828. * \returns the current hat position.
  829. *
  830. * \since This function is available since SDL 2.0.0.
  831. *
  832. * \sa SDL_JoystickNumHats
  833. *}
  834. function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: cint): cuint8; cdecl;
  835. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetHat' {$ENDIF} {$ENDIF};
  836. {**
  837. * Get the ball axis change since the last poll.
  838. *
  839. * Trackballs can only return relative motion since the last call to
  840. * SDL_JoystickGetBall(), these motion deltas are placed into `dx` and `dy`.
  841. *
  842. * Most joysticks do not have trackballs.
  843. *
  844. * \param joystick the SDL_Joystick to query
  845. * \param ball the ball index to query; ball indices start at index 0
  846. * \param dx stores the difference in the x axis position since the last poll
  847. * \param dy stores the difference in the y axis position since the last poll
  848. * \returns 0 on success or a negative error code on failure; call
  849. * SDL_GetError() for more information.
  850. *
  851. * \since This function is available since SDL 2.0.0.
  852. *
  853. * \sa SDL_JoystickNumBalls
  854. *}
  855. function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: cint; dx: pcint; dy: pcint): cint; cdecl;
  856. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetBall' {$ENDIF} {$ENDIF};
  857. {**
  858. * Get the current state of a button on a joystick.
  859. *
  860. * \param joystick an SDL_Joystick structure containing joystick information
  861. * \param button the button index to get the state from; indices start at
  862. * index 0
  863. * \returns 1 if the specified button is pressed, 0 otherwise.
  864. *
  865. * \since This function is available since SDL 2.0.0.
  866. *
  867. * \sa SDL_JoystickNumButtons
  868. *}
  869. function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: cint): cuint8; cdecl;
  870. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickGetButton' {$ENDIF} {$ENDIF};
  871. {**
  872. * Start a rumble effect.
  873. *
  874. * Each call to this function cancels any previous rumble effect, and calling
  875. * it with 0 intensity stops any rumbling.
  876. *
  877. * \param joystick The joystick to vibrate
  878. * \param low_frequency_rumble The intensity of the low frequency (left)
  879. * rumble motor, from 0 to 0xFFFF
  880. * \param high_frequency_rumble The intensity of the high frequency (right)
  881. * rumble motor, from 0 to 0xFFFF
  882. * \param duration_ms The duration of the rumble effect, in milliseconds
  883. * \returns 0, or -1 if rumble isn't supported on this joystick
  884. *
  885. * \since This function is available since SDL 2.0.9.
  886. *
  887. * \sa SDL_JoystickHasRumble
  888. *}
  889. function SDL_JoystickRumble(joystick: PSDL_Joystick; low_frequency_rumble: cuint16; high_frequency_rumble: cuint16; duration_ms: cuint32): cint; cdecl;
  890. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickRumble' {$ENDIF} {$ENDIF};
  891. {**
  892. * Start a rumble effect in the joystick's triggers
  893. *
  894. * Each call to this function cancels any previous trigger rumble effect, and
  895. * calling it with 0 intensity stops any rumbling.
  896. *
  897. * Note that this is rumbling of the _triggers_ and not the game controller as
  898. * a whole. This is currently only supported on Xbox One controllers. If you
  899. * want the (more common) whole-controller rumble, use SDL_JoystickRumble()
  900. * instead.
  901. *
  902. * \param joystick The joystick to vibrate
  903. * \param left_rumble The intensity of the left trigger rumble motor, from 0
  904. * to 0xFFFF
  905. * \param right_rumble The intensity of the right trigger rumble motor, from 0
  906. * to 0xFFFF
  907. * \param duration_ms The duration of the rumble effect, in milliseconds
  908. * \returns 0, or -1 if trigger rumble isn't supported on this joystick
  909. *
  910. * \since This function is available since SDL 2.0.14.
  911. *
  912. * \sa SDL_JoystickHasRumbleTriggers
  913. *}
  914. function SDL_JoystickRumbleTriggers(joystick: PSDL_Joystick; left_rumble: cuint16; right_rumble: cuint16; duration_ms: cuint32): cint; cdecl;
  915. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickRumbleTriggers' {$ENDIF} {$ENDIF};
  916. {**
  917. * Query whether a joystick has an LED.
  918. *
  919. * An example of a joystick LED is the light on the back of a PlayStation 4's
  920. * DualShock 4 controller.
  921. *
  922. * \param joystick The joystick to query
  923. * \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
  924. *
  925. * \since This function is available since SDL 2.0.14.
  926. *}
  927. function SDL_JoystickHasLED(joystick: PSDL_Joystick): TSDL_Bool; cdecl;
  928. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickHasLED' {$ENDIF} {$ENDIF};
  929. {**
  930. * Query whether a joystick has rumble support.
  931. *
  932. * \param joystick The joystick to query
  933. * \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
  934. *
  935. * \since This function is available since SDL 2.0.18.
  936. *
  937. * \sa SDL_JoystickRumble
  938. *}
  939. function SDL_JoystickHasRumble(joystick: PSDL_Joystick): TSDL_Bool; cdecl;
  940. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickHasRumble' {$ENDIF} {$ENDIF};
  941. {**
  942. * Query whether a joystick has rumble support on triggers.
  943. *
  944. * \param joystick The joystick to query
  945. * \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
  946. *
  947. * \since This function is available since SDL 2.0.18.
  948. *
  949. * \sa SDL_JoystickRumbleTriggers
  950. *}
  951. function SDL_JoystickHasRumbleTriggers(joystick: PSDL_Joystick): TSDL_Bool; cdecl;
  952. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickHasRumbleTriggers' {$ENDIF} {$ENDIF};
  953. {**
  954. * Update a joystick's LED color.
  955. *
  956. * An example of a joystick LED is the light on the back of a PlayStation 4's
  957. * DualShock 4 controller.
  958. *
  959. * \param joystick The joystick to update
  960. * \param red The intensity of the red LED
  961. * \param green The intensity of the green LED
  962. * \param blue The intensity of the blue LED
  963. * \returns 0 on success, -1 if this joystick does not have a modifiable LED
  964. *
  965. * \since This function is available since SDL 2.0.14.
  966. *}
  967. function SDL_JoystickSetLED(joystick: PSDL_Joystick; red: cuint8; green: cuint8; blue: cuint8): cint; cdecl;
  968. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickSetLED' {$ENDIF} {$ENDIF};
  969. {**
  970. * Send a joystick specific effect packet
  971. *
  972. * \param joystick The joystick to affect
  973. * \param data The data to send to the joystick
  974. * \param size The size of the data to send to the joystick
  975. * \returns 0, or -1 if this joystick or driver doesn't support effect packets
  976. *
  977. * \since This function is available since SDL 2.0.16.
  978. *}
  979. function SDL_JoystickSendEffect(joystick: PSDL_Joystick; const data: Pointer; size: cint): cint; cdecl;
  980. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickSendEffect' {$ENDIF} {$ENDIF};
  981. {**
  982. * Close a joystick previously opened with SDL_JoystickOpen().
  983. *
  984. * \param joystick The joystick device to close
  985. *
  986. * \since This function is available since SDL 2.0.0.
  987. *
  988. * \sa SDL_JoystickOpen
  989. *}
  990. procedure SDL_JoystickClose(joystick: PSDL_Joystick); cdecl;
  991. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickClose' {$ENDIF} {$ENDIF};
  992. {**
  993. * Get the battery level of a joystick as SDL_JoystickPowerLevel.
  994. *
  995. * \param joystick the SDL_Joystick to query
  996. * \returns the current battery level as SDL_JoystickPowerLevel on success or
  997. * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
  998. *
  999. * \since This function is available since SDL 2.0.4.
  1000. *}
  1001. function SDL_JoystickCurrentPowerLevel(joystick: PSDL_Joystick): TSDL_JoystickPowerLevel; cdecl;
  1002. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickCurrentPowerLevel' {$ENDIF} {$ENDIF};