SDL_gamepad.h 45 KB

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