1
0

SDL_gamepad.h 43 KB

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