sdl3_sys/generated/
joystick.rs

1//! SDL joystick support.
2//!
3//! This is the lower-level joystick handling. If you want the simpler option,
4//! where what each button does is well-defined, you should use the gamepad API
5//! instead.
6//!
7//! The term "instance_id" is the current instantiation of a joystick device in
8//! the system. If the joystick is removed and then re-inserted then it will
9//! get a new instance_id. instance_id's are monotonically increasing
10//! identifiers of a joystick plugged in.
11//!
12//! The term "player_index" is the number assigned to a player on a specific
13//! controller. For XInput controllers this returns the XInput user index. Many
14//! joysticks will not be able to supply this information.
15//!
16//! [`SDL_GUID`] is used as a stable 128-bit identifier for a joystick device that
17//! does not change over time. It identifies class of the device (a X360 wired
18//! controller for example). This identifier is platform dependent.
19//!
20//! In order to use these functions, [`SDL_Init()`] must have been called with the
21//! [`SDL_INIT_JOYSTICK`] flag. This causes SDL to scan the system for joysticks,
22//! and load appropriate drivers.
23//!
24//! If you would like to receive joystick updates while the application is in
25//! the background, you should set the following hint before calling
26//! [`SDL_Init()`]\: [`SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS`]
27//!
28//! SDL can provide virtual joysticks as well: the app defines an imaginary
29//! controller with [`SDL_AttachVirtualJoystick()`], and then can provide inputs
30//! for it via [`SDL_SetJoystickVirtualAxis()`], [`SDL_SetJoystickVirtualButton()`],
31//! etc. As this data is supplied, it will look like a normal joystick to SDL,
32//! just not backed by a hardware driver. This has been used to make unusual
33//! devices, like VR headset controllers, look like normal joysticks, or
34//! provide recording/playback of game inputs, etc.
35
36use super::stdinc::*;
37
38use super::error::*;
39
40use super::guid::*;
41
42use super::mutex::*;
43
44use super::power::*;
45
46use super::properties::*;
47
48use super::sensor::*;
49
50/// This is a unique ID for a joystick for the time it is connected to the
51/// system, and is never reused for the lifetime of the application.
52///
53/// If the joystick is disconnected and reconnected, it will get a new ID.
54///
55/// The value 0 is an invalid ID.
56///
57/// ## Availability
58/// This datatype is available since SDL 3.2.0.
59#[repr(transparent)]
60#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
61#[cfg_attr(feature = "debug-impls", derive(Debug))]
62pub struct SDL_JoystickID(pub Uint32);
63
64impl ::core::cmp::PartialEq<Uint32> for SDL_JoystickID {
65    #[inline(always)]
66    fn eq(&self, other: &Uint32) -> bool {
67        &self.0 == other
68    }
69}
70
71impl ::core::cmp::PartialEq<SDL_JoystickID> for Uint32 {
72    #[inline(always)]
73    fn eq(&self, other: &SDL_JoystickID) -> bool {
74        self == &other.0
75    }
76}
77
78impl From<SDL_JoystickID> for Uint32 {
79    #[inline(always)]
80    fn from(value: SDL_JoystickID) -> Self {
81        value.0
82    }
83}
84
85#[cfg(feature = "metadata")]
86impl sdl3_sys::metadata::GroupMetadata for SDL_JoystickID {
87    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
88        &crate::metadata::joystick::METADATA_SDL_JoystickID;
89}
90
91/// An enum of some common joystick types.
92///
93/// In some cases, SDL can identify a low-level joystick as being a certain
94/// type of device, and will report it through [`SDL_GetJoystickType`] (or
95/// [`SDL_GetJoystickTypeForID`]).
96///
97/// This is by no means a complete list of everything that can be plugged into
98/// a computer.
99///
100/// You may refer to
101/// [XInput Controller Types](https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes)
102/// table for a general understanding of each joystick type.
103///
104/// ## Availability
105/// This enum is available since SDL 3.2.0.
106///
107/// ## Known values (`sdl3-sys`)
108/// | Associated constant | Global constant | Description |
109/// | ------------------- | --------------- | ----------- |
110/// | [`UNKNOWN`](SDL_JoystickType::UNKNOWN) | [`SDL_JOYSTICK_TYPE_UNKNOWN`] | |
111/// | [`GAMEPAD`](SDL_JoystickType::GAMEPAD) | [`SDL_JOYSTICK_TYPE_GAMEPAD`] | |
112/// | [`WHEEL`](SDL_JoystickType::WHEEL) | [`SDL_JOYSTICK_TYPE_WHEEL`] | |
113/// | [`ARCADE_STICK`](SDL_JoystickType::ARCADE_STICK) | [`SDL_JOYSTICK_TYPE_ARCADE_STICK`] | |
114/// | [`FLIGHT_STICK`](SDL_JoystickType::FLIGHT_STICK) | [`SDL_JOYSTICK_TYPE_FLIGHT_STICK`] | |
115/// | [`DANCE_PAD`](SDL_JoystickType::DANCE_PAD) | [`SDL_JOYSTICK_TYPE_DANCE_PAD`] | |
116/// | [`GUITAR`](SDL_JoystickType::GUITAR) | [`SDL_JOYSTICK_TYPE_GUITAR`] | |
117/// | [`DRUM_KIT`](SDL_JoystickType::DRUM_KIT) | [`SDL_JOYSTICK_TYPE_DRUM_KIT`] | |
118/// | [`ARCADE_PAD`](SDL_JoystickType::ARCADE_PAD) | [`SDL_JOYSTICK_TYPE_ARCADE_PAD`] | |
119/// | [`THROTTLE`](SDL_JoystickType::THROTTLE) | [`SDL_JOYSTICK_TYPE_THROTTLE`] | |
120/// | [`COUNT`](SDL_JoystickType::COUNT) | [`SDL_JOYSTICK_TYPE_COUNT`] | |
121#[repr(transparent)]
122#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
123pub struct SDL_JoystickType(pub ::core::ffi::c_int);
124
125impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_JoystickType {
126    #[inline(always)]
127    fn eq(&self, other: &::core::ffi::c_int) -> bool {
128        &self.0 == other
129    }
130}
131
132impl ::core::cmp::PartialEq<SDL_JoystickType> for ::core::ffi::c_int {
133    #[inline(always)]
134    fn eq(&self, other: &SDL_JoystickType) -> bool {
135        self == &other.0
136    }
137}
138
139impl From<SDL_JoystickType> for ::core::ffi::c_int {
140    #[inline(always)]
141    fn from(value: SDL_JoystickType) -> Self {
142        value.0
143    }
144}
145
146#[cfg(feature = "debug-impls")]
147impl ::core::fmt::Debug for SDL_JoystickType {
148    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
149        #[allow(unreachable_patterns)]
150        f.write_str(match *self {
151            Self::UNKNOWN => "SDL_JOYSTICK_TYPE_UNKNOWN",
152            Self::GAMEPAD => "SDL_JOYSTICK_TYPE_GAMEPAD",
153            Self::WHEEL => "SDL_JOYSTICK_TYPE_WHEEL",
154            Self::ARCADE_STICK => "SDL_JOYSTICK_TYPE_ARCADE_STICK",
155            Self::FLIGHT_STICK => "SDL_JOYSTICK_TYPE_FLIGHT_STICK",
156            Self::DANCE_PAD => "SDL_JOYSTICK_TYPE_DANCE_PAD",
157            Self::GUITAR => "SDL_JOYSTICK_TYPE_GUITAR",
158            Self::DRUM_KIT => "SDL_JOYSTICK_TYPE_DRUM_KIT",
159            Self::ARCADE_PAD => "SDL_JOYSTICK_TYPE_ARCADE_PAD",
160            Self::THROTTLE => "SDL_JOYSTICK_TYPE_THROTTLE",
161            Self::COUNT => "SDL_JOYSTICK_TYPE_COUNT",
162
163            _ => return write!(f, "SDL_JoystickType({})", self.0),
164        })
165    }
166}
167
168impl SDL_JoystickType {
169    pub const UNKNOWN: Self = Self((0 as ::core::ffi::c_int));
170    pub const GAMEPAD: Self = Self((1 as ::core::ffi::c_int));
171    pub const WHEEL: Self = Self((2 as ::core::ffi::c_int));
172    pub const ARCADE_STICK: Self = Self((3 as ::core::ffi::c_int));
173    pub const FLIGHT_STICK: Self = Self((4 as ::core::ffi::c_int));
174    pub const DANCE_PAD: Self = Self((5 as ::core::ffi::c_int));
175    pub const GUITAR: Self = Self((6 as ::core::ffi::c_int));
176    pub const DRUM_KIT: Self = Self((7 as ::core::ffi::c_int));
177    pub const ARCADE_PAD: Self = Self((8 as ::core::ffi::c_int));
178    pub const THROTTLE: Self = Self((9 as ::core::ffi::c_int));
179    pub const COUNT: Self = Self((10 as ::core::ffi::c_int));
180}
181
182pub const SDL_JOYSTICK_TYPE_UNKNOWN: SDL_JoystickType = SDL_JoystickType::UNKNOWN;
183pub const SDL_JOYSTICK_TYPE_GAMEPAD: SDL_JoystickType = SDL_JoystickType::GAMEPAD;
184pub const SDL_JOYSTICK_TYPE_WHEEL: SDL_JoystickType = SDL_JoystickType::WHEEL;
185pub const SDL_JOYSTICK_TYPE_ARCADE_STICK: SDL_JoystickType = SDL_JoystickType::ARCADE_STICK;
186pub const SDL_JOYSTICK_TYPE_FLIGHT_STICK: SDL_JoystickType = SDL_JoystickType::FLIGHT_STICK;
187pub const SDL_JOYSTICK_TYPE_DANCE_PAD: SDL_JoystickType = SDL_JoystickType::DANCE_PAD;
188pub const SDL_JOYSTICK_TYPE_GUITAR: SDL_JoystickType = SDL_JoystickType::GUITAR;
189pub const SDL_JOYSTICK_TYPE_DRUM_KIT: SDL_JoystickType = SDL_JoystickType::DRUM_KIT;
190pub const SDL_JOYSTICK_TYPE_ARCADE_PAD: SDL_JoystickType = SDL_JoystickType::ARCADE_PAD;
191pub const SDL_JOYSTICK_TYPE_THROTTLE: SDL_JoystickType = SDL_JoystickType::THROTTLE;
192pub const SDL_JOYSTICK_TYPE_COUNT: SDL_JoystickType = SDL_JoystickType::COUNT;
193
194#[cfg(feature = "metadata")]
195impl sdl3_sys::metadata::GroupMetadata for SDL_JoystickType {
196    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
197        &crate::metadata::joystick::METADATA_SDL_JoystickType;
198}
199
200/// Possible connection states for a joystick device.
201///
202/// This is used by [`SDL_GetJoystickConnectionState`] to report how a device is
203/// connected to the system.
204///
205/// ## Availability
206/// This enum is available since SDL 3.2.0.
207///
208/// ## Known values (`sdl3-sys`)
209/// | Associated constant | Global constant | Description |
210/// | ------------------- | --------------- | ----------- |
211/// | [`INVALID`](SDL_JoystickConnectionState::INVALID) | [`SDL_JOYSTICK_CONNECTION_INVALID`] | |
212/// | [`UNKNOWN`](SDL_JoystickConnectionState::UNKNOWN) | [`SDL_JOYSTICK_CONNECTION_UNKNOWN`] | |
213/// | [`WIRED`](SDL_JoystickConnectionState::WIRED) | [`SDL_JOYSTICK_CONNECTION_WIRED`] | |
214/// | [`WIRELESS`](SDL_JoystickConnectionState::WIRELESS) | [`SDL_JOYSTICK_CONNECTION_WIRELESS`] | |
215#[repr(transparent)]
216#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
217pub struct SDL_JoystickConnectionState(pub ::core::ffi::c_int);
218
219impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_JoystickConnectionState {
220    #[inline(always)]
221    fn eq(&self, other: &::core::ffi::c_int) -> bool {
222        &self.0 == other
223    }
224}
225
226impl ::core::cmp::PartialEq<SDL_JoystickConnectionState> for ::core::ffi::c_int {
227    #[inline(always)]
228    fn eq(&self, other: &SDL_JoystickConnectionState) -> bool {
229        self == &other.0
230    }
231}
232
233impl From<SDL_JoystickConnectionState> for ::core::ffi::c_int {
234    #[inline(always)]
235    fn from(value: SDL_JoystickConnectionState) -> Self {
236        value.0
237    }
238}
239
240#[cfg(feature = "debug-impls")]
241impl ::core::fmt::Debug for SDL_JoystickConnectionState {
242    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
243        #[allow(unreachable_patterns)]
244        f.write_str(match *self {
245            Self::INVALID => "SDL_JOYSTICK_CONNECTION_INVALID",
246            Self::UNKNOWN => "SDL_JOYSTICK_CONNECTION_UNKNOWN",
247            Self::WIRED => "SDL_JOYSTICK_CONNECTION_WIRED",
248            Self::WIRELESS => "SDL_JOYSTICK_CONNECTION_WIRELESS",
249
250            _ => return write!(f, "SDL_JoystickConnectionState({})", self.0),
251        })
252    }
253}
254
255impl SDL_JoystickConnectionState {
256    pub const INVALID: Self = Self((-1_i32 as ::core::ffi::c_int));
257    pub const UNKNOWN: Self = Self((0_i32 as ::core::ffi::c_int));
258    pub const WIRED: Self = Self((1_i32 as ::core::ffi::c_int));
259    pub const WIRELESS: Self = Self((2_i32 as ::core::ffi::c_int));
260}
261
262pub const SDL_JOYSTICK_CONNECTION_INVALID: SDL_JoystickConnectionState =
263    SDL_JoystickConnectionState::INVALID;
264pub const SDL_JOYSTICK_CONNECTION_UNKNOWN: SDL_JoystickConnectionState =
265    SDL_JoystickConnectionState::UNKNOWN;
266pub const SDL_JOYSTICK_CONNECTION_WIRED: SDL_JoystickConnectionState =
267    SDL_JoystickConnectionState::WIRED;
268pub const SDL_JOYSTICK_CONNECTION_WIRELESS: SDL_JoystickConnectionState =
269    SDL_JoystickConnectionState::WIRELESS;
270
271#[cfg(feature = "metadata")]
272impl sdl3_sys::metadata::GroupMetadata for SDL_JoystickConnectionState {
273    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
274        &crate::metadata::joystick::METADATA_SDL_JoystickConnectionState;
275}
276
277/// The largest value an SDL_Joystick's axis can report.
278///
279/// ## Availability
280/// This macro is available since SDL 3.2.0.
281///
282/// ## See also
283/// - [`SDL_JOYSTICK_AXIS_MIN`]
284pub const SDL_JOYSTICK_AXIS_MAX: Sint16 = (32767 as Sint16);
285
286/// The smallest value an SDL_Joystick's axis can report.
287///
288/// This is a negative number!
289///
290/// ## Availability
291/// This macro is available since SDL 3.2.0.
292///
293/// ## See also
294/// - [`SDL_JOYSTICK_AXIS_MAX`]
295pub const SDL_JOYSTICK_AXIS_MIN: Sint16 = (-32768_i32 as Sint16);
296
297unsafe extern "C" {
298    /// Locking for atomic access to the joystick API.
299    ///
300    /// The SDL joystick functions are thread-safe, however you can lock the
301    /// joysticks while processing to guarantee that the joystick list won't change
302    /// and joystick and gamepad events will not be delivered.
303    ///
304    /// ## Thread safety
305    /// It is safe to call this function from any thread.
306    ///
307    /// ## Availability
308    /// This function is available since SDL 3.2.0.
309    pub fn SDL_LockJoysticks();
310}
311
312unsafe extern "C" {
313    /// Unlocking for atomic access to the joystick API.
314    ///
315    /// ## Thread safety
316    /// This should be called from the same thread that called
317    ///   [`SDL_LockJoysticks()`].
318    ///
319    /// ## Availability
320    /// This function is available since SDL 3.2.0.
321    pub fn SDL_UnlockJoysticks();
322}
323
324unsafe extern "C" {
325    /// Return whether a joystick is currently connected.
326    ///
327    /// ## Return value
328    /// Returns true if a joystick is connected, false otherwise.
329    ///
330    /// ## Thread safety
331    /// It is safe to call this function from any thread.
332    ///
333    /// ## Availability
334    /// This function is available since SDL 3.2.0.
335    ///
336    /// ## See also
337    /// - [`SDL_GetJoysticks`]
338    pub fn SDL_HasJoystick() -> ::core::primitive::bool;
339}
340
341unsafe extern "C" {
342    /// Get a list of currently connected joysticks.
343    ///
344    /// ## Parameters
345    /// - `count`: a pointer filled in with the number of joysticks returned, may
346    ///   be NULL.
347    ///
348    /// ## Return value
349    /// Returns a 0 terminated array of joystick instance IDs or NULL on failure;
350    ///   call [`SDL_GetError()`] for more information. This should be freed
351    ///   with [`SDL_free()`] when it is no longer needed.
352    ///
353    /// ## Thread safety
354    /// It is safe to call this function from any thread.
355    ///
356    /// ## Availability
357    /// This function is available since SDL 3.2.0.
358    ///
359    /// ## See also
360    /// - [`SDL_HasJoystick`]
361    /// - [`SDL_OpenJoystick`]
362    pub fn SDL_GetJoysticks(count: *mut ::core::ffi::c_int) -> *mut SDL_JoystickID;
363}
364
365unsafe extern "C" {
366    /// Get the implementation dependent name of a joystick.
367    ///
368    /// This can be called before any joysticks are opened.
369    ///
370    /// ## Parameters
371    /// - `instance_id`: the joystick instance ID.
372    ///
373    /// ## Return value
374    /// Returns the name of the selected joystick. If no name can be found, this
375    ///   function returns NULL; call [`SDL_GetError()`] for more information.
376    ///
377    /// ## Thread safety
378    /// It is safe to call this function from any thread.
379    ///
380    /// ## Availability
381    /// This function is available since SDL 3.2.0.
382    ///
383    /// ## See also
384    /// - [`SDL_GetJoystickName`]
385    /// - [`SDL_GetJoysticks`]
386    pub fn SDL_GetJoystickNameForID(instance_id: SDL_JoystickID) -> *const ::core::ffi::c_char;
387}
388
389unsafe extern "C" {
390    /// Get the implementation dependent path of a joystick.
391    ///
392    /// This can be called before any joysticks are opened.
393    ///
394    /// ## Parameters
395    /// - `instance_id`: the joystick instance ID.
396    ///
397    /// ## Return value
398    /// Returns the path of the selected joystick. If no path can be found, this
399    ///   function returns NULL; call [`SDL_GetError()`] for more information.
400    ///
401    /// ## Thread safety
402    /// It is safe to call this function from any thread.
403    ///
404    /// ## Availability
405    /// This function is available since SDL 3.2.0.
406    ///
407    /// ## See also
408    /// - [`SDL_GetJoystickPath`]
409    /// - [`SDL_GetJoysticks`]
410    pub fn SDL_GetJoystickPathForID(instance_id: SDL_JoystickID) -> *const ::core::ffi::c_char;
411}
412
413unsafe extern "C" {
414    /// Get the player index of a joystick.
415    ///
416    /// This can be called before any joysticks are opened.
417    ///
418    /// ## Parameters
419    /// - `instance_id`: the joystick instance ID.
420    ///
421    /// ## Return value
422    /// Returns the player index of a joystick, or -1 if it's not available.
423    ///
424    /// ## Thread safety
425    /// It is safe to call this function from any thread.
426    ///
427    /// ## Availability
428    /// This function is available since SDL 3.2.0.
429    ///
430    /// ## See also
431    /// - [`SDL_GetJoystickPlayerIndex`]
432    /// - [`SDL_GetJoysticks`]
433    pub fn SDL_GetJoystickPlayerIndexForID(instance_id: SDL_JoystickID) -> ::core::ffi::c_int;
434}
435
436unsafe extern "C" {
437    /// Get the implementation-dependent GUID of a joystick.
438    ///
439    /// This can be called before any joysticks are opened.
440    ///
441    /// ## Parameters
442    /// - `instance_id`: the joystick instance ID.
443    ///
444    /// ## Return value
445    /// Returns the GUID of the selected joystick. If called with an invalid
446    ///   instance_id, this function returns a zero GUID.
447    ///
448    /// ## Thread safety
449    /// It is safe to call this function from any thread.
450    ///
451    /// ## Availability
452    /// This function is available since SDL 3.2.0.
453    ///
454    /// ## See also
455    /// - [`SDL_GetJoystickGUID`]
456    /// - [`SDL_GUIDToString`]
457    pub fn SDL_GetJoystickGUIDForID(instance_id: SDL_JoystickID) -> SDL_GUID;
458}
459
460unsafe extern "C" {
461    /// Get the USB vendor ID of a joystick, if available.
462    ///
463    /// This can be called before any joysticks are opened. If the vendor ID isn't
464    /// available this function returns 0.
465    ///
466    /// ## Parameters
467    /// - `instance_id`: the joystick instance ID.
468    ///
469    /// ## Return value
470    /// Returns the USB vendor ID of the selected joystick. If called with an
471    ///   invalid instance_id, this function returns 0.
472    ///
473    /// ## Thread safety
474    /// It is safe to call this function from any thread.
475    ///
476    /// ## Availability
477    /// This function is available since SDL 3.2.0.
478    ///
479    /// ## See also
480    /// - [`SDL_GetJoystickVendor`]
481    /// - [`SDL_GetJoysticks`]
482    pub fn SDL_GetJoystickVendorForID(instance_id: SDL_JoystickID) -> Uint16;
483}
484
485unsafe extern "C" {
486    /// Get the USB product ID of a joystick, if available.
487    ///
488    /// This can be called before any joysticks are opened. If the product ID isn't
489    /// available this function returns 0.
490    ///
491    /// ## Parameters
492    /// - `instance_id`: the joystick instance ID.
493    ///
494    /// ## Return value
495    /// Returns the USB product ID of the selected joystick. If called with an
496    ///   invalid instance_id, this function returns 0.
497    ///
498    /// ## Thread safety
499    /// It is safe to call this function from any thread.
500    ///
501    /// ## Availability
502    /// This function is available since SDL 3.2.0.
503    ///
504    /// ## See also
505    /// - [`SDL_GetJoystickProduct`]
506    /// - [`SDL_GetJoysticks`]
507    pub fn SDL_GetJoystickProductForID(instance_id: SDL_JoystickID) -> Uint16;
508}
509
510unsafe extern "C" {
511    /// Get the product version of a joystick, if available.
512    ///
513    /// This can be called before any joysticks are opened. If the product version
514    /// isn't available this function returns 0.
515    ///
516    /// ## Parameters
517    /// - `instance_id`: the joystick instance ID.
518    ///
519    /// ## Return value
520    /// Returns the product version of the selected joystick. If called with an
521    ///   invalid instance_id, this function returns 0.
522    ///
523    /// ## Thread safety
524    /// It is safe to call this function from any thread.
525    ///
526    /// ## Availability
527    /// This function is available since SDL 3.2.0.
528    ///
529    /// ## See also
530    /// - [`SDL_GetJoystickProductVersion`]
531    /// - [`SDL_GetJoysticks`]
532    pub fn SDL_GetJoystickProductVersionForID(instance_id: SDL_JoystickID) -> Uint16;
533}
534
535unsafe extern "C" {
536    /// Get the type of a joystick, if available.
537    ///
538    /// This can be called before any joysticks are opened.
539    ///
540    /// ## Parameters
541    /// - `instance_id`: the joystick instance ID.
542    ///
543    /// ## Return value
544    /// Returns the [`SDL_JoystickType`] of the selected joystick. If called with an
545    ///   invalid instance_id, this function returns
546    ///   [`SDL_JOYSTICK_TYPE_UNKNOWN`].
547    ///
548    /// ## Thread safety
549    /// It is safe to call this function from any thread.
550    ///
551    /// ## Availability
552    /// This function is available since SDL 3.2.0.
553    ///
554    /// ## See also
555    /// - [`SDL_GetJoystickType`]
556    /// - [`SDL_GetJoysticks`]
557    pub fn SDL_GetJoystickTypeForID(instance_id: SDL_JoystickID) -> SDL_JoystickType;
558}
559
560unsafe extern "C" {
561    /// Open a joystick for use.
562    ///
563    /// The joystick subsystem must be initialized before a joystick can be opened
564    /// for use.
565    ///
566    /// ## Parameters
567    /// - `instance_id`: the joystick instance ID.
568    ///
569    /// ## Return value
570    /// Returns a joystick identifier or NULL on failure; call [`SDL_GetError()`] for
571    ///   more information.
572    ///
573    /// ## Thread safety
574    /// It is safe to call this function from any thread.
575    ///
576    /// ## Availability
577    /// This function is available since SDL 3.2.0.
578    ///
579    /// ## See also
580    /// - [`SDL_CloseJoystick`]
581    pub fn SDL_OpenJoystick(instance_id: SDL_JoystickID) -> *mut SDL_Joystick;
582}
583
584unsafe extern "C" {
585    /// Get the [`SDL_Joystick`] associated with an instance ID, if it has been opened.
586    ///
587    /// ## Parameters
588    /// - `instance_id`: the instance ID to get the [`SDL_Joystick`] for.
589    ///
590    /// ## Return value
591    /// Returns an [`SDL_Joystick`] on success or NULL on failure or if it hasn't been
592    ///   opened yet; call [`SDL_GetError()`] for more information.
593    ///
594    /// ## Thread safety
595    /// It is safe to call this function from any thread.
596    ///
597    /// ## Availability
598    /// This function is available since SDL 3.2.0.
599    pub fn SDL_GetJoystickFromID(instance_id: SDL_JoystickID) -> *mut SDL_Joystick;
600}
601
602unsafe extern "C" {
603    /// Get the [`SDL_Joystick`] associated with a player index.
604    ///
605    /// ## Parameters
606    /// - `player_index`: the player index to get the [`SDL_Joystick`] for.
607    ///
608    /// ## Return value
609    /// Returns an [`SDL_Joystick`] on success or NULL on failure; call [`SDL_GetError()`]
610    ///   for more information.
611    ///
612    /// ## Thread safety
613    /// It is safe to call this function from any thread.
614    ///
615    /// ## Availability
616    /// This function is available since SDL 3.2.0.
617    ///
618    /// ## See also
619    /// - [`SDL_GetJoystickPlayerIndex`]
620    /// - [`SDL_SetJoystickPlayerIndex`]
621    pub fn SDL_GetJoystickFromPlayerIndex(player_index: ::core::ffi::c_int) -> *mut SDL_Joystick;
622}
623
624/// The structure that describes a virtual joystick touchpad.
625///
626/// ## Availability
627/// This struct is available since SDL 3.2.0.
628///
629/// ## See also
630/// - [`SDL_VirtualJoystickDesc`]
631///
632/// ## Notes for `sdl3-sys`
633/// This struct has padding fields which shouldn't be accessed directly; use struct update syntax with e.g. `..Default::default()` for manual construction.
634#[repr(C)]
635#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
636#[cfg_attr(feature = "debug-impls", derive(Debug))]
637pub struct SDL_VirtualJoystickTouchpadDesc {
638    /// the number of simultaneous fingers on this touchpad
639    pub nfingers: Uint16,
640    #[deprecated(note = "padding fields are exempt from semver; init with `..Default::default()`")]
641    pub padding: [Uint16; 3],
642}
643
644/// The structure that describes a virtual joystick sensor.
645///
646/// ## Availability
647/// This struct is available since SDL 3.2.0.
648///
649/// ## See also
650/// - [`SDL_VirtualJoystickDesc`]
651#[repr(C)]
652#[derive(Clone, Copy, Default, PartialEq)]
653#[cfg_attr(feature = "debug-impls", derive(Debug))]
654pub struct SDL_VirtualJoystickSensorDesc {
655    /// the type of this sensor
656    pub r#type: SDL_SensorType,
657    /// the update frequency of this sensor, may be 0.0f
658    pub rate: ::core::ffi::c_float,
659}
660
661/// The structure that describes a virtual joystick.
662///
663/// This structure should be initialized using [`SDL_INIT_INTERFACE()`]. All
664/// elements of this structure are optional.
665///
666/// ## Availability
667/// This struct is available since SDL 3.2.0.
668///
669/// ## See also
670/// - [`SDL_AttachVirtualJoystick`]
671/// - [`SDL_INIT_INTERFACE`]
672/// - [`SDL_VirtualJoystickSensorDesc`]
673/// - [`SDL_VirtualJoystickTouchpadDesc`]
674///
675/// ## Notes for `sdl3-sys`
676/// - This interface struct can be initialized with [`SDL_VirtualJoystickDesc::new()`] or `Default::default()`.
677/// - This struct has padding fields which shouldn't be accessed directly; use struct update syntax with e.g. `..Default::default()` for manual construction.
678#[repr(C)]
679#[cfg_attr(feature = "debug-impls", derive(Debug))]
680pub struct SDL_VirtualJoystickDesc {
681    /// the version of this interface
682    pub version: Uint32,
683    /// [`SDL_JoystickType`]
684    pub r#type: Uint16,
685    /// unused
686    #[deprecated(note = "padding fields are exempt from semver; init with `..Default::default()`")]
687    pub padding: Uint16,
688    /// the USB vendor ID of this joystick
689    pub vendor_id: Uint16,
690    /// the USB product ID of this joystick
691    pub product_id: Uint16,
692    /// the number of axes on this joystick
693    pub naxes: Uint16,
694    /// the number of buttons on this joystick
695    pub nbuttons: Uint16,
696    /// the number of balls on this joystick
697    pub nballs: Uint16,
698    /// the number of hats on this joystick
699    pub nhats: Uint16,
700    /// the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions
701    pub ntouchpads: Uint16,
702    /// the number of sensors on this joystick, requires `sensors` to point at valid descriptions
703    pub nsensors: Uint16,
704    /// unused
705    #[deprecated(note = "padding fields are exempt from semver; init with `..Default::default()`")]
706    pub padding2: [Uint16; 2],
707    /// A mask of which buttons are valid for this controller
708    /// e.g. (1 << [`SDL_GAMEPAD_BUTTON_SOUTH`])
709    pub button_mask: Uint32,
710    /// A mask of which axes are valid for this controller
711    /// e.g. (1 << [`SDL_GAMEPAD_AXIS_LEFTX`])
712    pub axis_mask: Uint32,
713    /// the name of the joystick
714    pub name: *const ::core::ffi::c_char,
715    /// A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0
716    pub touchpads: *const SDL_VirtualJoystickTouchpadDesc,
717    /// A pointer to an array of sensor descriptions, required if `nsensors` is > 0
718    pub sensors: *const SDL_VirtualJoystickSensorDesc,
719    /// User data pointer passed to callbacks
720    pub userdata: *mut ::core::ffi::c_void,
721    /// Called when the joystick state should be updated
722    pub Update: ::core::option::Option<unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void)>,
723    /// Called when the player index is set
724    pub SetPlayerIndex: ::core::option::Option<
725        unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, player_index: ::core::ffi::c_int),
726    >,
727    /// Implements [`SDL_RumbleJoystick()`]
728    pub Rumble: ::core::option::Option<
729        unsafe extern "C" fn(
730            userdata: *mut ::core::ffi::c_void,
731            low_frequency_rumble: Uint16,
732            high_frequency_rumble: Uint16,
733        ) -> ::core::primitive::bool,
734    >,
735    /// Implements [`SDL_RumbleJoystickTriggers()`]
736    pub RumbleTriggers: ::core::option::Option<
737        unsafe extern "C" fn(
738            userdata: *mut ::core::ffi::c_void,
739            left_rumble: Uint16,
740            right_rumble: Uint16,
741        ) -> ::core::primitive::bool,
742    >,
743    /// Implements [`SDL_SetJoystickLED()`]
744    pub SetLED: ::core::option::Option<
745        unsafe extern "C" fn(
746            userdata: *mut ::core::ffi::c_void,
747            red: Uint8,
748            green: Uint8,
749            blue: Uint8,
750        ) -> ::core::primitive::bool,
751    >,
752    /// Implements [`SDL_SendJoystickEffect()`]
753    pub SendEffect: ::core::option::Option<
754        unsafe extern "C" fn(
755            userdata: *mut ::core::ffi::c_void,
756            data: *const ::core::ffi::c_void,
757            size: ::core::ffi::c_int,
758        ) -> ::core::primitive::bool,
759    >,
760    /// Implements [`SDL_SetGamepadSensorEnabled()`]
761    pub SetSensorsEnabled: ::core::option::Option<
762        unsafe extern "C" fn(
763            userdata: *mut ::core::ffi::c_void,
764            enabled: ::core::primitive::bool,
765        ) -> ::core::primitive::bool,
766    >,
767    /// Cleans up the userdata when the joystick is detached
768    pub Cleanup: ::core::option::Option<unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void)>,
769}
770
771impl SDL_VirtualJoystickDesc {
772    /// Create a new `SDL_VirtualJoystickDesc` initialized with `SDL_INIT_INTERFACE`
773    #[inline]
774    pub const fn new() -> Self {
775        const { ::core::assert!(::core::mem::size_of::<Self>() <= ::core::primitive::u32::MAX as usize) };
776        let mut this = unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() };
777        this.version = ::core::mem::size_of::<Self>() as ::core::primitive::u32;
778        this
779    }
780}
781
782impl ::core::default::Default for SDL_VirtualJoystickDesc {
783    /// Create a new `SDL_VirtualJoystickDesc` initialized with `SDL_INIT_INTERFACE`
784    #[inline(always)]
785    fn default() -> Self {
786        Self::new()
787    }
788}
789
790const _: () = ::core::assert!(
791    (((::core::mem::size_of::<*mut ::core::ffi::c_void>() == 4_usize)
792        && (::core::mem::size_of::<SDL_VirtualJoystickDesc>() == 84_usize))
793        || ((::core::mem::size_of::<*mut ::core::ffi::c_void>() == 8_usize)
794            && (::core::mem::size_of::<SDL_VirtualJoystickDesc>() == 136_usize)))
795);
796
797unsafe extern "C" {
798    /// Attach a new virtual joystick.
799    ///
800    /// Apps can create virtual joysticks, that exist without hardware directly
801    /// backing them, and have program-supplied inputs. Once attached, a virtual
802    /// joystick looks like any other joystick that SDL can access. These can be
803    /// used to make other things look like joysticks, or provide pre-recorded
804    /// input, etc.
805    ///
806    /// Once attached, the app can send joystick inputs to the new virtual joystick
807    /// using [`SDL_SetJoystickVirtualAxis()`], etc.
808    ///
809    /// When no longer needed, the virtual joystick can be removed by calling
810    /// [`SDL_DetachVirtualJoystick()`].
811    ///
812    /// ## Parameters
813    /// - `desc`: joystick description, initialized using [`SDL_INIT_INTERFACE()`].
814    ///
815    /// ## Return value
816    /// Returns the joystick instance ID, or 0 on failure; call [`SDL_GetError()`] for
817    ///   more information.
818    ///
819    /// ## Thread safety
820    /// It is safe to call this function from any thread.
821    ///
822    /// ## Availability
823    /// This function is available since SDL 3.2.0.
824    ///
825    /// ## See also
826    /// - [`SDL_DetachVirtualJoystick`]
827    /// - [`SDL_SetJoystickVirtualAxis`]
828    /// - [`SDL_SetJoystickVirtualButton`]
829    /// - [`SDL_SetJoystickVirtualBall`]
830    /// - [`SDL_SetJoystickVirtualHat`]
831    /// - [`SDL_SetJoystickVirtualTouchpad`]
832    /// - [`SDL_SetJoystickVirtualSensorData`]
833    pub fn SDL_AttachVirtualJoystick(desc: *const SDL_VirtualJoystickDesc) -> SDL_JoystickID;
834}
835
836unsafe extern "C" {
837    /// Detach a virtual joystick.
838    ///
839    /// ## Parameters
840    /// - `instance_id`: the joystick instance ID, previously returned from
841    ///   [`SDL_AttachVirtualJoystick()`].
842    ///
843    /// ## Return value
844    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
845    ///   information.
846    ///
847    /// ## Thread safety
848    /// It is safe to call this function from any thread.
849    ///
850    /// ## Availability
851    /// This function is available since SDL 3.2.0.
852    ///
853    /// ## See also
854    /// - [`SDL_AttachVirtualJoystick`]
855    pub fn SDL_DetachVirtualJoystick(instance_id: SDL_JoystickID) -> ::core::primitive::bool;
856}
857
858unsafe extern "C" {
859    /// Query whether or not a joystick is virtual.
860    ///
861    /// ## Parameters
862    /// - `instance_id`: the joystick instance ID.
863    ///
864    /// ## Return value
865    /// Returns true if the joystick is virtual, false otherwise.
866    ///
867    /// ## Thread safety
868    /// It is safe to call this function from any thread.
869    ///
870    /// ## Availability
871    /// This function is available since SDL 3.2.0.
872    pub fn SDL_IsJoystickVirtual(instance_id: SDL_JoystickID) -> ::core::primitive::bool;
873}
874
875unsafe extern "C" {
876    /// Set the state of an axis on an opened virtual joystick.
877    ///
878    /// Please note that values set here will not be applied until the next call to
879    /// [`SDL_UpdateJoysticks`], which can either be called directly, or can be called
880    /// indirectly through various other SDL APIs, including, but not limited to
881    /// the following: [`SDL_PollEvent`], [`SDL_PumpEvents`], [`SDL_WaitEventTimeout`],
882    /// [`SDL_WaitEvent`].
883    ///
884    /// Note that when sending trigger axes, you should scale the value to the full
885    /// range of Sint16. For example, a trigger at rest would have the value of
886    /// [`SDL_JOYSTICK_AXIS_MIN`].
887    ///
888    /// ## Parameters
889    /// - `joystick`: the virtual joystick on which to set state.
890    /// - `axis`: the index of the axis on the virtual joystick to update.
891    /// - `value`: the new value for the specified axis.
892    ///
893    /// ## Return value
894    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
895    ///   information.
896    ///
897    /// ## Thread safety
898    /// It is safe to call this function from any thread.
899    ///
900    /// ## Availability
901    /// This function is available since SDL 3.2.0.
902    ///
903    /// ## See also
904    /// - [`SDL_SetJoystickVirtualButton`]
905    /// - [`SDL_SetJoystickVirtualBall`]
906    /// - [`SDL_SetJoystickVirtualHat`]
907    /// - [`SDL_SetJoystickVirtualTouchpad`]
908    /// - [`SDL_SetJoystickVirtualSensorData`]
909    pub fn SDL_SetJoystickVirtualAxis(
910        joystick: *mut SDL_Joystick,
911        axis: ::core::ffi::c_int,
912        value: Sint16,
913    ) -> ::core::primitive::bool;
914}
915
916unsafe extern "C" {
917    /// Generate ball motion on an opened virtual joystick.
918    ///
919    /// Please note that values set here will not be applied until the next call to
920    /// [`SDL_UpdateJoysticks`], which can either be called directly, or can be called
921    /// indirectly through various other SDL APIs, including, but not limited to
922    /// the following: [`SDL_PollEvent`], [`SDL_PumpEvents`], [`SDL_WaitEventTimeout`],
923    /// [`SDL_WaitEvent`].
924    ///
925    /// ## Parameters
926    /// - `joystick`: the virtual joystick on which to set state.
927    /// - `ball`: the index of the ball on the virtual joystick to update.
928    /// - `xrel`: the relative motion on the X axis.
929    /// - `yrel`: the relative motion on the Y axis.
930    ///
931    /// ## Return value
932    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
933    ///   information.
934    ///
935    /// ## Thread safety
936    /// It is safe to call this function from any thread.
937    ///
938    /// ## Availability
939    /// This function is available since SDL 3.2.0.
940    ///
941    /// ## See also
942    /// - [`SDL_SetJoystickVirtualAxis`]
943    /// - [`SDL_SetJoystickVirtualButton`]
944    /// - [`SDL_SetJoystickVirtualHat`]
945    /// - [`SDL_SetJoystickVirtualTouchpad`]
946    /// - [`SDL_SetJoystickVirtualSensorData`]
947    pub fn SDL_SetJoystickVirtualBall(
948        joystick: *mut SDL_Joystick,
949        ball: ::core::ffi::c_int,
950        xrel: Sint16,
951        yrel: Sint16,
952    ) -> ::core::primitive::bool;
953}
954
955unsafe extern "C" {
956    /// Set the state of a button on an opened virtual joystick.
957    ///
958    /// Please note that values set here will not be applied until the next call to
959    /// [`SDL_UpdateJoysticks`], which can either be called directly, or can be called
960    /// indirectly through various other SDL APIs, including, but not limited to
961    /// the following: [`SDL_PollEvent`], [`SDL_PumpEvents`], [`SDL_WaitEventTimeout`],
962    /// [`SDL_WaitEvent`].
963    ///
964    /// ## Parameters
965    /// - `joystick`: the virtual joystick on which to set state.
966    /// - `button`: the index of the button on the virtual joystick to update.
967    /// - `down`: true if the button is pressed, false otherwise.
968    ///
969    /// ## Return value
970    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
971    ///   information.
972    ///
973    /// ## Thread safety
974    /// It is safe to call this function from any thread.
975    ///
976    /// ## Availability
977    /// This function is available since SDL 3.2.0.
978    ///
979    /// ## See also
980    /// - [`SDL_SetJoystickVirtualAxis`]
981    /// - [`SDL_SetJoystickVirtualBall`]
982    /// - [`SDL_SetJoystickVirtualHat`]
983    /// - [`SDL_SetJoystickVirtualTouchpad`]
984    /// - [`SDL_SetJoystickVirtualSensorData`]
985    pub fn SDL_SetJoystickVirtualButton(
986        joystick: *mut SDL_Joystick,
987        button: ::core::ffi::c_int,
988        down: ::core::primitive::bool,
989    ) -> ::core::primitive::bool;
990}
991
992unsafe extern "C" {
993    /// Set the state of a hat on an opened virtual joystick.
994    ///
995    /// Please note that values set here will not be applied until the next call to
996    /// [`SDL_UpdateJoysticks`], which can either be called directly, or can be called
997    /// indirectly through various other SDL APIs, including, but not limited to
998    /// the following: [`SDL_PollEvent`], [`SDL_PumpEvents`], [`SDL_WaitEventTimeout`],
999    /// [`SDL_WaitEvent`].
1000    ///
1001    /// ## Parameters
1002    /// - `joystick`: the virtual joystick on which to set state.
1003    /// - `hat`: the index of the hat on the virtual joystick to update.
1004    /// - `value`: the new value for the specified hat.
1005    ///
1006    /// ## Return value
1007    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1008    ///   information.
1009    ///
1010    /// ## Thread safety
1011    /// It is safe to call this function from any thread.
1012    ///
1013    /// ## Availability
1014    /// This function is available since SDL 3.2.0.
1015    ///
1016    /// ## See also
1017    /// - [`SDL_SetJoystickVirtualAxis`]
1018    /// - [`SDL_SetJoystickVirtualButton`]
1019    /// - [`SDL_SetJoystickVirtualBall`]
1020    /// - [`SDL_SetJoystickVirtualTouchpad`]
1021    /// - [`SDL_SetJoystickVirtualSensorData`]
1022    pub fn SDL_SetJoystickVirtualHat(
1023        joystick: *mut SDL_Joystick,
1024        hat: ::core::ffi::c_int,
1025        value: Uint8,
1026    ) -> ::core::primitive::bool;
1027}
1028
1029unsafe extern "C" {
1030    /// Set touchpad finger state on an opened virtual joystick.
1031    ///
1032    /// Please note that values set here will not be applied until the next call to
1033    /// [`SDL_UpdateJoysticks`], which can either be called directly, or can be called
1034    /// indirectly through various other SDL APIs, including, but not limited to
1035    /// the following: [`SDL_PollEvent`], [`SDL_PumpEvents`], [`SDL_WaitEventTimeout`],
1036    /// [`SDL_WaitEvent`].
1037    ///
1038    /// ## Parameters
1039    /// - `joystick`: the virtual joystick on which to set state.
1040    /// - `touchpad`: the index of the touchpad on the virtual joystick to
1041    ///   update.
1042    /// - `finger`: the index of the finger on the touchpad to set.
1043    /// - `down`: true if the finger is pressed, false if the finger is released.
1044    /// - `x`: the x coordinate of the finger on the touchpad, normalized 0 to 1,
1045    ///   with the origin in the upper left.
1046    /// - `y`: the y coordinate of the finger on the touchpad, normalized 0 to 1,
1047    ///   with the origin in the upper left.
1048    /// - `pressure`: the pressure of the finger.
1049    ///
1050    /// ## Return value
1051    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1052    ///   information.
1053    ///
1054    /// ## Thread safety
1055    /// It is safe to call this function from any thread.
1056    ///
1057    /// ## Availability
1058    /// This function is available since SDL 3.2.0.
1059    ///
1060    /// ## See also
1061    /// - [`SDL_SetJoystickVirtualAxis`]
1062    /// - [`SDL_SetJoystickVirtualButton`]
1063    /// - [`SDL_SetJoystickVirtualBall`]
1064    /// - [`SDL_SetJoystickVirtualHat`]
1065    /// - [`SDL_SetJoystickVirtualSensorData`]
1066    pub fn SDL_SetJoystickVirtualTouchpad(
1067        joystick: *mut SDL_Joystick,
1068        touchpad: ::core::ffi::c_int,
1069        finger: ::core::ffi::c_int,
1070        down: ::core::primitive::bool,
1071        x: ::core::ffi::c_float,
1072        y: ::core::ffi::c_float,
1073        pressure: ::core::ffi::c_float,
1074    ) -> ::core::primitive::bool;
1075}
1076
1077unsafe extern "C" {
1078    /// Send a sensor update for an opened virtual joystick.
1079    ///
1080    /// Please note that values set here will not be applied until the next call to
1081    /// [`SDL_UpdateJoysticks`], which can either be called directly, or can be called
1082    /// indirectly through various other SDL APIs, including, but not limited to
1083    /// the following: [`SDL_PollEvent`], [`SDL_PumpEvents`], [`SDL_WaitEventTimeout`],
1084    /// [`SDL_WaitEvent`].
1085    ///
1086    /// ## Parameters
1087    /// - `joystick`: the virtual joystick on which to set state.
1088    /// - `type`: the type of the sensor on the virtual joystick to update.
1089    /// - `sensor_timestamp`: a 64-bit timestamp in nanoseconds associated with
1090    ///   the sensor reading.
1091    /// - `data`: the data associated with the sensor reading.
1092    /// - `num_values`: the number of values pointed to by `data`.
1093    ///
1094    /// ## Return value
1095    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1096    ///   information.
1097    ///
1098    /// ## Thread safety
1099    /// It is safe to call this function from any thread.
1100    ///
1101    /// ## Availability
1102    /// This function is available since SDL 3.2.0.
1103    ///
1104    /// ## See also
1105    /// - [`SDL_SetJoystickVirtualAxis`]
1106    /// - [`SDL_SetJoystickVirtualButton`]
1107    /// - [`SDL_SetJoystickVirtualBall`]
1108    /// - [`SDL_SetJoystickVirtualHat`]
1109    /// - [`SDL_SetJoystickVirtualTouchpad`]
1110    pub fn SDL_SendJoystickVirtualSensorData(
1111        joystick: *mut SDL_Joystick,
1112        r#type: SDL_SensorType,
1113        sensor_timestamp: Uint64,
1114        data: *const ::core::ffi::c_float,
1115        num_values: ::core::ffi::c_int,
1116    ) -> ::core::primitive::bool;
1117}
1118
1119unsafe extern "C" {
1120    /// Get the properties associated with a joystick.
1121    ///
1122    /// The following read-only properties are provided by SDL:
1123    ///
1124    /// - [`SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`]\: true if this joystick has an
1125    ///   LED that has adjustable brightness
1126    /// - [`SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`]\: true if this joystick has an LED
1127    ///   that has adjustable color
1128    /// - [`SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`]\: true if this joystick has a
1129    ///   player LED
1130    /// - [`SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`]\: true if this joystick has
1131    ///   left/right rumble
1132    /// - [`SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`]\: true if this joystick has
1133    ///   simple trigger rumble
1134    ///
1135    /// ## Parameters
1136    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1137    ///
1138    /// ## Return value
1139    /// Returns a valid property ID on success or 0 on failure; call
1140    ///   [`SDL_GetError()`] for more information.
1141    ///
1142    /// ## Thread safety
1143    /// It is safe to call this function from any thread.
1144    ///
1145    /// ## Availability
1146    /// This function is available since SDL 3.2.0.
1147    pub fn SDL_GetJoystickProperties(joystick: *mut SDL_Joystick) -> SDL_PropertiesID;
1148}
1149
1150pub const SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN: *const ::core::ffi::c_char =
1151    c"SDL.joystick.cap.mono_led".as_ptr();
1152
1153pub const SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN: *const ::core::ffi::c_char =
1154    c"SDL.joystick.cap.rgb_led".as_ptr();
1155
1156pub const SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN: *const ::core::ffi::c_char =
1157    c"SDL.joystick.cap.player_led".as_ptr();
1158
1159pub const SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN: *const ::core::ffi::c_char =
1160    c"SDL.joystick.cap.rumble".as_ptr();
1161
1162pub const SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN: *const ::core::ffi::c_char =
1163    c"SDL.joystick.cap.trigger_rumble".as_ptr();
1164
1165unsafe extern "C" {
1166    /// Get the implementation dependent name of a joystick.
1167    ///
1168    /// ## Parameters
1169    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1170    ///
1171    /// ## Return value
1172    /// Returns the name of the selected joystick. If no name can be found, this
1173    ///   function returns NULL; call [`SDL_GetError()`] for more information.
1174    ///
1175    /// ## Thread safety
1176    /// It is safe to call this function from any thread.
1177    ///
1178    /// ## Availability
1179    /// This function is available since SDL 3.2.0.
1180    ///
1181    /// ## See also
1182    /// - [`SDL_GetJoystickNameForID`]
1183    pub fn SDL_GetJoystickName(joystick: *mut SDL_Joystick) -> *const ::core::ffi::c_char;
1184}
1185
1186unsafe extern "C" {
1187    /// Get the implementation dependent path of a joystick.
1188    ///
1189    /// ## Parameters
1190    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1191    ///
1192    /// ## Return value
1193    /// Returns the path of the selected joystick. If no path can be found, this
1194    ///   function returns NULL; call [`SDL_GetError()`] for more information.
1195    ///
1196    /// ## Thread safety
1197    /// It is safe to call this function from any thread.
1198    ///
1199    /// ## Availability
1200    /// This function is available since SDL 3.2.0.
1201    ///
1202    /// ## See also
1203    /// - [`SDL_GetJoystickPathForID`]
1204    pub fn SDL_GetJoystickPath(joystick: *mut SDL_Joystick) -> *const ::core::ffi::c_char;
1205}
1206
1207unsafe extern "C" {
1208    /// Get the player index of an opened joystick.
1209    ///
1210    /// For XInput controllers this returns the XInput user index. Many joysticks
1211    /// will not be able to supply this information.
1212    ///
1213    /// ## Parameters
1214    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1215    ///
1216    /// ## Return value
1217    /// Returns the player index, or -1 if it's not available.
1218    ///
1219    /// ## Thread safety
1220    /// It is safe to call this function from any thread.
1221    ///
1222    /// ## Availability
1223    /// This function is available since SDL 3.2.0.
1224    ///
1225    /// ## See also
1226    /// - [`SDL_SetJoystickPlayerIndex`]
1227    pub fn SDL_GetJoystickPlayerIndex(joystick: *mut SDL_Joystick) -> ::core::ffi::c_int;
1228}
1229
1230unsafe extern "C" {
1231    /// Set the player index of an opened joystick.
1232    ///
1233    /// ## Parameters
1234    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1235    /// - `player_index`: player index to assign to this joystick, or -1 to clear
1236    ///   the player index and turn off player LEDs.
1237    ///
1238    /// ## Return value
1239    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1240    ///   information.
1241    ///
1242    /// ## Thread safety
1243    /// It is safe to call this function from any thread.
1244    ///
1245    /// ## Availability
1246    /// This function is available since SDL 3.2.0.
1247    ///
1248    /// ## See also
1249    /// - [`SDL_GetJoystickPlayerIndex`]
1250    pub fn SDL_SetJoystickPlayerIndex(
1251        joystick: *mut SDL_Joystick,
1252        player_index: ::core::ffi::c_int,
1253    ) -> ::core::primitive::bool;
1254}
1255
1256unsafe extern "C" {
1257    /// Get the implementation-dependent GUID for the joystick.
1258    ///
1259    /// This function requires an open joystick.
1260    ///
1261    /// ## Parameters
1262    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1263    ///
1264    /// ## Return value
1265    /// Returns the GUID of the given joystick. If called on an invalid index,
1266    ///   this function returns a zero GUID; call [`SDL_GetError()`] for more
1267    ///   information.
1268    ///
1269    /// ## Thread safety
1270    /// It is safe to call this function from any thread.
1271    ///
1272    /// ## Availability
1273    /// This function is available since SDL 3.2.0.
1274    ///
1275    /// ## See also
1276    /// - [`SDL_GetJoystickGUIDForID`]
1277    /// - [`SDL_GUIDToString`]
1278    pub fn SDL_GetJoystickGUID(joystick: *mut SDL_Joystick) -> SDL_GUID;
1279}
1280
1281unsafe extern "C" {
1282    /// Get the USB vendor ID of an opened joystick, if available.
1283    ///
1284    /// If the vendor ID isn't available this function returns 0.
1285    ///
1286    /// ## Parameters
1287    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1288    ///
1289    /// ## Return value
1290    /// Returns the USB vendor ID of the selected joystick, or 0 if unavailable.
1291    ///
1292    /// ## Thread safety
1293    /// It is safe to call this function from any thread.
1294    ///
1295    /// ## Availability
1296    /// This function is available since SDL 3.2.0.
1297    ///
1298    /// ## See also
1299    /// - [`SDL_GetJoystickVendorForID`]
1300    pub fn SDL_GetJoystickVendor(joystick: *mut SDL_Joystick) -> Uint16;
1301}
1302
1303unsafe extern "C" {
1304    /// Get the USB product ID of an opened joystick, if available.
1305    ///
1306    /// If the product ID isn't available this function returns 0.
1307    ///
1308    /// ## Parameters
1309    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1310    ///
1311    /// ## Return value
1312    /// Returns the USB product ID of the selected joystick, or 0 if unavailable.
1313    ///
1314    /// ## Thread safety
1315    /// It is safe to call this function from any thread.
1316    ///
1317    /// ## Availability
1318    /// This function is available since SDL 3.2.0.
1319    ///
1320    /// ## See also
1321    /// - [`SDL_GetJoystickProductForID`]
1322    pub fn SDL_GetJoystickProduct(joystick: *mut SDL_Joystick) -> Uint16;
1323}
1324
1325unsafe extern "C" {
1326    /// Get the product version of an opened joystick, if available.
1327    ///
1328    /// If the product version isn't available this function returns 0.
1329    ///
1330    /// ## Parameters
1331    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1332    ///
1333    /// ## Return value
1334    /// Returns the product version of the selected joystick, or 0 if unavailable.
1335    ///
1336    /// ## Thread safety
1337    /// It is safe to call this function from any thread.
1338    ///
1339    /// ## Availability
1340    /// This function is available since SDL 3.2.0.
1341    ///
1342    /// ## See also
1343    /// - [`SDL_GetJoystickProductVersionForID`]
1344    pub fn SDL_GetJoystickProductVersion(joystick: *mut SDL_Joystick) -> Uint16;
1345}
1346
1347unsafe extern "C" {
1348    /// Get the firmware version of an opened joystick, if available.
1349    ///
1350    /// If the firmware version isn't available this function returns 0.
1351    ///
1352    /// ## Parameters
1353    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1354    ///
1355    /// ## Return value
1356    /// Returns the firmware version of the selected joystick, or 0 if
1357    ///   unavailable.
1358    ///
1359    /// ## Thread safety
1360    /// It is safe to call this function from any thread.
1361    ///
1362    /// ## Availability
1363    /// This function is available since SDL 3.2.0.
1364    pub fn SDL_GetJoystickFirmwareVersion(joystick: *mut SDL_Joystick) -> Uint16;
1365}
1366
1367unsafe extern "C" {
1368    /// Get the serial number of an opened joystick, if available.
1369    ///
1370    /// Returns the serial number of the joystick, or NULL if it is not available.
1371    ///
1372    /// ## Parameters
1373    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1374    ///
1375    /// ## Return value
1376    /// Returns the serial number of the selected joystick, or NULL if
1377    ///   unavailable.
1378    ///
1379    /// ## Thread safety
1380    /// It is safe to call this function from any thread.
1381    ///
1382    /// ## Availability
1383    /// This function is available since SDL 3.2.0.
1384    pub fn SDL_GetJoystickSerial(joystick: *mut SDL_Joystick) -> *const ::core::ffi::c_char;
1385}
1386
1387unsafe extern "C" {
1388    /// Get the type of an opened joystick.
1389    ///
1390    /// ## Parameters
1391    /// - `joystick`: the [`SDL_Joystick`] obtained from [`SDL_OpenJoystick()`].
1392    ///
1393    /// ## Return value
1394    /// Returns the [`SDL_JoystickType`] of the selected joystick.
1395    ///
1396    /// ## Thread safety
1397    /// It is safe to call this function from any thread.
1398    ///
1399    /// ## Availability
1400    /// This function is available since SDL 3.2.0.
1401    ///
1402    /// ## See also
1403    /// - [`SDL_GetJoystickTypeForID`]
1404    pub fn SDL_GetJoystickType(joystick: *mut SDL_Joystick) -> SDL_JoystickType;
1405}
1406
1407unsafe extern "C" {
1408    /// Get the device information encoded in a [`SDL_GUID`] structure.
1409    ///
1410    /// ## Parameters
1411    /// - `guid`: the [`SDL_GUID`] you wish to get info about.
1412    /// - `vendor`: a pointer filled in with the device VID, or 0 if not
1413    ///   available.
1414    /// - `product`: a pointer filled in with the device PID, or 0 if not
1415    ///   available.
1416    /// - `version`: a pointer filled in with the device version, or 0 if not
1417    ///   available.
1418    /// - `crc16`: a pointer filled in with a CRC used to distinguish different
1419    ///   products with the same VID/PID, or 0 if not available.
1420    ///
1421    /// ## Thread safety
1422    /// It is safe to call this function from any thread.
1423    ///
1424    /// ## Availability
1425    /// This function is available since SDL 3.2.0.
1426    ///
1427    /// ## See also
1428    /// - [`SDL_GetJoystickGUIDForID`]
1429    pub fn SDL_GetJoystickGUIDInfo(
1430        guid: SDL_GUID,
1431        vendor: *mut Uint16,
1432        product: *mut Uint16,
1433        version: *mut Uint16,
1434        crc16: *mut Uint16,
1435    );
1436}
1437
1438unsafe extern "C" {
1439    /// Get the status of a specified joystick.
1440    ///
1441    /// ## Parameters
1442    /// - `joystick`: the joystick to query.
1443    ///
1444    /// ## Return value
1445    /// Returns true if the joystick has been opened, false if it has not; call
1446    ///   [`SDL_GetError()`] for more information.
1447    ///
1448    /// ## Thread safety
1449    /// It is safe to call this function from any thread.
1450    ///
1451    /// ## Availability
1452    /// This function is available since SDL 3.2.0.
1453    pub fn SDL_JoystickConnected(joystick: *mut SDL_Joystick) -> ::core::primitive::bool;
1454}
1455
1456unsafe extern "C" {
1457    /// Get the instance ID of an opened joystick.
1458    ///
1459    /// ## Parameters
1460    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1461    ///
1462    /// ## Return value
1463    /// Returns the instance ID of the specified joystick on success or 0 on
1464    ///   failure; call [`SDL_GetError()`] for more information.
1465    ///
1466    /// ## Thread safety
1467    /// It is safe to call this function from any thread.
1468    ///
1469    /// ## Availability
1470    /// This function is available since SDL 3.2.0.
1471    pub fn SDL_GetJoystickID(joystick: *mut SDL_Joystick) -> SDL_JoystickID;
1472}
1473
1474unsafe extern "C" {
1475    /// Get the number of general axis controls on a joystick.
1476    ///
1477    /// Often, the directional pad on a game controller will either look like 4
1478    /// separate buttons or a POV hat, and not axes, but all of this is up to the
1479    /// device and platform.
1480    ///
1481    /// ## Parameters
1482    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1483    ///
1484    /// ## Return value
1485    /// Returns the number of axis controls/number of axes on success or -1 on
1486    ///   failure; call [`SDL_GetError()`] for more information.
1487    ///
1488    /// ## Thread safety
1489    /// It is safe to call this function from any thread.
1490    ///
1491    /// ## Availability
1492    /// This function is available since SDL 3.2.0.
1493    ///
1494    /// ## See also
1495    /// - [`SDL_GetJoystickAxis`]
1496    /// - [`SDL_GetNumJoystickBalls`]
1497    /// - [`SDL_GetNumJoystickButtons`]
1498    /// - [`SDL_GetNumJoystickHats`]
1499    pub fn SDL_GetNumJoystickAxes(joystick: *mut SDL_Joystick) -> ::core::ffi::c_int;
1500}
1501
1502unsafe extern "C" {
1503    /// Get the number of trackballs on a joystick.
1504    ///
1505    /// Joystick trackballs have only relative motion events associated with them
1506    /// and their state cannot be polled.
1507    ///
1508    /// Most joysticks do not have trackballs.
1509    ///
1510    /// ## Parameters
1511    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1512    ///
1513    /// ## Return value
1514    /// Returns the number of trackballs on success or -1 on failure; call
1515    ///   [`SDL_GetError()`] for more information.
1516    ///
1517    /// ## Thread safety
1518    /// It is safe to call this function from any thread.
1519    ///
1520    /// ## Availability
1521    /// This function is available since SDL 3.2.0.
1522    ///
1523    /// ## See also
1524    /// - [`SDL_GetJoystickBall`]
1525    /// - [`SDL_GetNumJoystickAxes`]
1526    /// - [`SDL_GetNumJoystickButtons`]
1527    /// - [`SDL_GetNumJoystickHats`]
1528    pub fn SDL_GetNumJoystickBalls(joystick: *mut SDL_Joystick) -> ::core::ffi::c_int;
1529}
1530
1531unsafe extern "C" {
1532    /// Get the number of POV hats on a joystick.
1533    ///
1534    /// ## Parameters
1535    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1536    ///
1537    /// ## Return value
1538    /// Returns the number of POV hats on success or -1 on failure; call
1539    ///   [`SDL_GetError()`] for more information.
1540    ///
1541    /// ## Thread safety
1542    /// It is safe to call this function from any thread.
1543    ///
1544    /// ## Availability
1545    /// This function is available since SDL 3.2.0.
1546    ///
1547    /// ## See also
1548    /// - [`SDL_GetJoystickHat`]
1549    /// - [`SDL_GetNumJoystickAxes`]
1550    /// - [`SDL_GetNumJoystickBalls`]
1551    /// - [`SDL_GetNumJoystickButtons`]
1552    pub fn SDL_GetNumJoystickHats(joystick: *mut SDL_Joystick) -> ::core::ffi::c_int;
1553}
1554
1555unsafe extern "C" {
1556    /// Get the number of buttons on a joystick.
1557    ///
1558    /// ## Parameters
1559    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1560    ///
1561    /// ## Return value
1562    /// Returns the number of buttons on success or -1 on failure; call
1563    ///   [`SDL_GetError()`] for more information.
1564    ///
1565    /// ## Thread safety
1566    /// It is safe to call this function from any thread.
1567    ///
1568    /// ## Availability
1569    /// This function is available since SDL 3.2.0.
1570    ///
1571    /// ## See also
1572    /// - [`SDL_GetJoystickButton`]
1573    /// - [`SDL_GetNumJoystickAxes`]
1574    /// - [`SDL_GetNumJoystickBalls`]
1575    /// - [`SDL_GetNumJoystickHats`]
1576    pub fn SDL_GetNumJoystickButtons(joystick: *mut SDL_Joystick) -> ::core::ffi::c_int;
1577}
1578
1579unsafe extern "C" {
1580    /// Set the state of joystick event processing.
1581    ///
1582    /// If joystick events are disabled, you must call [`SDL_UpdateJoysticks()`]
1583    /// yourself and check the state of the joystick when you want joystick
1584    /// information.
1585    ///
1586    /// ## Parameters
1587    /// - `enabled`: whether to process joystick events or not.
1588    ///
1589    /// ## Thread safety
1590    /// It is safe to call this function from any thread.
1591    ///
1592    /// ## Availability
1593    /// This function is available since SDL 3.2.0.
1594    ///
1595    /// ## See also
1596    /// - [`SDL_JoystickEventsEnabled`]
1597    /// - [`SDL_UpdateJoysticks`]
1598    pub fn SDL_SetJoystickEventsEnabled(enabled: ::core::primitive::bool);
1599}
1600
1601unsafe extern "C" {
1602    /// Query the state of joystick event processing.
1603    ///
1604    /// If joystick events are disabled, you must call [`SDL_UpdateJoysticks()`]
1605    /// yourself and check the state of the joystick when you want joystick
1606    /// information.
1607    ///
1608    /// ## Return value
1609    /// Returns true if joystick events are being processed, false otherwise.
1610    ///
1611    /// ## Thread safety
1612    /// It is safe to call this function from any thread.
1613    ///
1614    /// ## Availability
1615    /// This function is available since SDL 3.2.0.
1616    ///
1617    /// ## See also
1618    /// - [`SDL_SetJoystickEventsEnabled`]
1619    pub fn SDL_JoystickEventsEnabled() -> ::core::primitive::bool;
1620}
1621
1622unsafe extern "C" {
1623    /// Update the current state of the open joysticks.
1624    ///
1625    /// This is called automatically by the event loop if any joystick events are
1626    /// enabled.
1627    ///
1628    /// ## Thread safety
1629    /// It is safe to call this function from any thread.
1630    ///
1631    /// ## Availability
1632    /// This function is available since SDL 3.2.0.
1633    pub fn SDL_UpdateJoysticks();
1634}
1635
1636unsafe extern "C" {
1637    /// Get the current state of an axis control on a joystick.
1638    ///
1639    /// SDL makes no promises about what part of the joystick any given axis refers
1640    /// to. Your game should have some sort of configuration UI to let users
1641    /// specify what each axis should be bound to. Alternately, SDL's higher-level
1642    /// Game Controller API makes a great effort to apply order to this lower-level
1643    /// interface, so you know that a specific axis is the "left thumb stick," etc.
1644    ///
1645    /// The value returned by [`SDL_GetJoystickAxis()`] is a signed integer (-32768 to
1646    /// 32767) representing the current position of the axis. It may be necessary
1647    /// to impose certain tolerances on these values to account for jitter.
1648    ///
1649    /// ## Parameters
1650    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1651    /// - `axis`: the axis to query; the axis indices start at index 0.
1652    ///
1653    /// ## Return value
1654    /// Returns a 16-bit signed integer representing the current position of the
1655    ///   axis or 0 on failure; call [`SDL_GetError()`] for more information.
1656    ///
1657    /// ## Thread safety
1658    /// It is safe to call this function from any thread.
1659    ///
1660    /// ## Availability
1661    /// This function is available since SDL 3.2.0.
1662    ///
1663    /// ## See also
1664    /// - [`SDL_GetNumJoystickAxes`]
1665    pub fn SDL_GetJoystickAxis(joystick: *mut SDL_Joystick, axis: ::core::ffi::c_int) -> Sint16;
1666}
1667
1668unsafe extern "C" {
1669    /// Get the initial state of an axis control on a joystick.
1670    ///
1671    /// The state is a value ranging from -32768 to 32767.
1672    ///
1673    /// The axis indices start at index 0.
1674    ///
1675    /// ## Parameters
1676    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1677    /// - `axis`: the axis to query; the axis indices start at index 0.
1678    /// - `state`: upon return, the initial value is supplied here.
1679    ///
1680    /// ## Return value
1681    /// Returns true if this axis has any initial value, or false if not.
1682    ///
1683    /// ## Thread safety
1684    /// It is safe to call this function from any thread.
1685    ///
1686    /// ## Availability
1687    /// This function is available since SDL 3.2.0.
1688    pub fn SDL_GetJoystickAxisInitialState(
1689        joystick: *mut SDL_Joystick,
1690        axis: ::core::ffi::c_int,
1691        state: *mut Sint16,
1692    ) -> ::core::primitive::bool;
1693}
1694
1695unsafe extern "C" {
1696    /// Get the ball axis change since the last poll.
1697    ///
1698    /// Trackballs can only return relative motion since the last call to
1699    /// [`SDL_GetJoystickBall()`], these motion deltas are placed into `dx` and `dy`.
1700    ///
1701    /// Most joysticks do not have trackballs.
1702    ///
1703    /// ## Parameters
1704    /// - `joystick`: the [`SDL_Joystick`] to query.
1705    /// - `ball`: the ball index to query; ball indices start at index 0.
1706    /// - `dx`: stores the difference in the x axis position since the last poll.
1707    /// - `dy`: stores the difference in the y axis position since the last poll.
1708    ///
1709    /// ## Return value
1710    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1711    ///   information.
1712    ///
1713    /// ## Thread safety
1714    /// It is safe to call this function from any thread.
1715    ///
1716    /// ## Availability
1717    /// This function is available since SDL 3.2.0.
1718    ///
1719    /// ## See also
1720    /// - [`SDL_GetNumJoystickBalls`]
1721    pub fn SDL_GetJoystickBall(
1722        joystick: *mut SDL_Joystick,
1723        ball: ::core::ffi::c_int,
1724        dx: *mut ::core::ffi::c_int,
1725        dy: *mut ::core::ffi::c_int,
1726    ) -> ::core::primitive::bool;
1727}
1728
1729unsafe extern "C" {
1730    /// Get the current state of a POV hat on a joystick.
1731    ///
1732    /// The returned value will be one of the `SDL_HAT_*` values.
1733    ///
1734    /// ## Parameters
1735    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1736    /// - `hat`: the hat index to get the state from; indices start at index 0.
1737    ///
1738    /// ## Return value
1739    /// Returns the current hat position.
1740    ///
1741    /// ## Thread safety
1742    /// It is safe to call this function from any thread.
1743    ///
1744    /// ## Availability
1745    /// This function is available since SDL 3.2.0.
1746    ///
1747    /// ## See also
1748    /// - [`SDL_GetNumJoystickHats`]
1749    pub fn SDL_GetJoystickHat(joystick: *mut SDL_Joystick, hat: ::core::ffi::c_int) -> Uint8;
1750}
1751
1752pub const SDL_HAT_CENTERED: Uint8 = (0x00 as Uint8);
1753
1754pub const SDL_HAT_UP: Uint8 = (0x01 as Uint8);
1755
1756pub const SDL_HAT_RIGHT: Uint8 = (0x02 as Uint8);
1757
1758pub const SDL_HAT_DOWN: Uint8 = (0x04 as Uint8);
1759
1760pub const SDL_HAT_LEFT: Uint8 = (0x08 as Uint8);
1761
1762pub const SDL_HAT_RIGHTUP: Uint8 = (SDL_HAT_RIGHT | SDL_HAT_UP);
1763
1764pub const SDL_HAT_RIGHTDOWN: Uint8 = (SDL_HAT_RIGHT | SDL_HAT_DOWN);
1765
1766pub const SDL_HAT_LEFTUP: Uint8 = (SDL_HAT_LEFT | SDL_HAT_UP);
1767
1768pub const SDL_HAT_LEFTDOWN: Uint8 = (SDL_HAT_LEFT | SDL_HAT_DOWN);
1769
1770unsafe extern "C" {
1771    /// Get the current state of a button on a joystick.
1772    ///
1773    /// ## Parameters
1774    /// - `joystick`: an [`SDL_Joystick`] structure containing joystick information.
1775    /// - `button`: the button index to get the state from; indices start at
1776    ///   index 0.
1777    ///
1778    /// ## Return value
1779    /// Returns true if the button is pressed, false otherwise.
1780    ///
1781    /// ## Thread safety
1782    /// It is safe to call this function from any thread.
1783    ///
1784    /// ## Availability
1785    /// This function is available since SDL 3.2.0.
1786    ///
1787    /// ## See also
1788    /// - [`SDL_GetNumJoystickButtons`]
1789    pub fn SDL_GetJoystickButton(
1790        joystick: *mut SDL_Joystick,
1791        button: ::core::ffi::c_int,
1792    ) -> ::core::primitive::bool;
1793}
1794
1795unsafe extern "C" {
1796    /// Start a rumble effect.
1797    ///
1798    /// Each call to this function cancels any previous rumble effect, and calling
1799    /// it with 0 intensity stops any rumbling.
1800    ///
1801    /// This function requires you to process SDL events or call
1802    /// [`SDL_UpdateJoysticks()`] to update rumble state.
1803    ///
1804    /// ## Parameters
1805    /// - `joystick`: the joystick to vibrate.
1806    /// - `low_frequency_rumble`: the intensity of the low frequency (left)
1807    ///   rumble motor, from 0 to 0xFFFF.
1808    /// - `high_frequency_rumble`: the intensity of the high frequency (right)
1809    ///   rumble motor, from 0 to 0xFFFF.
1810    /// - `duration_ms`: the duration of the rumble effect, in milliseconds.
1811    ///
1812    /// ## Return value
1813    /// Returns true, or false if rumble isn't supported on this joystick.
1814    ///
1815    /// ## Thread safety
1816    /// It is safe to call this function from any thread.
1817    ///
1818    /// ## Availability
1819    /// This function is available since SDL 3.2.0.
1820    pub fn SDL_RumbleJoystick(
1821        joystick: *mut SDL_Joystick,
1822        low_frequency_rumble: Uint16,
1823        high_frequency_rumble: Uint16,
1824        duration_ms: Uint32,
1825    ) -> ::core::primitive::bool;
1826}
1827
1828unsafe extern "C" {
1829    /// Start a rumble effect in the joystick's triggers.
1830    ///
1831    /// Each call to this function cancels any previous trigger rumble effect, and
1832    /// calling it with 0 intensity stops any rumbling.
1833    ///
1834    /// Note that this is rumbling of the _triggers_ and not the game controller as
1835    /// a whole. This is currently only supported on Xbox One controllers. If you
1836    /// want the (more common) whole-controller rumble, use [`SDL_RumbleJoystick()`]
1837    /// instead.
1838    ///
1839    /// This function requires you to process SDL events or call
1840    /// [`SDL_UpdateJoysticks()`] to update rumble state.
1841    ///
1842    /// ## Parameters
1843    /// - `joystick`: the joystick to vibrate.
1844    /// - `left_rumble`: the intensity of the left trigger rumble motor, from 0
1845    ///   to 0xFFFF.
1846    /// - `right_rumble`: the intensity of the right trigger rumble motor, from 0
1847    ///   to 0xFFFF.
1848    /// - `duration_ms`: the duration of the rumble effect, in milliseconds.
1849    ///
1850    /// ## Return value
1851    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1852    ///   information.
1853    ///
1854    /// ## Thread safety
1855    /// It is safe to call this function from any thread.
1856    ///
1857    /// ## Availability
1858    /// This function is available since SDL 3.2.0.
1859    ///
1860    /// ## See also
1861    /// - [`SDL_RumbleJoystick`]
1862    pub fn SDL_RumbleJoystickTriggers(
1863        joystick: *mut SDL_Joystick,
1864        left_rumble: Uint16,
1865        right_rumble: Uint16,
1866        duration_ms: Uint32,
1867    ) -> ::core::primitive::bool;
1868}
1869
1870unsafe extern "C" {
1871    /// Update a joystick's LED color.
1872    ///
1873    /// An example of a joystick LED is the light on the back of a PlayStation 4's
1874    /// DualShock 4 controller.
1875    ///
1876    /// For joysticks with a single color LED, the maximum of the RGB values will
1877    /// be used as the LED brightness.
1878    ///
1879    /// ## Parameters
1880    /// - `joystick`: the joystick to update.
1881    /// - `red`: the intensity of the red LED.
1882    /// - `green`: the intensity of the green LED.
1883    /// - `blue`: the intensity of the blue LED.
1884    ///
1885    /// ## Return value
1886    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1887    ///   information.
1888    ///
1889    /// ## Thread safety
1890    /// It is safe to call this function from any thread.
1891    ///
1892    /// ## Availability
1893    /// This function is available since SDL 3.2.0.
1894    pub fn SDL_SetJoystickLED(
1895        joystick: *mut SDL_Joystick,
1896        red: Uint8,
1897        green: Uint8,
1898        blue: Uint8,
1899    ) -> ::core::primitive::bool;
1900}
1901
1902unsafe extern "C" {
1903    /// Send a joystick specific effect packet.
1904    ///
1905    /// ## Parameters
1906    /// - `joystick`: the joystick to affect.
1907    /// - `data`: the data to send to the joystick.
1908    /// - `size`: the size of the data to send to the joystick.
1909    ///
1910    /// ## Return value
1911    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1912    ///   information.
1913    ///
1914    /// ## Thread safety
1915    /// It is safe to call this function from any thread.
1916    ///
1917    /// ## Availability
1918    /// This function is available since SDL 3.2.0.
1919    pub fn SDL_SendJoystickEffect(
1920        joystick: *mut SDL_Joystick,
1921        data: *const ::core::ffi::c_void,
1922        size: ::core::ffi::c_int,
1923    ) -> ::core::primitive::bool;
1924}
1925
1926unsafe extern "C" {
1927    /// Close a joystick previously opened with [`SDL_OpenJoystick()`].
1928    ///
1929    /// ## Parameters
1930    /// - `joystick`: the joystick device to close.
1931    ///
1932    /// ## Thread safety
1933    /// It is safe to call this function from any thread.
1934    ///
1935    /// ## Availability
1936    /// This function is available since SDL 3.2.0.
1937    ///
1938    /// ## See also
1939    /// - [`SDL_OpenJoystick`]
1940    pub fn SDL_CloseJoystick(joystick: *mut SDL_Joystick);
1941}
1942
1943unsafe extern "C" {
1944    /// Get the connection state of a joystick.
1945    ///
1946    /// ## Parameters
1947    /// - `joystick`: the joystick to query.
1948    ///
1949    /// ## Return value
1950    /// Returns the connection state on success or
1951    ///   [`SDL_JOYSTICK_CONNECTION_INVALID`] on failure; call [`SDL_GetError()`]
1952    ///   for more information.
1953    ///
1954    /// ## Thread safety
1955    /// It is safe to call this function from any thread.
1956    ///
1957    /// ## Availability
1958    /// This function is available since SDL 3.2.0.
1959    pub fn SDL_GetJoystickConnectionState(
1960        joystick: *mut SDL_Joystick,
1961    ) -> SDL_JoystickConnectionState;
1962}
1963
1964unsafe extern "C" {
1965    /// Get the battery state of a joystick.
1966    ///
1967    /// You should never take a battery status as absolute truth. Batteries
1968    /// (especially failing batteries) are delicate hardware, and the values
1969    /// reported here are best estimates based on what that hardware reports. It's
1970    /// not uncommon for older batteries to lose stored power much faster than it
1971    /// reports, or completely drain when reporting it has 20 percent left, etc.
1972    ///
1973    /// ## Parameters
1974    /// - `joystick`: the joystick to query.
1975    /// - `percent`: a pointer filled in with the percentage of battery life
1976    ///   left, between 0 and 100, or NULL to ignore. This will be
1977    ///   filled in with -1 we can't determine a value or there is no
1978    ///   battery.
1979    ///
1980    /// ## Return value
1981    /// Returns the current battery state or [`SDL_POWERSTATE_ERROR`] on failure;
1982    ///   call [`SDL_GetError()`] for more information.
1983    ///
1984    /// ## Thread safety
1985    /// It is safe to call this function from any thread.
1986    ///
1987    /// ## Availability
1988    /// This function is available since SDL 3.2.0.
1989    pub fn SDL_GetJoystickPowerInfo(
1990        joystick: *mut SDL_Joystick,
1991        percent: *mut ::core::ffi::c_int,
1992    ) -> SDL_PowerState;
1993}
1994
1995/// The joystick structure used to identify an SDL joystick.
1996///
1997/// This is opaque data.
1998///
1999/// ## Availability
2000/// This struct is available since SDL 3.2.0.
2001#[repr(C)]
2002pub struct SDL_Joystick {
2003    _opaque: [::core::primitive::u8; 0],
2004}
2005
2006#[cfg(doc)]
2007use crate::everything::*;