sdlgamecontroller.inc 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. //from sdl_gamecontroller.h
  2. {**
  3. * SDL_gamecontroller.h
  4. *
  5. * In order to use these functions, SDL_Init() must have been called
  6. * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
  7. * for game controllers, and load appropriate drivers.
  8. *
  9. * If you would like to receive controller updates while the application
  10. * is in the background, you should set the following hint before calling
  11. * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
  12. *}
  13. {* The gamecontroller structure used to identify an SDL game controller *}
  14. type
  15. PPSDL_GameController = ^PSDL_GameController;
  16. PSDL_GameController = ^TSDL_GameController;
  17. TSDL_GameController = record end;
  18. PPSDL_GameControllerType = ^PSDL_GameControllerType;
  19. PSDL_GameControllerType = ^TSDL_GameControllerType;
  20. TSDL_GameControllerType = type cint;
  21. const
  22. SDL_CONTROLLER_TYPE_UNKNOWN = TSDL_GameControllerType(0);
  23. SDL_CONTROLLER_TYPE_XBOX360 = TSDL_GameControllerType(1);
  24. SDL_CONTROLLER_TYPE_XBOXONE = TSDL_GameControllerType(2);
  25. SDL_CONTROLLER_TYPE_PS3 = TSDL_GameControllerType(3);
  26. SDL_CONTROLLER_TYPE_PS4 = TSDL_GameControllerType(4);
  27. SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO = TSDL_GameControllerType(5);
  28. SDL_CONTROLLER_TYPE_VIRTUAL = TSDL_GameControllerType(6);
  29. SDL_CONTROLLER_TYPE_PS5 = TSDL_GameControllerType(7);
  30. SDL_CONTROLLER_TYPE_AMAZON_LUNA = TSDL_GameControllerType(8);
  31. SDL_CONTROLLER_TYPE_GOOGLE_STADIA = TSDL_GameControllerType(9);
  32. SDL_CONTROLLER_TYPE_NVIDIA_SHIELD = TSDL_GameControllerType(10);
  33. SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT = TSDL_GameControllerType(11);
  34. SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT = TSDL_GameControllerType(12);
  35. SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR = TSDL_GameControllerType(13);
  36. type
  37. PPSDL_GameControllerBindType = ^PSDL_GameControllerBindType;
  38. PSDL_GameControllerBindType = ^TSDL_GameControllerBindType;
  39. TSDL_GameControllerBindType = type cint;
  40. const
  41. SDL_CONTROLLER_BINDTYPE_NONE = TSDL_GameControllerBindType(0);
  42. SDL_CONTROLLER_BINDTYPE_BUTTON = TSDL_GameControllerBindType(1);
  43. SDL_CONTROLLER_BINDTYPE_AXIS = TSDL_GameControllerBindType(2);
  44. SDL_CONTROLLER_BINDTYPE_HAT = TSDL_GameControllerBindType(3);
  45. {**
  46. * Get the SDL joystick layer binding for this controller button/axis mapping
  47. *}
  48. type
  49. THat = record
  50. hat: cint;
  51. hat_mask: cint;
  52. end;
  53. PPSDL_GameControllerButtonBind = ^PSDL_GameControllerButtonBind;
  54. PSDL_GameControllerButtonBind = ^TSDL_GameControllerButtonBind;
  55. TSDL_GameControllerButtonBind = record
  56. bindType: TSDL_GameControllerBindType;
  57. case cint of
  58. 0: ( button: cint; );
  59. 1: ( axis: cint; );
  60. 2: ( hat: THat; );
  61. end;
  62. {**
  63. * To count the number of game controllers in the system for the following:
  64. * int nJoysticks = SDL_NumJoysticks();
  65. * int nGameControllers = 0;
  66. * for ( int i = 0; i < nJoysticks; i++ ) [
  67. * if ( SDL_IsGameController(i) ) [
  68. * nGameControllers++;
  69. *
  70. * !! Pascal Conv.: Changed curly to square brackets in above example code
  71. to prevent opening comment blocks!
  72. *
  73. * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
  74. * guid,name,mappings
  75. *
  76. * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones.
  77. * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
  78. * The mapping format for joystick is:
  79. * bX - a joystick button, index X
  80. * hX.Y - hat X with value Y
  81. * aX - axis X of the joystick
  82. * Buttons can be used as a controller axis and vice versa.
  83. *
  84. * This string shows an example of a valid mapping for a controller
  85. * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
  86. *
  87. *}
  88. {**
  89. * Add or update an existing mapping configuration
  90. *
  91. * 1 if mapping is added, 0 if updated, -1 on error
  92. *}
  93. function SDL_GameControllerAddMapping( mappingString: PAnsiChar ): cint cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerAddMapping' {$ENDIF} {$ENDIF};
  94. {**
  95. * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform()
  96. * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
  97. *
  98. * If freerw is non-zero, the stream will be closed after being read.
  99. *
  100. * Returns number of mappings added, -1 on error
  101. *}
  102. function SDL_GameControllerAddMappingsFromRW(rw: PSDL_RWops; freerw: cint32):cint32;
  103. cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerAddMappingsFromRW' {$ENDIF} {$ENDIF};
  104. {**
  105. * Get the number of mappings installed.
  106. *}
  107. function SDL_GameControllerNumMappings():cint; cdecl;
  108. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerNumMappings' {$ENDIF} {$ENDIF};
  109. {**
  110. * Get a mapping string for a GUID
  111. *
  112. * the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available
  113. *}
  114. function SDL_GameControllerMappingForGUID( guid: TSDL_JoystickGUID ): PAnsiChar cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerMappingForGUID' {$ENDIF} {$ENDIF};
  115. {**
  116. * Get the mapping at a particular index.
  117. *
  118. * Returns the mapping string. Must be freed with SDL_free().
  119. * Returns NIL if the index is out of range.
  120. *}
  121. function SDL_GameControllerMappingForIndex(mapping_index: cint): PAnsiChar; cdecl;
  122. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerMappingForIndex' {$ENDIF} {$ENDIF};
  123. {**
  124. * Get a mapping string for an open GameController
  125. *
  126. * the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available
  127. *}
  128. function SDL_GameControllerMapping( gamecontroller: PSDL_GameController ): PAnsiChar cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerMapping' {$ENDIF} {$ENDIF};
  129. {**
  130. * Is the joystick on this index supported by the game controller interface?
  131. *}
  132. function SDL_IsGameController(joystick_index: cint): TSDL_Bool cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IsGameController' {$ENDIF} {$ENDIF};
  133. {**
  134. * Get the implementation dependent name of a game controller.
  135. * This can be called before any controllers are opened.
  136. * If no name can be found, this function returns NULL.
  137. *}
  138. function SDL_GameControllerNameForIndex(joystick_index: cint): PAnsiChar cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerNameForIndex' {$ENDIF} {$ENDIF};
  139. {**
  140. * Get the implementation dependent path for the game controller.
  141. *
  142. * This function can be called before any controllers are opened.
  143. *
  144. * `joystick_index` is the same as the `device_index` passed to
  145. * SDL_JoystickOpen().
  146. *
  147. * \param joystick_index the device_index of a device, from zero to
  148. * SDL_NumJoysticks()-1
  149. * \returns the implementation-dependent path for the game controller, or NIL
  150. * if there is no path or the index is invalid.
  151. *
  152. * \since This function is available since SDL 2.24.0.
  153. *
  154. * \sa SDL_GameControllerPath
  155. *}
  156. function SDL_GameControllerPathForIndex(joystick_index: cint): PAnsiChar; cdecl;
  157. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerPathForIndex' {$ENDIF} {$ENDIF};
  158. {**
  159. * Get the type of a game controller.
  160. * This can be called before any controllers are opened.
  161. *}
  162. function SDL_GameControllerTypeForIndex(joystick_index: cint): TSDL_GameControllerType; cdecl;
  163. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerTypeForIndex' {$ENDIF} {$ENDIF};
  164. {**
  165. * Get the mapping of a game controller.
  166. * This can be called before any controllers are opened.
  167. *
  168. * Returns the mapping string. Must be freed with SDL_free().
  169. * Returns NIL if no mapping is available.
  170. *}
  171. function SDL_GameControllerMappingForDeviceIndex(joystick_index: cint): PAnsiChar; cdecl;
  172. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerMappingForDeviceIndex' {$ENDIF} {$ENDIF};
  173. {**
  174. * Open a game controller for use.
  175. * The index passed as an argument refers to the N'th game controller on the system.
  176. * This index is the value which will identify this controller in future controller
  177. * events.
  178. *
  179. * A controller identifier, or NULL if an error occurred.
  180. *}
  181. function SDL_GameControllerOpen(joystick_index: cint): PSDL_GameController cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerOpen' {$ENDIF} {$ENDIF};
  182. {**
  183. * Return the SDL_GameController associated with an instance id.
  184. *}
  185. function SDL_GameControllerFromInstanceID(joyid: TSDL_JoystickID): PSDL_GameController; cdecl;
  186. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerFromInstanceID' {$ENDIF} {$ENDIF};
  187. {**
  188. * Get the SDL_GameController associated with a player index.
  189. *
  190. * Please note that the player index is _not_ the device index, nor is it the
  191. * instance id!
  192. *
  193. *}
  194. function SDL_GameControllerFromPlayerIndex(player_index: cint): PSDL_GameController; cdecl;
  195. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerFromPlayerIndex' {$ENDIF} {$ENDIF};
  196. {**
  197. * Return the name for this currently opened controller
  198. *}
  199. function SDL_GameControllerName(gamecontroller: PSDL_GameController): PAnsiChar cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerName' {$ENDIF} {$ENDIF};
  200. {**
  201. * Get the implementation-dependent path for an opened game controller.
  202. *
  203. * This is the same path as returned by SDL_GameControllerNameForIndex(), but
  204. * it takes a controller identifier instead of the (unstable) device index.
  205. *
  206. * \param gamecontroller a game controller identifier previously returned by
  207. * SDL_GameControllerOpen()
  208. * \returns the implementation dependent path for the game controller, or NIL
  209. * if there is no path or the identifier passed is invalid.
  210. *
  211. * \since This function is available since SDL 2.24.0.
  212. *
  213. * \sa SDL_GameControllerPathForIndex
  214. *}
  215. function SDL_GameControllerPath(gamecontroller: PSDL_GameController): PAnsiChar; cdecl;
  216. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerPath' {$ENDIF} {$ENDIF};
  217. {**
  218. * Get the type of this currently opened controller
  219. *
  220. * This is the same name as returned by SDL_GameControllerTypeForIndex(), but
  221. * it takes a controller identifier instead of the (unstable) device index.
  222. *}
  223. function SDL_GameControllerGetType(gamecontroller: PSDL_GameController): TSDL_GameControllerType; cdecl;
  224. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetType' {$ENDIF} {$ENDIF};
  225. {**
  226. * Get the player index of an opened game controller.
  227. * For XInput controllers this returns the XInput user index.
  228. *
  229. * Returns the player index for controller, or -1 if it's not available.
  230. *}
  231. function SDL_GameControllerGetPlayerIndex(gamecontroller: PSDL_GameController): cint; cdecl;
  232. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetPlayerIndex' {$ENDIF} {$ENDIF};
  233. {**
  234. * Set the player index of an opened game controller.
  235. *}
  236. procedure SDL_GameControllerSetPlayerIndex(gamecontroller: PSDL_GameController; player_index: cint); cdecl;
  237. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerSetPlayerIndex' {$ENDIF} {$ENDIF};
  238. {**
  239. * Get the USB vendor ID of an opened controller, if available.
  240. *
  241. * If the vendor ID isn't available this function returns 0.
  242. *
  243. * \param gamecontroller the game controller object to query.
  244. * \return the USB vendor ID, or zero if unavailable.
  245. *
  246. * \since This function is available since SDL 2.0.6.
  247. *}
  248. function SDL_GameControllerGetVendor(gamecontroller: PSDL_GameController): cuint16; cdecl;
  249. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetVendor' {$ENDIF} {$ENDIF};
  250. {**
  251. * Get the USB product ID of an opened controller, if available.
  252. * If the product ID isn't available, this function returns 0.
  253. *}
  254. function SDL_GameControllerGetProduct(gamecontroller: PSDL_GameController): cuint16; cdecl;
  255. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetProduct' {$ENDIF} {$ENDIF};
  256. {**
  257. * Get the product version of an opened controller, if available.
  258. * If the product version isn't available, this function returns 0.
  259. *}
  260. function SDL_GameControllerGetProductVersion(gamecontroller: PSDL_GameController): cuint16; cdecl;
  261. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetProductVersion' {$ENDIF} {$ENDIF};
  262. {**
  263. * Get the firmware version of an opened controller, if available.
  264. *
  265. * If the firmware version isn't available this function returns 0.
  266. *
  267. * \param gamecontroller the game controller object to query.
  268. * \return the controller firmware version, or zero if unavailable.
  269. *
  270. * \since This function is available since SDL 2.24.0.
  271. *}
  272. function SDL_GameControllerGetFirmwareVersion(gamecontroller: PSDL_GameController): cuint16; cdecl;
  273. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetFirmwareVersion' {$ENDIF} {$ENDIF};
  274. {**
  275. * Get the serial number of an opened controller, if available.
  276. *
  277. * Returns a string containing the serial number of the controller,
  278. * or NIL if it is not available. Do _not_ free the string with SDL_free().
  279. *}
  280. function SDL_GameControllerGetSerial(gamecontroller: PSDL_GameController): PAnsiChar; cdecl;
  281. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetSerial' {$ENDIF} {$ENDIF};
  282. {**
  283. * Returns SDL_TRUE if the controller has been opened and currently connected,
  284. * or SDL_FALSE if it has not.
  285. *}
  286. function SDL_GameControllerGetAttached(gamecontroller: PSDL_GameController): TSDL_Bool cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetAttached' {$ENDIF} {$ENDIF};
  287. {**
  288. * Get the underlying joystick object used by a controller
  289. *}
  290. function SDL_GameControllerGetJoystick(gamecontroller: PSDL_GameController): PSDL_Joystick cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetJoystick' {$ENDIF} {$ENDIF};
  291. {**
  292. * Enable/disable controller event polling.
  293. *
  294. * If controller events are disabled, you must call SDL_GameControllerUpdate()
  295. * yourself and check the state of the controller when you want controller
  296. * information.
  297. *
  298. * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
  299. *}
  300. function SDL_GameControllerEventState(state: cint): cint cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerEventState' {$ENDIF} {$ENDIF};
  301. {**
  302. * Update the current state of the open game controllers.
  303. *
  304. * This is called automatically by the event loop if any game controller
  305. * events are enabled.
  306. *}
  307. procedure SDL_GameControllerUpdate() cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerUpdate' {$ENDIF} {$ENDIF};
  308. {**
  309. * The list of axes available from a controller
  310. *}
  311. type
  312. PPSDL_GameControllerAxis = ^PSDL_GameControllerAxis;
  313. PSDL_GameControllerAxis = ^TSDL_GameControllerAxis;
  314. TSDL_GameControllerAxis = type cint;
  315. const
  316. SDL_CONTROLLER_AXIS_INVALID = TSDL_GameControllerAxis(-1);
  317. SDL_CONTROLLER_AXIS_LEFTX = TSDL_GameControllerAxis(0);
  318. SDL_CONTROLLER_AXIS_LEFTY = TSDL_GameControllerAxis(1);
  319. SDL_CONTROLLER_AXIS_RIGHTX = TSDL_GameControllerAxis(2);
  320. SDL_CONTROLLER_AXIS_RIGHTY = TSDL_GameControllerAxis(3);
  321. SDL_CONTROLLER_AXIS_TRIGGERLEFT = TSDL_GameControllerAxis(4);
  322. SDL_CONTROLLER_AXIS_TRIGGERRIGHT = TSDL_GameControllerAxis(5);
  323. SDL_CONTROLLER_AXIS_MAX = TSDL_GameControllerAxis(6);
  324. {**
  325. * turn this string into a axis mapping
  326. *}
  327. function SDL_GameControllerGetAxisFromString(pchString: PAnsiChar): TSDL_GameControllerAxis cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetAxisFromString' {$ENDIF} {$ENDIF};
  328. {**
  329. * turn this axis enum into a string mapping
  330. *}
  331. function SDL_GameControllerGetStringForAxis(axis: TSDL_GameControllerAxis): PAnsiChar cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetStringForAxis' {$ENDIF} {$ENDIF};
  332. {**
  333. * Get the SDL joystick layer binding for this controller button mapping
  334. *}
  335. function SDL_GameControllerGetBindForAxis(gamecontroller: PSDL_GameController; axis: TSDL_GameControllerAxis): TSDL_GameControllerButtonBind cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetBindForAxis' {$ENDIF} {$ENDIF};
  336. {**
  337. * Query whether a game controller has a given axis.
  338. *
  339. * This merely reports whether the controller's mapping defined this axis,
  340. * as that is all the information SDL has about the physical device.
  341. *}
  342. function SDL_GameControllerHasAxis(gamecontroller: PSDL_GameController; axis: TSDL_GameControllerAxis): TSDL_Bool; cdecl;
  343. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerHasAxis' {$ENDIF} {$ENDIF};
  344. {**
  345. * Get the current state of an axis control on a game controller.
  346. *
  347. * The state is a value ranging from -32768 to 32767.
  348. *
  349. * The axis indices start at index 0.
  350. *}
  351. function SDL_GameControllerGetAxis(gamecontroller: PSDL_GameController; axis: TSDL_GameControllerAxis): cint16 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetAxis' {$ENDIF} {$ENDIF};
  352. {**
  353. * The list of buttons available from a controller
  354. *}
  355. type
  356. PPSDL_GameControllerButton = ^PSDL_GameControllerButton;
  357. PSDL_GameControllerButton = ^TSDL_GameControllerButton;
  358. TSDL_GameControllerButton = type cint;
  359. const
  360. SDL_CONTROLLER_BUTTON_INVALID = TSDL_GameControllerButton(-1);
  361. SDL_CONTROLLER_BUTTON_A = TSDL_GameControllerButton(0);
  362. SDL_CONTROLLER_BUTTON_B = TSDL_GameControllerButton(1);
  363. SDL_CONTROLLER_BUTTON_X = TSDL_GameControllerButton(2);
  364. SDL_CONTROLLER_BUTTON_Y = TSDL_GameControllerButton(3);
  365. SDL_CONTROLLER_BUTTON_BACK = TSDL_GameControllerButton(4);
  366. SDL_CONTROLLER_BUTTON_GUIDE = TSDL_GameControllerButton(5);
  367. SDL_CONTROLLER_BUTTON_START = TSDL_GameControllerButton(6);
  368. SDL_CONTROLLER_BUTTON_LEFTSTICK = TSDL_GameControllerButton(7);
  369. SDL_CONTROLLER_BUTTON_RIGHTSTICK = TSDL_GameControllerButton(8);
  370. SDL_CONTROLLER_BUTTON_LEFTSHOULDER = TSDL_GameControllerButton(9);
  371. SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = TSDL_GameControllerButton(10);
  372. SDL_CONTROLLER_BUTTON_DPAD_UP = TSDL_GameControllerButton(11);
  373. SDL_CONTROLLER_BUTTON_DPAD_DOWN = TSDL_GameControllerButton(12);
  374. SDL_CONTROLLER_BUTTON_DPAD_LEFT = TSDL_GameControllerButton(13);
  375. SDL_CONTROLLER_BUTTON_DPAD_RIGHT = TSDL_GameControllerButton(14);
  376. SDL_CONTROLLER_BUTTON_MISC1 = TSDL_GameControllerButton(15); {**< Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button *}
  377. SDL_CONTROLLER_BUTTON_PADDLE1 = TSDL_GameControllerButton(16); {**< Xbox Elite paddle P1 *}
  378. SDL_CONTROLLER_BUTTON_PADDLE2 = TSDL_GameControllerButton(17); {**< Xbox Elite paddle P3 *}
  379. SDL_CONTROLLER_BUTTON_PADDLE3 = TSDL_GameControllerButton(18); {**< Xbox Elite paddle P2 *}
  380. SDL_CONTROLLER_BUTTON_PADDLE4 = TSDL_GameControllerButton(19); {**< Xbox Elite paddle P4 *}
  381. SDL_CONTROLLER_BUTTON_TOUCHPAD = TSDL_GameControllerButton(20); {**< PS4/PS5 touchpad button *}
  382. SDL_CONTROLLER_BUTTON_MAX = TSDL_GameControllerButton(21);
  383. {**
  384. * turn this string into a button mapping
  385. *}
  386. function SDL_GameControllerGetButtonFromString(pchString: PAnsiChar): TSDL_GameControllerButton cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetButtonFromString' {$ENDIF} {$ENDIF};
  387. {**
  388. * turn this button enum into a string mapping
  389. *}
  390. function SDL_GameControllerGetStringForButton(button: TSDL_GameControllerButton): PAnsiChar cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetStringForButton' {$ENDIF} {$ENDIF};
  391. {**
  392. * Get the SDL joystick layer binding for this controller button mapping
  393. *}
  394. function SDL_GameControllerGetBindForButton(gamecontroller: PSDL_GameController; button: TSDL_GameControllerButton): TSDL_GameControllerButtonBind cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetBindForButton' {$ENDIF} {$ENDIF};
  395. {**
  396. * Query whether a game controller has a given button.
  397. *
  398. * This merely reports whether the controller's mapping defined this button,
  399. * as that is all the information SDL has about the physical device.
  400. *}
  401. function SDL_GameControllerHasButton(gamecontroller: PSDL_GameController; button: TSDL_GameControllerButton): TSDL_Bool; cdecl;
  402. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerHasButton' {$ENDIF} {$ENDIF};
  403. {**
  404. * Get the current state of a button on a game controller.
  405. *
  406. * The button indices start at index 0.
  407. *}
  408. function SDL_GameControllerGetButton(gamecontroller: PSDL_GameController; button: TSDL_GameControllerButton): cuint8 cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetButton' {$ENDIF} {$ENDIF};
  409. {**
  410. * Get the number of touchpads on a game controller.
  411. *}
  412. function SDL_GameControllerGetNumTouchpads(gamecontroller: PSDL_GameController): cint; cdecl;
  413. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetNumTouchpads' {$ENDIF} {$ENDIF};
  414. {**
  415. * Get the number of supported simultaneous fingers on a touchpad on a game controller.
  416. *}
  417. function SDL_GameControllerGetNumTouchpadFingers(gamecontroller: PSDL_GameController; touchpad: cint): cint; cdecl;
  418. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetNumTouchpadFingers' {$ENDIF} {$ENDIF};
  419. {**
  420. * Get the current state of a finger on a touchpad on a game controller.
  421. *}
  422. function SDL_GameControllerGetTouchpadFinger(
  423. gamecontroller: PSDL_GameController;
  424. touchpad, finger: cint;
  425. state: pcuint8;
  426. x, y, pressure: pcfloat
  427. ): cint; cdecl;
  428. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetTouchpadFinger' {$ENDIF} {$ENDIF};
  429. {**
  430. * Return whether a game controller has a particular sensor.
  431. *}
  432. function SDL_GameControllerHasSensor(gamecontroller: PSDL_GameController; senstype: TSDL_SensorType): TSDL_Bool; cdecl;
  433. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerHasSensor' {$ENDIF} {$ENDIF};
  434. {**
  435. * Set whether data reporting for a game controller sensor is enabled.
  436. *}
  437. function SDL_GameControllerSetSensorEnabled(gamecontroller: PSDL_GameController; senstype: TSDL_SensorType; enabled: TSDL_bool): cint; cdecl;
  438. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerSetSensorEnabled' {$ENDIF} {$ENDIF};
  439. {**
  440. * Query whether sensor data reporting is enabled for a game controller.
  441. *}
  442. function SDL_GameControllerIsSensorEnabled(gamecontroller: PSDL_GameController; senstype: TSDL_SensorType): TSDL_Bool; cdecl;
  443. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerIsSensorEnabled' {$ENDIF} {$ENDIF};
  444. {**
  445. * Get the data rate (number of events per second) of
  446. * a game controller sensor.
  447. *
  448. * Returns the data rate, or 0.0 if the data rate is not available.
  449. *}
  450. function SDL_GameControllerGetSensorDataRate(gamecontroller: PSDL_GameController; senstype: TSDL_SensorType): cfloat; cdecl;
  451. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetSensorDataRate' {$ENDIF} {$ENDIF};
  452. {**
  453. * Get the current state of a game controller sensor.
  454. *
  455. * The number of values and interpretation of the data is sensor dependent.
  456. * See sdlsensor.inc for the details for each type of sensor.
  457. *}
  458. function SDL_GameControllerGetSensorData(gamecontroller: PSDL_GameController; senstype: TSDL_SensorType; data: pcfloat; num_values: cint): cint; cdecl;
  459. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetSensorData' {$ENDIF} {$ENDIF};
  460. {**
  461. * Query whether a game controller has rumble support.
  462. *}
  463. function SDL_GameControllerHasRumble(gamecontroller: PSDL_GameController): TSDL_Bool; cdecl;
  464. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerHasRumble' {$ENDIF} {$ENDIF};
  465. {**
  466. * Start a rumble effect on a game controller.
  467. *
  468. * Each call to this function cancels any previous rumble effect, and calling
  469. * it with 0 intensity stops any rumbling.
  470. *
  471. * Returns 0, or -1 if rumble isn't supported on this controller.
  472. *}
  473. function SDL_GameControllerRumble(
  474. gamecontroller: PSDL_GameController;
  475. low_frequency_rumble, high_frequency_rumble: cuint16;
  476. duration_ms: cuint32
  477. ): cint; cdecl;
  478. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerRumble' {$ENDIF} {$ENDIF};
  479. {**
  480. * Query whether a game controller has rumble support on triggers.
  481. *}
  482. function SDL_GameControllerHasRumbleTriggers(gamecontroller: PSDL_GameController): TSDL_Bool; cdecl;
  483. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerHasRumbleTriggers' {$ENDIF} {$ENDIF};
  484. {**
  485. * Start a rumble effect in the game controller's triggers.
  486. *
  487. * Each call to this function cancels any previous trigger rumble effect, and
  488. * calling it with 0 intensity stops any rumbling.
  489. *
  490. * Note that this is rumbling of the _triggers_ and not the game controller as
  491. * a whole. This is currently only supported on Xbox One controllers. If you
  492. * want the (more common) whole-controller rumble, use
  493. * SDL_GameControllerRumble() instead.
  494. *
  495. * Returns 0, or -1 if trigger rumble isn't supported on this controller
  496. *}
  497. function SDL_GameControllerRumbleTriggers(
  498. gamecontroller: PSDL_GameController;
  499. left_rumble, right_rumble: cuint16;
  500. duration_ms: cuint32
  501. ): cint; cdecl;
  502. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerRumbleTriggers' {$ENDIF} {$ENDIF};
  503. {**
  504. * Query whether a game controller has an LED.
  505. *}
  506. function SDL_GameControllerHasLED(gamecontroller: PSDL_GameController): TSDL_Bool; cdecl;
  507. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerHasLED' {$ENDIF} {$ENDIF};
  508. {**
  509. * Update a game controller's LED color.
  510. *
  511. * Returns 0, or -1 if this controller does not have a modifiable LED.
  512. *}
  513. function SDL_GameControllerSetLED(gamecontroller: PSDL_GameController; red, green, blue: cuint8): cint; cdecl;
  514. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerSetLED' {$ENDIF} {$ENDIF};
  515. {**
  516. * Send a controller-specific effect packet.
  517. *
  518. * Returns 0, or -1 if this controller or driver does not
  519. * support effect packets.
  520. *}
  521. function SDL_GameControllerSendEffect(gamecontroller: PSDL_GameController; data: Pointer; size: cint): cint; cdecl;
  522. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerSendEffect' {$ENDIF} {$ENDIF};
  523. {**
  524. * Close a controller previously opened with SDL_GameControllerOpen().
  525. *}
  526. procedure SDL_GameControllerClose(gamecontroller: PSDL_GameController) cdecl; external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerClose' {$ENDIF} {$ENDIF};
  527. {**
  528. * Return the sfSymbolsName for a given axis on a game controller
  529. * on Apple platforms.
  530. *
  531. * Returns the sfSymbolsName, or NIL if the name can't be found.
  532. * Do _not_ pass this string to SDL_free().
  533. *}
  534. function SDL_GameControllerGetAppleSFSymbolsNameForAxis(gamecontroller: PSDL_GameController; axis: TSDL_GameControllerAxis): PAnsiChar; cdecl;
  535. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetAppleSFSymbolsNameForAxis' {$ENDIF} {$ENDIF};
  536. {**
  537. * Return the sfSymbolsName for a given button on a game controller
  538. * on Apple platforms.
  539. *
  540. * Returns the sfSymbolsName, or NIL if the name can't be found.
  541. * Do _not_ pass this string to SDL_free().
  542. *}
  543. function SDL_GameControllerGetAppleSFSymbolsNameForButton(gamecontroller: PSDL_GameController; button: TSDL_GameControllerButton): PAnsiChar; cdecl;
  544. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GameControllerGetAppleSFSymbolsNameForButton' {$ENDIF} {$ENDIF};
  545. function SDL_GameControllerAddMappingsFromFile(Const FilePath:PAnsiChar):cint32;