SDL_gamepad.h 44 KB

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