SDL_gamepad.h 58 KB

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