SDL_gamepad.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_gamepad.h
  20. *
  21. * \brief Include file for SDL gamepad event handling
  22. */
  23. #ifndef SDL_gamepad_h_
  24. #define SDL_gamepad_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/SDL_error.h>
  27. #include <SDL3/SDL_rwops.h>
  28. #include <SDL3/SDL_sensor.h>
  29. #include <SDL3/SDL_joystick.h>
  30. #include <SDL3/SDL_begin_code.h>
  31. /* Set up for C function definitions, even when using C++ */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. * \file SDL_gamepad.h
  37. *
  38. * In order to use these functions, SDL_Init() must have been called
  39. * with the ::SDL_INIT_GAMEPAD flag. This causes SDL to scan the system
  40. * for gamepads, and load appropriate drivers.
  41. *
  42. * If you would like to receive gamepad updates while the application
  43. * is in the background, you should set the following hint before calling
  44. * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
  45. */
  46. /**
  47. * The structure used to identify an SDL gamepad
  48. */
  49. struct SDL_Gamepad;
  50. typedef struct SDL_Gamepad SDL_Gamepad;
  51. typedef enum
  52. {
  53. SDL_GAMEPAD_TYPE_UNKNOWN = 0,
  54. SDL_GAMEPAD_TYPE_STANDARD,
  55. SDL_GAMEPAD_TYPE_XBOX360,
  56. SDL_GAMEPAD_TYPE_XBOXONE,
  57. SDL_GAMEPAD_TYPE_PS3,
  58. SDL_GAMEPAD_TYPE_PS4,
  59. SDL_GAMEPAD_TYPE_PS5,
  60. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO,
  61. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
  62. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
  63. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
  64. SDL_GAMEPAD_TYPE_MAX
  65. } SDL_GamepadType;
  66. /**
  67. * The list of buttons available on a gamepad
  68. */
  69. typedef enum
  70. {
  71. SDL_GAMEPAD_BUTTON_INVALID = -1,
  72. SDL_GAMEPAD_BUTTON_A,
  73. SDL_GAMEPAD_BUTTON_B,
  74. SDL_GAMEPAD_BUTTON_X,
  75. SDL_GAMEPAD_BUTTON_Y,
  76. SDL_GAMEPAD_BUTTON_BACK,
  77. SDL_GAMEPAD_BUTTON_GUIDE,
  78. SDL_GAMEPAD_BUTTON_START,
  79. SDL_GAMEPAD_BUTTON_LEFT_STICK,
  80. SDL_GAMEPAD_BUTTON_RIGHT_STICK,
  81. SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
  82. SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
  83. SDL_GAMEPAD_BUTTON_DPAD_UP,
  84. SDL_GAMEPAD_BUTTON_DPAD_DOWN,
  85. SDL_GAMEPAD_BUTTON_DPAD_LEFT,
  86. SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
  87. SDL_GAMEPAD_BUTTON_MISC1, /* Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button) */
  88. SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /* Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */
  89. SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /* Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */
  90. SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /* Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */
  91. SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /* Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */
  92. SDL_GAMEPAD_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
  93. SDL_GAMEPAD_BUTTON_MAX
  94. } SDL_GamepadButton;
  95. /**
  96. * The list of axes available on a gamepad
  97. *
  98. * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
  99. * and are centered within ~8000 of zero, though advanced UI will allow users to set
  100. * or autodetect the dead zone, which varies between gamepads.
  101. *
  102. * Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.
  103. */
  104. typedef enum
  105. {
  106. SDL_GAMEPAD_AXIS_INVALID = -1,
  107. SDL_GAMEPAD_AXIS_LEFTX,
  108. SDL_GAMEPAD_AXIS_LEFTY,
  109. SDL_GAMEPAD_AXIS_RIGHTX,
  110. SDL_GAMEPAD_AXIS_RIGHTY,
  111. SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
  112. SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,
  113. SDL_GAMEPAD_AXIS_MAX
  114. } SDL_GamepadAxis;
  115. /**
  116. * Add support for gamepads that SDL is unaware of or change the binding of an
  117. * existing gamepad.
  118. *
  119. * The mapping string has the format "GUID,name,mapping", where GUID is the
  120. * string value from SDL_GetJoystickGUIDString(), name is the human readable
  121. * string for the device and mappings are gamepad mappings to joystick ones.
  122. * Under Windows there is a reserved GUID of "xinput" that covers all XInput
  123. * devices. The mapping format for joystick is:
  124. *
  125. * - `bX`: a joystick button, index X
  126. * - `hX.Y`: hat X with value Y
  127. * - `aX`: axis X of the joystick
  128. *
  129. * Buttons can be used as a gamepad axes and vice versa.
  130. *
  131. * This string shows an example of a valid mapping for a gamepad:
  132. *
  133. * ```c
  134. * "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"
  135. * ```
  136. *
  137. * \param mapping the mapping string
  138. * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
  139. * -1 on error; call SDL_GetError() for more information.
  140. *
  141. * \since This function is available since SDL 3.0.0.
  142. *
  143. * \sa SDL_GetGamepadMapping
  144. * \sa SDL_GetGamepadMappingForGUID
  145. */
  146. extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
  147. /**
  148. * Load a set of gamepad mappings from a seekable SDL data stream.
  149. *
  150. * You can call this function several times, if needed, to load different
  151. * database files.
  152. *
  153. * If a new mapping is loaded for an already known gamepad GUID, the later
  154. * version will overwrite the one currently loaded.
  155. *
  156. * Mappings not belonging to the current platform or with no platform field
  157. * specified will be ignored (i.e. mappings for Linux will be ignored in
  158. * Windows, etc).
  159. *
  160. * This function will load the text database entirely in memory before
  161. * processing it, so take this into consideration if you are in a memory
  162. * constrained environment.
  163. *
  164. * \param src the data stream for the mappings to be added
  165. * \param freesrc if SDL_TRUE, calls SDL_RWclose() on `src` before returning,
  166. * even in the case of an error
  167. * \returns the number of mappings added or -1 on error; call SDL_GetError()
  168. * for more information.
  169. *
  170. * \since This function is available since SDL 3.0.0.
  171. *
  172. * \sa SDL_AddGamepadMapping
  173. * \sa SDL_AddGamepadMappingsFromFile
  174. * \sa SDL_GetGamepadMappingForGUID
  175. */
  176. extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc);
  177. /**
  178. * Load a set of gamepad mappings from a file.
  179. *
  180. * You can call this function several times, if needed, to load different
  181. * database files.
  182. *
  183. * If a new mapping is loaded for an already known gamepad GUID, the later
  184. * version will overwrite the one currently loaded.
  185. *
  186. * Mappings not belonging to the current platform or with no platform field
  187. * specified will be ignored (i.e. mappings for Linux will be ignored in
  188. * Windows, etc).
  189. *
  190. * \param file the mappings file to load
  191. * \returns the number of mappings added or -1 on error; call SDL_GetError()
  192. * for more information.
  193. *
  194. * \since This function is available since SDL 3.0.0.
  195. *
  196. * \sa SDL_AddGamepadMapping
  197. * \sa SDL_AddGamepadMappingsFromRW
  198. * \sa SDL_GetGamepadMappingForGUID
  199. */
  200. extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
  201. /**
  202. * Reinitialize the SDL mapping database to its initial state.
  203. *
  204. * This will generate gamepad events as needed if device mappings change.
  205. *
  206. * \returns 0 on success or a negative error code on failure; call
  207. * SDL_GetError() for more information.
  208. *
  209. * \since This function is available since SDL 3.0.0.
  210. */
  211. extern DECLSPEC int SDLCALL SDL_ReloadGamepadMappings(void);
  212. /**
  213. * Get the number of mappings installed.
  214. *
  215. * \returns the number of mappings.
  216. *
  217. * \since This function is available since SDL 3.0.0.
  218. */
  219. extern DECLSPEC int SDLCALL SDL_GetNumGamepadMappings(void);
  220. /**
  221. * Get the mapping at a particular index.
  222. *
  223. * \param mapping_index mapping index
  224. * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
  225. * the index is out of range.
  226. *
  227. * \since This function is available since SDL 3.0.0.
  228. */
  229. extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForIndex(int mapping_index);
  230. /**
  231. * Get the gamepad mapping string for a given GUID.
  232. *
  233. * The returned string must be freed with SDL_free().
  234. *
  235. * \param guid a structure containing the GUID for which a mapping is desired
  236. * \returns a mapping string or NULL on error; call SDL_GetError() for more
  237. * information.
  238. *
  239. * \since This function is available since SDL 3.0.0.
  240. *
  241. * \sa SDL_GetJoystickInstanceGUID
  242. * \sa SDL_GetJoystickGUID
  243. */
  244. extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid);
  245. /**
  246. * Get the current mapping of a gamepad.
  247. *
  248. * The returned string must be freed with SDL_free().
  249. *
  250. * Details about mappings are discussed with SDL_AddGamepadMapping().
  251. *
  252. * \param gamepad the gamepad you want to get the current mapping for
  253. * \returns a string that has the gamepad's mapping or NULL if no mapping is
  254. * available; call SDL_GetError() for more information.
  255. *
  256. * \since This function is available since SDL 3.0.0.
  257. *
  258. * \sa SDL_AddGamepadMapping
  259. * \sa SDL_GetGamepadMappingForGUID
  260. * \sa SDL_SetGamepadMapping
  261. */
  262. extern DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
  263. /**
  264. * Set the current mapping of a joystick or gamepad.
  265. *
  266. * Details about mappings are discussed with SDL_AddGamepadMapping().
  267. *
  268. * \param instance_id the joystick instance ID
  269. * \param mapping the mapping to use for this device, or NULL to clear the
  270. * mapping
  271. * \returns 0 on success or a negative error code on failure; call
  272. * SDL_GetError() for more information.
  273. *
  274. * \since This function is available since SDL 3.0.0.
  275. *
  276. * \sa SDL_AddGamepadMapping
  277. * \sa SDL_GetGamepadMapping
  278. */
  279. extern DECLSPEC int SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
  280. /**
  281. * Get a list of currently connected gamepads.
  282. *
  283. * \param count a pointer filled in with the number of gamepads returned
  284. * \returns a 0 terminated array of joystick instance IDs which should be
  285. * freed with SDL_free(), or NULL on error; call SDL_GetError() for
  286. * more details.
  287. *
  288. * \since This function is available since SDL 3.0.0.
  289. *
  290. * \sa SDL_OpenGamepad
  291. */
  292. extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetGamepads(int *count);
  293. /**
  294. * Check if the given joystick is supported by the gamepad interface.
  295. *
  296. * \param instance_id the joystick instance ID
  297. * \returns SDL_TRUE if the given joystick is supported by the gamepad
  298. * interface, SDL_FALSE if it isn't or it's an invalid index.
  299. *
  300. * \since This function is available since SDL 3.0.0.
  301. *
  302. * \sa SDL_OpenGamepad
  303. */
  304. extern DECLSPEC SDL_bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
  305. /**
  306. * Get the implementation dependent name of a gamepad.
  307. *
  308. * This can be called before any gamepads are opened.
  309. *
  310. * \param instance_id the joystick instance ID
  311. * \returns the name of the selected gamepad. If no name can be found, this
  312. * function returns NULL; call SDL_GetError() for more information.
  313. *
  314. * \since This function is available since SDL 3.0.0.
  315. *
  316. * \sa SDL_GetGamepadName
  317. * \sa SDL_OpenGamepad
  318. */
  319. extern DECLSPEC const char *SDLCALL SDL_GetGamepadInstanceName(SDL_JoystickID instance_id);
  320. /**
  321. * Get the implementation dependent path of a gamepad.
  322. *
  323. * This can be called before any gamepads are opened.
  324. *
  325. * \param instance_id the joystick instance ID
  326. * \returns the path of the selected gamepad. If no path can be found, this
  327. * function returns NULL; call SDL_GetError() for more information.
  328. *
  329. * \since This function is available since SDL 3.0.0.
  330. *
  331. * \sa SDL_GetGamepadPath
  332. * \sa SDL_OpenGamepad
  333. */
  334. extern DECLSPEC const char *SDLCALL SDL_GetGamepadInstancePath(SDL_JoystickID instance_id);
  335. /**
  336. * Get the player index of a gamepad.
  337. *
  338. * This can be called before any gamepads are opened.
  339. *
  340. * \param instance_id the joystick instance ID
  341. * \returns the player index of a gamepad, or -1 if it's not available
  342. *
  343. * \since This function is available since SDL 3.0.0.
  344. *
  345. * \sa SDL_GetGamepadPlayerIndex
  346. * \sa SDL_OpenGamepad
  347. */
  348. extern DECLSPEC int SDLCALL SDL_GetGamepadInstancePlayerIndex(SDL_JoystickID instance_id);
  349. /**
  350. * Get the implementation-dependent GUID of a gamepad.
  351. *
  352. * This can be called before any gamepads are opened.
  353. *
  354. * \param instance_id the joystick instance ID
  355. * \returns the GUID of the selected gamepad. If called on an invalid index,
  356. * this function returns a zero GUID
  357. *
  358. * \since This function is available since SDL 3.0.0.
  359. *
  360. * \sa SDL_GetGamepadGUID
  361. * \sa SDL_GetGamepadGUIDString
  362. */
  363. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetGamepadInstanceGUID(SDL_JoystickID instance_id);
  364. /**
  365. * Get the USB vendor ID of a gamepad, if available.
  366. *
  367. * This can be called before any gamepads are opened. If the vendor ID isn't
  368. * available this function returns 0.
  369. *
  370. * \param instance_id the joystick instance ID
  371. * \returns the USB vendor ID of the selected gamepad. If called on an invalid
  372. * index, this function returns zero
  373. *
  374. * \since This function is available since SDL 3.0.0.
  375. */
  376. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceVendor(SDL_JoystickID instance_id);
  377. /**
  378. * Get the USB product ID of a gamepad, if available.
  379. *
  380. * This can be called before any gamepads are opened. If the product ID isn't
  381. * available this function returns 0.
  382. *
  383. * \param instance_id the joystick instance ID
  384. * \returns the USB product ID of the selected gamepad. If called on an
  385. * invalid index, this function returns zero
  386. *
  387. * \since This function is available since SDL 3.0.0.
  388. */
  389. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceProduct(SDL_JoystickID instance_id);
  390. /**
  391. * Get the product version of a gamepad, if available.
  392. *
  393. * This can be called before any gamepads are opened. If the product version
  394. * isn't available this function returns 0.
  395. *
  396. * \param instance_id the joystick instance ID
  397. * \returns the product version of the selected gamepad. If called on an
  398. * invalid index, this function returns zero
  399. *
  400. * \since This function is available since SDL 3.0.0.
  401. */
  402. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceProductVersion(SDL_JoystickID instance_id);
  403. /**
  404. * Get the type of a gamepad.
  405. *
  406. * This can be called before any gamepads are opened.
  407. *
  408. * \param instance_id the joystick instance ID
  409. * \returns the gamepad type.
  410. *
  411. * \since This function is available since SDL 3.0.0.
  412. */
  413. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadInstanceType(SDL_JoystickID instance_id);
  414. /**
  415. * Get the type of a gamepad, ignoring any mapping override.
  416. *
  417. * This can be called before any gamepads are opened.
  418. *
  419. * \param instance_id the joystick instance ID
  420. * \returns the gamepad type.
  421. *
  422. * \since This function is available since SDL 3.0.0.
  423. */
  424. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadInstanceType(SDL_JoystickID instance_id);
  425. /**
  426. * Get the mapping of a gamepad.
  427. *
  428. * This can be called before any gamepads are opened.
  429. *
  430. * \param instance_id the joystick instance ID
  431. * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
  432. * no mapping is available.
  433. *
  434. * \since This function is available since SDL 3.0.0.
  435. */
  436. extern DECLSPEC char *SDLCALL SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id);
  437. /**
  438. * Open a gamepad for use.
  439. *
  440. * \param instance_id the joystick instance ID
  441. * \returns a gamepad identifier or NULL if an error occurred; call
  442. * SDL_GetError() for more information.
  443. *
  444. * \since This function is available since SDL 3.0.0.
  445. *
  446. * \sa SDL_CloseGamepad
  447. * \sa SDL_IsGamepad
  448. */
  449. extern DECLSPEC SDL_Gamepad *SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);
  450. /**
  451. * Get the SDL_Gamepad associated with a joystick instance ID, if it has been
  452. * opened.
  453. *
  454. * \param instance_id the joystick instance ID of the gamepad
  455. * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
  456. * opened yet; call SDL_GetError() for more information.
  457. *
  458. * \since This function is available since SDL 3.0.0.
  459. */
  460. extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromInstanceID(SDL_JoystickID instance_id);
  461. /**
  462. * Get the SDL_Gamepad associated with a player index.
  463. *
  464. * \param player_index the player index, which different from the instance ID
  465. * \returns the SDL_Gamepad associated with a player index.
  466. *
  467. * \since This function is available since SDL 3.0.0.
  468. *
  469. * \sa SDL_GetGamepadPlayerIndex
  470. * \sa SDL_SetGamepadPlayerIndex
  471. */
  472. extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
  473. /**
  474. * Get the instance ID of an opened gamepad.
  475. *
  476. * \param gamepad a gamepad identifier previously returned by
  477. * SDL_OpenGamepad()
  478. * \returns the instance ID of the specified gamepad on success or 0 on
  479. * failure; call SDL_GetError() for more information.
  480. *
  481. * \since This function is available since SDL 3.0.0.
  482. *
  483. * \sa SDL_OpenGamepad
  484. */
  485. extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad);
  486. /**
  487. * Get the implementation-dependent name for an opened gamepad.
  488. *
  489. * \param gamepad a gamepad identifier previously returned by
  490. * SDL_OpenGamepad()
  491. * \returns the implementation dependent name for the gamepad, or NULL if
  492. * there is no name or the identifier passed is invalid.
  493. *
  494. * \since This function is available since SDL 3.0.0.
  495. *
  496. * \sa SDL_GetGamepadInstanceName
  497. * \sa SDL_OpenGamepad
  498. */
  499. extern DECLSPEC const char *SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
  500. /**
  501. * Get the implementation-dependent path for an opened gamepad.
  502. *
  503. * \param gamepad a gamepad identifier previously returned by
  504. * SDL_OpenGamepad()
  505. * \returns the implementation dependent path for the gamepad, or NULL if
  506. * there is no path or the identifier passed is invalid.
  507. *
  508. * \since This function is available since SDL 3.0.0.
  509. *
  510. * \sa SDL_GetGamepadInstancePath
  511. */
  512. extern DECLSPEC const char *SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
  513. /**
  514. * Get the type of an opened gamepad.
  515. *
  516. * \param gamepad the gamepad object to query.
  517. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
  518. * available.
  519. *
  520. * \since This function is available since SDL 3.0.0.
  521. *
  522. * \sa SDL_GetGamepadInstanceType
  523. */
  524. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
  525. /**
  526. * Get the type of an opened gamepad, ignoring any mapping override.
  527. *
  528. * \param gamepad the gamepad object to query.
  529. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
  530. * available.
  531. *
  532. * \since This function is available since SDL 3.0.0.
  533. *
  534. * \sa SDL_GetRealGamepadInstanceType
  535. */
  536. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
  537. /**
  538. * Get the player index of an opened gamepad.
  539. *
  540. * For XInput gamepads this returns the XInput user index.
  541. *
  542. * \param gamepad the gamepad object to query.
  543. * \returns the player index for gamepad, or -1 if it's not available.
  544. *
  545. * \since This function is available since SDL 3.0.0.
  546. */
  547. extern DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
  548. /**
  549. * Set the player index of an opened gamepad.
  550. *
  551. * \param gamepad the gamepad object to adjust.
  552. * \param player_index Player index to assign to this gamepad, or -1 to clear
  553. * the player index and turn off player LEDs.
  554. * \returns 0 on success or a negative error code on failure; call
  555. * SDL_GetError() for more information.
  556. *
  557. * \since This function is available since SDL 3.0.0.
  558. */
  559. extern DECLSPEC int SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
  560. /**
  561. * Get the USB vendor ID of an opened gamepad, if available.
  562. *
  563. * If the vendor ID isn't available this function returns 0.
  564. *
  565. * \param gamepad the gamepad object to query.
  566. * \returns the USB vendor ID, or zero if unavailable.
  567. *
  568. * \since This function is available since SDL 3.0.0.
  569. */
  570. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
  571. /**
  572. * Get the USB product ID of an opened gamepad, if available.
  573. *
  574. * If the product ID isn't available this function returns 0.
  575. *
  576. * \param gamepad the gamepad object to query.
  577. * \returns the USB product ID, or zero if unavailable.
  578. *
  579. * \since This function is available since SDL 3.0.0.
  580. */
  581. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
  582. /**
  583. * Get the product version of an opened gamepad, if available.
  584. *
  585. * If the product version isn't available this function returns 0.
  586. *
  587. * \param gamepad the gamepad object to query.
  588. * \returns the USB product version, or zero if unavailable.
  589. *
  590. * \since This function is available since SDL 3.0.0.
  591. */
  592. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
  593. /**
  594. * Get the firmware version of an opened gamepad, if available.
  595. *
  596. * If the firmware version isn't available this function returns 0.
  597. *
  598. * \param gamepad the gamepad object to query.
  599. * \returns the gamepad firmware version, or zero if unavailable.
  600. *
  601. * \since This function is available since SDL 3.0.0.
  602. */
  603. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
  604. /**
  605. * Get the serial number of an opened gamepad, if available.
  606. *
  607. * Returns the serial number of the gamepad, or NULL if it is not available.
  608. *
  609. * \param gamepad the gamepad object to query.
  610. * \returns the serial number, or NULL if unavailable.
  611. *
  612. * \since This function is available since SDL 3.0.0.
  613. */
  614. extern DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
  615. /**
  616. * Get the battery level of a gamepad, if available.
  617. *
  618. * \param gamepad a gamepad identifier previously returned by
  619. * SDL_OpenGamepad()
  620. * \returns the current battery level as SDL_JoystickPowerLevel on success or
  621. * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
  622. *
  623. * \since This function is available since SDL 3.0.0.
  624. */
  625. extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad);
  626. /**
  627. * Check if a gamepad has been opened and is currently connected.
  628. *
  629. * \param gamepad a gamepad identifier previously returned by
  630. * SDL_OpenGamepad()
  631. * \returns SDL_TRUE if the gamepad has been opened and is currently
  632. * connected, or SDL_FALSE if not.
  633. *
  634. * \since This function is available since SDL 3.0.0.
  635. *
  636. * \sa SDL_CloseGamepad
  637. * \sa SDL_OpenGamepad
  638. */
  639. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
  640. /**
  641. * Get the underlying joystick from a gamepad
  642. *
  643. * This function will give you a SDL_Joystick object, which allows you to use
  644. * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
  645. * for getting a joystick's position at any given time, even if it hasn't
  646. * moved (moving it would produce an event, which would have the axis' value).
  647. *
  648. * The pointer returned is owned by the SDL_Gamepad. You should not call
  649. * SDL_CloseJoystick() on it, for example, since doing so will likely cause
  650. * SDL to crash.
  651. *
  652. * \param gamepad the gamepad object that you want to get a joystick from
  653. * \returns an SDL_Joystick object; call SDL_GetError() for more information.
  654. *
  655. * \since This function is available since SDL 3.0.0.
  656. */
  657. extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
  658. /**
  659. * Set the state of gamepad event processing.
  660. *
  661. * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
  662. * and check the state of the gamepad when you want gamepad information.
  663. *
  664. * \param enabled whether to process gamepad events or not
  665. *
  666. * \since This function is available since SDL 3.0.0.
  667. *
  668. * \sa SDL_GamepadEventsEnabled
  669. */
  670. extern DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(SDL_bool enabled);
  671. /**
  672. * Query the state of gamepad event processing.
  673. *
  674. * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
  675. * and check the state of the gamepad when you want gamepad information.
  676. *
  677. * \returns SDL_TRUE if gamepad events are being processed, SDL_FALSE
  678. * otherwise.
  679. *
  680. * \since This function is available since SDL 3.0.0.
  681. *
  682. * \sa SDL_SetGamepadEventsEnabled
  683. */
  684. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadEventsEnabled(void);
  685. /**
  686. * Manually pump gamepad updates if not using the loop.
  687. *
  688. * This function is called automatically by the event loop if events are
  689. * enabled. Under such circumstances, it will not be necessary to call this
  690. * function.
  691. *
  692. * \since This function is available since SDL 3.0.0.
  693. */
  694. extern DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
  695. /**
  696. * Convert a string into SDL_GamepadType enum.
  697. *
  698. * This function is called internally to translate SDL_Gamepad mapping strings
  699. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  700. * You do not normally need to call this function unless you are parsing
  701. * SDL_Gamepad mappings in your own code.
  702. *
  703. * \param str string representing a SDL_GamepadType type
  704. * \returns the SDL_GamepadType enum corresponding to the input string, or
  705. * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
  706. *
  707. * \since This function is available since SDL 3.0.0.
  708. *
  709. * \sa SDL_GetGamepadStringForType
  710. */
  711. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
  712. /**
  713. * Convert from an SDL_GamepadType enum to a string.
  714. *
  715. * The caller should not SDL_free() the returned string.
  716. *
  717. * \param type an enum value for a given SDL_GamepadType
  718. * \returns a string for the given type, or NULL if an invalid type is
  719. * specified. The string returned is of the format used by
  720. * SDL_Gamepad mapping strings.
  721. *
  722. * \since This function is available since SDL 3.0.0.
  723. *
  724. * \sa SDL_GetGamepadTypeFromString
  725. */
  726. extern DECLSPEC const char *SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
  727. /**
  728. * Convert a string into SDL_GamepadAxis enum.
  729. *
  730. * This function is called internally to translate SDL_Gamepad mapping strings
  731. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  732. * You do not normally need to call this function unless you are parsing
  733. * SDL_Gamepad mappings in your own code.
  734. *
  735. * Note specially that "righttrigger" and "lefttrigger" map to
  736. * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
  737. * respectively.
  738. *
  739. * \param str string representing a SDL_Gamepad axis
  740. * \returns the SDL_GamepadAxis enum corresponding to the input string, or
  741. * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
  742. *
  743. * \since This function is available since SDL 3.0.0.
  744. *
  745. * \sa SDL_GetGamepadStringForAxis
  746. */
  747. extern DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
  748. /**
  749. * Convert from an SDL_GamepadAxis enum to a string.
  750. *
  751. * The caller should not SDL_free() the returned string.
  752. *
  753. * \param axis an enum value for a given SDL_GamepadAxis
  754. * \returns a string for the given axis, or NULL if an invalid axis is
  755. * specified. The string returned is of the format used by
  756. * SDL_Gamepad mapping strings.
  757. *
  758. * \since This function is available since SDL 3.0.0.
  759. *
  760. * \sa SDL_GetGamepadAxisFromString
  761. */
  762. extern DECLSPEC const char* SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
  763. /**
  764. * Query whether a gamepad has a given axis.
  765. *
  766. * This merely reports whether the gamepad's mapping defined this axis, as
  767. * that is all the information SDL has about the physical device.
  768. *
  769. * \param gamepad a gamepad
  770. * \param axis an axis enum value (an SDL_GamepadAxis value)
  771. * \returns SDL_TRUE if the gamepad has this axis, SDL_FALSE otherwise.
  772. *
  773. * \since This function is available since SDL 3.0.0.
  774. */
  775. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  776. /**
  777. * Get the current state of an axis control on a gamepad.
  778. *
  779. * The axis indices start at index 0.
  780. *
  781. * The state is a value ranging from -32768 to 32767. Triggers, however, range
  782. * from 0 to 32767 (they never return a negative value).
  783. *
  784. * \param gamepad a gamepad
  785. * \param axis an axis index (one of the SDL_GamepadAxis values)
  786. * \returns axis state (including 0) on success or 0 (also) on failure; call
  787. * SDL_GetError() for more information.
  788. *
  789. * \since This function is available since SDL 3.0.0.
  790. *
  791. * \sa SDL_GetGamepadButton
  792. */
  793. extern DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  794. /**
  795. * Convert a string into an SDL_GamepadButton enum.
  796. *
  797. * This function is called internally to translate SDL_Gamepad mapping strings
  798. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  799. * You do not normally need to call this function unless you are parsing
  800. * SDL_Gamepad mappings in your own code.
  801. *
  802. * \param str string representing a SDL_Gamepad axis
  803. * \returns the SDL_GamepadButton enum corresponding to the input string, or
  804. * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
  805. *
  806. * \since This function is available since SDL 3.0.0.
  807. */
  808. extern DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
  809. /**
  810. * Convert from an SDL_GamepadButton enum to a string.
  811. *
  812. * The caller should not SDL_free() the returned string.
  813. *
  814. * \param button an enum value for a given SDL_GamepadButton
  815. * \returns a string for the given button, or NULL if an invalid button is
  816. * specified. The string returned is of the format used by
  817. * SDL_Gamepad mapping strings.
  818. *
  819. * \since This function is available since SDL 3.0.0.
  820. *
  821. * \sa SDL_GetGamepadButtonFromString
  822. */
  823. extern DECLSPEC const char* SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
  824. /**
  825. * Query whether a gamepad has a given button.
  826. *
  827. * This merely reports whether the gamepad's mapping defined this button, as
  828. * that is all the information SDL has about the physical device.
  829. *
  830. * \param gamepad a gamepad
  831. * \param button a button enum value (an SDL_GamepadButton value)
  832. * \returns SDL_TRUE if the gamepad has this button, SDL_FALSE otherwise.
  833. *
  834. * \since This function is available since SDL 3.0.0.
  835. */
  836. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  837. /**
  838. * Get the current state of a button on a gamepad.
  839. *
  840. * \param gamepad a gamepad
  841. * \param button a button index (one of the SDL_GamepadButton values)
  842. * \returns 1 for pressed state or 0 for not pressed state or error; call
  843. * SDL_GetError() for more information.
  844. *
  845. * \since This function is available since SDL 3.0.0.
  846. *
  847. * \sa SDL_GetGamepadAxis
  848. */
  849. extern DECLSPEC Uint8 SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  850. /**
  851. * Get the number of touchpads on a gamepad.
  852. *
  853. * \param gamepad a gamepad
  854. * \returns number of touchpads
  855. *
  856. * \since This function is available since SDL 3.0.0.
  857. */
  858. extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
  859. /**
  860. * Get the number of supported simultaneous fingers on a touchpad on a game
  861. * gamepad.
  862. *
  863. * \param gamepad a gamepad
  864. * \param touchpad a touchpad
  865. * \returns number of supported simultaneous fingers
  866. *
  867. * \since This function is available since SDL 3.0.0.
  868. */
  869. extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
  870. /**
  871. * Get the current state of a finger on a touchpad on a gamepad.
  872. *
  873. * \param gamepad a gamepad
  874. * \param touchpad a touchpad
  875. * \param finger a finger
  876. * \param state filled with state
  877. * \param x filled with x position
  878. * \param y filled with y position
  879. * \param pressure filled with pressure value
  880. * \returns 0 on success or a negative error code on failure; call
  881. * SDL_GetError() for more information.
  882. *
  883. * \since This function is available since SDL 3.0.0.
  884. */
  885. extern DECLSPEC int SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
  886. /**
  887. * Return whether a gamepad has a particular sensor.
  888. *
  889. * \param gamepad The gamepad to query
  890. * \param type The type of sensor to query
  891. * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
  892. *
  893. * \since This function is available since SDL 3.0.0.
  894. */
  895. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
  896. /**
  897. * Set whether data reporting for a gamepad sensor is enabled.
  898. *
  899. * \param gamepad The gamepad to update
  900. * \param type The type of sensor to enable/disable
  901. * \param enabled Whether data reporting should be enabled
  902. * \returns 0 on success or a negative error code on failure; call
  903. * SDL_GetError() for more information.
  904. *
  905. * \since This function is available since SDL 3.0.0.
  906. */
  907. extern DECLSPEC int SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled);
  908. /**
  909. * Query whether sensor data reporting is enabled for a gamepad.
  910. *
  911. * \param gamepad The gamepad to query
  912. * \param type The type of sensor to query
  913. * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
  914. *
  915. * \since This function is available since SDL 3.0.0.
  916. */
  917. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
  918. /**
  919. * Get the data rate (number of events per second) of a gamepad sensor.
  920. *
  921. * \param gamepad The gamepad to query
  922. * \param type The type of sensor to query
  923. * \returns the data rate, or 0.0f if the data rate is not available.
  924. *
  925. * \since This function is available since SDL 3.0.0.
  926. */
  927. extern DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
  928. /**
  929. * Get the current state of a gamepad sensor.
  930. *
  931. * The number of values and interpretation of the data is sensor dependent.
  932. * See SDL_sensor.h for the details for each type of sensor.
  933. *
  934. * \param gamepad The gamepad to query
  935. * \param type The type of sensor to query
  936. * \param data A pointer filled with the current sensor state
  937. * \param num_values The number of values to write to data
  938. * \returns 0 on success or a negative error code on failure; call
  939. * SDL_GetError() for more information.
  940. *
  941. * \since This function is available since SDL 3.0.0.
  942. */
  943. extern DECLSPEC int SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
  944. /**
  945. * Start a rumble effect on a gamepad.
  946. *
  947. * Each call to this function cancels any previous rumble effect, and calling
  948. * it with 0 intensity stops any rumbling.
  949. *
  950. * \param gamepad The gamepad to vibrate
  951. * \param low_frequency_rumble The intensity of the low frequency (left)
  952. * rumble motor, from 0 to 0xFFFF
  953. * \param high_frequency_rumble The intensity of the high frequency (right)
  954. * rumble motor, from 0 to 0xFFFF
  955. * \param duration_ms The duration of the rumble effect, in milliseconds
  956. * \returns 0, or -1 if rumble isn't supported on this gamepad
  957. *
  958. * \since This function is available since SDL 3.0.0.
  959. *
  960. * \sa SDL_GamepadHasRumble
  961. */
  962. extern DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
  963. /**
  964. * Start a rumble effect in the gamepad's triggers.
  965. *
  966. * Each call to this function cancels any previous trigger rumble effect, and
  967. * calling it with 0 intensity stops any rumbling.
  968. *
  969. * Note that this is rumbling of the _triggers_ and not the gamepad as a
  970. * whole. This is currently only supported on Xbox One gamepads. If you want
  971. * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
  972. *
  973. * \param gamepad The gamepad to vibrate
  974. * \param left_rumble The intensity of the left trigger rumble motor, from 0
  975. * to 0xFFFF
  976. * \param right_rumble The intensity of the right trigger rumble motor, from 0
  977. * to 0xFFFF
  978. * \param duration_ms The duration of the rumble effect, in milliseconds
  979. * \returns 0 on success or a negative error code on failure; call
  980. * SDL_GetError() for more information.
  981. *
  982. * \since This function is available since SDL 3.0.0.
  983. *
  984. * \sa SDL_GamepadHasRumbleTriggers
  985. */
  986. extern DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
  987. /**
  988. * Query whether a gamepad has an LED.
  989. *
  990. * \param gamepad The gamepad to query
  991. * \returns SDL_TRUE, or SDL_FALSE if this gamepad does not have a modifiable
  992. * LED
  993. *
  994. * \since This function is available since SDL 3.0.0.
  995. */
  996. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasLED(SDL_Gamepad *gamepad);
  997. /**
  998. * Query whether a gamepad has rumble support.
  999. *
  1000. * \param gamepad The gamepad to query
  1001. * \returns SDL_TRUE, or SDL_FALSE if this gamepad does not have rumble
  1002. * support
  1003. *
  1004. * \since This function is available since SDL 3.0.0.
  1005. *
  1006. * \sa SDL_RumbleGamepad
  1007. */
  1008. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasRumble(SDL_Gamepad *gamepad);
  1009. /**
  1010. * Query whether a gamepad has rumble support on triggers.
  1011. *
  1012. * \param gamepad The gamepad to query
  1013. * \returns SDL_TRUE, or SDL_FALSE if this gamepad does not have trigger
  1014. * rumble support
  1015. *
  1016. * \since This function is available since SDL 3.0.0.
  1017. *
  1018. * \sa SDL_RumbleGamepadTriggers
  1019. */
  1020. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasRumbleTriggers(SDL_Gamepad *gamepad);
  1021. /**
  1022. * Update a gamepad's LED color.
  1023. *
  1024. * \param gamepad The gamepad to update
  1025. * \param red The intensity of the red LED
  1026. * \param green The intensity of the green LED
  1027. * \param blue The intensity of the blue LED
  1028. * \returns 0 on success or a negative error code on failure; call
  1029. * SDL_GetError() for more information.
  1030. *
  1031. * \since This function is available since SDL 3.0.0.
  1032. */
  1033. extern DECLSPEC int SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
  1034. /**
  1035. * Send a gamepad specific effect packet
  1036. *
  1037. * \param gamepad The gamepad to affect
  1038. * \param data The data to send to the gamepad
  1039. * \param size The size of the data to send to the gamepad
  1040. * \returns 0 on success or a negative error code on failure; call
  1041. * SDL_GetError() for more information.
  1042. *
  1043. * \since This function is available since SDL 3.0.0.
  1044. */
  1045. extern DECLSPEC int SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
  1046. /**
  1047. * Close a gamepad previously opened with SDL_OpenGamepad().
  1048. *
  1049. * \param gamepad a gamepad identifier previously returned by
  1050. * SDL_OpenGamepad()
  1051. *
  1052. * \since This function is available since SDL 3.0.0.
  1053. *
  1054. * \sa SDL_OpenGamepad
  1055. */
  1056. extern DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
  1057. /**
  1058. * Return the sfSymbolsName for a given button on a gamepad on Apple
  1059. * platforms.
  1060. *
  1061. * \param gamepad the gamepad to query
  1062. * \param button a button on the gamepad
  1063. * \returns the sfSymbolsName or NULL if the name can't be found
  1064. *
  1065. * \since This function is available since SDL 3.0.0.
  1066. *
  1067. * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
  1068. */
  1069. extern DECLSPEC const char* SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  1070. /**
  1071. * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
  1072. *
  1073. * \param gamepad the gamepad to query
  1074. * \param axis an axis on the gamepad
  1075. * \returns the sfSymbolsName or NULL if the name can't be found
  1076. *
  1077. * \since This function is available since SDL 3.0.0.
  1078. *
  1079. * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
  1080. */
  1081. extern DECLSPEC const char* SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  1082. /* Ends C function definitions when using C++ */
  1083. #ifdef __cplusplus
  1084. }
  1085. #endif
  1086. #include <SDL3/SDL_close_code.h>
  1087. #endif /* SDL_gamepad_h_ */