SDL_gamepad.h 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2026 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. * # CategoryGamepad
  20. *
  21. * SDL provides a low-level joystick API, which just treats joysticks as an
  22. * arbitrary pile of buttons, axes, and hat switches. If you're planning to
  23. * write your own control configuration screen, this can give you a lot of
  24. * flexibility, but that's a lot of work, and most things that we consider
  25. * "joysticks" now are actually console-style gamepads. So SDL provides the
  26. * gamepad API on top of the lower-level joystick functionality.
  27. *
  28. * The difference between a joystick and a gamepad is that a gamepad tells you
  29. * _where_ a button or axis is on the device. You don't speak to gamepads in
  30. * terms of arbitrary numbers like "button 3" or "axis 2" but in standard
  31. * locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or
  32. * X/O/Square/Triangle, if you will).
  33. *
  34. * One turns a joystick into a gamepad by providing a magic configuration
  35. * string, which tells SDL the details of a specific device: when you see this
  36. * specific hardware, if button 2 gets pressed, this is actually D-Pad Up,
  37. * etc.
  38. *
  39. * SDL has many popular controllers configured out of the box, and users can
  40. * add their own controller details through an environment variable if it's
  41. * otherwise unknown to SDL.
  42. *
  43. * In order to use these functions, SDL_Init() must have been called with the
  44. * SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and
  45. * load appropriate drivers.
  46. *
  47. * If you're using SDL gamepad support in a Steam game, you must call
  48. * SteamAPI_InitEx() before calling SDL_Init().
  49. *
  50. * If you would like to receive gamepad updates while the application is in
  51. * the background, you should set the following hint before calling
  52. * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
  53. *
  54. * Gamepads support various optional features such as rumble, color LEDs,
  55. * touchpad, gyro, etc. The support for these features varies depending on the
  56. * controller and OS support available. You can check for LED and rumble
  57. * capabilities at runtime by calling SDL_GetGamepadProperties() and checking
  58. * the various capability properties. You can check for touchpad by calling
  59. * SDL_GetNumGamepadTouchpads() and check for gyro and accelerometer by
  60. * calling SDL_GamepadHasSensor().
  61. *
  62. * By default SDL will try to use the most capable driver available, but you
  63. * can tune which OS drivers to use with the various joystick hints in
  64. * SDL_hints.h.
  65. *
  66. * Your application should always support gamepad hotplugging. On some
  67. * platforms like Xbox, Steam Deck, etc., this is a requirement for
  68. * certification. On other platforms, like macOS and Windows when using
  69. * Windows.Gaming.Input, controllers may not be available at startup and will
  70. * come in at some point after you've started processing events.
  71. */
  72. #ifndef SDL_gamepad_h_
  73. #define SDL_gamepad_h_
  74. #include <SDL3/SDL_stdinc.h>
  75. #include <SDL3/SDL_error.h>
  76. #include <SDL3/SDL_guid.h>
  77. #include <SDL3/SDL_iostream.h>
  78. #include <SDL3/SDL_joystick.h>
  79. #include <SDL3/SDL_power.h>
  80. #include <SDL3/SDL_properties.h>
  81. #include <SDL3/SDL_sensor.h>
  82. #include <SDL3/SDL_begin_code.h>
  83. /* Set up for C function definitions, even when using C++ */
  84. #ifdef __cplusplus
  85. extern "C" {
  86. #endif
  87. /**
  88. * The structure used to identify an SDL gamepad
  89. *
  90. * \since This struct is available since SDL 3.2.0.
  91. */
  92. typedef struct SDL_Gamepad SDL_Gamepad;
  93. /**
  94. * Standard gamepad types.
  95. *
  96. * This type does not necessarily map to first-party controllers from
  97. * Microsoft/Sony/Nintendo; in many cases, third-party controllers can report
  98. * as these, either because they were designed for a specific console, or they
  99. * simply most closely match that console's controllers (does it have A/B/X/Y
  100. * buttons or X/O/Square/Triangle? Does it have a touchpad? etc).
  101. */
  102. typedef enum SDL_GamepadType
  103. {
  104. SDL_GAMEPAD_TYPE_UNKNOWN = 0,
  105. SDL_GAMEPAD_TYPE_STANDARD,
  106. SDL_GAMEPAD_TYPE_XBOX360,
  107. SDL_GAMEPAD_TYPE_XBOXONE,
  108. SDL_GAMEPAD_TYPE_PS3,
  109. SDL_GAMEPAD_TYPE_PS4,
  110. SDL_GAMEPAD_TYPE_PS5,
  111. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO,
  112. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
  113. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
  114. SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
  115. SDL_GAMEPAD_TYPE_GAMECUBE,
  116. SDL_GAMEPAD_TYPE_COUNT
  117. } SDL_GamepadType;
  118. /**
  119. * The list of buttons available on a gamepad
  120. *
  121. * For controllers that use a diamond pattern for the face buttons, the
  122. * south/east/west/north buttons below correspond to the locations in the
  123. * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo
  124. * Switch controllers, this would be B/A/Y/X, for GameCube controllers this
  125. * would be A/X/B/Y, for PlayStation controllers this would be
  126. * Cross/Circle/Square/Triangle.
  127. *
  128. * For controllers that don't use a diamond pattern for the face buttons, the
  129. * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or
  130. * 1, 2, 3, 4, or for controllers that aren't labeled, they are the primary,
  131. * secondary, etc. buttons.
  132. *
  133. * The activate action is often the south button and the cancel action is
  134. * often the east button, but in some regions this is reversed, so your game
  135. * should allow remapping actions based on user preferences.
  136. *
  137. * You can query the labels for the face buttons using
  138. * SDL_GetGamepadButtonLabel()
  139. *
  140. * \since This enum is available since SDL 3.2.0.
  141. */
  142. typedef enum SDL_GamepadButton
  143. {
  144. SDL_GAMEPAD_BUTTON_INVALID = -1,
  145. SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */
  146. SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */
  147. SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */
  148. SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */
  149. SDL_GAMEPAD_BUTTON_BACK,
  150. SDL_GAMEPAD_BUTTON_GUIDE,
  151. SDL_GAMEPAD_BUTTON_START,
  152. SDL_GAMEPAD_BUTTON_LEFT_STICK,
  153. SDL_GAMEPAD_BUTTON_RIGHT_STICK,
  154. SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
  155. SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
  156. SDL_GAMEPAD_BUTTON_DPAD_UP,
  157. SDL_GAMEPAD_BUTTON_DPAD_DOWN,
  158. SDL_GAMEPAD_BUTTON_DPAD_LEFT,
  159. SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
  160. 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, Google Stadia capture button) */
  161. SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button) */
  162. SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button) */
  163. SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button) */
  164. SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button) */
  165. SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */
  166. SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */
  167. SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button (e.g. Nintendo GameCube left trigger click) */
  168. SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button (e.g. Nintendo GameCube right trigger click) */
  169. SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */
  170. SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */
  171. SDL_GAMEPAD_BUTTON_COUNT
  172. } SDL_GamepadButton;
  173. /**
  174. * The set of gamepad button labels
  175. *
  176. * This isn't a complete set, just the face buttons to make it easy to show
  177. * button prompts.
  178. *
  179. * For a complete set, you should look at the button and gamepad type and have
  180. * a set of symbols that work well with your art style.
  181. *
  182. * \since This enum is available since SDL 3.2.0.
  183. */
  184. typedef enum SDL_GamepadButtonLabel
  185. {
  186. SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN,
  187. SDL_GAMEPAD_BUTTON_LABEL_A,
  188. SDL_GAMEPAD_BUTTON_LABEL_B,
  189. SDL_GAMEPAD_BUTTON_LABEL_X,
  190. SDL_GAMEPAD_BUTTON_LABEL_Y,
  191. SDL_GAMEPAD_BUTTON_LABEL_CROSS,
  192. SDL_GAMEPAD_BUTTON_LABEL_CIRCLE,
  193. SDL_GAMEPAD_BUTTON_LABEL_SQUARE,
  194. SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE
  195. } SDL_GamepadButtonLabel;
  196. /**
  197. * The list of axes available on a gamepad
  198. *
  199. * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to
  200. * SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though
  201. * advanced UI will allow users to set or autodetect the dead zone, which
  202. * varies between gamepads.
  203. *
  204. * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully
  205. * pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the
  206. * same range that will be reported by the lower-level SDL_GetJoystickAxis().
  207. *
  208. * \since This enum is available since SDL 3.2.0.
  209. */
  210. typedef enum SDL_GamepadAxis
  211. {
  212. SDL_GAMEPAD_AXIS_INVALID = -1,
  213. SDL_GAMEPAD_AXIS_LEFTX,
  214. SDL_GAMEPAD_AXIS_LEFTY,
  215. SDL_GAMEPAD_AXIS_RIGHTX,
  216. SDL_GAMEPAD_AXIS_RIGHTY,
  217. SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
  218. SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,
  219. SDL_GAMEPAD_AXIS_COUNT
  220. } SDL_GamepadAxis;
  221. /**
  222. * Types of gamepad control bindings.
  223. *
  224. * A gamepad is a collection of bindings that map arbitrary joystick buttons,
  225. * axes and hat switches to specific positions on a generic console-style
  226. * gamepad. This enum is used as part of SDL_GamepadBinding to specify those
  227. * mappings.
  228. *
  229. * \since This enum is available since SDL 3.2.0.
  230. */
  231. typedef enum SDL_GamepadBindingType
  232. {
  233. SDL_GAMEPAD_BINDTYPE_NONE = 0,
  234. SDL_GAMEPAD_BINDTYPE_BUTTON,
  235. SDL_GAMEPAD_BINDTYPE_AXIS,
  236. SDL_GAMEPAD_BINDTYPE_HAT
  237. } SDL_GamepadBindingType;
  238. /**
  239. * A mapping between one joystick input to a gamepad control.
  240. *
  241. * A gamepad has a collection of several bindings, to say, for example, when
  242. * joystick button number 5 is pressed, that should be treated like the
  243. * gamepad's "start" button.
  244. *
  245. * SDL has these bindings built-in for many popular controllers, and can add
  246. * more with a simple text string. Those strings are parsed into a collection
  247. * of these structs to make it easier to operate on the data.
  248. *
  249. * \since This struct is available since SDL 3.2.0.
  250. *
  251. * \sa SDL_GetGamepadBindings
  252. */
  253. typedef struct SDL_GamepadBinding
  254. {
  255. SDL_GamepadBindingType input_type;
  256. union
  257. {
  258. int button;
  259. struct
  260. {
  261. int axis;
  262. int axis_min;
  263. int axis_max;
  264. } axis;
  265. struct
  266. {
  267. int hat;
  268. int hat_mask;
  269. } hat;
  270. } input;
  271. SDL_GamepadBindingType output_type;
  272. union
  273. {
  274. SDL_GamepadButton button;
  275. struct
  276. {
  277. SDL_GamepadAxis axis;
  278. int axis_min;
  279. int axis_max;
  280. } axis;
  281. } output;
  282. } SDL_GamepadBinding;
  283. /**
  284. * Add support for gamepads that SDL is unaware of or change the binding of an
  285. * existing gamepad.
  286. *
  287. * The mapping string has the format "GUID,name,mapping", where GUID is the
  288. * string value from SDL_GUIDToString(), name is the human readable string for
  289. * the device and mappings are gamepad mappings to joystick ones. Under
  290. * Windows there is a reserved GUID of "xinput" that covers all XInput
  291. * devices. The mapping format for joystick is:
  292. *
  293. * - `bX`: a joystick button, index X
  294. * - `hX.Y`: hat X with value Y
  295. * - `aX`: axis X of the joystick
  296. *
  297. * Buttons can be used as a gamepad axes and vice versa.
  298. *
  299. * If a device with this GUID is already plugged in, SDL will generate an
  300. * SDL_EVENT_GAMEPAD_ADDED event.
  301. *
  302. * This string shows an example of a valid mapping for a gamepad:
  303. *
  304. * ```c
  305. * "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"
  306. * ```
  307. *
  308. * \param mapping the mapping string.
  309. * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
  310. * -1 on failure; call SDL_GetError() for more information.
  311. *
  312. * \threadsafety It is safe to call this function from any thread.
  313. *
  314. * \since This function is available since SDL 3.2.0.
  315. *
  316. * \sa SDL_AddGamepadMappingsFromFile
  317. * \sa SDL_AddGamepadMappingsFromIO
  318. * \sa SDL_GetGamepadMapping
  319. * \sa SDL_GetGamepadMappingForGUID
  320. * \sa SDL_HINT_GAMECONTROLLERCONFIG
  321. * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
  322. * \sa SDL_EVENT_GAMEPAD_ADDED
  323. */
  324. extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
  325. /**
  326. * Load a set of gamepad mappings from an SDL_IOStream.
  327. *
  328. * You can call this function several times, if needed, to load different
  329. * database files.
  330. *
  331. * If a new mapping is loaded for an already known gamepad GUID, the later
  332. * version will overwrite the one currently loaded.
  333. *
  334. * Any new mappings for already plugged in controllers will generate
  335. * SDL_EVENT_GAMEPAD_ADDED events.
  336. *
  337. * Mappings not belonging to the current platform or with no platform field
  338. * specified will be ignored (i.e. mappings for Linux will be ignored in
  339. * Windows, etc).
  340. *
  341. * This function will load the text database entirely in memory before
  342. * processing it, so take this into consideration if you are in a memory
  343. * constrained environment.
  344. *
  345. * \param src the data stream for the mappings to be added.
  346. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
  347. * in the case of an error.
  348. * \returns the number of mappings added or -1 on failure; call SDL_GetError()
  349. * for more information.
  350. *
  351. * \threadsafety It is safe to call this function from any thread.
  352. *
  353. * \since This function is available since SDL 3.2.0.
  354. *
  355. * \sa SDL_AddGamepadMapping
  356. * \sa SDL_AddGamepadMappingsFromFile
  357. * \sa SDL_GetGamepadMapping
  358. * \sa SDL_GetGamepadMappingForGUID
  359. * \sa SDL_HINT_GAMECONTROLLERCONFIG
  360. * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
  361. * \sa SDL_EVENT_GAMEPAD_ADDED
  362. */
  363. extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio);
  364. /**
  365. * Load a set of gamepad mappings from a file.
  366. *
  367. * You can call this function several times, if needed, to load different
  368. * database files.
  369. *
  370. * If a new mapping is loaded for an already known gamepad GUID, the later
  371. * version will overwrite the one currently loaded.
  372. *
  373. * Any new mappings for already plugged in controllers will generate
  374. * SDL_EVENT_GAMEPAD_ADDED events.
  375. *
  376. * Mappings not belonging to the current platform or with no platform field
  377. * specified will be ignored (i.e. mappings for Linux will be ignored in
  378. * Windows, etc).
  379. *
  380. * \param file the mappings file to load.
  381. * \returns the number of mappings added or -1 on failure; call SDL_GetError()
  382. * for more information.
  383. *
  384. * \threadsafety It is safe to call this function from any thread.
  385. *
  386. * \since This function is available since SDL 3.2.0.
  387. *
  388. * \sa SDL_AddGamepadMapping
  389. * \sa SDL_AddGamepadMappingsFromIO
  390. * \sa SDL_GetGamepadMapping
  391. * \sa SDL_GetGamepadMappingForGUID
  392. * \sa SDL_HINT_GAMECONTROLLERCONFIG
  393. * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
  394. * \sa SDL_EVENT_GAMEPAD_ADDED
  395. */
  396. extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
  397. /**
  398. * Reinitialize the SDL mapping database to its initial state.
  399. *
  400. * This will generate gamepad events as needed if device mappings change.
  401. *
  402. * \returns true on success or false on failure; call SDL_GetError() for more
  403. * information.
  404. *
  405. * \threadsafety It is safe to call this function from any thread.
  406. *
  407. * \since This function is available since SDL 3.2.0.
  408. */
  409. extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void);
  410. /**
  411. * Get the current gamepad mappings.
  412. *
  413. * \param count a pointer filled in with the number of mappings returned, can
  414. * be NULL.
  415. * \returns an array of the mapping strings, NULL-terminated, or NULL on
  416. * failure; call SDL_GetError() for more information. This is a
  417. * single allocation that should be freed with SDL_free() when it is
  418. * no longer needed.
  419. *
  420. * \threadsafety It is safe to call this function from any thread.
  421. *
  422. * \since This function is available since SDL 3.2.0.
  423. */
  424. extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
  425. /**
  426. * Get the gamepad mapping string for a given GUID.
  427. *
  428. * \param guid a structure containing the GUID for which a mapping is desired.
  429. * \returns a mapping string or NULL on failure; call SDL_GetError() for more
  430. * information. This should be freed with SDL_free() when it is no
  431. * longer needed.
  432. *
  433. * \threadsafety It is safe to call this function from any thread.
  434. *
  435. * \since This function is available since SDL 3.2.0.
  436. *
  437. * \sa SDL_GetJoystickGUIDForID
  438. * \sa SDL_GetJoystickGUID
  439. */
  440. extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
  441. /**
  442. * Get the current mapping of a gamepad.
  443. *
  444. * Details about mappings are discussed with SDL_AddGamepadMapping().
  445. *
  446. * \param gamepad the gamepad you want to get the current mapping for.
  447. * \returns a string that has the gamepad's mapping or NULL if no mapping is
  448. * available; call SDL_GetError() for more information. This should
  449. * be freed with SDL_free() when it is no longer needed.
  450. *
  451. * \threadsafety It is safe to call this function from any thread.
  452. *
  453. * \since This function is available since SDL 3.2.0.
  454. *
  455. * \sa SDL_AddGamepadMapping
  456. * \sa SDL_GetGamepadMappingForID
  457. * \sa SDL_GetGamepadMappingForGUID
  458. * \sa SDL_SetGamepadMapping
  459. */
  460. extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
  461. /**
  462. * Set the current mapping of a joystick or gamepad.
  463. *
  464. * Details about mappings are discussed with SDL_AddGamepadMapping().
  465. *
  466. * \param instance_id the joystick instance ID.
  467. * \param mapping the mapping to use for this device, or NULL to clear the
  468. * mapping.
  469. * \returns true on success or false on failure; call SDL_GetError() for more
  470. * information.
  471. *
  472. * \threadsafety It is safe to call this function from any thread.
  473. *
  474. * \since This function is available since SDL 3.2.0.
  475. *
  476. * \sa SDL_AddGamepadMapping
  477. * \sa SDL_GetGamepadMapping
  478. */
  479. extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
  480. /**
  481. * Return whether a gamepad is currently connected.
  482. *
  483. * \returns true if a gamepad is connected, false otherwise.
  484. *
  485. * \threadsafety It is safe to call this function from any thread.
  486. *
  487. * \since This function is available since SDL 3.2.0.
  488. *
  489. * \sa SDL_GetGamepads
  490. */
  491. extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void);
  492. /**
  493. * Get a list of currently connected gamepads.
  494. *
  495. * \param count a pointer filled in with the number of gamepads returned, may
  496. * be NULL.
  497. * \returns a 0 terminated array of joystick instance IDs or NULL on failure;
  498. * call SDL_GetError() for more information. This should be freed
  499. * with SDL_free() when it is no longer needed.
  500. *
  501. * \threadsafety It is safe to call this function from any thread.
  502. *
  503. * \since This function is available since SDL 3.2.0.
  504. *
  505. * \sa SDL_HasGamepad
  506. * \sa SDL_OpenGamepad
  507. */
  508. extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);
  509. /**
  510. * Check if the given joystick is supported by the gamepad interface.
  511. *
  512. * \param instance_id the joystick instance ID.
  513. * \returns true if the given joystick is supported by the gamepad interface,
  514. * false if it isn't or it's an invalid index.
  515. *
  516. * \threadsafety It is safe to call this function from any thread.
  517. *
  518. * \since This function is available since SDL 3.2.0.
  519. *
  520. * \sa SDL_GetJoysticks
  521. * \sa SDL_OpenGamepad
  522. */
  523. extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
  524. /**
  525. * Get the implementation dependent name of a gamepad.
  526. *
  527. * This can be called before any gamepads are opened.
  528. *
  529. * \param instance_id the joystick instance ID.
  530. * \returns the name of the selected gamepad. If no name can be found, this
  531. * function returns NULL; call SDL_GetError() for more information.
  532. *
  533. * \threadsafety It is safe to call this function from any thread.
  534. *
  535. * \since This function is available since SDL 3.2.0.
  536. *
  537. * \sa SDL_GetGamepadName
  538. * \sa SDL_GetGamepads
  539. */
  540. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id);
  541. /**
  542. * Get the implementation dependent path of a gamepad.
  543. *
  544. * This can be called before any gamepads are opened.
  545. *
  546. * \param instance_id the joystick instance ID.
  547. * \returns the path of the selected gamepad. If no path can be found, this
  548. * function returns NULL; call SDL_GetError() for more information.
  549. *
  550. * \threadsafety It is safe to call this function from any thread.
  551. *
  552. * \since This function is available since SDL 3.2.0.
  553. *
  554. * \sa SDL_GetGamepadPath
  555. * \sa SDL_GetGamepads
  556. */
  557. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id);
  558. /**
  559. * Get the player index of a gamepad.
  560. *
  561. * This can be called before any gamepads are opened.
  562. *
  563. * \param instance_id the joystick instance ID.
  564. * \returns the player index of a gamepad, or -1 if it's not available.
  565. *
  566. * \threadsafety It is safe to call this function from any thread.
  567. *
  568. * \since This function is available since SDL 3.2.0.
  569. *
  570. * \sa SDL_GetGamepadPlayerIndex
  571. * \sa SDL_GetGamepads
  572. */
  573. extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id);
  574. /**
  575. * Get the implementation-dependent GUID of a gamepad.
  576. *
  577. * This can be called before any gamepads are opened.
  578. *
  579. * \param instance_id the joystick instance ID.
  580. * \returns the GUID of the selected gamepad. If called on an invalid index,
  581. * this function returns a zero GUID.
  582. *
  583. * \threadsafety It is safe to call this function from any thread.
  584. *
  585. * \since This function is available since SDL 3.2.0.
  586. *
  587. * \sa SDL_GUIDToString
  588. * \sa SDL_GetGamepads
  589. */
  590. extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
  591. /**
  592. * Get the USB vendor ID of a gamepad, if available.
  593. *
  594. * This can be called before any gamepads are opened. If the vendor ID isn't
  595. * available this function returns 0.
  596. *
  597. * \param instance_id the joystick instance ID.
  598. * \returns the USB vendor ID of the selected gamepad. If called on an invalid
  599. * index, this function returns zero.
  600. *
  601. * \threadsafety It is safe to call this function from any thread.
  602. *
  603. * \since This function is available since SDL 3.2.0.
  604. *
  605. * \sa SDL_GetGamepadVendor
  606. * \sa SDL_GetGamepads
  607. */
  608. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id);
  609. /**
  610. * Get the USB product ID of a gamepad, if available.
  611. *
  612. * This can be called before any gamepads are opened. If the product ID isn't
  613. * available this function returns 0.
  614. *
  615. * \param instance_id the joystick instance ID.
  616. * \returns the USB product ID of the selected gamepad. If called on an
  617. * invalid index, this function returns zero.
  618. *
  619. * \threadsafety It is safe to call this function from any thread.
  620. *
  621. * \since This function is available since SDL 3.2.0.
  622. *
  623. * \sa SDL_GetGamepadProduct
  624. * \sa SDL_GetGamepads
  625. */
  626. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id);
  627. /**
  628. * Get the product version of a gamepad, if available.
  629. *
  630. * This can be called before any gamepads are opened. If the product version
  631. * isn't available this function returns 0.
  632. *
  633. * \param instance_id the joystick instance ID.
  634. * \returns the product version of the selected gamepad. If called on an
  635. * invalid index, this function returns zero.
  636. *
  637. * \threadsafety It is safe to call this function from any thread.
  638. *
  639. * \since This function is available since SDL 3.2.0.
  640. *
  641. * \sa SDL_GetGamepadProductVersion
  642. * \sa SDL_GetGamepads
  643. */
  644. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id);
  645. /**
  646. * Get the type of a gamepad.
  647. *
  648. * This can be called before any gamepads are opened.
  649. *
  650. * \param instance_id the joystick instance ID.
  651. * \returns the gamepad type.
  652. *
  653. * \threadsafety It is safe to call this function from any thread.
  654. *
  655. * \since This function is available since SDL 3.2.0.
  656. *
  657. * \sa SDL_GetGamepadType
  658. * \sa SDL_GetGamepads
  659. * \sa SDL_GetRealGamepadTypeForID
  660. */
  661. extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id);
  662. /**
  663. * Get the type of a gamepad, ignoring any mapping override.
  664. *
  665. * This can be called before any gamepads are opened.
  666. *
  667. * \param instance_id the joystick instance ID.
  668. * \returns the gamepad type.
  669. *
  670. * \threadsafety It is safe to call this function from any thread.
  671. *
  672. * \since This function is available since SDL 3.2.0.
  673. *
  674. * \sa SDL_GetGamepadTypeForID
  675. * \sa SDL_GetGamepads
  676. * \sa SDL_GetRealGamepadType
  677. */
  678. extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id);
  679. /**
  680. * Get the mapping of a gamepad.
  681. *
  682. * This can be called before any gamepads are opened.
  683. *
  684. * \param instance_id the joystick instance ID.
  685. * \returns the mapping string. Returns NULL if no mapping is available. This
  686. * should be freed with SDL_free() when it is no longer needed.
  687. *
  688. * \threadsafety It is safe to call this function from any thread.
  689. *
  690. * \since This function is available since SDL 3.2.0.
  691. *
  692. * \sa SDL_GetGamepads
  693. * \sa SDL_GetGamepadMapping
  694. */
  695. extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);
  696. /**
  697. * Open a gamepad for use.
  698. *
  699. * \param instance_id the joystick instance ID.
  700. * \returns a gamepad identifier or NULL if an error occurred; call
  701. * SDL_GetError() for more information.
  702. *
  703. * \threadsafety It is safe to call this function from any thread.
  704. *
  705. * \since This function is available since SDL 3.2.0.
  706. *
  707. * \sa SDL_CloseGamepad
  708. * \sa SDL_IsGamepad
  709. */
  710. extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);
  711. /**
  712. * Get the SDL_Gamepad associated with a joystick instance ID, if it has been
  713. * opened.
  714. *
  715. * \param instance_id the joystick instance ID of the gamepad.
  716. * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
  717. * opened yet; call SDL_GetError() for more information.
  718. *
  719. * \threadsafety It is safe to call this function from any thread.
  720. *
  721. * \since This function is available since SDL 3.2.0.
  722. */
  723. extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id);
  724. /**
  725. * Get the SDL_Gamepad associated with a player index.
  726. *
  727. * \param player_index the player index, which different from the instance ID.
  728. * \returns the SDL_Gamepad associated with a player index.
  729. *
  730. * \threadsafety It is safe to call this function from any thread.
  731. *
  732. * \since This function is available since SDL 3.2.0.
  733. *
  734. * \sa SDL_GetGamepadPlayerIndex
  735. * \sa SDL_SetGamepadPlayerIndex
  736. */
  737. extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
  738. /**
  739. * Get the properties associated with an opened gamepad.
  740. *
  741. * These properties are shared with the underlying joystick object.
  742. *
  743. * The following read-only properties are provided by SDL:
  744. *
  745. * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED
  746. * that has adjustable brightness
  747. * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED
  748. * that has adjustable color
  749. * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a
  750. * player LED
  751. * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has
  752. * left/right rumble
  753. * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has
  754. * simple trigger rumble
  755. *
  756. * \param gamepad a gamepad identifier previously returned by
  757. * SDL_OpenGamepad().
  758. * \returns a valid property ID on success or 0 on failure; call
  759. * SDL_GetError() for more information.
  760. *
  761. * \threadsafety It is safe to call this function from any thread.
  762. *
  763. * \since This function is available since SDL 3.2.0.
  764. */
  765. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
  766. #define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN
  767. #define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
  768. #define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN
  769. #define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
  770. #define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
  771. /**
  772. * Get the instance ID of an opened gamepad.
  773. *
  774. * \param gamepad a gamepad identifier previously returned by
  775. * SDL_OpenGamepad().
  776. * \returns the instance ID of the specified gamepad on success or 0 on
  777. * failure; call SDL_GetError() for more information.
  778. *
  779. * \threadsafety It is safe to call this function from any thread.
  780. *
  781. * \since This function is available since SDL 3.2.0.
  782. */
  783. extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);
  784. /**
  785. * Get the implementation-dependent name for an opened gamepad.
  786. *
  787. * \param gamepad a gamepad identifier previously returned by
  788. * SDL_OpenGamepad().
  789. * \returns the implementation dependent name for the gamepad, or NULL if
  790. * there is no name or the identifier passed is invalid.
  791. *
  792. * \threadsafety It is safe to call this function from any thread.
  793. *
  794. * \since This function is available since SDL 3.2.0.
  795. *
  796. * \sa SDL_GetGamepadNameForID
  797. */
  798. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
  799. /**
  800. * Get the implementation-dependent path for an opened gamepad.
  801. *
  802. * \param gamepad a gamepad identifier previously returned by
  803. * SDL_OpenGamepad().
  804. * \returns the implementation dependent path for the gamepad, or NULL if
  805. * there is no path or the identifier passed is invalid.
  806. *
  807. * \threadsafety It is safe to call this function from any thread.
  808. *
  809. * \since This function is available since SDL 3.2.0.
  810. *
  811. * \sa SDL_GetGamepadPathForID
  812. */
  813. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
  814. /**
  815. * Get the type of an opened gamepad.
  816. *
  817. * \param gamepad the gamepad object to query.
  818. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
  819. * available.
  820. *
  821. * \threadsafety It is safe to call this function from any thread.
  822. *
  823. * \since This function is available since SDL 3.2.0.
  824. *
  825. * \sa SDL_GetGamepadTypeForID
  826. */
  827. extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
  828. /**
  829. * Get the type of an opened gamepad, ignoring any mapping override.
  830. *
  831. * \param gamepad the gamepad object to query.
  832. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
  833. * available.
  834. *
  835. * \threadsafety It is safe to call this function from any thread.
  836. *
  837. * \since This function is available since SDL 3.2.0.
  838. *
  839. * \sa SDL_GetRealGamepadTypeForID
  840. */
  841. extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
  842. /**
  843. * Get the player index of an opened gamepad.
  844. *
  845. * For XInput gamepads this returns the XInput user index.
  846. *
  847. * \param gamepad the gamepad object to query.
  848. * \returns the player index for gamepad, or -1 if it's not available.
  849. *
  850. * \threadsafety It is safe to call this function from any thread.
  851. *
  852. * \since This function is available since SDL 3.2.0.
  853. *
  854. * \sa SDL_SetGamepadPlayerIndex
  855. */
  856. extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
  857. /**
  858. * Set the player index of an opened gamepad.
  859. *
  860. * \param gamepad the gamepad object to adjust.
  861. * \param player_index player index to assign to this gamepad, or -1 to clear
  862. * the player index and turn off player LEDs.
  863. * \returns true on success or false on failure; call SDL_GetError() for more
  864. * information.
  865. *
  866. * \threadsafety It is safe to call this function from any thread.
  867. *
  868. * \since This function is available since SDL 3.2.0.
  869. *
  870. * \sa SDL_GetGamepadPlayerIndex
  871. */
  872. extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
  873. /**
  874. * Get the USB vendor ID of an opened gamepad, if available.
  875. *
  876. * If the vendor ID isn't available this function returns 0.
  877. *
  878. * \param gamepad the gamepad object to query.
  879. * \returns the USB vendor ID, or zero if unavailable.
  880. *
  881. * \threadsafety It is safe to call this function from any thread.
  882. *
  883. * \since This function is available since SDL 3.2.0.
  884. *
  885. * \sa SDL_GetGamepadVendorForID
  886. */
  887. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
  888. /**
  889. * Get the USB product ID of an opened gamepad, if available.
  890. *
  891. * If the product ID isn't available this function returns 0.
  892. *
  893. * \param gamepad the gamepad object to query.
  894. * \returns the USB product ID, or zero if unavailable.
  895. *
  896. * \threadsafety It is safe to call this function from any thread.
  897. *
  898. * \since This function is available since SDL 3.2.0.
  899. *
  900. * \sa SDL_GetGamepadProductForID
  901. */
  902. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
  903. /**
  904. * Get the product version of an opened gamepad, if available.
  905. *
  906. * If the product version isn't available this function returns 0.
  907. *
  908. * \param gamepad the gamepad object to query.
  909. * \returns the USB product version, or zero if unavailable.
  910. *
  911. * \threadsafety It is safe to call this function from any thread.
  912. *
  913. * \since This function is available since SDL 3.2.0.
  914. *
  915. * \sa SDL_GetGamepadProductVersionForID
  916. */
  917. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
  918. /**
  919. * Get the firmware version of an opened gamepad, if available.
  920. *
  921. * If the firmware version isn't available this function returns 0.
  922. *
  923. * \param gamepad the gamepad object to query.
  924. * \returns the gamepad firmware version, or zero if unavailable.
  925. *
  926. * \threadsafety It is safe to call this function from any thread.
  927. *
  928. * \since This function is available since SDL 3.2.0.
  929. */
  930. extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
  931. /**
  932. * Get the serial number of an opened gamepad, if available.
  933. *
  934. * Returns the serial number of the gamepad, or NULL if it is not available.
  935. *
  936. * \param gamepad the gamepad object to query.
  937. * \returns the serial number, or NULL if unavailable.
  938. *
  939. * \threadsafety It is safe to call this function from any thread.
  940. *
  941. * \since This function is available since SDL 3.2.0.
  942. */
  943. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
  944. /**
  945. * Get the Steam Input handle of an opened gamepad, if available.
  946. *
  947. * Returns an InputHandle_t for the gamepad that can be used with Steam Input
  948. * API: https://partner.steamgames.com/doc/api/ISteamInput
  949. *
  950. * \param gamepad the gamepad object to query.
  951. * \returns the gamepad handle, or 0 if unavailable.
  952. *
  953. * \threadsafety It is safe to call this function from any thread.
  954. *
  955. * \since This function is available since SDL 3.2.0.
  956. */
  957. extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
  958. /**
  959. * Get the connection state of a gamepad.
  960. *
  961. * \param gamepad the gamepad object to query.
  962. * \returns the connection state on success or
  963. * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
  964. * for more information.
  965. *
  966. * \threadsafety It is safe to call this function from any thread.
  967. *
  968. * \since This function is available since SDL 3.2.0.
  969. */
  970. extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad);
  971. /**
  972. * Get the battery state of a gamepad.
  973. *
  974. * You should never take a battery status as absolute truth. Batteries
  975. * (especially failing batteries) are delicate hardware, and the values
  976. * reported here are best estimates based on what that hardware reports. It's
  977. * not uncommon for older batteries to lose stored power much faster than it
  978. * reports, or completely drain when reporting it has 20 percent left, etc.
  979. *
  980. * \param gamepad the gamepad object to query.
  981. * \param percent a pointer filled in with the percentage of battery life
  982. * left, between 0 and 100, or NULL to ignore. This will be
  983. * filled in with -1 we can't determine a value or there is no
  984. * battery.
  985. * \returns the current battery state.
  986. *
  987. * \threadsafety It is safe to call this function from any thread.
  988. *
  989. * \since This function is available since SDL 3.2.0.
  990. */
  991. extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
  992. /**
  993. * Check if a gamepad has been opened and is currently connected.
  994. *
  995. * \param gamepad a gamepad identifier previously returned by
  996. * SDL_OpenGamepad().
  997. * \returns true if the gamepad has been opened and is currently connected, or
  998. * false if not.
  999. *
  1000. * \threadsafety It is safe to call this function from any thread.
  1001. *
  1002. * \since This function is available since SDL 3.2.0.
  1003. */
  1004. extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
  1005. /**
  1006. * Get the underlying joystick from a gamepad.
  1007. *
  1008. * This function will give you a SDL_Joystick object, which allows you to use
  1009. * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
  1010. * for getting a joystick's position at any given time, even if it hasn't
  1011. * moved (moving it would produce an event, which would have the axis' value).
  1012. *
  1013. * The pointer returned is owned by the SDL_Gamepad. You should not call
  1014. * SDL_CloseJoystick() on it, for example, since doing so will likely cause
  1015. * SDL to crash.
  1016. *
  1017. * \param gamepad the gamepad object that you want to get a joystick from.
  1018. * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError()
  1019. * for more information.
  1020. *
  1021. * \threadsafety It is safe to call this function from any thread.
  1022. *
  1023. * \since This function is available since SDL 3.2.0.
  1024. */
  1025. extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
  1026. /**
  1027. * Set the state of gamepad event processing.
  1028. *
  1029. * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
  1030. * and check the state of the gamepad when you want gamepad information.
  1031. *
  1032. * \param enabled whether to process gamepad events or not.
  1033. *
  1034. * \threadsafety It is safe to call this function from any thread.
  1035. *
  1036. * \since This function is available since SDL 3.2.0.
  1037. *
  1038. * \sa SDL_GamepadEventsEnabled
  1039. * \sa SDL_UpdateGamepads
  1040. */
  1041. extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled);
  1042. /**
  1043. * Query the state of gamepad event processing.
  1044. *
  1045. * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
  1046. * and check the state of the gamepad when you want gamepad information.
  1047. *
  1048. * \returns true if gamepad events are being processed, false otherwise.
  1049. *
  1050. * \threadsafety It is safe to call this function from any thread.
  1051. *
  1052. * \since This function is available since SDL 3.2.0.
  1053. *
  1054. * \sa SDL_SetGamepadEventsEnabled
  1055. */
  1056. extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);
  1057. /**
  1058. * Get the SDL joystick layer bindings for a gamepad.
  1059. *
  1060. * \param gamepad a gamepad.
  1061. * \param count a pointer filled in with the number of bindings returned.
  1062. * \returns a NULL terminated array of pointers to bindings or NULL on
  1063. * failure; call SDL_GetError() for more information. This is a
  1064. * single allocation that should be freed with SDL_free() when it is
  1065. * no longer needed.
  1066. *
  1067. * \threadsafety It is safe to call this function from any thread.
  1068. *
  1069. * \since This function is available since SDL 3.2.0.
  1070. */
  1071. extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
  1072. /**
  1073. * Manually pump gamepad updates if not using the loop.
  1074. *
  1075. * This function is called automatically by the event loop if events are
  1076. * enabled. Under such circumstances, it will not be necessary to call this
  1077. * function.
  1078. *
  1079. * \threadsafety It is safe to call this function from any thread.
  1080. *
  1081. * \since This function is available since SDL 3.2.0.
  1082. */
  1083. extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
  1084. /**
  1085. * Convert a string into SDL_GamepadType enum.
  1086. *
  1087. * This function is called internally to translate SDL_Gamepad mapping strings
  1088. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  1089. * You do not normally need to call this function unless you are parsing
  1090. * SDL_Gamepad mappings in your own code.
  1091. *
  1092. * \param str string representing a SDL_GamepadType type.
  1093. * \returns the SDL_GamepadType enum corresponding to the input string, or
  1094. * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
  1095. *
  1096. * \threadsafety It is safe to call this function from any thread.
  1097. *
  1098. * \since This function is available since SDL 3.2.0.
  1099. *
  1100. * \sa SDL_GetGamepadStringForType
  1101. */
  1102. extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
  1103. /**
  1104. * Convert from an SDL_GamepadType enum to a string.
  1105. *
  1106. * \param type an enum value for a given SDL_GamepadType.
  1107. * \returns a string for the given type, or NULL if an invalid type is
  1108. * specified. The string returned is of the format used by
  1109. * SDL_Gamepad mapping strings.
  1110. *
  1111. * \threadsafety It is safe to call this function from any thread.
  1112. *
  1113. * \since This function is available since SDL 3.2.0.
  1114. *
  1115. * \sa SDL_GetGamepadTypeFromString
  1116. */
  1117. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
  1118. /**
  1119. * Convert a string into SDL_GamepadAxis enum.
  1120. *
  1121. * This function is called internally to translate SDL_Gamepad mapping strings
  1122. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  1123. * You do not normally need to call this function unless you are parsing
  1124. * SDL_Gamepad mappings in your own code.
  1125. *
  1126. * Note specially that "righttrigger" and "lefttrigger" map to
  1127. * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
  1128. * respectively.
  1129. *
  1130. * \param str string representing a SDL_Gamepad axis.
  1131. * \returns the SDL_GamepadAxis enum corresponding to the input string, or
  1132. * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
  1133. *
  1134. * \threadsafety It is safe to call this function from any thread.
  1135. *
  1136. * \since This function is available since SDL 3.2.0.
  1137. *
  1138. * \sa SDL_GetGamepadStringForAxis
  1139. */
  1140. extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
  1141. /**
  1142. * Convert from an SDL_GamepadAxis enum to a string.
  1143. *
  1144. * \param axis an enum value for a given SDL_GamepadAxis.
  1145. * \returns a string for the given axis, or NULL if an invalid axis is
  1146. * specified. The string returned is of the format used by
  1147. * SDL_Gamepad mapping strings.
  1148. *
  1149. * \threadsafety It is safe to call this function from any thread.
  1150. *
  1151. * \since This function is available since SDL 3.2.0.
  1152. *
  1153. * \sa SDL_GetGamepadAxisFromString
  1154. */
  1155. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
  1156. /**
  1157. * Query whether a gamepad has a given axis.
  1158. *
  1159. * This merely reports whether the gamepad's mapping defined this axis, as
  1160. * that is all the information SDL has about the physical device.
  1161. *
  1162. * \param gamepad a gamepad.
  1163. * \param axis an axis enum value (an SDL_GamepadAxis value).
  1164. * \returns true if the gamepad has this axis, false otherwise.
  1165. *
  1166. * \threadsafety It is safe to call this function from any thread.
  1167. *
  1168. * \since This function is available since SDL 3.2.0.
  1169. *
  1170. * \sa SDL_GamepadHasButton
  1171. * \sa SDL_GetGamepadAxis
  1172. */
  1173. extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  1174. /**
  1175. * Get the current state of an axis control on a gamepad.
  1176. *
  1177. * The axis indices start at index 0.
  1178. *
  1179. * For thumbsticks, the state is a value ranging from -32768 (up/left) to
  1180. * 32767 (down/right).
  1181. *
  1182. * Triggers range from 0 when released to 32767 when fully pressed, and never
  1183. * return a negative value. Note that this differs from the value reported by
  1184. * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
  1185. *
  1186. * Note that for invalid gamepads or axes, this will return 0. Zero is also a
  1187. * valid value in normal operation; usually it means a centered axis.
  1188. *
  1189. * \param gamepad a gamepad.
  1190. * \param axis an axis index (one of the SDL_GamepadAxis values).
  1191. * \returns axis state.
  1192. *
  1193. * \threadsafety It is safe to call this function from any thread.
  1194. *
  1195. * \since This function is available since SDL 3.2.0.
  1196. *
  1197. * \sa SDL_GamepadHasAxis
  1198. * \sa SDL_GetGamepadButton
  1199. */
  1200. extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  1201. /**
  1202. * Convert a string into an SDL_GamepadButton enum.
  1203. *
  1204. * This function is called internally to translate SDL_Gamepad mapping strings
  1205. * for the underlying joystick device into the consistent SDL_Gamepad mapping.
  1206. * You do not normally need to call this function unless you are parsing
  1207. * SDL_Gamepad mappings in your own code.
  1208. *
  1209. * \param str string representing a SDL_Gamepad button.
  1210. * \returns the SDL_GamepadButton enum corresponding to the input string, or
  1211. * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
  1212. *
  1213. * \threadsafety It is safe to call this function from any thread.
  1214. *
  1215. * \since This function is available since SDL 3.2.0.
  1216. *
  1217. * \sa SDL_GetGamepadStringForButton
  1218. */
  1219. extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
  1220. /**
  1221. * Convert from an SDL_GamepadButton enum to a string.
  1222. *
  1223. * \param button an enum value for a given SDL_GamepadButton.
  1224. * \returns a string for the given button, or NULL if an invalid button is
  1225. * specified. The string returned is of the format used by
  1226. * SDL_Gamepad mapping strings.
  1227. *
  1228. * \threadsafety It is safe to call this function from any thread.
  1229. *
  1230. * \since This function is available since SDL 3.2.0.
  1231. *
  1232. * \sa SDL_GetGamepadButtonFromString
  1233. */
  1234. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
  1235. /**
  1236. * Query whether a gamepad has a given button.
  1237. *
  1238. * This merely reports whether the gamepad's mapping defined this button, as
  1239. * that is all the information SDL has about the physical device.
  1240. *
  1241. * \param gamepad a gamepad.
  1242. * \param button a button enum value (an SDL_GamepadButton value).
  1243. * \returns true if the gamepad has this button, false otherwise.
  1244. *
  1245. * \threadsafety It is safe to call this function from any thread.
  1246. *
  1247. * \since This function is available since SDL 3.2.0.
  1248. *
  1249. * \sa SDL_GamepadHasAxis
  1250. */
  1251. extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  1252. /**
  1253. * Get the current state of a button on a gamepad.
  1254. *
  1255. * \param gamepad a gamepad.
  1256. * \param button a button index (one of the SDL_GamepadButton values).
  1257. * \returns true if the button is pressed, false otherwise.
  1258. *
  1259. * \threadsafety It is safe to call this function from any thread.
  1260. *
  1261. * \since This function is available since SDL 3.2.0.
  1262. *
  1263. * \sa SDL_GamepadHasButton
  1264. * \sa SDL_GetGamepadAxis
  1265. */
  1266. extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  1267. /**
  1268. * Get the label of a button on a gamepad.
  1269. *
  1270. * \param type the type of gamepad to check.
  1271. * \param button a button index (one of the SDL_GamepadButton values).
  1272. * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
  1273. *
  1274. * \threadsafety It is safe to call this function from any thread.
  1275. *
  1276. * \since This function is available since SDL 3.2.0.
  1277. *
  1278. * \sa SDL_GetGamepadButtonLabel
  1279. */
  1280. extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);
  1281. /**
  1282. * Get the label of a button on a gamepad.
  1283. *
  1284. * \param gamepad a gamepad.
  1285. * \param button a button index (one of the SDL_GamepadButton values).
  1286. * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
  1287. *
  1288. * \threadsafety It is safe to call this function from any thread.
  1289. *
  1290. * \since This function is available since SDL 3.2.0.
  1291. *
  1292. * \sa SDL_GetGamepadButtonLabelForType
  1293. */
  1294. extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  1295. /**
  1296. * Get the number of touchpads on a gamepad.
  1297. *
  1298. * \param gamepad a gamepad.
  1299. * \returns number of touchpads.
  1300. *
  1301. * \threadsafety It is safe to call this function from any thread.
  1302. *
  1303. * \since This function is available since SDL 3.2.0.
  1304. *
  1305. * \sa SDL_GetNumGamepadTouchpadFingers
  1306. */
  1307. extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
  1308. /**
  1309. * Get the number of supported simultaneous fingers on a touchpad on a game
  1310. * gamepad.
  1311. *
  1312. * \param gamepad a gamepad.
  1313. * \param touchpad a touchpad.
  1314. * \returns number of supported simultaneous fingers.
  1315. *
  1316. * \threadsafety It is safe to call this function from any thread.
  1317. *
  1318. * \since This function is available since SDL 3.2.0.
  1319. *
  1320. * \sa SDL_GetGamepadTouchpadFinger
  1321. * \sa SDL_GetNumGamepadTouchpads
  1322. */
  1323. extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
  1324. /**
  1325. * Get the current state of a finger on a touchpad on a gamepad.
  1326. *
  1327. * \param gamepad a gamepad.
  1328. * \param touchpad a touchpad.
  1329. * \param finger a finger.
  1330. * \param down a pointer filled with true if the finger is down, false
  1331. * otherwise, may be NULL.
  1332. * \param x a pointer filled with the x position, normalized 0 to 1, with the
  1333. * origin in the upper left, may be NULL.
  1334. * \param y a pointer filled with the y position, normalized 0 to 1, with the
  1335. * origin in the upper left, may be NULL.
  1336. * \param pressure a pointer filled with pressure value, may be NULL.
  1337. * \returns true on success or false on failure; call SDL_GetError() for more
  1338. * information.
  1339. *
  1340. * \threadsafety It is safe to call this function from any thread.
  1341. *
  1342. * \since This function is available since SDL 3.2.0.
  1343. *
  1344. * \sa SDL_GetNumGamepadTouchpadFingers
  1345. */
  1346. extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure);
  1347. /**
  1348. * Return whether a gamepad has a particular sensor.
  1349. *
  1350. * \param gamepad the gamepad to query.
  1351. * \param type the type of sensor to query.
  1352. * \returns true if the sensor exists, false otherwise.
  1353. *
  1354. * \threadsafety It is safe to call this function from any thread.
  1355. *
  1356. * \since This function is available since SDL 3.2.0.
  1357. *
  1358. * \sa SDL_GetGamepadSensorData
  1359. * \sa SDL_GetGamepadSensorDataRate
  1360. * \sa SDL_SetGamepadSensorEnabled
  1361. */
  1362. extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
  1363. /**
  1364. * Set whether data reporting for a gamepad sensor is enabled.
  1365. *
  1366. * \param gamepad the gamepad to update.
  1367. * \param type the type of sensor to enable/disable.
  1368. * \param enabled whether data reporting should be enabled.
  1369. * \returns true on success or false on failure; call SDL_GetError() for more
  1370. * information.
  1371. *
  1372. * \threadsafety It is safe to call this function from any thread.
  1373. *
  1374. * \since This function is available since SDL 3.2.0.
  1375. *
  1376. * \sa SDL_GamepadHasSensor
  1377. * \sa SDL_GamepadSensorEnabled
  1378. */
  1379. extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled);
  1380. /**
  1381. * Query whether sensor data reporting is enabled for a gamepad.
  1382. *
  1383. * \param gamepad the gamepad to query.
  1384. * \param type the type of sensor to query.
  1385. * \returns true if the sensor is enabled, false otherwise.
  1386. *
  1387. * \threadsafety It is safe to call this function from any thread.
  1388. *
  1389. * \since This function is available since SDL 3.2.0.
  1390. *
  1391. * \sa SDL_SetGamepadSensorEnabled
  1392. */
  1393. extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
  1394. /**
  1395. * Get the data rate (number of events per second) of a gamepad sensor.
  1396. *
  1397. * \param gamepad the gamepad to query.
  1398. * \param type the type of sensor to query.
  1399. * \returns the data rate, or 0.0f if the data rate is not available.
  1400. *
  1401. * \threadsafety It is safe to call this function from any thread.
  1402. *
  1403. * \since This function is available since SDL 3.2.0.
  1404. */
  1405. extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
  1406. /**
  1407. * Get the current state of a gamepad sensor.
  1408. *
  1409. * The number of values and interpretation of the data is sensor dependent.
  1410. * See the remarks in SDL_SensorType for details for each type of sensor.
  1411. *
  1412. * \param gamepad the gamepad to query.
  1413. * \param type the type of sensor to query.
  1414. * \param data a pointer filled with the current sensor state.
  1415. * \param num_values the number of values to write to data.
  1416. * \returns true on success or false on failure; call SDL_GetError() for more
  1417. * information.
  1418. *
  1419. * \threadsafety It is safe to call this function from any thread.
  1420. *
  1421. * \since This function is available since SDL 3.2.0.
  1422. */
  1423. extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
  1424. /**
  1425. * Start a rumble effect on a gamepad.
  1426. *
  1427. * Each call to this function cancels any previous rumble effect, and calling
  1428. * it with 0 intensity stops any rumbling.
  1429. *
  1430. * This function requires you to process SDL events or call
  1431. * SDL_UpdateJoysticks() to update rumble state.
  1432. *
  1433. * \param gamepad the gamepad to vibrate.
  1434. * \param low_frequency_rumble the intensity of the low frequency (left)
  1435. * rumble motor, from 0 to 0xFFFF.
  1436. * \param high_frequency_rumble the intensity of the high frequency (right)
  1437. * rumble motor, from 0 to 0xFFFF.
  1438. * \param duration_ms the duration of the rumble effect, in milliseconds.
  1439. * \returns true on success or false on failure; call SDL_GetError() for more
  1440. * information.
  1441. *
  1442. * \threadsafety It is safe to call this function from any thread.
  1443. *
  1444. * \since This function is available since SDL 3.2.0.
  1445. */
  1446. extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
  1447. /**
  1448. * Start a rumble effect in the gamepad's triggers.
  1449. *
  1450. * Each call to this function cancels any previous trigger rumble effect, and
  1451. * calling it with 0 intensity stops any rumbling.
  1452. *
  1453. * Note that this is rumbling of the _triggers_ and not the gamepad as a
  1454. * whole. This is currently only supported on Xbox One gamepads. If you want
  1455. * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
  1456. *
  1457. * This function requires you to process SDL events or call
  1458. * SDL_UpdateJoysticks() to update rumble state.
  1459. *
  1460. * \param gamepad the gamepad to vibrate.
  1461. * \param left_rumble the intensity of the left trigger rumble motor, from 0
  1462. * to 0xFFFF.
  1463. * \param right_rumble the intensity of the right trigger rumble motor, from 0
  1464. * to 0xFFFF.
  1465. * \param duration_ms the duration of the rumble effect, in milliseconds.
  1466. * \returns true on success or false on failure; call SDL_GetError() for more
  1467. * information.
  1468. *
  1469. * \threadsafety It is safe to call this function from any thread.
  1470. *
  1471. * \since This function is available since SDL 3.2.0.
  1472. *
  1473. * \sa SDL_RumbleGamepad
  1474. */
  1475. extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
  1476. /**
  1477. * Update a gamepad's LED color.
  1478. *
  1479. * An example of a joystick LED is the light on the back of a PlayStation 4's
  1480. * DualShock 4 controller.
  1481. *
  1482. * For gamepads with a single color LED, the maximum of the RGB values will be
  1483. * used as the LED brightness.
  1484. *
  1485. * \param gamepad the gamepad to update.
  1486. * \param red the intensity of the red LED.
  1487. * \param green the intensity of the green LED.
  1488. * \param blue the intensity of the blue LED.
  1489. * \returns true on success or false on failure; call SDL_GetError() for more
  1490. * information.
  1491. *
  1492. * \threadsafety It is safe to call this function from any thread.
  1493. *
  1494. * \since This function is available since SDL 3.2.0.
  1495. */
  1496. extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
  1497. /**
  1498. * Send a gamepad specific effect packet.
  1499. *
  1500. * \param gamepad the gamepad to affect.
  1501. * \param data the data to send to the gamepad.
  1502. * \param size the size of the data to send to the gamepad.
  1503. * \returns true on success or false on failure; call SDL_GetError() for more
  1504. * information.
  1505. *
  1506. * \threadsafety It is safe to call this function from any thread.
  1507. *
  1508. * \since This function is available since SDL 3.2.0.
  1509. */
  1510. extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
  1511. /**
  1512. * Close a gamepad previously opened with SDL_OpenGamepad().
  1513. *
  1514. * \param gamepad a gamepad identifier previously returned by
  1515. * SDL_OpenGamepad().
  1516. *
  1517. * \threadsafety It is safe to call this function from any thread.
  1518. *
  1519. * \since This function is available since SDL 3.2.0.
  1520. *
  1521. * \sa SDL_OpenGamepad
  1522. */
  1523. extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
  1524. /**
  1525. * Return the sfSymbolsName for a given button on a gamepad on Apple
  1526. * platforms.
  1527. *
  1528. * \param gamepad the gamepad to query.
  1529. * \param button a button on the gamepad.
  1530. * \returns the sfSymbolsName or NULL if the name can't be found.
  1531. *
  1532. * \threadsafety It is safe to call this function from any thread.
  1533. *
  1534. * \since This function is available since SDL 3.2.0.
  1535. *
  1536. * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
  1537. */
  1538. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
  1539. /**
  1540. * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
  1541. *
  1542. * \param gamepad the gamepad to query.
  1543. * \param axis an axis on the gamepad.
  1544. * \returns the sfSymbolsName or NULL if the name can't be found.
  1545. *
  1546. * \threadsafety It is safe to call this function from any thread.
  1547. *
  1548. * \since This function is available since SDL 3.2.0.
  1549. *
  1550. * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
  1551. */
  1552. extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
  1553. /* Ends C function definitions when using C++ */
  1554. #ifdef __cplusplus
  1555. }
  1556. #endif
  1557. #include <SDL3/SDL_close_code.h>
  1558. #endif /* SDL_gamepad_h_ */