SDL_gamepad.h 41 KB

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