SDL_joystick.h 39 KB

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