SDL_joystick.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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. * \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 on an invalid index,
  195. * 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 on an
  211. * invalid index, this function returns zero
  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 on an
  227. * invalid index, this function returns zero
  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 on an
  243. * invalid index, this function returns zero
  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 on an
  258. * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
  259. *
  260. * \since This function is available since SDL 3.0.0.
  261. *
  262. * \sa SDL_GetJoystickType
  263. * \sa SDL_GetJoysticks
  264. */
  265. extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickInstanceType(SDL_JoystickID instance_id);
  266. /**
  267. * Open a joystick for use.
  268. *
  269. * The joystick subsystem must be initialized before a joystick can be opened
  270. * for use.
  271. *
  272. * \param instance_id the joystick instance ID
  273. * \returns a joystick identifier or NULL if an error occurred; call
  274. * SDL_GetError() for more information.
  275. *
  276. * \since This function is available since SDL 3.0.0.
  277. *
  278. * \sa SDL_CloseJoystick
  279. */
  280. extern DECLSPEC SDL_Joystick *SDLCALL SDL_OpenJoystick(SDL_JoystickID instance_id);
  281. /**
  282. * Get the SDL_Joystick associated with an instance ID, if it has been opened.
  283. *
  284. * \param instance_id the instance ID to get the SDL_Joystick for
  285. * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been
  286. * opened yet; call SDL_GetError() for more information.
  287. *
  288. * \since This function is available since SDL 3.0.0.
  289. */
  290. extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromInstanceID(SDL_JoystickID instance_id);
  291. /**
  292. * Get the SDL_Joystick associated with a player index.
  293. *
  294. * \param player_index the player index to get the SDL_Joystick for
  295. * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
  296. * for more information.
  297. *
  298. * \since This function is available since SDL 3.0.0.
  299. *
  300. * \sa SDL_GetJoystickPlayerIndex
  301. * \sa SDL_SetJoystickPlayerIndex
  302. */
  303. extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index);
  304. /**
  305. * Attach a new virtual joystick.
  306. *
  307. * \param type type of joystick
  308. * \param naxes number of axes
  309. * \param nbuttons number of buttons
  310. * \param nhats number of hats
  311. * \returns the joystick instance ID, or 0 if an error occurred; call
  312. * SDL_GetError() for more information.
  313. *
  314. * \since This function is available since SDL 3.0.0.
  315. *
  316. * \sa SDL_AttachVirtualJoystickEx
  317. * \sa SDL_DetachVirtualJoystick
  318. */
  319. extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(SDL_JoystickType type,
  320. int naxes,
  321. int nbuttons,
  322. int nhats);
  323. /**
  324. * The structure that defines an extended virtual joystick description
  325. *
  326. * The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_AttachVirtualJoystickEx()
  327. * All other elements of this structure are optional and can be left 0.
  328. *
  329. * \sa SDL_AttachVirtualJoystickEx
  330. */
  331. typedef struct SDL_VirtualJoystickDesc
  332. {
  333. Uint16 version; /**< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` */
  334. Uint16 type; /**< `SDL_JoystickType` */
  335. Uint16 naxes; /**< the number of axes on this joystick */
  336. Uint16 nbuttons; /**< the number of buttons on this joystick */
  337. Uint16 nhats; /**< the number of hats on this joystick */
  338. Uint16 vendor_id; /**< the USB vendor ID of this joystick */
  339. Uint16 product_id; /**< the USB product ID of this joystick */
  340. Uint16 padding; /**< unused */
  341. Uint32 button_mask; /**< A mask of which buttons are valid for this controller
  342. e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
  343. Uint32 axis_mask; /**< A mask of which axes are valid for this controller
  344. e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
  345. const char *name; /**< the name of the joystick */
  346. void *userdata; /**< User data pointer passed to callbacks */
  347. void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
  348. void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
  349. int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
  350. int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
  351. int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
  352. int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
  353. } SDL_VirtualJoystickDesc;
  354. /**
  355. * The current version of the SDL_VirtualJoystickDesc structure
  356. */
  357. #define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
  358. /**
  359. * Attach a new virtual joystick with extended properties.
  360. *
  361. * \param desc Joystick description
  362. * \returns the joystick instance ID, or 0 if an error occurred; call
  363. * SDL_GetError() for more information.
  364. *
  365. * \since This function is available since SDL 3.0.0.
  366. *
  367. * \sa SDL_AttachVirtualJoystick
  368. * \sa SDL_DetachVirtualJoystick
  369. */
  370. extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystickEx(const SDL_VirtualJoystickDesc *desc);
  371. /**
  372. * Detach a virtual joystick.
  373. *
  374. * \param instance_id the joystick instance ID, previously returned from
  375. * SDL_AttachVirtualJoystick()
  376. * \returns 0 on success or a negative error code on failure; call
  377. * SDL_GetError() for more information.
  378. *
  379. * \since This function is available since SDL 3.0.0.
  380. *
  381. * \sa SDL_AttachVirtualJoystick
  382. * \sa SDL_AttachVirtualJoystickEx
  383. */
  384. extern DECLSPEC int SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
  385. /**
  386. * Query whether or not a joystick is virtual.
  387. *
  388. * \param instance_id the joystick instance ID
  389. * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
  390. *
  391. * \since This function is available since SDL 3.0.0.
  392. */
  393. extern DECLSPEC SDL_bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id);
  394. /**
  395. * Set values on an opened, virtual-joystick's axis.
  396. *
  397. * Please note that values set here will not be applied until the next call to
  398. * SDL_UpdateJoysticks, which can either be called directly, or can be called
  399. * indirectly through various other SDL APIs, including, but not limited to
  400. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  401. * SDL_WaitEvent.
  402. *
  403. * Note that when sending trigger axes, you should scale the value to the full
  404. * range of Sint16. For example, a trigger at rest would have the value of
  405. * `SDL_JOYSTICK_AXIS_MIN`.
  406. *
  407. * \param joystick the virtual joystick on which to set state.
  408. * \param axis the specific axis on the virtual joystick to set.
  409. * \param value the new value for the specified axis.
  410. * \returns 0 on success or a negative error code on failure; call
  411. * SDL_GetError() for more information.
  412. *
  413. * \since This function is available since SDL 3.0.0.
  414. */
  415. extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
  416. /**
  417. * Set values on an opened, virtual-joystick's button.
  418. *
  419. * Please note that values set here will not be applied until the next call to
  420. * SDL_UpdateJoysticks, which can either be called directly, or can be called
  421. * indirectly through various other SDL APIs, including, but not limited to
  422. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  423. * SDL_WaitEvent.
  424. *
  425. * \param joystick the virtual joystick on which to set state.
  426. * \param button the specific button on the virtual joystick to set.
  427. * \param value the new value for the specified button.
  428. * \returns 0 on success or a negative error code on failure; call
  429. * SDL_GetError() for more information.
  430. *
  431. * \since This function is available since SDL 3.0.0.
  432. */
  433. extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
  434. /**
  435. * Set values on an opened, virtual-joystick's hat.
  436. *
  437. * Please note that values set here will not be applied until the next call to
  438. * SDL_UpdateJoysticks, which can either be called directly, or can be called
  439. * indirectly through various other SDL APIs, including, but not limited to
  440. * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
  441. * SDL_WaitEvent.
  442. *
  443. * \param joystick the virtual joystick on which to set state.
  444. * \param hat the specific hat on the virtual joystick to set.
  445. * \param value the new value for the specified hat.
  446. * \returns 0 on success or a negative error code on failure; call
  447. * SDL_GetError() for more information.
  448. *
  449. * \since This function is available since SDL 3.0.0.
  450. */
  451. extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
  452. /**
  453. * Get the properties associated with a joystick.
  454. *
  455. * The following read-only properties are provided by SDL:
  456. *
  457. * - `SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`: true if this joystick has an
  458. * LED that has adjustable brightness
  459. * - `SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`: true if this joystick has an LED
  460. * that has adjustable color
  461. * - `SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`: true if this joystick has a
  462. * player LED
  463. * - `SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`: true if this joystick has
  464. * left/right rumble
  465. * - `SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this joystick has
  466. * simple trigger rumble
  467. *
  468. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  469. * \returns a valid property ID on success or 0 on failure; call
  470. * SDL_GetError() for more information.
  471. *
  472. * \since This function is available since SDL 3.0.0.
  473. *
  474. * \sa SDL_GetProperty
  475. * \sa SDL_SetProperty
  476. */
  477. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick);
  478. #define SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN "SDL.joystick.cap.mono_led"
  479. #define SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN "SDL.joystick.cap.rgb_led"
  480. #define SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN "SDL.joystick.cap.player_led"
  481. #define SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN "SDL.joystick.cap.rumble"
  482. #define SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN "SDL.joystick.cap.trigger_rumble"
  483. /**
  484. * Get the implementation dependent name of a joystick.
  485. *
  486. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  487. * \returns the name of the selected joystick. If no name can be found, this
  488. * function returns NULL; call SDL_GetError() for more information.
  489. *
  490. * \since This function is available since SDL 3.0.0.
  491. *
  492. * \sa SDL_GetJoystickInstanceName
  493. */
  494. extern DECLSPEC const char *SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick);
  495. /**
  496. * Get the implementation dependent path of a joystick.
  497. *
  498. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  499. * \returns the path of the selected joystick. If no path can be found, this
  500. * function returns NULL; call SDL_GetError() for more information.
  501. *
  502. * \since This function is available since SDL 3.0.0.
  503. *
  504. * \sa SDL_GetJoystickInstancePath
  505. */
  506. extern DECLSPEC const char *SDLCALL SDL_GetJoystickPath(SDL_Joystick *joystick);
  507. /**
  508. * Get the player index of an opened joystick.
  509. *
  510. * For XInput controllers this returns the XInput user index. Many joysticks
  511. * will not be able to supply this information.
  512. *
  513. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  514. * \returns the player index, or -1 if it's not available.
  515. *
  516. * \since This function is available since SDL 3.0.0.
  517. *
  518. * \sa SDL_SetJoystickPlayerIndex
  519. */
  520. extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
  521. /**
  522. * Set the player index of an opened joystick.
  523. *
  524. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  525. * \param player_index Player index to assign to this joystick, or -1 to clear
  526. * the player index and turn off player LEDs.
  527. * \returns 0 on success or a negative error code on failure; call
  528. * SDL_GetError() for more information.
  529. *
  530. * \since This function is available since SDL 3.0.0.
  531. *
  532. * \sa SDL_GetJoystickPlayerIndex
  533. */
  534. extern DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
  535. /**
  536. * Get the implementation-dependent GUID for the joystick.
  537. *
  538. * This function requires an open joystick.
  539. *
  540. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  541. * \returns the GUID of the given joystick. If called on an invalid index,
  542. * this function returns a zero GUID; call SDL_GetError() for more
  543. * information.
  544. *
  545. * \since This function is available since SDL 3.0.0.
  546. *
  547. * \sa SDL_GetJoystickInstanceGUID
  548. * \sa SDL_GetJoystickGUIDString
  549. */
  550. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick);
  551. /**
  552. * Get the USB vendor ID of an opened joystick, if available.
  553. *
  554. * If the vendor ID isn't available this function returns 0.
  555. *
  556. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  557. * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
  558. *
  559. * \since This function is available since SDL 3.0.0.
  560. *
  561. * \sa SDL_GetJoystickInstanceVendor
  562. */
  563. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick);
  564. /**
  565. * Get the USB product ID of an opened joystick, if available.
  566. *
  567. * If the product ID isn't available this function returns 0.
  568. *
  569. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  570. * \returns the USB product ID of the selected joystick, or 0 if unavailable.
  571. *
  572. * \since This function is available since SDL 3.0.0.
  573. *
  574. * \sa SDL_GetJoystickInstanceProduct
  575. */
  576. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick);
  577. /**
  578. * Get the product version of an opened joystick, if available.
  579. *
  580. * If the product version isn't available this function returns 0.
  581. *
  582. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  583. * \returns the product version of the selected joystick, or 0 if unavailable.
  584. *
  585. * \since This function is available since SDL 3.0.0.
  586. *
  587. * \sa SDL_GetJoystickInstanceProductVersion
  588. */
  589. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *joystick);
  590. /**
  591. * Get the firmware version of an opened joystick, if available.
  592. *
  593. * If the firmware version isn't available this function returns 0.
  594. *
  595. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  596. * \returns the firmware version of the selected joystick, or 0 if
  597. * unavailable.
  598. *
  599. * \since This function is available since SDL 3.0.0.
  600. */
  601. extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick);
  602. /**
  603. * Get the serial number of an opened joystick, if available.
  604. *
  605. * Returns the serial number of the joystick, or NULL if it is not available.
  606. *
  607. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  608. * \returns the serial number of the selected joystick, or NULL if
  609. * unavailable.
  610. *
  611. * \since This function is available since SDL 3.0.0.
  612. */
  613. extern DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick);
  614. /**
  615. * Get the type of an opened joystick.
  616. *
  617. * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  618. * \returns the SDL_JoystickType of the selected joystick.
  619. *
  620. * \since This function is available since SDL 3.0.0.
  621. *
  622. * \sa SDL_GetJoystickInstanceType
  623. */
  624. extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick);
  625. /**
  626. * Get an ASCII string representation for a given SDL_JoystickGUID.
  627. *
  628. * You should supply at least 33 bytes for pszGUID.
  629. *
  630. * \param guid the SDL_JoystickGUID you wish to convert to string
  631. * \param pszGUID buffer in which to write the ASCII string
  632. * \param cbGUID the size of pszGUID
  633. * \returns 0 on success or a negative error code on failure; call
  634. * SDL_GetError() for more information.
  635. *
  636. * \since This function is available since SDL 3.0.0.
  637. *
  638. * \sa SDL_GetJoystickInstanceGUID
  639. * \sa SDL_GetJoystickGUID
  640. * \sa SDL_GetJoystickGUIDFromString
  641. */
  642. extern DECLSPEC int SDLCALL SDL_GetJoystickGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
  643. /**
  644. * Convert a GUID string into a SDL_JoystickGUID structure.
  645. *
  646. * Performs no error checking. If this function is given a string containing
  647. * an invalid GUID, the function will silently succeed, but the GUID generated
  648. * will not be useful.
  649. *
  650. * \param pchGUID string containing an ASCII representation of a GUID
  651. * \returns a SDL_JoystickGUID structure.
  652. *
  653. * \since This function is available since SDL 3.0.0.
  654. *
  655. * \sa SDL_GetJoystickGUIDString
  656. */
  657. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUIDFromString(const char *pchGUID);
  658. /**
  659. * Get the device information encoded in a SDL_JoystickGUID structure
  660. *
  661. * \param guid the SDL_JoystickGUID you wish to get info about
  662. * \param vendor A pointer filled in with the device VID, or 0 if not
  663. * available
  664. * \param product A pointer filled in with the device PID, or 0 if not
  665. * available
  666. * \param version A pointer filled in with the device version, or 0 if not
  667. * available
  668. * \param crc16 A pointer filled in with a CRC used to distinguish different
  669. * products with the same VID/PID, or 0 if not available
  670. *
  671. * \since This function is available since SDL 3.0.0.
  672. *
  673. * \sa SDL_GetJoystickInstanceGUID
  674. */
  675. extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16);
  676. /**
  677. * Get the status of a specified joystick.
  678. *
  679. * \param joystick the joystick to query
  680. * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
  681. * call SDL_GetError() for more information.
  682. *
  683. * \since This function is available since SDL 3.0.0.
  684. */
  685. extern DECLSPEC SDL_bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
  686. /**
  687. * Get the instance ID of an opened joystick.
  688. *
  689. * \param joystick an SDL_Joystick structure containing joystick information
  690. * \returns the instance ID of the specified joystick on success or 0 on
  691. * failure; call SDL_GetError() for more information.
  692. *
  693. * \since This function is available since SDL 3.0.0.
  694. */
  695. extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickInstanceID(SDL_Joystick *joystick);
  696. /**
  697. * Get the number of general axis controls on a joystick.
  698. *
  699. * Often, the directional pad on a game controller will either look like 4
  700. * separate buttons or a POV hat, and not axes, but all of this is up to the
  701. * device and platform.
  702. *
  703. * \param joystick an SDL_Joystick structure containing joystick information
  704. * \returns the number of axis controls/number of axes on success or a
  705. * negative error code on failure; call SDL_GetError() for more
  706. * information.
  707. *
  708. * \since This function is available since SDL 3.0.0.
  709. *
  710. * \sa SDL_GetJoystickAxis
  711. * \sa SDL_GetNumJoystickBalls
  712. * \sa SDL_GetNumJoystickButtons
  713. * \sa SDL_GetNumJoystickHats
  714. */
  715. extern DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
  716. /**
  717. * Get the number of trackballs on a joystick.
  718. *
  719. * Joystick trackballs have only relative motion events associated with them
  720. * and their state cannot be polled.
  721. *
  722. * Most joysticks do not have trackballs.
  723. *
  724. * \param joystick an SDL_Joystick structure containing joystick information
  725. * \returns the number of trackballs on success or a negative error code on
  726. * failure; call SDL_GetError() for more information.
  727. *
  728. * \since This function is available since SDL 3.0.0.
  729. *
  730. * \sa SDL_GetJoystickBall
  731. * \sa SDL_GetNumJoystickAxes
  732. * \sa SDL_GetNumJoystickButtons
  733. * \sa SDL_GetNumJoystickHats
  734. */
  735. extern DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
  736. /**
  737. * Get the number of POV hats on a joystick.
  738. *
  739. * \param joystick an SDL_Joystick structure containing joystick information
  740. * \returns the number of POV hats on success or a negative error code on
  741. * failure; call SDL_GetError() for more information.
  742. *
  743. * \since This function is available since SDL 3.0.0.
  744. *
  745. * \sa SDL_GetJoystickHat
  746. * \sa SDL_GetNumJoystickAxes
  747. * \sa SDL_GetNumJoystickBalls
  748. * \sa SDL_GetNumJoystickButtons
  749. */
  750. extern DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
  751. /**
  752. * Get the number of buttons on a joystick.
  753. *
  754. * \param joystick an SDL_Joystick structure containing joystick information
  755. * \returns the number of buttons on success or a negative error code on
  756. * failure; call SDL_GetError() for more information.
  757. *
  758. * \since This function is available since SDL 3.0.0.
  759. *
  760. * \sa SDL_GetJoystickButton
  761. * \sa SDL_GetNumJoystickAxes
  762. * \sa SDL_GetNumJoystickBalls
  763. * \sa SDL_GetNumJoystickHats
  764. */
  765. extern DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
  766. /**
  767. * Set the state of joystick event processing.
  768. *
  769. * If joystick events are disabled, you must call SDL_UpdateJoysticks()
  770. * yourself and check the state of the joystick when you want joystick
  771. * information.
  772. *
  773. * \param enabled whether to process joystick events or not
  774. *
  775. * \since This function is available since SDL 3.0.0.
  776. *
  777. * \sa SDL_JoystickEventsEnabled
  778. * \sa SDL_UpdateJoysticks
  779. */
  780. extern DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(SDL_bool enabled);
  781. /**
  782. * Query the state of joystick event processing.
  783. *
  784. * If joystick events are disabled, you must call SDL_UpdateJoysticks()
  785. * yourself and check the state of the joystick when you want joystick
  786. * information.
  787. *
  788. * \returns SDL_TRUE if joystick events are being processed, SDL_FALSE
  789. * otherwise.
  790. *
  791. * \since This function is available since SDL 3.0.0.
  792. *
  793. * \sa SDL_SetJoystickEventsEnabled
  794. */
  795. extern DECLSPEC SDL_bool SDLCALL SDL_JoystickEventsEnabled(void);
  796. /**
  797. * Update the current state of the open joysticks.
  798. *
  799. * This is called automatically by the event loop if any joystick events are
  800. * enabled.
  801. *
  802. * \since This function is available since SDL 3.0.0.
  803. */
  804. extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
  805. /**
  806. * Get the current state of an axis control on a joystick.
  807. *
  808. * SDL makes no promises about what part of the joystick any given axis refers
  809. * to. Your game should have some sort of configuration UI to let users
  810. * specify what each axis should be bound to. Alternately, SDL's higher-level
  811. * Game Controller API makes a great effort to apply order to this lower-level
  812. * interface, so you know that a specific axis is the "left thumb stick," etc.
  813. *
  814. * The value returned by SDL_GetJoystickAxis() is a signed integer (-32768 to
  815. * 32767) representing the current position of the axis. It may be necessary
  816. * to impose certain tolerances on these values to account for jitter.
  817. *
  818. * \param joystick an SDL_Joystick structure containing joystick information
  819. * \param axis the axis to query; the axis indices start at index 0
  820. * \returns a 16-bit signed integer representing the current position of the
  821. * axis or 0 on failure; call SDL_GetError() for more information.
  822. *
  823. * \since This function is available since SDL 3.0.0.
  824. *
  825. * \sa SDL_GetNumJoystickAxes
  826. */
  827. extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
  828. /**
  829. * Get the initial state of an axis control on a joystick.
  830. *
  831. * The state is a value ranging from -32768 to 32767.
  832. *
  833. * The axis indices start at index 0.
  834. *
  835. * \param joystick an SDL_Joystick structure containing joystick information
  836. * \param axis the axis to query; the axis indices start at index 0
  837. * \param state Upon return, the initial value is supplied here.
  838. * \returns SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
  839. *
  840. * \since This function is available since SDL 3.0.0.
  841. */
  842. extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
  843. /**
  844. * Get the ball axis change since the last poll.
  845. *
  846. * Trackballs can only return relative motion since the last call to
  847. * SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`.
  848. *
  849. * Most joysticks do not have trackballs.
  850. *
  851. * \param joystick the SDL_Joystick to query
  852. * \param ball the ball index to query; ball indices start at index 0
  853. * \param dx stores the difference in the x axis position since the last poll
  854. * \param dy stores the difference in the y axis position since the last poll
  855. * \returns 0 on success or a negative error code on failure; call
  856. * SDL_GetError() for more information.
  857. *
  858. * \since This function is available since SDL 3.0.0.
  859. *
  860. * \sa SDL_GetNumJoystickBalls
  861. */
  862. extern DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
  863. /**
  864. * \name Hat positions
  865. */
  866. /* @{ */
  867. #define SDL_HAT_CENTERED 0x00
  868. #define SDL_HAT_UP 0x01
  869. #define SDL_HAT_RIGHT 0x02
  870. #define SDL_HAT_DOWN 0x04
  871. #define SDL_HAT_LEFT 0x08
  872. #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
  873. #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
  874. #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
  875. #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
  876. /* @} */
  877. /**
  878. * Get the current state of a POV hat on a joystick.
  879. *
  880. * The returned value will be one of the following positions:
  881. *
  882. * - `SDL_HAT_CENTERED`
  883. * - `SDL_HAT_UP`
  884. * - `SDL_HAT_RIGHT`
  885. * - `SDL_HAT_DOWN`
  886. * - `SDL_HAT_LEFT`
  887. * - `SDL_HAT_RIGHTUP`
  888. * - `SDL_HAT_RIGHTDOWN`
  889. * - `SDL_HAT_LEFTUP`
  890. * - `SDL_HAT_LEFTDOWN`
  891. *
  892. * \param joystick an SDL_Joystick structure containing joystick information
  893. * \param hat the hat index to get the state from; indices start at index 0
  894. * \returns the current hat position.
  895. *
  896. * \since This function is available since SDL 3.0.0.
  897. *
  898. * \sa SDL_GetNumJoystickHats
  899. */
  900. extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
  901. /**
  902. * Get the current state of a button on a joystick.
  903. *
  904. * \param joystick an SDL_Joystick structure containing joystick information
  905. * \param button the button index to get the state from; indices start at
  906. * index 0
  907. * \returns 1 if the specified button is pressed, 0 otherwise.
  908. *
  909. * \since This function is available since SDL 3.0.0.
  910. *
  911. * \sa SDL_GetNumJoystickButtons
  912. */
  913. extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button);
  914. /**
  915. * Start a rumble effect.
  916. *
  917. * Each call to this function cancels any previous rumble effect, and calling
  918. * it with 0 intensity stops any rumbling.
  919. *
  920. * This function requires you to process SDL events or call
  921. * SDL_UpdateJoysticks() to update rumble state.
  922. *
  923. * \param joystick The joystick to vibrate
  924. * \param low_frequency_rumble The intensity of the low frequency (left)
  925. * rumble motor, from 0 to 0xFFFF
  926. * \param high_frequency_rumble The intensity of the high frequency (right)
  927. * rumble motor, from 0 to 0xFFFF
  928. * \param duration_ms The duration of the rumble effect, in milliseconds
  929. * \returns 0, or -1 if rumble isn't supported on this joystick
  930. *
  931. * \since This function is available since SDL 3.0.0.
  932. */
  933. extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
  934. /**
  935. * Start a rumble effect in the joystick's triggers
  936. *
  937. * Each call to this function cancels any previous trigger rumble effect, and
  938. * calling it with 0 intensity stops any rumbling.
  939. *
  940. * Note that this is rumbling of the _triggers_ and not the game controller as
  941. * a whole. This is currently only supported on Xbox One controllers. If you
  942. * want the (more common) whole-controller rumble, use SDL_RumbleJoystick()
  943. * instead.
  944. *
  945. * This function requires you to process SDL events or call
  946. * SDL_UpdateJoysticks() to update rumble state.
  947. *
  948. * \param joystick The joystick to vibrate
  949. * \param left_rumble The intensity of the left trigger rumble motor, from 0
  950. * to 0xFFFF
  951. * \param right_rumble The intensity of the right trigger rumble motor, from 0
  952. * to 0xFFFF
  953. * \param duration_ms The duration of the rumble effect, in milliseconds
  954. * \returns 0 on success or a negative error code on failure; call
  955. * SDL_GetError() for more information.
  956. *
  957. * \since This function is available since SDL 3.0.0.
  958. *
  959. * \sa SDL_RumbleJoystick
  960. */
  961. extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
  962. /**
  963. * Update a joystick's LED color.
  964. *
  965. * An example of a joystick LED is the light on the back of a PlayStation 4's
  966. * DualShock 4 controller.
  967. *
  968. * For joysticks with a single color LED, the maximum of the RGB values will
  969. * be used as the LED brightness.
  970. *
  971. * \param joystick The joystick to update
  972. * \param red The intensity of the red LED
  973. * \param green The intensity of the green LED
  974. * \param blue The intensity of the blue LED
  975. * \returns 0 on success or a negative error code on failure; call
  976. * SDL_GetError() for more information.
  977. *
  978. * \since This function is available since SDL 3.0.0.
  979. */
  980. extern DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
  981. /**
  982. * Send a joystick specific effect packet
  983. *
  984. * \param joystick The joystick to affect
  985. * \param data The data to send to the joystick
  986. * \param size The size of the data to send to the joystick
  987. * \returns 0 on success or a negative error code on failure; call
  988. * SDL_GetError() for more information.
  989. *
  990. * \since This function is available since SDL 3.0.0.
  991. */
  992. extern DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
  993. /**
  994. * Close a joystick previously opened with SDL_OpenJoystick().
  995. *
  996. * \param joystick The joystick device to close
  997. *
  998. * \since This function is available since SDL 3.0.0.
  999. *
  1000. * \sa SDL_OpenJoystick
  1001. */
  1002. extern DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
  1003. /**
  1004. * Get the battery level of a joystick as SDL_JoystickPowerLevel.
  1005. *
  1006. * \param joystick the SDL_Joystick to query
  1007. * \returns the current battery level as SDL_JoystickPowerLevel on success or
  1008. * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
  1009. *
  1010. * \since This function is available since SDL 3.0.0.
  1011. */
  1012. extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_GetJoystickPowerLevel(SDL_Joystick *joystick);
  1013. /* Ends C function definitions when using C++ */
  1014. #ifdef __cplusplus
  1015. }
  1016. #endif
  1017. #include <SDL3/SDL_close_code.h>
  1018. #endif /* SDL_joystick_h_ */