SDL_gamepad.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  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. * 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 mapping at a particular index.
  288. *
  289. * You must free the returned pointer with SDL_free() when you are done with
  290. * it, but you do _not_ free each string in the array.
  291. *
  292. * \param count a pointer filled in with the number of mappings returned, can
  293. * be NULL.
  294. * \returns an array of the mapping strings, NULL-terminated. Must be freed
  295. * with SDL_free(). Returns NULL on error.
  296. *
  297. * \since This function is available since SDL 3.0.0.
  298. */
  299. extern DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
  300. /**
  301. * Get the gamepad mapping string for a given GUID.
  302. *
  303. * The returned string must be freed with SDL_free().
  304. *
  305. * \param guid a structure containing the GUID for which a mapping is desired
  306. * \returns a mapping string or NULL on error; call SDL_GetError() for more
  307. * information.
  308. *
  309. * \since This function is available since SDL 3.0.0.
  310. *
  311. * \sa SDL_GetJoystickInstanceGUID
  312. * \sa SDL_GetJoystickGUID
  313. */
  314. extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid);
  315. /**
  316. * Get the current mapping of a gamepad.
  317. *
  318. * The returned string must be freed with SDL_free().
  319. *
  320. * Details about mappings are discussed with SDL_AddGamepadMapping().
  321. *
  322. * \param gamepad the gamepad you want to get the current mapping for
  323. * \returns a string that has the gamepad's mapping or NULL if no mapping is
  324. * available; call SDL_GetError() for more information.
  325. *
  326. * \since This function is available since SDL 3.0.0.
  327. *
  328. * \sa SDL_AddGamepadMapping
  329. * \sa SDL_GetGamepadMappingForGUID
  330. * \sa SDL_SetGamepadMapping
  331. */
  332. extern DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
  333. /**
  334. * Set the current mapping of a joystick or gamepad.
  335. *
  336. * Details about mappings are discussed with SDL_AddGamepadMapping().
  337. *
  338. * \param instance_id the joystick instance ID
  339. * \param mapping the mapping to use for this device, or NULL to clear the
  340. * mapping
  341. * \returns 0 on success or a negative error code on failure; call
  342. * SDL_GetError() for more information.
  343. *
  344. * \since This function is available since SDL 3.0.0.
  345. *
  346. * \sa SDL_AddGamepadMapping
  347. * \sa SDL_GetGamepadMapping
  348. */
  349. extern DECLSPEC int SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
  350. /**
  351. * Get a list of currently connected gamepads.
  352. *
  353. * \param count a pointer filled in with the number of gamepads returned
  354. * \returns a 0 terminated array of joystick instance IDs which should be
  355. * freed with SDL_free(), or NULL on error; call SDL_GetError() for
  356. * more details.
  357. *
  358. * \since This function is available since SDL 3.0.0.
  359. *
  360. * \sa SDL_OpenGamepad
  361. */
  362. extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetGamepads(int *count);
  363. /**
  364. * Check if the given joystick is supported by the gamepad interface.
  365. *
  366. * \param instance_id the joystick instance ID
  367. * \returns SDL_TRUE if the given joystick is supported by the gamepad
  368. * interface, SDL_FALSE if it isn't or it's an invalid index.
  369. *
  370. * \since This function is available since SDL 3.0.0.
  371. *
  372. * \sa SDL_OpenGamepad
  373. */
  374. extern DECLSPEC SDL_bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
  375. /**
  376. * Get the implementation dependent name of a gamepad.
  377. *
  378. * This can be called before any gamepads are opened.
  379. *
  380. * \param instance_id the joystick instance ID
  381. * \returns the name of the selected gamepad. If no name can be found, this
  382. * function returns NULL; call SDL_GetError() for more information.
  383. *
  384. * \since This function is available since SDL 3.0.0.
  385. *
  386. * \sa SDL_GetGamepadName
  387. * \sa SDL_OpenGamepad
  388. */
  389. extern DECLSPEC const char *SDLCALL SDL_GetGamepadInstanceName(SDL_JoystickID instance_id);
  390. /**
  391. * Get the implementation dependent path of a gamepad.
  392. *
  393. * This can be called before any gamepads are opened.
  394. *
  395. * \param instance_id the joystick instance ID
  396. * \returns the path of the selected gamepad. If no path can be found, this
  397. * function returns NULL; call SDL_GetError() for more information.
  398. *
  399. * \since This function is available since SDL 3.0.0.
  400. *
  401. * \sa SDL_GetGamepadPath
  402. * \sa SDL_OpenGamepad
  403. */
  404. extern DECLSPEC const char *SDLCALL SDL_GetGamepadInstancePath(SDL_JoystickID instance_id);
  405. /**
  406. * Get the player index of a gamepad.
  407. *
  408. * This can be called before any gamepads are opened.
  409. *
  410. * \param instance_id the joystick instance ID
  411. * \returns the player index of a gamepad, or -1 if it's not available
  412. *
  413. * \since This function is available since SDL 3.0.0.
  414. *
  415. * \sa SDL_GetGamepadPlayerIndex
  416. * \sa SDL_OpenGamepad
  417. */
  418. extern DECLSPEC int SDLCALL SDL_GetGamepadInstancePlayerIndex(SDL_JoystickID instance_id);
  419. /**
  420. * Get the implementation-dependent GUID of a gamepad.
  421. *
  422. * This can be called before any gamepads are opened.
  423. *
  424. * \param instance_id the joystick instance ID
  425. * \returns the GUID of the selected gamepad. If called on an invalid index,
  426. * this function returns a zero GUID
  427. *
  428. * \since This function is available since SDL 3.0.0.
  429. *
  430. * \sa SDL_GetGamepadGUID
  431. * \sa SDL_GetGamepadGUIDString
  432. */
  433. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetGamepadInstanceGUID(SDL_JoystickID instance_id);
  434. /**
  435. * Get the USB vendor ID of a gamepad, if available.
  436. *
  437. * This can be called before any gamepads are opened. If the vendor ID isn't
  438. * available this function returns 0.
  439. *
  440. * \param instance_id the joystick instance ID
  441. * \returns the USB vendor ID of the selected gamepad. If called on an invalid
  442. * index, this function returns zero
  443. *
  444. * \since This function is available since SDL 3.0.0.
  445. */
  446. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceVendor(SDL_JoystickID instance_id);
  447. /**
  448. * Get the USB product ID of a gamepad, if available.
  449. *
  450. * This can be called before any gamepads are opened. If the product ID isn't
  451. * available this function returns 0.
  452. *
  453. * \param instance_id the joystick instance ID
  454. * \returns the USB product ID 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_GetGamepadInstanceProduct(SDL_JoystickID instance_id);
  460. /**
  461. * Get the product version of a gamepad, if available.
  462. *
  463. * This can be called before any gamepads are opened. If the product version
  464. * isn't available this function returns 0.
  465. *
  466. * \param instance_id the joystick instance ID
  467. * \returns the product version of the selected gamepad. If called on an
  468. * invalid index, this function returns zero
  469. *
  470. * \since This function is available since SDL 3.0.0.
  471. */
  472. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceProductVersion(SDL_JoystickID instance_id);
  473. /**
  474. * Get the type of a gamepad.
  475. *
  476. * This can be called before any gamepads are opened.
  477. *
  478. * \param instance_id the joystick instance ID
  479. * \returns the gamepad type.
  480. *
  481. * \since This function is available since SDL 3.0.0.
  482. */
  483. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadInstanceType(SDL_JoystickID instance_id);
  484. /**
  485. * Get the type of a gamepad, ignoring any mapping override.
  486. *
  487. * This can be called before any gamepads are opened.
  488. *
  489. * \param instance_id the joystick instance ID
  490. * \returns the gamepad type.
  491. *
  492. * \since This function is available since SDL 3.0.0.
  493. */
  494. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadInstanceType(SDL_JoystickID instance_id);
  495. /**
  496. * Get the mapping of a gamepad.
  497. *
  498. * This can be called before any gamepads are opened.
  499. *
  500. * \param instance_id the joystick instance ID
  501. * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
  502. * no mapping is available.
  503. *
  504. * \since This function is available since SDL 3.0.0.
  505. */
  506. extern DECLSPEC char *SDLCALL SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id);
  507. /**
  508. * Open a gamepad for use.
  509. *
  510. * \param instance_id the joystick instance ID
  511. * \returns a gamepad identifier or NULL if an error occurred; call
  512. * SDL_GetError() for more information.
  513. *
  514. * \since This function is available since SDL 3.0.0.
  515. *
  516. * \sa SDL_CloseGamepad
  517. * \sa SDL_IsGamepad
  518. */
  519. extern DECLSPEC SDL_Gamepad *SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);
  520. /**
  521. * Get the SDL_Gamepad associated with a joystick instance ID, if it has been
  522. * opened.
  523. *
  524. * \param instance_id the joystick instance ID of the gamepad
  525. * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
  526. * opened yet; call SDL_GetError() for more information.
  527. *
  528. * \since This function is available since SDL 3.0.0.
  529. */
  530. extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromInstanceID(SDL_JoystickID instance_id);
  531. /**
  532. * Get the SDL_Gamepad associated with a player index.
  533. *
  534. * \param player_index the player index, which different from the instance ID
  535. * \returns the SDL_Gamepad associated with a player index.
  536. *
  537. * \since This function is available since SDL 3.0.0.
  538. *
  539. * \sa SDL_GetGamepadPlayerIndex
  540. * \sa SDL_SetGamepadPlayerIndex
  541. */
  542. extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
  543. /**
  544. * Get the properties associated with an opened gamepad.
  545. *
  546. * These properties are shared with the underlying joystick object.
  547. *
  548. * \param gamepad a gamepad identifier previously returned by
  549. * SDL_OpenGamepad()
  550. * \returns a valid property ID on success or 0 on failure; call
  551. * SDL_GetError() for more information.
  552. *
  553. * \since This function is available since SDL 3.0.0.
  554. *
  555. * \sa SDL_GetProperty
  556. * \sa SDL_SetProperty
  557. */
  558. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
  559. /**
  560. * Get the instance ID of an opened gamepad.
  561. *
  562. * \param gamepad a gamepad identifier previously returned by
  563. * SDL_OpenGamepad()
  564. * \returns the instance ID of the specified gamepad on success or 0 on
  565. * failure; call SDL_GetError() for more information.
  566. *
  567. * \since This function is available since SDL 3.0.0.
  568. *
  569. * \sa SDL_OpenGamepad
  570. */
  571. extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad);
  572. /**
  573. * Get the implementation-dependent name for an opened gamepad.
  574. *
  575. * \param gamepad a gamepad identifier previously returned by
  576. * SDL_OpenGamepad()
  577. * \returns the implementation dependent name for the gamepad, or NULL if
  578. * there is no name or the identifier passed is invalid.
  579. *
  580. * \since This function is available since SDL 3.0.0.
  581. *
  582. * \sa SDL_GetGamepadInstanceName
  583. * \sa SDL_OpenGamepad
  584. */
  585. extern DECLSPEC const char *SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
  586. /**
  587. * Get the implementation-dependent path for an opened gamepad.
  588. *
  589. * \param gamepad a gamepad identifier previously returned by
  590. * SDL_OpenGamepad()
  591. * \returns the implementation dependent path for the gamepad, or NULL if
  592. * there is no path or the identifier passed is invalid.
  593. *
  594. * \since This function is available since SDL 3.0.0.
  595. *
  596. * \sa SDL_GetGamepadInstancePath
  597. */
  598. extern DECLSPEC const char *SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
  599. /**
  600. * Get the type of an opened gamepad.
  601. *
  602. * \param gamepad the gamepad object to query.
  603. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
  604. * available.
  605. *
  606. * \since This function is available since SDL 3.0.0.
  607. *
  608. * \sa SDL_GetGamepadInstanceType
  609. */
  610. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
  611. /**
  612. * Get the type of an opened gamepad, ignoring any mapping override.
  613. *
  614. * \param gamepad the gamepad object to query.
  615. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
  616. * available.
  617. *
  618. * \since This function is available since SDL 3.0.0.
  619. *
  620. * \sa SDL_GetRealGamepadInstanceType
  621. */
  622. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
  623. /**
  624. * Get the player index of an opened gamepad.
  625. *
  626. * For XInput gamepads this returns the XInput user index.
  627. *
  628. * \param gamepad the gamepad object to query.
  629. * \returns the player index for gamepad, or -1 if it's not available.
  630. *
  631. * \since This function is available since SDL 3.0.0.
  632. */
  633. extern DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
  634. /**
  635. * Set the player index of an opened gamepad.
  636. *
  637. * \param gamepad the gamepad object to adjust.
  638. * \param player_index Player index to assign to this gamepad, or -1 to clear
  639. * the player index and turn off player LEDs.
  640. * \returns 0 on success or a negative error code on failure; call
  641. * SDL_GetError() for more information.
  642. *
  643. * \since This function is available since SDL 3.0.0.
  644. */
  645. extern DECLSPEC int SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
  646. /**
  647. * Get the USB vendor ID of an opened gamepad, if available.
  648. *
  649. * If the vendor ID isn't available this function returns 0.
  650. *
  651. * \param gamepad the gamepad object to query.
  652. * \returns the USB vendor ID, or zero if unavailable.
  653. *
  654. * \since This function is available since SDL 3.0.0.
  655. */
  656. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
  657. /**
  658. * Get the USB product ID of an opened gamepad, if available.
  659. *
  660. * If the product ID isn't available this function returns 0.
  661. *
  662. * \param gamepad the gamepad object to query.
  663. * \returns the USB product ID, or zero if unavailable.
  664. *
  665. * \since This function is available since SDL 3.0.0.
  666. */
  667. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
  668. /**
  669. * Get the product version of an opened gamepad, if available.
  670. *
  671. * If the product version isn't available this function returns 0.
  672. *
  673. * \param gamepad the gamepad object to query.
  674. * \returns the USB product version, or zero if unavailable.
  675. *
  676. * \since This function is available since SDL 3.0.0.
  677. */
  678. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
  679. /**
  680. * Get the firmware version of an opened gamepad, if available.
  681. *
  682. * If the firmware version isn't available this function returns 0.
  683. *
  684. * \param gamepad the gamepad object to query.
  685. * \returns the gamepad firmware version, or zero if unavailable.
  686. *
  687. * \since This function is available since SDL 3.0.0.
  688. */
  689. extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
  690. /**
  691. * Get the serial number of an opened gamepad, if available.
  692. *
  693. * Returns the serial number of the gamepad, or NULL if it is not available.
  694. *
  695. * \param gamepad the gamepad object to query.
  696. * \returns the serial number, or NULL if unavailable.
  697. *
  698. * \since This function is available since SDL 3.0.0.
  699. */
  700. extern DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
  701. /**
  702. * Get the battery level of a gamepad, if available.
  703. *
  704. * \param gamepad a gamepad identifier previously returned by
  705. * SDL_OpenGamepad()
  706. * \returns the current battery level as SDL_JoystickPowerLevel on success or
  707. * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
  708. *
  709. * \since This function is available since SDL 3.0.0.
  710. */
  711. extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad);
  712. /**
  713. * Check if a gamepad has been opened and is currently connected.
  714. *
  715. * \param gamepad a gamepad identifier previously returned by
  716. * SDL_OpenGamepad()
  717. * \returns SDL_TRUE if the gamepad has been opened and is currently
  718. * connected, or SDL_FALSE if not.
  719. *
  720. * \since This function is available since SDL 3.0.0.
  721. *
  722. * \sa SDL_CloseGamepad
  723. * \sa SDL_OpenGamepad
  724. */
  725. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
  726. /**
  727. * Get the underlying joystick from a gamepad
  728. *
  729. * This function will give you a SDL_Joystick object, which allows you to use
  730. * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
  731. * for getting a joystick's position at any given time, even if it hasn't
  732. * moved (moving it would produce an event, which would have the axis' value).
  733. *
  734. * The pointer returned is owned by the SDL_Gamepad. You should not call
  735. * SDL_CloseJoystick() on it, for example, since doing so will likely cause
  736. * SDL to crash.
  737. *
  738. * \param gamepad the gamepad object that you want to get a joystick from
  739. * \returns an SDL_Joystick object; call SDL_GetError() for more information.
  740. *
  741. * \since This function is available since SDL 3.0.0.
  742. */
  743. extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
  744. /**
  745. * Set 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. * \param enabled whether to process gamepad events or not
  751. *
  752. * \since This function is available since SDL 3.0.0.
  753. *
  754. * \sa SDL_GamepadEventsEnabled
  755. */
  756. extern DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(SDL_bool enabled);
  757. /**
  758. * Query the state of gamepad event processing.
  759. *
  760. * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
  761. * and check the state of the gamepad when you want gamepad information.
  762. *
  763. * \returns SDL_TRUE if gamepad events are being processed, SDL_FALSE
  764. * otherwise.
  765. *
  766. * \since This function is available since SDL 3.0.0.
  767. *
  768. * \sa SDL_SetGamepadEventsEnabled
  769. */
  770. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadEventsEnabled(void);
  771. /**
  772. * Get the SDL joystick layer bindings for a gamepad
  773. *
  774. * \param gamepad a gamepad
  775. * \param count a pointer filled in with the number of bindings returned
  776. * \returns a NULL terminated array of pointers to bindings which should be
  777. * freed with SDL_free(), or NULL on error; call SDL_GetError() for
  778. * more details.
  779. *
  780. * \since This function is available since SDL 3.0.0.
  781. */
  782. extern DECLSPEC SDL_GamepadBinding **SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
  783. /**
  784. * Manually pump gamepad updates if not using the loop.
  785. *
  786. * This function is called automatically by the event loop if events are
  787. * enabled. Under such circumstances, it will not be necessary to call this
  788. * function.
  789. *
  790. * \since This function is available since SDL 3.0.0.
  791. */
  792. extern DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
  793. /**
  794. * Convert a string into SDL_GamepadType enum.
  795. *
  796. * This function is called internally to translate SDL_Gamepad mapping strings
  797. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  798. * You do not normally need to call this function unless you are parsing
  799. * SDL_Gamepad mappings in your own code.
  800. *
  801. * \param str string representing a SDL_GamepadType type
  802. * \returns the SDL_GamepadType enum corresponding to the input string, or
  803. * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
  804. *
  805. * \since This function is available since SDL 3.0.0.
  806. *
  807. * \sa SDL_GetGamepadStringForType
  808. */
  809. extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
  810. /**
  811. * Convert from an SDL_GamepadType enum to a string.
  812. *
  813. * The caller should not SDL_free() the returned string.
  814. *
  815. * \param type an enum value for a given SDL_GamepadType
  816. * \returns a string for the given type, or NULL if an invalid type is
  817. * specified. The string returned is of the format used by
  818. * SDL_Gamepad mapping strings.
  819. *
  820. * \since This function is available since SDL 3.0.0.
  821. *
  822. * \sa SDL_GetGamepadTypeFromString
  823. */
  824. extern DECLSPEC const char *SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
  825. /**
  826. * Convert a string into SDL_GamepadAxis enum.
  827. *
  828. * This function is called internally to translate SDL_Gamepad mapping strings
  829. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  830. * You do not normally need to call this function unless you are parsing
  831. * SDL_Gamepad mappings in your own code.
  832. *
  833. * Note specially that "righttrigger" and "lefttrigger" map to
  834. * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
  835. * respectively.
  836. *
  837. * \param str string representing a SDL_Gamepad axis
  838. * \returns the SDL_GamepadAxis enum corresponding to the input string, or
  839. * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
  840. *
  841. * \since This function is available since SDL 3.0.0.
  842. *
  843. * \sa SDL_GetGamepadStringForAxis
  844. */
  845. extern DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
  846. /**
  847. * Convert from an SDL_GamepadAxis enum to a string.
  848. *
  849. * The caller should not SDL_free() the returned string.
  850. *
  851. * \param axis an enum value for a given SDL_GamepadAxis
  852. * \returns a string for the given axis, or NULL if an invalid axis is
  853. * specified. The string returned is of the format used by
  854. * SDL_Gamepad mapping strings.
  855. *
  856. * \since This function is available since SDL 3.0.0.
  857. *
  858. * \sa SDL_GetGamepadAxisFromString
  859. */
  860. extern DECLSPEC const char* SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
  861. /**
  862. * Query whether a gamepad has a given axis.
  863. *
  864. * This merely reports whether the gamepad's mapping defined this axis, as
  865. * that is all the information SDL has about the physical device.
  866. *
  867. * \param gamepad a gamepad
  868. * \param axis an axis enum value (an SDL_GamepadAxis value)
  869. * \returns SDL_TRUE if the gamepad has this axis, SDL_FALSE otherwise.
  870. *
  871. * \since This function is available since SDL 3.0.0.
  872. */
  873. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  874. /**
  875. * Get the current state of an axis control on a gamepad.
  876. *
  877. * The axis indices start at index 0.
  878. *
  879. * The state is a value ranging from -32768 to 32767. Triggers, however, range
  880. * from 0 to 32767 (they never return a negative value).
  881. *
  882. * \param gamepad a gamepad
  883. * \param axis an axis index (one of the SDL_GamepadAxis values)
  884. * \returns axis state (including 0) on success or 0 (also) on failure; call
  885. * SDL_GetError() for more information.
  886. *
  887. * \since This function is available since SDL 3.0.0.
  888. *
  889. * \sa SDL_GetGamepadButton
  890. */
  891. extern DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  892. /**
  893. * Convert a string into an SDL_GamepadButton enum.
  894. *
  895. * This function is called internally to translate SDL_Gamepad mapping strings
  896. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  897. * You do not normally need to call this function unless you are parsing
  898. * SDL_Gamepad mappings in your own code.
  899. *
  900. * \param str string representing a SDL_Gamepad axis
  901. * \returns the SDL_GamepadButton enum corresponding to the input string, or
  902. * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
  903. *
  904. * \since This function is available since SDL 3.0.0.
  905. */
  906. extern DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
  907. /**
  908. * Convert from an SDL_GamepadButton enum to a string.
  909. *
  910. * The caller should not SDL_free() the returned string.
  911. *
  912. * \param button an enum value for a given SDL_GamepadButton
  913. * \returns a string for the given button, or NULL if an invalid button is
  914. * specified. The string returned is of the format used by
  915. * SDL_Gamepad mapping strings.
  916. *
  917. * \since This function is available since SDL 3.0.0.
  918. *
  919. * \sa SDL_GetGamepadButtonFromString
  920. */
  921. extern DECLSPEC const char* SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
  922. /**
  923. * Query whether a gamepad has a given button.
  924. *
  925. * This merely reports whether the gamepad's mapping defined this button, as
  926. * that is all the information SDL has about the physical device.
  927. *
  928. * \param gamepad a gamepad
  929. * \param button a button enum value (an SDL_GamepadButton value)
  930. * \returns SDL_TRUE if the gamepad has this button, SDL_FALSE otherwise.
  931. *
  932. * \since This function is available since SDL 3.0.0.
  933. */
  934. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  935. /**
  936. * Get the current state of a button on a gamepad.
  937. *
  938. * \param gamepad a gamepad
  939. * \param button a button index (one of the SDL_GamepadButton values)
  940. * \returns 1 for pressed state or 0 for not pressed state or error; call
  941. * SDL_GetError() for more information.
  942. *
  943. * \since This function is available since SDL 3.0.0.
  944. *
  945. * \sa SDL_GetGamepadAxis
  946. */
  947. extern DECLSPEC Uint8 SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  948. /**
  949. * Get the label of a button on a gamepad.
  950. *
  951. * \param type the type of gamepad to check
  952. * \param button a button index (one of the SDL_GamepadButton values)
  953. * \returns the SDL_GamepadButtonLabel enum corresponding to the button label
  954. *
  955. * \since This function is available since SDL 3.0.0.
  956. *
  957. * \sa SDL_GetGamepadButtonLabel
  958. */
  959. extern DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);
  960. /**
  961. * Get the label of a button on a gamepad.
  962. *
  963. * \param gamepad a gamepad
  964. * \param button a button index (one of the SDL_GamepadButton values)
  965. * \returns the SDL_GamepadButtonLabel enum corresponding to the button label
  966. *
  967. * \since This function is available since SDL 3.0.0.
  968. *
  969. * \sa SDL_GetGamepadButtonLabelForType
  970. */
  971. extern DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  972. /**
  973. * Get the number of touchpads on a gamepad.
  974. *
  975. * \param gamepad a gamepad
  976. * \returns number of touchpads
  977. *
  978. * \since This function is available since SDL 3.0.0.
  979. */
  980. extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
  981. /**
  982. * Get the number of supported simultaneous fingers on a touchpad on a game
  983. * gamepad.
  984. *
  985. * \param gamepad a gamepad
  986. * \param touchpad a touchpad
  987. * \returns number of supported simultaneous fingers
  988. *
  989. * \since This function is available since SDL 3.0.0.
  990. */
  991. extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
  992. /**
  993. * Get the current state of a finger on a touchpad on a gamepad.
  994. *
  995. * \param gamepad a gamepad
  996. * \param touchpad a touchpad
  997. * \param finger a finger
  998. * \param state filled with state
  999. * \param x filled with x position
  1000. * \param y filled with y position
  1001. * \param pressure filled with pressure value
  1002. * \returns 0 on success or a negative error code on failure; call
  1003. * SDL_GetError() for more information.
  1004. *
  1005. * \since This function is available since SDL 3.0.0.
  1006. */
  1007. extern DECLSPEC int SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
  1008. /**
  1009. * Return whether a gamepad has a particular sensor.
  1010. *
  1011. * \param gamepad The gamepad to query
  1012. * \param type The type of sensor to query
  1013. * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
  1014. *
  1015. * \since This function is available since SDL 3.0.0.
  1016. */
  1017. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
  1018. /**
  1019. * Set whether data reporting for a gamepad sensor is enabled.
  1020. *
  1021. * \param gamepad The gamepad to update
  1022. * \param type The type of sensor to enable/disable
  1023. * \param enabled Whether data reporting should be enabled
  1024. * \returns 0 on success or a negative error code on failure; call
  1025. * SDL_GetError() for more information.
  1026. *
  1027. * \since This function is available since SDL 3.0.0.
  1028. */
  1029. extern DECLSPEC int SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled);
  1030. /**
  1031. * Query whether sensor data reporting is enabled for a gamepad.
  1032. *
  1033. * \param gamepad The gamepad to query
  1034. * \param type The type of sensor to query
  1035. * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
  1036. *
  1037. * \since This function is available since SDL 3.0.0.
  1038. */
  1039. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
  1040. /**
  1041. * Get the data rate (number of events per second) of a gamepad sensor.
  1042. *
  1043. * \param gamepad The gamepad to query
  1044. * \param type The type of sensor to query
  1045. * \returns the data rate, or 0.0f if the data rate is not available.
  1046. *
  1047. * \since This function is available since SDL 3.0.0.
  1048. */
  1049. extern DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
  1050. /**
  1051. * Get the current state of a gamepad sensor.
  1052. *
  1053. * The number of values and interpretation of the data is sensor dependent.
  1054. * See SDL_sensor.h for the details for each type of sensor.
  1055. *
  1056. * \param gamepad The gamepad to query
  1057. * \param type The type of sensor to query
  1058. * \param data A pointer filled with the current sensor state
  1059. * \param num_values The number of values to write to data
  1060. * \returns 0 on success or a negative error code on failure; call
  1061. * SDL_GetError() for more information.
  1062. *
  1063. * \since This function is available since SDL 3.0.0.
  1064. */
  1065. extern DECLSPEC int SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
  1066. /**
  1067. * Start a rumble effect on a gamepad.
  1068. *
  1069. * Each call to this function cancels any previous rumble effect, and calling
  1070. * it with 0 intensity stops any rumbling.
  1071. *
  1072. * \param gamepad The gamepad to vibrate
  1073. * \param low_frequency_rumble The intensity of the low frequency (left)
  1074. * rumble motor, from 0 to 0xFFFF
  1075. * \param high_frequency_rumble The intensity of the high frequency (right)
  1076. * rumble motor, from 0 to 0xFFFF
  1077. * \param duration_ms The duration of the rumble effect, in milliseconds
  1078. * \returns 0, or -1 if rumble isn't supported on this gamepad
  1079. *
  1080. * \since This function is available since SDL 3.0.0.
  1081. *
  1082. * \sa SDL_GamepadHasRumble
  1083. */
  1084. extern DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
  1085. /**
  1086. * Start a rumble effect in the gamepad's triggers.
  1087. *
  1088. * Each call to this function cancels any previous trigger rumble effect, and
  1089. * calling it with 0 intensity stops any rumbling.
  1090. *
  1091. * Note that this is rumbling of the _triggers_ and not the gamepad as a
  1092. * whole. This is currently only supported on Xbox One gamepads. If you want
  1093. * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
  1094. *
  1095. * \param gamepad The gamepad to vibrate
  1096. * \param left_rumble The intensity of the left trigger rumble motor, from 0
  1097. * to 0xFFFF
  1098. * \param right_rumble The intensity of the right trigger rumble motor, from 0
  1099. * to 0xFFFF
  1100. * \param duration_ms The duration of the rumble effect, in milliseconds
  1101. * \returns 0 on success or a negative error code on failure; call
  1102. * SDL_GetError() for more information.
  1103. *
  1104. * \since This function is available since SDL 3.0.0.
  1105. *
  1106. * \sa SDL_GamepadHasRumbleTriggers
  1107. */
  1108. extern DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
  1109. /**
  1110. * Query whether a gamepad has an LED.
  1111. *
  1112. * \param gamepad The gamepad to query
  1113. * \returns SDL_TRUE, or SDL_FALSE if this gamepad does not have a modifiable
  1114. * LED
  1115. *
  1116. * \since This function is available since SDL 3.0.0.
  1117. */
  1118. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasLED(SDL_Gamepad *gamepad);
  1119. /**
  1120. * Query whether a gamepad has rumble support.
  1121. *
  1122. * \param gamepad The gamepad to query
  1123. * \returns SDL_TRUE, or SDL_FALSE if this gamepad does not have rumble
  1124. * support
  1125. *
  1126. * \since This function is available since SDL 3.0.0.
  1127. *
  1128. * \sa SDL_RumbleGamepad
  1129. */
  1130. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasRumble(SDL_Gamepad *gamepad);
  1131. /**
  1132. * Query whether a gamepad has rumble support on triggers.
  1133. *
  1134. * \param gamepad The gamepad to query
  1135. * \returns SDL_TRUE, or SDL_FALSE if this gamepad does not have trigger
  1136. * rumble support
  1137. *
  1138. * \since This function is available since SDL 3.0.0.
  1139. *
  1140. * \sa SDL_RumbleGamepadTriggers
  1141. */
  1142. extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasRumbleTriggers(SDL_Gamepad *gamepad);
  1143. /**
  1144. * Update a gamepad's LED color.
  1145. *
  1146. * \param gamepad The gamepad to update
  1147. * \param red The intensity of the red LED
  1148. * \param green The intensity of the green LED
  1149. * \param blue The intensity of the blue LED
  1150. * \returns 0 on success or a negative error code on failure; call
  1151. * SDL_GetError() for more information.
  1152. *
  1153. * \since This function is available since SDL 3.0.0.
  1154. */
  1155. extern DECLSPEC int SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
  1156. /**
  1157. * Send a gamepad specific effect packet
  1158. *
  1159. * \param gamepad The gamepad to affect
  1160. * \param data The data to send to the gamepad
  1161. * \param size The size of the data to send to the gamepad
  1162. * \returns 0 on success or a negative error code on failure; call
  1163. * SDL_GetError() for more information.
  1164. *
  1165. * \since This function is available since SDL 3.0.0.
  1166. */
  1167. extern DECLSPEC int SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
  1168. /**
  1169. * Close a gamepad previously opened with SDL_OpenGamepad().
  1170. *
  1171. * \param gamepad a gamepad identifier previously returned by
  1172. * SDL_OpenGamepad()
  1173. *
  1174. * \since This function is available since SDL 3.0.0.
  1175. *
  1176. * \sa SDL_OpenGamepad
  1177. */
  1178. extern DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
  1179. /**
  1180. * Return the sfSymbolsName for a given button on a gamepad on Apple
  1181. * platforms.
  1182. *
  1183. * \param gamepad the gamepad to query
  1184. * \param button a button on the gamepad
  1185. * \returns the sfSymbolsName or NULL if the name can't be found
  1186. *
  1187. * \since This function is available since SDL 3.0.0.
  1188. *
  1189. * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
  1190. */
  1191. extern DECLSPEC const char* SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  1192. /**
  1193. * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
  1194. *
  1195. * \param gamepad the gamepad to query
  1196. * \param axis an axis on the gamepad
  1197. * \returns the sfSymbolsName or NULL if the name can't be found
  1198. *
  1199. * \since This function is available since SDL 3.0.0.
  1200. *
  1201. * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
  1202. */
  1203. extern DECLSPEC const char* SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  1204. /* Ends C function definitions when using C++ */
  1205. #ifdef __cplusplus
  1206. }
  1207. #endif
  1208. #include <SDL3/SDL_close_code.h>
  1209. #endif /* SDL_gamepad_h_ */