SDL_gamepad.h 41 KB

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