SDL_joystick.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_joystick.h
  20. *
  21. * Include file for SDL joystick event handling
  22. *
  23. * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
  24. * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
  25. *
  26. * The term "player_index" is the number assigned to a player on a specific
  27. * controller. For XInput controllers this returns the XInput user index.
  28. * Many joysticks will not be able to supply this information.
  29. *
  30. * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
  31. * the device (a X360 wired controller for example). This identifier is platform dependent.
  32. */
  33. #ifndef SDL_joystick_h_
  34. #define SDL_joystick_h_
  35. #include <SDL3/SDL_stdinc.h>
  36. #include <SDL3/SDL_error.h>
  37. #include <SDL3/SDL_guid.h>
  38. #include <SDL3/SDL_mutex.h>
  39. #include <SDL3/SDL_properties.h>
  40. #include <SDL3/SDL_begin_code.h>
  41. /* Set up for C function definitions, even when using C++ */
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /**
  46. * \file SDL_joystick.h
  47. *
  48. * In order to use these functions, SDL_Init() must have been called
  49. * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
  50. * for joysticks, and load appropriate drivers.
  51. *
  52. * If you would like to receive joystick updates while the application
  53. * is in the background, you should set the following hint before calling
  54. * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
  55. */
  56. /**
  57. * The joystick structure used to identify an SDL joystick
  58. */
  59. #ifdef SDL_THREAD_SAFETY_ANALYSIS
  60. extern SDL_Mutex *SDL_joystick_lock;
  61. #endif
  62. struct SDL_Joystick;
  63. typedef struct SDL_Joystick SDL_Joystick;
  64. /* A structure that encodes the stable unique id for a joystick device */
  65. typedef SDL_GUID SDL_JoystickGUID;
  66. /**
  67. * This is a unique ID for a joystick for the time it is connected to the system,
  68. * and is never reused for the lifetime of the application. If the joystick is
  69. * disconnected and reconnected, it will get a new ID.
  70. *
  71. * The ID value starts at 1 and increments from there. The value 0 is an invalid ID.
  72. */
  73. typedef Uint32 SDL_JoystickID;
  74. typedef enum
  75. {
  76. SDL_JOYSTICK_TYPE_UNKNOWN,
  77. SDL_JOYSTICK_TYPE_GAMEPAD,
  78. SDL_JOYSTICK_TYPE_WHEEL,
  79. SDL_JOYSTICK_TYPE_ARCADE_STICK,
  80. SDL_JOYSTICK_TYPE_FLIGHT_STICK,
  81. SDL_JOYSTICK_TYPE_DANCE_PAD,
  82. SDL_JOYSTICK_TYPE_GUITAR,
  83. SDL_JOYSTICK_TYPE_DRUM_KIT,
  84. SDL_JOYSTICK_TYPE_ARCADE_PAD,
  85. SDL_JOYSTICK_TYPE_THROTTLE
  86. } SDL_JoystickType;
  87. typedef enum
  88. {
  89. SDL_JOYSTICK_POWER_UNKNOWN = -1,
  90. SDL_JOYSTICK_POWER_EMPTY, /* <= 5% */
  91. SDL_JOYSTICK_POWER_LOW, /* <= 20% */
  92. SDL_JOYSTICK_POWER_MEDIUM, /* <= 70% */
  93. SDL_JOYSTICK_POWER_FULL, /* <= 100% */
  94. SDL_JOYSTICK_POWER_WIRED,
  95. SDL_JOYSTICK_POWER_MAX
  96. } SDL_JoystickPowerLevel;
  97. #define SDL_JOYSTICK_AXIS_MAX 32767
  98. #define SDL_JOYSTICK_AXIS_MIN -32768
  99. /* Set max recognized G-force from accelerometer
  100. See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
  101. */
  102. #define SDL_IPHONE_MAX_GFORCE 5.0
  103. /* Function prototypes */
  104. /**
  105. * Locking for atomic access to the joystick API
  106. *
  107. * The SDL joystick functions are thread-safe, however you can lock the
  108. * joysticks while processing to guarantee that the joystick list won't change
  109. * and joystick and gamepad events will not be delivered.
  110. *
  111. * \since This function is available since SDL 3.0.0.
  112. */
  113. extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
  114. /**
  115. * Unlocking for atomic access to the joystick API
  116. *
  117. * \since This function is available since SDL 3.0.0.
  118. */
  119. extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
  120. /**
  121. * Return whether a joystick is currently connected.
  122. *
  123. * \returns SDL_TRUE if a joystick is connected, SDL_FALSE otherwise.
  124. *
  125. * \since This function is available since SDL 3.0.0.
  126. *
  127. * \sa SDL_GetJoysticks
  128. */
  129. extern DECLSPEC SDL_bool SDLCALL SDL_HasJoystick(void);
  130. /**
  131. * Get a list of currently connected joysticks.
  132. *
  133. * \param count a pointer filled in with the number of joysticks returned
  134. * \returns a 0 terminated array of joystick instance IDs which should be
  135. * freed with SDL_free(), or NULL on error; call SDL_GetError() for
  136. * more details.
  137. *
  138. * \since This function is available since SDL 3.0.0.
  139. *
  140. * \sa SDL_HasJoystick
  141. * \sa SDL_OpenJoystick
  142. */
  143. extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetJoysticks(int *count);
  144. /**
  145. * Get the implementation dependent name of a joystick.
  146. *
  147. * This can be called before any joysticks are opened.
  148. *
  149. * \param instance_id the joystick instance ID
  150. * \returns the name of the selected joystick. If no name can be found, this
  151. * function returns NULL; call SDL_GetError() for more information.
  152. *
  153. * \since This function is available since SDL 3.0.0.
  154. *
  155. * \sa SDL_GetJoystickName
  156. * \sa SDL_GetJoysticks
  157. */
  158. extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstanceName(SDL_JoystickID instance_id);
  159. /**
  160. * Get the implementation dependent path of a joystick.
  161. *
  162. * This can be called before any joysticks are opened.
  163. *
  164. * \param instance_id the joystick instance ID
  165. * \returns the path of the selected joystick. If no path can be found, this
  166. * function returns NULL; call SDL_GetError() for more information.
  167. *
  168. * \since This function is available since SDL 3.0.0.
  169. *
  170. * \sa SDL_GetJoystickPath
  171. * \sa SDL_GetJoysticks
  172. */
  173. extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstancePath(SDL_JoystickID instance_id);
  174. /**
  175. * Get the player index of a joystick.
  176. *
  177. * This can be called before any joysticks are opened.
  178. *
  179. * \param instance_id the joystick instance ID
  180. * \returns the player index of a joystick, or -1 if it's not available
  181. *
  182. * \since This function is available since SDL 3.0.0.
  183. *
  184. * \sa SDL_GetJoystickPlayerIndex
  185. * \sa SDL_GetJoysticks
  186. */
  187. extern DECLSPEC int SDLCALL SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID instance_id);
  188. /**
  189. * Get the implementation-dependent GUID of a joystick.
  190. *
  191. * This can be called before any joysticks are opened.
  192. *
  193. * \param instance_id the joystick instance ID
  194. * \returns the GUID of the selected joystick. If called with an invalid
  195. * instance_id, this function returns a zero GUID.
  196. *
  197. * \since This function is available since SDL 3.0.0.
  198. *
  199. * \sa SDL_GetJoystickGUID
  200. * \sa SDL_GetJoystickGUIDString
  201. */
  202. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickInstanceGUID(SDL_JoystickID instance_id);
  203. /**
  204. * Get the USB vendor ID of a joystick, if available.
  205. *
  206. * This can be called before any joysticks are opened. If the vendor ID isn't
  207. * available this function returns 0.
  208. *
  209. * \param instance_id the joystick instance ID
  210. * \returns the USB vendor ID of the selected joystick. If called with an
  211. * invalid instance_id, this function returns 0.
  212. *
  213. * \since This function is available since SDL 3.0.0.
  214. *
  215. * \sa SDL_GetJoystickVendor
  216. * \sa SDL_GetJoysticks
  217. */
  218. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceVendor(SDL_JoystickID instance_id);
  219. /**
  220. * Get the USB product ID of a joystick, if available.
  221. *
  222. * This can be called before any joysticks are opened. If the product ID isn't
  223. * available this function returns 0.
  224. *
  225. * \param instance_id the joystick instance ID
  226. * \returns the USB product ID of the selected joystick. If called with an
  227. * invalid instance_id, this function returns 0.
  228. *
  229. * \since This function is available since SDL 3.0.0.
  230. *
  231. * \sa SDL_GetJoystickProduct
  232. * \sa SDL_GetJoysticks
  233. */
  234. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProduct(SDL_JoystickID instance_id);
  235. /**
  236. * Get the product version of a joystick, if available.
  237. *
  238. * This can be called before any joysticks are opened. If the product version
  239. * isn't available this function returns 0.
  240. *
  241. * \param instance_id the joystick instance ID
  242. * \returns the product version of the selected joystick. If called with an
  243. * invalid instance_id, this function returns 0.
  244. *
  245. * \since This function is available since SDL 3.0.0.
  246. *
  247. * \sa SDL_GetJoystickProductVersion
  248. * \sa SDL_GetJoysticks
  249. */
  250. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProductVersion(SDL_JoystickID instance_id);
  251. /**
  252. * Get the type of a joystick, if available.
  253. *
  254. * This can be called before any joysticks are opened.
  255. *
  256. * \param instance_id the joystick instance ID
  257. * \returns the SDL_JoystickType of the selected joystick. If called with an
  258. * invalid instance_id, this function returns
  259. * `SDL_JOYSTICK_TYPE_UNKNOWN`.
  260. *
  261. * \since This function is available since SDL 3.0.0.
  262. *
  263. * \sa SDL_GetJoystickType
  264. * \sa SDL_GetJoysticks
  265. */
  266. extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickInstanceType(SDL_JoystickID instance_id);
  267. /**
  268. * Open a joystick for use.
  269. *
  270. * The joystick subsystem must be initialized before a joystick can be opened
  271. * for use.
  272. *
  273. * \param instance_id the joystick instance ID
  274. * \returns a joystick identifier or NULL if an error occurred; call
  275. * SDL_GetError() for more information.
  276. *
  277. * \since This function is available since SDL 3.0.0.
  278. *
  279. * \sa SDL_CloseJoystick
  280. */
  281. extern DECLSPEC SDL_Joystick *SDLCALL SDL_OpenJoystick(SDL_JoystickID instance_id);
  282. /**
  283. * Get the SDL_Joystick associated with an instance ID, if it has been opened.
  284. *
  285. * \param instance_id the instance ID to get the SDL_Joystick for
  286. * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been
  287. * opened yet; call SDL_GetError() for more information.
  288. *
  289. * \since This function is available since SDL 3.0.0.
  290. */
  291. extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromInstanceID(SDL_JoystickID instance_id);
  292. /**
  293. * Get the SDL_Joystick associated with a player index.
  294. *
  295. * \param player_index the player index to get the SDL_Joystick for
  296. * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
  297. * for more information.
  298. *
  299. * \since This function is available since SDL 3.0.0.
  300. *
  301. * \sa SDL_GetJoystickPlayerIndex
  302. * \sa SDL_SetJoystickPlayerIndex
  303. */
  304. extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index);
  305. /**
  306. * Attach a new virtual joystick.
  307. *
  308. * \param type type of joystick
  309. * \param naxes number of axes
  310. * \param nbuttons number of buttons
  311. * \param nhats number of hats
  312. * \returns the joystick instance ID, or 0 if an error occurred; call
  313. * SDL_GetError() for more information.
  314. *
  315. * \since This function is available since SDL 3.0.0.
  316. *
  317. * \sa SDL_AttachVirtualJoystickEx
  318. * \sa SDL_DetachVirtualJoystick
  319. */
  320. extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(SDL_JoystickType type,
  321. int naxes,
  322. int nbuttons,
  323. int nhats);
  324. /**
  325. * The structure that defines an extended virtual joystick description
  326. *
  327. * The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_AttachVirtualJoystickEx()
  328. * All other elements of this structure are optional and can be left 0.
  329. *
  330. * \sa SDL_AttachVirtualJoystickEx
  331. */
  332. typedef struct SDL_VirtualJoystickDesc
  333. {
  334. Uint16 version; /**< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` */
  335. Uint16 type; /**< `SDL_JoystickType` */
  336. Uint16 naxes; /**< the number of axes on this joystick */
  337. Uint16 nbuttons; /**< the number of buttons on this joystick */
  338. Uint16 nhats; /**< the number of hats on this joystick */
  339. Uint16 vendor_id; /**< the USB vendor ID of this joystick */
  340. Uint16 product_id; /**< the USB product ID of this joystick */
  341. Uint16 padding; /**< unused */
  342. Uint32 button_mask; /**< A mask of which buttons are valid for this controller
  343. e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
  344. Uint32 axis_mask; /**< A mask of which axes are valid for this controller
  345. e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
  346. const char *name; /**< the name of the joystick */
  347. void *userdata; /**< User data pointer passed to callbacks */
  348. void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
  349. void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
  350. int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
  351. int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
  352. int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
  353. int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
  354. } SDL_VirtualJoystickDesc;
  355. /**
  356. * The current version of the SDL_VirtualJoystickDesc structure
  357. */
  358. #define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
  359. /**
  360. * Attach a new virtual joystick with extended properties.
  361. *
  362. * \param desc Joystick description
  363. * \returns the joystick instance ID, or 0 if an error occurred; call
  364. * SDL_GetError() for more information.
  365. *
  366. * \since This function is available since SDL 3.0.0.
  367. *
  368. * \sa SDL_AttachVirtualJoystick
  369. * \sa SDL_DetachVirtualJoystick
  370. */
  371. extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystickEx(const SDL_VirtualJoystickDesc *desc);
  372. /**
  373. * Detach a virtual joystick.
  374. *
  375. * \param instance_id the joystick instance ID, previously returned from
  376. * SDL_AttachVirtualJoystick()
  377. * \returns 0 on success or a negative error code on failure; call
  378. * SDL_GetError() for more information.
  379. *
  380. * \since This function is available since SDL 3.0.0.
  381. *
  382. * \sa SDL_AttachVirtualJoystick
  383. * \sa SDL_AttachVirtualJoystickEx
  384. */
  385. extern DECLSPEC int SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
  386. /**
  387. * Query whether or not a joystick is virtual.
  388. *
  389. * \param instance_id the joystick instance ID
  390. * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
  391. *
  392. * \since This function is available since SDL 3.0.0.
  393. */
  394. extern DECLSPEC SDL_bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id);
  395. /**
  396. * Set values on an opened, virtual-joystick's axis.
  397. *
  398. * Please note that values set here will not be applied until the next call to
  399. * SDL_UpdateJoysticks, which can either be called directly, or can be called
  400. * indirectly through various other SDL APIs, including, but not limited to
  401. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  402. * SDL_WaitEvent.
  403. *
  404. * Note that when sending trigger axes, you should scale the value to the full
  405. * range of Sint16. For example, a trigger at rest would have the value of
  406. * `SDL_JOYSTICK_AXIS_MIN`.
  407. *
  408. * \param joystick the virtual joystick on which to set state.
  409. * \param axis the specific axis on the virtual joystick to set.
  410. * \param value the new value for the specified axis.
  411. * \returns 0 on success or a negative error code on failure; call
  412. * SDL_GetError() for more information.
  413. *
  414. * \since This function is available since SDL 3.0.0.
  415. */
  416. extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
  417. /**
  418. * Set values on an opened, virtual-joystick's button.
  419. *
  420. * Please note that values set here will not be applied until the next call to
  421. * SDL_UpdateJoysticks, which can either be called directly, or can be called
  422. * indirectly through various other SDL APIs, including, but not limited to
  423. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  424. * SDL_WaitEvent.
  425. *
  426. * \param joystick the virtual joystick on which to set state.
  427. * \param button the specific button on the virtual joystick to set.
  428. * \param value the new value for the specified button.
  429. * \returns 0 on success or a negative error code on failure; call
  430. * SDL_GetError() for more information.
  431. *
  432. * \since This function is available since SDL 3.0.0.
  433. */
  434. extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
  435. /**
  436. * Set values on an opened, virtual-joystick's hat.
  437. *
  438. * Please note that values set here will not be applied until the next call to
  439. * SDL_UpdateJoysticks, which can either be called directly, or can be called
  440. * indirectly through various other SDL APIs, including, but not limited to
  441. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  442. * SDL_WaitEvent.
  443. *
  444. * \param joystick the virtual joystick on which to set state.
  445. * \param hat the specific hat on the virtual joystick to set.
  446. * \param value the new value for the specified hat.
  447. * \returns 0 on success or a negative error code on failure; call
  448. * SDL_GetError() for more information.
  449. *
  450. * \since This function is available since SDL 3.0.0.
  451. */
  452. extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
  453. /**
  454. * Get the properties associated with a joystick.
  455. *
  456. * The following read-only properties are provided by SDL:
  457. *
  458. * - `SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`: true if this joystick has an
  459. * LED that has adjustable brightness
  460. * - `SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`: true if this joystick has an LED
  461. * that has adjustable color
  462. * - `SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`: true if this joystick has a
  463. * player LED
  464. * - `SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`: true if this joystick has
  465. * left/right rumble
  466. * - `SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this joystick has
  467. * simple trigger rumble
  468. *
  469. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  470. * \returns a valid property ID on success or 0 on failure; call
  471. * SDL_GetError() for more information.
  472. *
  473. * \since This function is available since SDL 3.0.0.
  474. *
  475. * \sa SDL_GetProperty
  476. * \sa SDL_SetProperty
  477. */
  478. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick);
  479. #define SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN "SDL.joystick.cap.mono_led"
  480. #define SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN "SDL.joystick.cap.rgb_led"
  481. #define SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN "SDL.joystick.cap.player_led"
  482. #define SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN "SDL.joystick.cap.rumble"
  483. #define SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN "SDL.joystick.cap.trigger_rumble"
  484. /**
  485. * Get the implementation dependent name of a joystick.
  486. *
  487. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  488. * \returns the name of the selected joystick. If no name can be found, this
  489. * function returns NULL; call SDL_GetError() for more information.
  490. *
  491. * \since This function is available since SDL 3.0.0.
  492. *
  493. * \sa SDL_GetJoystickInstanceName
  494. */
  495. extern DECLSPEC const char *SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick);
  496. /**
  497. * Get the implementation dependent path of a joystick.
  498. *
  499. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  500. * \returns the path of the selected joystick. If no path can be found, this
  501. * function returns NULL; call SDL_GetError() for more information.
  502. *
  503. * \since This function is available since SDL 3.0.0.
  504. *
  505. * \sa SDL_GetJoystickInstancePath
  506. */
  507. extern DECLSPEC const char *SDLCALL SDL_GetJoystickPath(SDL_Joystick *joystick);
  508. /**
  509. * Get the player index of an opened joystick.
  510. *
  511. * For XInput controllers this returns the XInput user index. Many joysticks
  512. * will not be able to supply this information.
  513. *
  514. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  515. * \returns the player index, or -1 if it's not available.
  516. *
  517. * \since This function is available since SDL 3.0.0.
  518. *
  519. * \sa SDL_SetJoystickPlayerIndex
  520. */
  521. extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
  522. /**
  523. * Set the player index of an opened joystick.
  524. *
  525. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  526. * \param player_index Player index to assign to this joystick, or -1 to clear
  527. * the player index and turn off player LEDs.
  528. * \returns 0 on success or a negative error code on failure; call
  529. * SDL_GetError() for more information.
  530. *
  531. * \since This function is available since SDL 3.0.0.
  532. *
  533. * \sa SDL_GetJoystickPlayerIndex
  534. */
  535. extern DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
  536. /**
  537. * Get the implementation-dependent GUID for the joystick.
  538. *
  539. * This function requires an open joystick.
  540. *
  541. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  542. * \returns the GUID of the given joystick. If called on an invalid index,
  543. * this function returns a zero GUID; call SDL_GetError() for more
  544. * information.
  545. *
  546. * \since This function is available since SDL 3.0.0.
  547. *
  548. * \sa SDL_GetJoystickInstanceGUID
  549. * \sa SDL_GetJoystickGUIDString
  550. */
  551. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick);
  552. /**
  553. * Get the USB vendor ID of an opened joystick, if available.
  554. *
  555. * If the vendor ID isn't available this function returns 0.
  556. *
  557. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  558. * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
  559. *
  560. * \since This function is available since SDL 3.0.0.
  561. *
  562. * \sa SDL_GetJoystickInstanceVendor
  563. */
  564. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick);
  565. /**
  566. * Get the USB product ID of an opened joystick, if available.
  567. *
  568. * If the product ID isn't available this function returns 0.
  569. *
  570. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  571. * \returns the USB product ID of the selected joystick, or 0 if unavailable.
  572. *
  573. * \since This function is available since SDL 3.0.0.
  574. *
  575. * \sa SDL_GetJoystickInstanceProduct
  576. */
  577. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick);
  578. /**
  579. * Get the product version of an opened joystick, if available.
  580. *
  581. * If the product version isn't available this function returns 0.
  582. *
  583. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  584. * \returns the product version of the selected joystick, or 0 if unavailable.
  585. *
  586. * \since This function is available since SDL 3.0.0.
  587. *
  588. * \sa SDL_GetJoystickInstanceProductVersion
  589. */
  590. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *joystick);
  591. /**
  592. * Get the firmware version of an opened joystick, if available.
  593. *
  594. * If the firmware version isn't available this function returns 0.
  595. *
  596. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  597. * \returns the firmware version of the selected joystick, or 0 if
  598. * unavailable.
  599. *
  600. * \since This function is available since SDL 3.0.0.
  601. */
  602. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick);
  603. /**
  604. * Get the serial number of an opened joystick, if available.
  605. *
  606. * Returns the serial number of the joystick, or NULL if it is not available.
  607. *
  608. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  609. * \returns the serial number of the selected joystick, or NULL if
  610. * unavailable.
  611. *
  612. * \since This function is available since SDL 3.0.0.
  613. */
  614. extern DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick);
  615. /**
  616. * Get the type of an opened joystick.
  617. *
  618. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  619. * \returns the SDL_JoystickType of the selected joystick.
  620. *
  621. * \since This function is available since SDL 3.0.0.
  622. *
  623. * \sa SDL_GetJoystickInstanceType
  624. */
  625. extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick);
  626. /**
  627. * Get an ASCII string representation for a given SDL_JoystickGUID.
  628. *
  629. * You should supply at least 33 bytes for pszGUID.
  630. *
  631. * \param guid the SDL_JoystickGUID you wish to convert to string
  632. * \param pszGUID buffer in which to write the ASCII string
  633. * \param cbGUID the size of pszGUID
  634. * \returns 0 on success or a negative error code on failure; call
  635. * SDL_GetError() for more information.
  636. *
  637. * \since This function is available since SDL 3.0.0.
  638. *
  639. * \sa SDL_GetJoystickInstanceGUID
  640. * \sa SDL_GetJoystickGUID
  641. * \sa SDL_GetJoystickGUIDFromString
  642. */
  643. extern DECLSPEC int SDLCALL SDL_GetJoystickGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
  644. /**
  645. * Convert a GUID string into a SDL_JoystickGUID structure.
  646. *
  647. * Performs no error checking. If this function is given a string containing
  648. * an invalid GUID, the function will silently succeed, but the GUID generated
  649. * will not be useful.
  650. *
  651. * \param pchGUID string containing an ASCII representation of a GUID
  652. * \returns a SDL_JoystickGUID structure.
  653. *
  654. * \since This function is available since SDL 3.0.0.
  655. *
  656. * \sa SDL_GetJoystickGUIDString
  657. */
  658. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUIDFromString(const char *pchGUID);
  659. /**
  660. * Get the device information encoded in a SDL_JoystickGUID structure
  661. *
  662. * \param guid the SDL_JoystickGUID you wish to get info about
  663. * \param vendor A pointer filled in with the device VID, or 0 if not
  664. * available
  665. * \param product A pointer filled in with the device PID, or 0 if not
  666. * available
  667. * \param version A pointer filled in with the device version, or 0 if not
  668. * available
  669. * \param crc16 A pointer filled in with a CRC used to distinguish different
  670. * products with the same VID/PID, or 0 if not available
  671. *
  672. * \since This function is available since SDL 3.0.0.
  673. *
  674. * \sa SDL_GetJoystickInstanceGUID
  675. */
  676. extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16);
  677. /**
  678. * Get the status of a specified joystick.
  679. *
  680. * \param joystick the joystick to query
  681. * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
  682. * call SDL_GetError() for more information.
  683. *
  684. * \since This function is available since SDL 3.0.0.
  685. */
  686. extern DECLSPEC SDL_bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
  687. /**
  688. * Get the instance ID of an opened joystick.
  689. *
  690. * \param joystick an SDL_Joystick structure containing joystick information
  691. * \returns the instance ID of the specified joystick on success or 0 on
  692. * failure; call SDL_GetError() for more information.
  693. *
  694. * \since This function is available since SDL 3.0.0.
  695. */
  696. extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickInstanceID(SDL_Joystick *joystick);
  697. /**
  698. * Get the number of general axis controls on a joystick.
  699. *
  700. * Often, the directional pad on a game controller will either look like 4
  701. * separate buttons or a POV hat, and not axes, but all of this is up to the
  702. * device and platform.
  703. *
  704. * \param joystick an SDL_Joystick structure containing joystick information
  705. * \returns the number of axis controls/number of axes on success or a
  706. * negative error code on failure; call SDL_GetError() for more
  707. * information.
  708. *
  709. * \since This function is available since SDL 3.0.0.
  710. *
  711. * \sa SDL_GetJoystickAxis
  712. * \sa SDL_GetNumJoystickBalls
  713. * \sa SDL_GetNumJoystickButtons
  714. * \sa SDL_GetNumJoystickHats
  715. */
  716. extern DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
  717. /**
  718. * Get the number of trackballs on a joystick.
  719. *
  720. * Joystick trackballs have only relative motion events associated with them
  721. * and their state cannot be polled.
  722. *
  723. * Most joysticks do not have trackballs.
  724. *
  725. * \param joystick an SDL_Joystick structure containing joystick information
  726. * \returns the number of trackballs on success or a negative error code on
  727. * failure; call SDL_GetError() for more information.
  728. *
  729. * \since This function is available since SDL 3.0.0.
  730. *
  731. * \sa SDL_GetJoystickBall
  732. * \sa SDL_GetNumJoystickAxes
  733. * \sa SDL_GetNumJoystickButtons
  734. * \sa SDL_GetNumJoystickHats
  735. */
  736. extern DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
  737. /**
  738. * Get the number of POV hats on a joystick.
  739. *
  740. * \param joystick an SDL_Joystick structure containing joystick information
  741. * \returns the number of POV hats on success or a negative error code on
  742. * failure; call SDL_GetError() for more information.
  743. *
  744. * \since This function is available since SDL 3.0.0.
  745. *
  746. * \sa SDL_GetJoystickHat
  747. * \sa SDL_GetNumJoystickAxes
  748. * \sa SDL_GetNumJoystickBalls
  749. * \sa SDL_GetNumJoystickButtons
  750. */
  751. extern DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
  752. /**
  753. * Get the number of buttons on a joystick.
  754. *
  755. * \param joystick an SDL_Joystick structure containing joystick information
  756. * \returns the number of buttons on success or a negative error code on
  757. * failure; call SDL_GetError() for more information.
  758. *
  759. * \since This function is available since SDL 3.0.0.
  760. *
  761. * \sa SDL_GetJoystickButton
  762. * \sa SDL_GetNumJoystickAxes
  763. * \sa SDL_GetNumJoystickBalls
  764. * \sa SDL_GetNumJoystickHats
  765. */
  766. extern DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
  767. /**
  768. * Set the state of joystick event processing.
  769. *
  770. * If joystick events are disabled, you must call SDL_UpdateJoysticks()
  771. * yourself and check the state of the joystick when you want joystick
  772. * information.
  773. *
  774. * \param enabled whether to process joystick events or not
  775. *
  776. * \since This function is available since SDL 3.0.0.
  777. *
  778. * \sa SDL_JoystickEventsEnabled
  779. * \sa SDL_UpdateJoysticks
  780. */
  781. extern DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(SDL_bool enabled);
  782. /**
  783. * Query the state of joystick event processing.
  784. *
  785. * If joystick events are disabled, you must call SDL_UpdateJoysticks()
  786. * yourself and check the state of the joystick when you want joystick
  787. * information.
  788. *
  789. * \returns SDL_TRUE if joystick events are being processed, SDL_FALSE
  790. * otherwise.
  791. *
  792. * \since This function is available since SDL 3.0.0.
  793. *
  794. * \sa SDL_SetJoystickEventsEnabled
  795. */
  796. extern DECLSPEC SDL_bool SDLCALL SDL_JoystickEventsEnabled(void);
  797. /**
  798. * Update the current state of the open joysticks.
  799. *
  800. * This is called automatically by the event loop if any joystick events are
  801. * enabled.
  802. *
  803. * \since This function is available since SDL 3.0.0.
  804. */
  805. extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
  806. /**
  807. * Get the current state of an axis control on a joystick.
  808. *
  809. * SDL makes no promises about what part of the joystick any given axis refers
  810. * to. Your game should have some sort of configuration UI to let users
  811. * specify what each axis should be bound to. Alternately, SDL's higher-level
  812. * Game Controller API makes a great effort to apply order to this lower-level
  813. * interface, so you know that a specific axis is the "left thumb stick," etc.
  814. *
  815. * The value returned by SDL_GetJoystickAxis() is a signed integer (-32768 to
  816. * 32767) representing the current position of the axis. It may be necessary
  817. * to impose certain tolerances on these values to account for jitter.
  818. *
  819. * \param joystick an SDL_Joystick structure containing joystick information
  820. * \param axis the axis to query; the axis indices start at index 0
  821. * \returns a 16-bit signed integer representing the current position of the
  822. * axis or 0 on failure; call SDL_GetError() for more information.
  823. *
  824. * \since This function is available since SDL 3.0.0.
  825. *
  826. * \sa SDL_GetNumJoystickAxes
  827. */
  828. extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
  829. /**
  830. * Get the initial state of an axis control on a joystick.
  831. *
  832. * The state is a value ranging from -32768 to 32767.
  833. *
  834. * The axis indices start at index 0.
  835. *
  836. * \param joystick an SDL_Joystick structure containing joystick information
  837. * \param axis the axis to query; the axis indices start at index 0
  838. * \param state Upon return, the initial value is supplied here.
  839. * \returns SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
  840. *
  841. * \since This function is available since SDL 3.0.0.
  842. */
  843. extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
  844. /**
  845. * Get the ball axis change since the last poll.
  846. *
  847. * Trackballs can only return relative motion since the last call to
  848. * SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`.
  849. *
  850. * Most joysticks do not have trackballs.
  851. *
  852. * \param joystick the SDL_Joystick to query
  853. * \param ball the ball index to query; ball indices start at index 0
  854. * \param dx stores the difference in the x axis position since the last poll
  855. * \param dy stores the difference in the y axis position since the last poll
  856. * \returns 0 on success or a negative error code on failure; call
  857. * SDL_GetError() for more information.
  858. *
  859. * \since This function is available since SDL 3.0.0.
  860. *
  861. * \sa SDL_GetNumJoystickBalls
  862. */
  863. extern DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
  864. /**
  865. * \name Hat positions
  866. */
  867. /* @{ */
  868. #define SDL_HAT_CENTERED 0x00
  869. #define SDL_HAT_UP 0x01
  870. #define SDL_HAT_RIGHT 0x02
  871. #define SDL_HAT_DOWN 0x04
  872. #define SDL_HAT_LEFT 0x08
  873. #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
  874. #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
  875. #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
  876. #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
  877. /* @} */
  878. /**
  879. * Get the current state of a POV hat on a joystick.
  880. *
  881. * The returned value will be one of the following positions:
  882. *
  883. * - `SDL_HAT_CENTERED`
  884. * - `SDL_HAT_UP`
  885. * - `SDL_HAT_RIGHT`
  886. * - `SDL_HAT_DOWN`
  887. * - `SDL_HAT_LEFT`
  888. * - `SDL_HAT_RIGHTUP`
  889. * - `SDL_HAT_RIGHTDOWN`
  890. * - `SDL_HAT_LEFTUP`
  891. * - `SDL_HAT_LEFTDOWN`
  892. *
  893. * \param joystick an SDL_Joystick structure containing joystick information
  894. * \param hat the hat index to get the state from; indices start at index 0
  895. * \returns the current hat position.
  896. *
  897. * \since This function is available since SDL 3.0.0.
  898. *
  899. * \sa SDL_GetNumJoystickHats
  900. */
  901. extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
  902. /**
  903. * Get the current state of a button on a joystick.
  904. *
  905. * \param joystick an SDL_Joystick structure containing joystick information
  906. * \param button the button index to get the state from; indices start at
  907. * index 0
  908. * \returns 1 if the specified button is pressed, 0 otherwise.
  909. *
  910. * \since This function is available since SDL 3.0.0.
  911. *
  912. * \sa SDL_GetNumJoystickButtons
  913. */
  914. extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button);
  915. /**
  916. * Start a rumble effect.
  917. *
  918. * Each call to this function cancels any previous rumble effect, and calling
  919. * it with 0 intensity stops any rumbling.
  920. *
  921. * This function requires you to process SDL events or call
  922. * SDL_UpdateJoysticks() to update rumble state.
  923. *
  924. * \param joystick The joystick to vibrate
  925. * \param low_frequency_rumble The intensity of the low frequency (left)
  926. * rumble motor, from 0 to 0xFFFF
  927. * \param high_frequency_rumble The intensity of the high frequency (right)
  928. * rumble motor, from 0 to 0xFFFF
  929. * \param duration_ms The duration of the rumble effect, in milliseconds
  930. * \returns 0, or -1 if rumble isn't supported on this joystick
  931. *
  932. * \since This function is available since SDL 3.0.0.
  933. */
  934. extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
  935. /**
  936. * Start a rumble effect in the joystick's triggers
  937. *
  938. * Each call to this function cancels any previous trigger rumble effect, and
  939. * calling it with 0 intensity stops any rumbling.
  940. *
  941. * Note that this is rumbling of the _triggers_ and not the game controller as
  942. * a whole. This is currently only supported on Xbox One controllers. If you
  943. * want the (more common) whole-controller rumble, use SDL_RumbleJoystick()
  944. * instead.
  945. *
  946. * This function requires you to process SDL events or call
  947. * SDL_UpdateJoysticks() to update rumble state.
  948. *
  949. * \param joystick The joystick to vibrate
  950. * \param left_rumble The intensity of the left trigger rumble motor, from 0
  951. * to 0xFFFF
  952. * \param right_rumble The intensity of the right trigger rumble motor, from 0
  953. * to 0xFFFF
  954. * \param duration_ms The duration of the rumble effect, in milliseconds
  955. * \returns 0 on success or a negative error code on failure; call
  956. * SDL_GetError() for more information.
  957. *
  958. * \since This function is available since SDL 3.0.0.
  959. *
  960. * \sa SDL_RumbleJoystick
  961. */
  962. extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
  963. /**
  964. * Update a joystick's LED color.
  965. *
  966. * An example of a joystick LED is the light on the back of a PlayStation 4's
  967. * DualShock 4 controller.
  968. *
  969. * For joysticks with a single color LED, the maximum of the RGB values will
  970. * be used as the LED brightness.
  971. *
  972. * \param joystick The joystick to update
  973. * \param red The intensity of the red LED
  974. * \param green The intensity of the green LED
  975. * \param blue The intensity of the blue LED
  976. * \returns 0 on success or a negative error code on failure; call
  977. * SDL_GetError() for more information.
  978. *
  979. * \since This function is available since SDL 3.0.0.
  980. */
  981. extern DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
  982. /**
  983. * Send a joystick specific effect packet
  984. *
  985. * \param joystick The joystick to affect
  986. * \param data The data to send to the joystick
  987. * \param size The size of the data to send to the joystick
  988. * \returns 0 on success or a negative error code on failure; call
  989. * SDL_GetError() for more information.
  990. *
  991. * \since This function is available since SDL 3.0.0.
  992. */
  993. extern DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
  994. /**
  995. * Close a joystick previously opened with SDL_OpenJoystick().
  996. *
  997. * \param joystick The joystick device to close
  998. *
  999. * \since This function is available since SDL 3.0.0.
  1000. *
  1001. * \sa SDL_OpenJoystick
  1002. */
  1003. extern DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
  1004. /**
  1005. * Get the battery level of a joystick as SDL_JoystickPowerLevel.
  1006. *
  1007. * \param joystick the SDL_Joystick to query
  1008. * \returns the current battery level as SDL_JoystickPowerLevel on success or
  1009. * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
  1010. *
  1011. * \since This function is available since SDL 3.0.0.
  1012. */
  1013. extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_GetJoystickPowerLevel(SDL_Joystick *joystick);
  1014. /* Ends C function definitions when using C++ */
  1015. #ifdef __cplusplus
  1016. }
  1017. #endif
  1018. #include <SDL3/SDL_close_code.h>
  1019. #endif /* SDL_joystick_h_ */