sdl3_sys/generated/
mouse.rs

1//! Any GUI application has to deal with the mouse, and SDL provides functions
2//! to manage mouse input and the displayed cursor.
3//!
4//! Most interactions with the mouse will come through the event subsystem.
5//! Moving a mouse generates an [`SDL_EVENT_MOUSE_MOTION`] event, pushing a button
6//! generates [`SDL_EVENT_MOUSE_BUTTON_DOWN`], etc, but one can also query the
7//! current state of the mouse at any time with [`SDL_GetMouseState()`].
8//!
9//! For certain games, it's useful to disassociate the mouse cursor from mouse
10//! input. An FPS, for example, would not want the player's motion to stop as
11//! the mouse hits the edge of the window. For these scenarios, use
12//! [`SDL_SetWindowRelativeMouseMode()`], which hides the cursor, grabs mouse input
13//! to the window, and reads mouse input no matter how far it moves.
14//!
15//! Games that want the system to track the mouse but want to draw their own
16//! cursor can use [`SDL_HideCursor()`] and [`SDL_ShowCursor()`]. It might be more
17//! efficient to let the system manage the cursor, if possible, using
18//! [`SDL_SetCursor()`] with a custom image made through [`SDL_CreateColorCursor()`],
19//! or perhaps just a specific system cursor from [`SDL_CreateSystemCursor()`].
20//!
21//! SDL can, on many platforms, differentiate between multiple connected mice,
22//! allowing for interesting input scenarios and multiplayer games. They can be
23//! enumerated with [`SDL_GetMice()`], and SDL will send [`SDL_EVENT_MOUSE_ADDED`] and
24//! [`SDL_EVENT_MOUSE_REMOVED`] events as they are connected and unplugged.
25//!
26//! Since many apps only care about basic mouse input, SDL offers a virtual
27//! mouse device for touch and pen input, which often can make a desktop
28//! application work on a touchscreen phone without any code changes. Apps that
29//! care about touch/pen separately from mouse input should filter out events
30//! with a `which` field of SDL_TOUCH_MOUSEID/SDL_PEN_MOUSEID.
31
32use super::stdinc::*;
33
34use super::error::*;
35
36use super::surface::*;
37
38use super::video::*;
39
40/// This is a unique ID for a mouse for the time it is connected to the system,
41/// and is never reused for the lifetime of the application.
42///
43/// If the mouse is disconnected and reconnected, it will get a new ID.
44///
45/// The value 0 is an invalid ID.
46///
47/// ## Availability
48/// This datatype is available since SDL 3.2.0.
49#[repr(transparent)]
50#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
51#[cfg_attr(feature = "debug-impls", derive(Debug))]
52pub struct SDL_MouseID(pub Uint32);
53
54impl ::core::cmp::PartialEq<Uint32> for SDL_MouseID {
55    #[inline(always)]
56    fn eq(&self, other: &Uint32) -> bool {
57        &self.0 == other
58    }
59}
60
61impl ::core::cmp::PartialEq<SDL_MouseID> for Uint32 {
62    #[inline(always)]
63    fn eq(&self, other: &SDL_MouseID) -> bool {
64        self == &other.0
65    }
66}
67
68impl From<SDL_MouseID> for Uint32 {
69    #[inline(always)]
70    fn from(value: SDL_MouseID) -> Self {
71        value.0
72    }
73}
74
75#[cfg(feature = "metadata")]
76impl sdl3_sys::metadata::GroupMetadata for SDL_MouseID {
77    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
78        &crate::metadata::mouse::METADATA_SDL_MouseID;
79}
80
81/// Cursor types for [`SDL_CreateSystemCursor()`].
82///
83/// ## Availability
84/// This enum is available since SDL 3.2.0.
85///
86/// ## Known values (`sdl3-sys`)
87/// | Associated constant | Global constant | Description |
88/// | ------------------- | --------------- | ----------- |
89/// | [`DEFAULT`](SDL_SystemCursor::DEFAULT) | [`SDL_SYSTEM_CURSOR_DEFAULT`] | Default cursor. Usually an arrow. |
90/// | [`TEXT`](SDL_SystemCursor::TEXT) | [`SDL_SYSTEM_CURSOR_TEXT`] | Text selection. Usually an I-beam. |
91/// | [`WAIT`](SDL_SystemCursor::WAIT) | [`SDL_SYSTEM_CURSOR_WAIT`] | Wait. Usually an hourglass or watch or spinning ball. |
92/// | [`CROSSHAIR`](SDL_SystemCursor::CROSSHAIR) | [`SDL_SYSTEM_CURSOR_CROSSHAIR`] | Crosshair. |
93/// | [`PROGRESS`](SDL_SystemCursor::PROGRESS) | [`SDL_SYSTEM_CURSOR_PROGRESS`] | Program is busy but still interactive. Usually it's WAIT with an arrow. |
94/// | [`NWSE_RESIZE`](SDL_SystemCursor::NWSE_RESIZE) | [`SDL_SYSTEM_CURSOR_NWSE_RESIZE`] | Double arrow pointing northwest and southeast. |
95/// | [`NESW_RESIZE`](SDL_SystemCursor::NESW_RESIZE) | [`SDL_SYSTEM_CURSOR_NESW_RESIZE`] | Double arrow pointing northeast and southwest. |
96/// | [`EW_RESIZE`](SDL_SystemCursor::EW_RESIZE) | [`SDL_SYSTEM_CURSOR_EW_RESIZE`] | Double arrow pointing west and east. |
97/// | [`NS_RESIZE`](SDL_SystemCursor::NS_RESIZE) | [`SDL_SYSTEM_CURSOR_NS_RESIZE`] | Double arrow pointing north and south. |
98/// | [`MOVE`](SDL_SystemCursor::MOVE) | [`SDL_SYSTEM_CURSOR_MOVE`] | Four pointed arrow pointing north, south, east, and west. |
99/// | [`NOT_ALLOWED`](SDL_SystemCursor::NOT_ALLOWED) | [`SDL_SYSTEM_CURSOR_NOT_ALLOWED`] | Not permitted. Usually a slashed circle or crossbones. |
100/// | [`POINTER`](SDL_SystemCursor::POINTER) | [`SDL_SYSTEM_CURSOR_POINTER`] | Pointer that indicates a link. Usually a pointing hand. |
101/// | [`NW_RESIZE`](SDL_SystemCursor::NW_RESIZE) | [`SDL_SYSTEM_CURSOR_NW_RESIZE`] | Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE. |
102/// | [`N_RESIZE`](SDL_SystemCursor::N_RESIZE) | [`SDL_SYSTEM_CURSOR_N_RESIZE`] | Window resize top. May be NS_RESIZE. |
103/// | [`NE_RESIZE`](SDL_SystemCursor::NE_RESIZE) | [`SDL_SYSTEM_CURSOR_NE_RESIZE`] | Window resize top-right. May be NESW_RESIZE. |
104/// | [`E_RESIZE`](SDL_SystemCursor::E_RESIZE) | [`SDL_SYSTEM_CURSOR_E_RESIZE`] | Window resize right. May be EW_RESIZE. |
105/// | [`SE_RESIZE`](SDL_SystemCursor::SE_RESIZE) | [`SDL_SYSTEM_CURSOR_SE_RESIZE`] | Window resize bottom-right. May be NWSE_RESIZE. |
106/// | [`S_RESIZE`](SDL_SystemCursor::S_RESIZE) | [`SDL_SYSTEM_CURSOR_S_RESIZE`] | Window resize bottom. May be NS_RESIZE. |
107/// | [`SW_RESIZE`](SDL_SystemCursor::SW_RESIZE) | [`SDL_SYSTEM_CURSOR_SW_RESIZE`] | Window resize bottom-left. May be NESW_RESIZE. |
108/// | [`W_RESIZE`](SDL_SystemCursor::W_RESIZE) | [`SDL_SYSTEM_CURSOR_W_RESIZE`] | Window resize left. May be EW_RESIZE. |
109/// | [`COUNT`](SDL_SystemCursor::COUNT) | [`SDL_SYSTEM_CURSOR_COUNT`] | |
110#[repr(transparent)]
111#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
112pub struct SDL_SystemCursor(pub ::core::ffi::c_int);
113
114impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_SystemCursor {
115    #[inline(always)]
116    fn eq(&self, other: &::core::ffi::c_int) -> bool {
117        &self.0 == other
118    }
119}
120
121impl ::core::cmp::PartialEq<SDL_SystemCursor> for ::core::ffi::c_int {
122    #[inline(always)]
123    fn eq(&self, other: &SDL_SystemCursor) -> bool {
124        self == &other.0
125    }
126}
127
128impl From<SDL_SystemCursor> for ::core::ffi::c_int {
129    #[inline(always)]
130    fn from(value: SDL_SystemCursor) -> Self {
131        value.0
132    }
133}
134
135#[cfg(feature = "debug-impls")]
136impl ::core::fmt::Debug for SDL_SystemCursor {
137    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
138        #[allow(unreachable_patterns)]
139        f.write_str(match *self {
140            Self::DEFAULT => "SDL_SYSTEM_CURSOR_DEFAULT",
141            Self::TEXT => "SDL_SYSTEM_CURSOR_TEXT",
142            Self::WAIT => "SDL_SYSTEM_CURSOR_WAIT",
143            Self::CROSSHAIR => "SDL_SYSTEM_CURSOR_CROSSHAIR",
144            Self::PROGRESS => "SDL_SYSTEM_CURSOR_PROGRESS",
145            Self::NWSE_RESIZE => "SDL_SYSTEM_CURSOR_NWSE_RESIZE",
146            Self::NESW_RESIZE => "SDL_SYSTEM_CURSOR_NESW_RESIZE",
147            Self::EW_RESIZE => "SDL_SYSTEM_CURSOR_EW_RESIZE",
148            Self::NS_RESIZE => "SDL_SYSTEM_CURSOR_NS_RESIZE",
149            Self::MOVE => "SDL_SYSTEM_CURSOR_MOVE",
150            Self::NOT_ALLOWED => "SDL_SYSTEM_CURSOR_NOT_ALLOWED",
151            Self::POINTER => "SDL_SYSTEM_CURSOR_POINTER",
152            Self::NW_RESIZE => "SDL_SYSTEM_CURSOR_NW_RESIZE",
153            Self::N_RESIZE => "SDL_SYSTEM_CURSOR_N_RESIZE",
154            Self::NE_RESIZE => "SDL_SYSTEM_CURSOR_NE_RESIZE",
155            Self::E_RESIZE => "SDL_SYSTEM_CURSOR_E_RESIZE",
156            Self::SE_RESIZE => "SDL_SYSTEM_CURSOR_SE_RESIZE",
157            Self::S_RESIZE => "SDL_SYSTEM_CURSOR_S_RESIZE",
158            Self::SW_RESIZE => "SDL_SYSTEM_CURSOR_SW_RESIZE",
159            Self::W_RESIZE => "SDL_SYSTEM_CURSOR_W_RESIZE",
160            Self::COUNT => "SDL_SYSTEM_CURSOR_COUNT",
161
162            _ => return write!(f, "SDL_SystemCursor({})", self.0),
163        })
164    }
165}
166
167impl SDL_SystemCursor {
168    /// Default cursor. Usually an arrow.
169    pub const DEFAULT: Self = Self((0 as ::core::ffi::c_int));
170    /// Text selection. Usually an I-beam.
171    pub const TEXT: Self = Self((1 as ::core::ffi::c_int));
172    /// Wait. Usually an hourglass or watch or spinning ball.
173    pub const WAIT: Self = Self((2 as ::core::ffi::c_int));
174    /// Crosshair.
175    pub const CROSSHAIR: Self = Self((3 as ::core::ffi::c_int));
176    /// Program is busy but still interactive. Usually it's WAIT with an arrow.
177    pub const PROGRESS: Self = Self((4 as ::core::ffi::c_int));
178    /// Double arrow pointing northwest and southeast.
179    pub const NWSE_RESIZE: Self = Self((5 as ::core::ffi::c_int));
180    /// Double arrow pointing northeast and southwest.
181    pub const NESW_RESIZE: Self = Self((6 as ::core::ffi::c_int));
182    /// Double arrow pointing west and east.
183    pub const EW_RESIZE: Self = Self((7 as ::core::ffi::c_int));
184    /// Double arrow pointing north and south.
185    pub const NS_RESIZE: Self = Self((8 as ::core::ffi::c_int));
186    /// Four pointed arrow pointing north, south, east, and west.
187    pub const MOVE: Self = Self((9 as ::core::ffi::c_int));
188    /// Not permitted. Usually a slashed circle or crossbones.
189    pub const NOT_ALLOWED: Self = Self((10 as ::core::ffi::c_int));
190    /// Pointer that indicates a link. Usually a pointing hand.
191    pub const POINTER: Self = Self((11 as ::core::ffi::c_int));
192    /// Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE.
193    pub const NW_RESIZE: Self = Self((12 as ::core::ffi::c_int));
194    /// Window resize top. May be NS_RESIZE.
195    pub const N_RESIZE: Self = Self((13 as ::core::ffi::c_int));
196    /// Window resize top-right. May be NESW_RESIZE.
197    pub const NE_RESIZE: Self = Self((14 as ::core::ffi::c_int));
198    /// Window resize right. May be EW_RESIZE.
199    pub const E_RESIZE: Self = Self((15 as ::core::ffi::c_int));
200    /// Window resize bottom-right. May be NWSE_RESIZE.
201    pub const SE_RESIZE: Self = Self((16 as ::core::ffi::c_int));
202    /// Window resize bottom. May be NS_RESIZE.
203    pub const S_RESIZE: Self = Self((17 as ::core::ffi::c_int));
204    /// Window resize bottom-left. May be NESW_RESIZE.
205    pub const SW_RESIZE: Self = Self((18 as ::core::ffi::c_int));
206    /// Window resize left. May be EW_RESIZE.
207    pub const W_RESIZE: Self = Self((19 as ::core::ffi::c_int));
208    pub const COUNT: Self = Self((20 as ::core::ffi::c_int));
209}
210
211/// Default cursor. Usually an arrow.
212pub const SDL_SYSTEM_CURSOR_DEFAULT: SDL_SystemCursor = SDL_SystemCursor::DEFAULT;
213/// Text selection. Usually an I-beam.
214pub const SDL_SYSTEM_CURSOR_TEXT: SDL_SystemCursor = SDL_SystemCursor::TEXT;
215/// Wait. Usually an hourglass or watch or spinning ball.
216pub const SDL_SYSTEM_CURSOR_WAIT: SDL_SystemCursor = SDL_SystemCursor::WAIT;
217/// Crosshair.
218pub const SDL_SYSTEM_CURSOR_CROSSHAIR: SDL_SystemCursor = SDL_SystemCursor::CROSSHAIR;
219/// Program is busy but still interactive. Usually it's WAIT with an arrow.
220pub const SDL_SYSTEM_CURSOR_PROGRESS: SDL_SystemCursor = SDL_SystemCursor::PROGRESS;
221/// Double arrow pointing northwest and southeast.
222pub const SDL_SYSTEM_CURSOR_NWSE_RESIZE: SDL_SystemCursor = SDL_SystemCursor::NWSE_RESIZE;
223/// Double arrow pointing northeast and southwest.
224pub const SDL_SYSTEM_CURSOR_NESW_RESIZE: SDL_SystemCursor = SDL_SystemCursor::NESW_RESIZE;
225/// Double arrow pointing west and east.
226pub const SDL_SYSTEM_CURSOR_EW_RESIZE: SDL_SystemCursor = SDL_SystemCursor::EW_RESIZE;
227/// Double arrow pointing north and south.
228pub const SDL_SYSTEM_CURSOR_NS_RESIZE: SDL_SystemCursor = SDL_SystemCursor::NS_RESIZE;
229/// Four pointed arrow pointing north, south, east, and west.
230pub const SDL_SYSTEM_CURSOR_MOVE: SDL_SystemCursor = SDL_SystemCursor::MOVE;
231/// Not permitted. Usually a slashed circle or crossbones.
232pub const SDL_SYSTEM_CURSOR_NOT_ALLOWED: SDL_SystemCursor = SDL_SystemCursor::NOT_ALLOWED;
233/// Pointer that indicates a link. Usually a pointing hand.
234pub const SDL_SYSTEM_CURSOR_POINTER: SDL_SystemCursor = SDL_SystemCursor::POINTER;
235/// Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE.
236pub const SDL_SYSTEM_CURSOR_NW_RESIZE: SDL_SystemCursor = SDL_SystemCursor::NW_RESIZE;
237/// Window resize top. May be NS_RESIZE.
238pub const SDL_SYSTEM_CURSOR_N_RESIZE: SDL_SystemCursor = SDL_SystemCursor::N_RESIZE;
239/// Window resize top-right. May be NESW_RESIZE.
240pub const SDL_SYSTEM_CURSOR_NE_RESIZE: SDL_SystemCursor = SDL_SystemCursor::NE_RESIZE;
241/// Window resize right. May be EW_RESIZE.
242pub const SDL_SYSTEM_CURSOR_E_RESIZE: SDL_SystemCursor = SDL_SystemCursor::E_RESIZE;
243/// Window resize bottom-right. May be NWSE_RESIZE.
244pub const SDL_SYSTEM_CURSOR_SE_RESIZE: SDL_SystemCursor = SDL_SystemCursor::SE_RESIZE;
245/// Window resize bottom. May be NS_RESIZE.
246pub const SDL_SYSTEM_CURSOR_S_RESIZE: SDL_SystemCursor = SDL_SystemCursor::S_RESIZE;
247/// Window resize bottom-left. May be NESW_RESIZE.
248pub const SDL_SYSTEM_CURSOR_SW_RESIZE: SDL_SystemCursor = SDL_SystemCursor::SW_RESIZE;
249/// Window resize left. May be EW_RESIZE.
250pub const SDL_SYSTEM_CURSOR_W_RESIZE: SDL_SystemCursor = SDL_SystemCursor::W_RESIZE;
251pub const SDL_SYSTEM_CURSOR_COUNT: SDL_SystemCursor = SDL_SystemCursor::COUNT;
252
253#[cfg(feature = "metadata")]
254impl sdl3_sys::metadata::GroupMetadata for SDL_SystemCursor {
255    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
256        &crate::metadata::mouse::METADATA_SDL_SystemCursor;
257}
258
259/// Scroll direction types for the Scroll event
260///
261/// ## Availability
262/// This enum is available since SDL 3.2.0.
263///
264/// ## Known values (`sdl3-sys`)
265/// | Associated constant | Global constant | Description |
266/// | ------------------- | --------------- | ----------- |
267/// | [`NORMAL`](SDL_MouseWheelDirection::NORMAL) | [`SDL_MOUSEWHEEL_NORMAL`] | The scroll direction is normal |
268/// | [`FLIPPED`](SDL_MouseWheelDirection::FLIPPED) | [`SDL_MOUSEWHEEL_FLIPPED`] | The scroll direction is flipped / natural |
269#[repr(transparent)]
270#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
271pub struct SDL_MouseWheelDirection(pub ::core::ffi::c_int);
272
273impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_MouseWheelDirection {
274    #[inline(always)]
275    fn eq(&self, other: &::core::ffi::c_int) -> bool {
276        &self.0 == other
277    }
278}
279
280impl ::core::cmp::PartialEq<SDL_MouseWheelDirection> for ::core::ffi::c_int {
281    #[inline(always)]
282    fn eq(&self, other: &SDL_MouseWheelDirection) -> bool {
283        self == &other.0
284    }
285}
286
287impl From<SDL_MouseWheelDirection> for ::core::ffi::c_int {
288    #[inline(always)]
289    fn from(value: SDL_MouseWheelDirection) -> Self {
290        value.0
291    }
292}
293
294#[cfg(feature = "debug-impls")]
295impl ::core::fmt::Debug for SDL_MouseWheelDirection {
296    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
297        #[allow(unreachable_patterns)]
298        f.write_str(match *self {
299            Self::NORMAL => "SDL_MOUSEWHEEL_NORMAL",
300            Self::FLIPPED => "SDL_MOUSEWHEEL_FLIPPED",
301
302            _ => return write!(f, "SDL_MouseWheelDirection({})", self.0),
303        })
304    }
305}
306
307impl SDL_MouseWheelDirection {
308    /// The scroll direction is normal
309    pub const NORMAL: Self = Self((0 as ::core::ffi::c_int));
310    /// The scroll direction is flipped / natural
311    pub const FLIPPED: Self = Self((1 as ::core::ffi::c_int));
312}
313
314/// The scroll direction is normal
315pub const SDL_MOUSEWHEEL_NORMAL: SDL_MouseWheelDirection = SDL_MouseWheelDirection::NORMAL;
316/// The scroll direction is flipped / natural
317pub const SDL_MOUSEWHEEL_FLIPPED: SDL_MouseWheelDirection = SDL_MouseWheelDirection::FLIPPED;
318
319#[cfg(feature = "metadata")]
320impl sdl3_sys::metadata::GroupMetadata for SDL_MouseWheelDirection {
321    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
322        &crate::metadata::mouse::METADATA_SDL_MouseWheelDirection;
323}
324
325/// Animated cursor frame info.
326///
327/// ## Availability
328/// This struct is available since SDL 3.4.0.
329#[repr(C)]
330#[cfg_attr(feature = "debug-impls", derive(Debug))]
331pub struct SDL_CursorFrameInfo {
332    /// The surface data for this frame
333    pub surface: *mut SDL_Surface,
334    /// The frame duration in milliseconds (a duration of 0 is infinite)
335    pub duration: Uint32,
336}
337
338impl ::core::default::Default for SDL_CursorFrameInfo {
339    /// Initialize all fields to zero
340    #[inline(always)]
341    fn default() -> Self {
342        unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
343    }
344}
345
346pub const SDL_BUTTON_LEFT: ::core::primitive::i32 = 1;
347
348pub const SDL_BUTTON_MIDDLE: ::core::primitive::i32 = 2;
349
350pub const SDL_BUTTON_RIGHT: ::core::primitive::i32 = 3;
351
352pub const SDL_BUTTON_X1: ::core::primitive::i32 = 4;
353
354pub const SDL_BUTTON_X2: ::core::primitive::i32 = 5;
355
356#[inline(always)]
357pub const fn SDL_BUTTON_MASK(X: ::core::primitive::i32) -> SDL_MouseButtonFlags {
358    SDL_MouseButtonFlags(((1_u32 << (X - 1_i32)) as Uint32))
359}
360
361/// A callback used to transform mouse motion delta from raw values.
362///
363/// This is called during SDL's handling of platform mouse events to scale the
364/// values of the resulting motion delta.
365///
366/// ## Parameters
367/// - `userdata`: what was passed as `userdata` to
368///   [`SDL_SetRelativeMouseTransform()`].
369/// - `timestamp`: the associated time at which this mouse motion event was
370///   received.
371/// - `window`: the associated window to which this mouse motion event was
372///   addressed.
373/// - `mouseID`: the associated mouse from which this mouse motion event was
374///   emitted.
375/// - `x`: pointer to a variable that will be treated as the resulting x-axis
376///   motion.
377/// - `y`: pointer to a variable that will be treated as the resulting y-axis
378///   motion.
379///
380/// ## Thread safety
381/// This callback is called by SDL's internal mouse input
382///   processing procedure, which may be a thread separate from the
383///   main event loop that is run at realtime priority. Stalling
384///   this thread with too much work in the callback can therefore
385///   potentially freeze the entire system. Care should be taken
386///   with proper synchronization practices when adding other side
387///   effects beyond mutation of the x and y values.
388///
389/// ## Availability
390/// This datatype is available since SDL 3.4.0.
391///
392/// ## See also
393/// - [`SDL_SetRelativeMouseTransform`]
394pub type SDL_MouseMotionTransformCallback = ::core::option::Option<
395    unsafe extern "C" fn(
396        userdata: *mut ::core::ffi::c_void,
397        timestamp: Uint64,
398        window: *mut SDL_Window,
399        mouseID: SDL_MouseID,
400        x: *mut ::core::ffi::c_float,
401        y: *mut ::core::ffi::c_float,
402    ),
403>;
404
405unsafe extern "C" {
406    /// Return whether a mouse is currently connected.
407    ///
408    /// ## Return value
409    /// Returns true if a mouse is connected, false otherwise.
410    ///
411    /// ## Thread safety
412    /// This function should only be called on the main thread.
413    ///
414    /// ## Availability
415    /// This function is available since SDL 3.2.0.
416    ///
417    /// ## See also
418    /// - [`SDL_GetMice`]
419    pub fn SDL_HasMouse() -> ::core::primitive::bool;
420}
421
422unsafe extern "C" {
423    /// Get a list of currently connected mice.
424    ///
425    /// Note that this will include any device or virtual driver that includes
426    /// mouse functionality, including some game controllers, KVM switches, etc.
427    /// You should wait for input from a device before you consider it actively in
428    /// use.
429    ///
430    /// ## Parameters
431    /// - `count`: a pointer filled in with the number of mice returned, may be
432    ///   NULL.
433    ///
434    /// ## Return value
435    /// Returns a 0 terminated array of mouse instance IDs or NULL on failure;
436    ///   call [`SDL_GetError()`] for more information. This should be freed
437    ///   with [`SDL_free()`] when it is no longer needed.
438    ///
439    /// ## Thread safety
440    /// This function should only be called on the main thread.
441    ///
442    /// ## Availability
443    /// This function is available since SDL 3.2.0.
444    ///
445    /// ## See also
446    /// - [`SDL_GetMouseNameForID`]
447    /// - [`SDL_HasMouse`]
448    pub fn SDL_GetMice(count: *mut ::core::ffi::c_int) -> *mut SDL_MouseID;
449}
450
451unsafe extern "C" {
452    /// Get the name of a mouse.
453    ///
454    /// This function returns "" if the mouse doesn't have a name.
455    ///
456    /// ## Parameters
457    /// - `instance_id`: the mouse instance ID.
458    ///
459    /// ## Return value
460    /// Returns the name of the selected mouse, or NULL on failure; call
461    ///   [`SDL_GetError()`] for more information.
462    ///
463    /// ## Thread safety
464    /// This function should only be called on the main thread.
465    ///
466    /// ## Availability
467    /// This function is available since SDL 3.2.0.
468    ///
469    /// ## See also
470    /// - [`SDL_GetMice`]
471    pub fn SDL_GetMouseNameForID(instance_id: SDL_MouseID) -> *const ::core::ffi::c_char;
472}
473
474unsafe extern "C" {
475    /// Get the window which currently has mouse focus.
476    ///
477    /// ## Return value
478    /// Returns the window with mouse focus.
479    ///
480    /// ## Thread safety
481    /// This function should only be called on the main thread.
482    ///
483    /// ## Availability
484    /// This function is available since SDL 3.2.0.
485    pub fn SDL_GetMouseFocus() -> *mut SDL_Window;
486}
487
488unsafe extern "C" {
489    /// Query SDL's cache for the synchronous mouse button state and the
490    /// window-relative SDL-cursor position.
491    ///
492    /// This function returns the cached synchronous state as SDL understands it
493    /// from the last pump of the event queue.
494    ///
495    /// To query the platform for immediate asynchronous state, use
496    /// [`SDL_GetGlobalMouseState`].
497    ///
498    /// Passing non-NULL pointers to `x` or `y` will write the destination with
499    /// respective x or y coordinates relative to the focused window.
500    ///
501    /// In Relative Mode, the SDL-cursor's position usually contradicts the
502    /// platform-cursor's position as manually calculated from
503    /// [`SDL_GetGlobalMouseState()`] and [`SDL_GetWindowPosition`].
504    ///
505    /// ## Parameters
506    /// - `x`: a pointer to receive the SDL-cursor's x-position from the focused
507    ///   window's top left corner, can be NULL if unused.
508    /// - `y`: a pointer to receive the SDL-cursor's y-position from the focused
509    ///   window's top left corner, can be NULL if unused.
510    ///
511    /// ## Return value
512    /// Returns a 32-bit bitmask of the button state that can be bitwise-compared
513    ///   against the SDL_BUTTON_MASK(X) macro.
514    ///
515    /// ## Thread safety
516    /// This function should only be called on the main thread.
517    ///
518    /// ## Availability
519    /// This function is available since SDL 3.2.0.
520    ///
521    /// ## See also
522    /// - [`SDL_GetGlobalMouseState`]
523    /// - [`SDL_GetRelativeMouseState`]
524    pub fn SDL_GetMouseState(
525        x: *mut ::core::ffi::c_float,
526        y: *mut ::core::ffi::c_float,
527    ) -> SDL_MouseButtonFlags;
528}
529
530unsafe extern "C" {
531    /// Query the platform for the asynchronous mouse button state and the
532    /// desktop-relative platform-cursor position.
533    ///
534    /// This function immediately queries the platform for the most recent
535    /// asynchronous state, more costly than retrieving SDL's cached state in
536    /// [`SDL_GetMouseState()`].
537    ///
538    /// Passing non-NULL pointers to `x` or `y` will write the destination with
539    /// respective x or y coordinates relative to the desktop.
540    ///
541    /// In Relative Mode, the platform-cursor's position usually contradicts the
542    /// SDL-cursor's position as manually calculated from [`SDL_GetMouseState()`] and
543    /// [`SDL_GetWindowPosition`].
544    ///
545    /// This function can be useful if you need to track the mouse outside of a
546    /// specific window and [`SDL_CaptureMouse()`] doesn't fit your needs. For example,
547    /// it could be useful if you need to track the mouse while dragging a window,
548    /// where coordinates relative to a window might not be in sync at all times.
549    ///
550    /// ## Parameters
551    /// - `x`: a pointer to receive the platform-cursor's x-position from the
552    ///   desktop's top left corner, can be NULL if unused.
553    /// - `y`: a pointer to receive the platform-cursor's y-position from the
554    ///   desktop's top left corner, can be NULL if unused.
555    ///
556    /// ## Return value
557    /// Returns a 32-bit bitmask of the button state that can be bitwise-compared
558    ///   against the SDL_BUTTON_MASK(X) macro.
559    ///
560    /// ## Thread safety
561    /// This function should only be called on the main thread.
562    ///
563    /// ## Availability
564    /// This function is available since SDL 3.2.0.
565    ///
566    /// ## See also
567    /// - [`SDL_CaptureMouse`]
568    /// - [`SDL_GetMouseState`]
569    /// - [`SDL_GetGlobalMouseState`]
570    pub fn SDL_GetGlobalMouseState(
571        x: *mut ::core::ffi::c_float,
572        y: *mut ::core::ffi::c_float,
573    ) -> SDL_MouseButtonFlags;
574}
575
576unsafe extern "C" {
577    /// Query SDL's cache for the synchronous mouse button state and accumulated
578    /// mouse delta since last call.
579    ///
580    /// This function returns the cached synchronous state as SDL understands it
581    /// from the last pump of the event queue.
582    ///
583    /// To query the platform for immediate asynchronous state, use
584    /// [`SDL_GetGlobalMouseState`].
585    ///
586    /// Passing non-NULL pointers to `x` or `y` will write the destination with
587    /// respective x or y deltas accumulated since the last call to this function
588    /// (or since event initialization).
589    ///
590    /// This function is useful for reducing overhead by processing relative mouse
591    /// inputs in one go per-frame instead of individually per-event, at the
592    /// expense of losing the order between events within the frame (e.g. quickly
593    /// pressing and releasing a button within the same frame).
594    ///
595    /// ## Parameters
596    /// - `x`: a pointer to receive the x mouse delta accumulated since last
597    ///   call, can be NULL if unused.
598    /// - `y`: a pointer to receive the y mouse delta accumulated since last
599    ///   call, can be NULL if unused.
600    ///
601    /// ## Return value
602    /// Returns a 32-bit bitmask of the button state that can be bitwise-compared
603    ///   against the SDL_BUTTON_MASK(X) macro.
604    ///
605    /// ## Thread safety
606    /// This function should only be called on the main thread.
607    ///
608    /// ## Availability
609    /// This function is available since SDL 3.2.0.
610    ///
611    /// ## See also
612    /// - [`SDL_GetMouseState`]
613    /// - [`SDL_GetGlobalMouseState`]
614    pub fn SDL_GetRelativeMouseState(
615        x: *mut ::core::ffi::c_float,
616        y: *mut ::core::ffi::c_float,
617    ) -> SDL_MouseButtonFlags;
618}
619
620unsafe extern "C" {
621    /// Move the mouse cursor to the given position within the window.
622    ///
623    /// This function generates a mouse motion event if relative mode is not
624    /// enabled. If relative mode is enabled, you can force mouse events for the
625    /// warp by setting the [`SDL_HINT_MOUSE_RELATIVE_WARP_MOTION`] hint.
626    ///
627    /// Note that this function will appear to succeed, but not actually move the
628    /// mouse when used over Microsoft Remote Desktop.
629    ///
630    /// ## Parameters
631    /// - `window`: the window to move the mouse into, or NULL for the current
632    ///   mouse focus.
633    /// - `x`: the x coordinate within the window.
634    /// - `y`: the y coordinate within the window.
635    ///
636    /// ## Thread safety
637    /// This function should only be called on the main thread.
638    ///
639    /// ## Availability
640    /// This function is available since SDL 3.2.0.
641    ///
642    /// ## See also
643    /// - [`SDL_WarpMouseGlobal`]
644    pub fn SDL_WarpMouseInWindow(
645        window: *mut SDL_Window,
646        x: ::core::ffi::c_float,
647        y: ::core::ffi::c_float,
648    );
649}
650
651unsafe extern "C" {
652    /// Move the mouse to the given position in global screen space.
653    ///
654    /// This function generates a mouse motion event.
655    ///
656    /// A failure of this function usually means that it is unsupported by a
657    /// platform.
658    ///
659    /// Note that this function will appear to succeed, but not actually move the
660    /// mouse when used over Microsoft Remote Desktop.
661    ///
662    /// ## Parameters
663    /// - `x`: the x coordinate.
664    /// - `y`: the y coordinate.
665    ///
666    /// ## Return value
667    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
668    ///   information.
669    ///
670    /// ## Thread safety
671    /// This function should only be called on the main thread.
672    ///
673    /// ## Availability
674    /// This function is available since SDL 3.2.0.
675    ///
676    /// ## See also
677    /// - [`SDL_WarpMouseInWindow`]
678    pub fn SDL_WarpMouseGlobal(
679        x: ::core::ffi::c_float,
680        y: ::core::ffi::c_float,
681    ) -> ::core::primitive::bool;
682}
683
684unsafe extern "C" {
685    /// Set a user-defined function by which to transform relative mouse inputs.
686    ///
687    /// This overrides the relative system scale and relative speed scale hints.
688    /// Should be called prior to enabling relative mouse mode, fails otherwise.
689    ///
690    /// ## Parameters
691    /// - `callback`: a callback used to transform relative mouse motion, or NULL
692    ///   for default behavior.
693    /// - `userdata`: a pointer that will be passed to `callback`.
694    ///
695    /// ## Return value
696    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
697    ///   information.
698    ///
699    /// ## Thread safety
700    /// This function should only be called on the main thread.
701    ///
702    /// ## Availability
703    /// This function is available since SDL 3.4.0.
704    pub fn SDL_SetRelativeMouseTransform(
705        callback: SDL_MouseMotionTransformCallback,
706        userdata: *mut ::core::ffi::c_void,
707    ) -> ::core::primitive::bool;
708}
709
710unsafe extern "C" {
711    /// Set relative mouse mode for a window.
712    ///
713    /// While the window has focus and relative mouse mode is enabled, the cursor
714    /// is hidden, the mouse position is constrained to the window, and SDL will
715    /// report continuous relative mouse motion even if the mouse is at the edge of
716    /// the window.
717    ///
718    /// If you'd like to keep the mouse position fixed while in relative mode you
719    /// can use [`SDL_SetWindowMouseRect()`]. If you'd like the cursor to be at a
720    /// specific location when relative mode ends, you should use
721    /// [`SDL_WarpMouseInWindow()`] before disabling relative mode.
722    ///
723    /// This function will flush any pending mouse motion for this window.
724    ///
725    /// ## Parameters
726    /// - `window`: the window to change.
727    /// - `enabled`: true to enable relative mode, false to disable.
728    ///
729    /// ## Return value
730    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
731    ///   information.
732    ///
733    /// ## Thread safety
734    /// This function should only be called on the main thread.
735    ///
736    /// ## Availability
737    /// This function is available since SDL 3.2.0.
738    ///
739    /// ## See also
740    /// - [`SDL_GetWindowRelativeMouseMode`]
741    pub fn SDL_SetWindowRelativeMouseMode(
742        window: *mut SDL_Window,
743        enabled: ::core::primitive::bool,
744    ) -> ::core::primitive::bool;
745}
746
747unsafe extern "C" {
748    /// Query whether relative mouse mode is enabled for a window.
749    ///
750    /// ## Parameters
751    /// - `window`: the window to query.
752    ///
753    /// ## Return value
754    /// Returns true if relative mode is enabled for a window or false otherwise.
755    ///
756    /// ## Thread safety
757    /// This function should only be called on the main thread.
758    ///
759    /// ## Availability
760    /// This function is available since SDL 3.2.0.
761    ///
762    /// ## See also
763    /// - [`SDL_SetWindowRelativeMouseMode`]
764    pub fn SDL_GetWindowRelativeMouseMode(window: *mut SDL_Window) -> ::core::primitive::bool;
765}
766
767unsafe extern "C" {
768    /// Capture the mouse and to track input outside an SDL window.
769    ///
770    /// Capturing enables your app to obtain mouse events globally, instead of just
771    /// within your window. Not all video targets support this function. When
772    /// capturing is enabled, the current window will get all mouse events, but
773    /// unlike relative mode, no change is made to the cursor and it is not
774    /// restrained to your window.
775    ///
776    /// This function may also deny mouse input to other windows--both those in
777    /// your application and others on the system--so you should use this function
778    /// sparingly, and in small bursts. For example, you might want to track the
779    /// mouse while the user is dragging something, until the user releases a mouse
780    /// button. It is not recommended that you capture the mouse for long periods
781    /// of time, such as the entire time your app is running. For that, you should
782    /// probably use [`SDL_SetWindowRelativeMouseMode()`] or [`SDL_SetWindowMouseGrab()`],
783    /// depending on your goals.
784    ///
785    /// While captured, mouse events still report coordinates relative to the
786    /// current (foreground) window, but those coordinates may be outside the
787    /// bounds of the window (including negative values). Capturing is only allowed
788    /// for the foreground window. If the window loses focus while capturing, the
789    /// capture will be disabled automatically.
790    ///
791    /// While capturing is enabled, the current window will have the
792    /// [`SDL_WINDOW_MOUSE_CAPTURE`] flag set.
793    ///
794    /// Please note that SDL will attempt to "auto capture" the mouse while the
795    /// user is pressing a button; this is to try and make mouse behavior more
796    /// consistent between platforms, and deal with the common case of a user
797    /// dragging the mouse outside of the window. This means that if you are
798    /// calling [`SDL_CaptureMouse()`] only to deal with this situation, you do not
799    /// have to (although it is safe to do so). If this causes problems for your
800    /// app, you can disable auto capture by setting the
801    /// [`SDL_HINT_MOUSE_AUTO_CAPTURE`] hint to zero.
802    ///
803    /// ## Parameters
804    /// - `enabled`: true to enable capturing, false to disable.
805    ///
806    /// ## Return value
807    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
808    ///   information.
809    ///
810    /// ## Thread safety
811    /// This function should only be called on the main thread.
812    ///
813    /// ## Availability
814    /// This function is available since SDL 3.2.0.
815    ///
816    /// ## See also
817    /// - [`SDL_GetGlobalMouseState`]
818    pub fn SDL_CaptureMouse(enabled: ::core::primitive::bool) -> ::core::primitive::bool;
819}
820
821unsafe extern "C" {
822    /// Create a cursor using the specified bitmap data and mask (in MSB format).
823    ///
824    /// `mask` has to be in MSB (Most Significant Bit) format.
825    ///
826    /// The cursor width (`w`) must be a multiple of 8 bits.
827    ///
828    /// The cursor is created in black and white according to the following:
829    ///
830    /// - data=0, mask=1: white
831    /// - data=1, mask=1: black
832    /// - data=0, mask=0: transparent
833    /// - data=1, mask=0: inverted color if possible, black if not.
834    ///
835    /// Cursors created with this function must be freed with [`SDL_DestroyCursor()`].
836    ///
837    /// If you want to have a color cursor, or create your cursor from an
838    /// [`SDL_Surface`], you should use [`SDL_CreateColorCursor()`]. Alternately, you can
839    /// hide the cursor and draw your own as part of your game's rendering, but it
840    /// will be bound to the framerate.
841    ///
842    /// Also, [`SDL_CreateSystemCursor()`] is available, which provides several
843    /// readily-available system cursors to pick from.
844    ///
845    /// ## Parameters
846    /// - `data`: the color value for each pixel of the cursor.
847    /// - `mask`: the mask value for each pixel of the cursor.
848    /// - `w`: the width of the cursor.
849    /// - `h`: the height of the cursor.
850    /// - `hot_x`: the x-axis offset from the left of the cursor image to the
851    ///   mouse x position, in the range of 0 to `w` - 1.
852    /// - `hot_y`: the y-axis offset from the top of the cursor image to the
853    ///   mouse y position, in the range of 0 to `h` - 1.
854    ///
855    /// ## Return value
856    /// Returns a new cursor with the specified parameters on success or NULL on
857    ///   failure; call [`SDL_GetError()`] for more information.
858    ///
859    /// ## Thread safety
860    /// This function should only be called on the main thread.
861    ///
862    /// ## Availability
863    /// This function is available since SDL 3.2.0.
864    ///
865    /// ## See also
866    /// - [`SDL_CreateAnimatedCursor`]
867    /// - [`SDL_CreateColorCursor`]
868    /// - [`SDL_CreateSystemCursor`]
869    /// - [`SDL_DestroyCursor`]
870    /// - [`SDL_SetCursor`]
871    pub fn SDL_CreateCursor(
872        data: *const Uint8,
873        mask: *const Uint8,
874        w: ::core::ffi::c_int,
875        h: ::core::ffi::c_int,
876        hot_x: ::core::ffi::c_int,
877        hot_y: ::core::ffi::c_int,
878    ) -> *mut SDL_Cursor;
879}
880
881unsafe extern "C" {
882    /// Create a color cursor.
883    ///
884    /// If this function is passed a surface with alternate representations added
885    /// with [`SDL_AddSurfaceAlternateImage()`], the surface will be interpreted as the
886    /// content to be used for 100% display scale, and the alternate
887    /// representations will be used for high DPI situations if
888    /// [`SDL_HINT_MOUSE_DPI_SCALE_CURSORS`] is enabled. For example, if the original
889    /// surface is 32x32, then on a 2x macOS display or 200% display scale on
890    /// Windows, a 64x64 version of the image will be used, if available. If a
891    /// matching version of the image isn't available, the closest larger size
892    /// image will be downscaled to the appropriate size and be used instead, if
893    /// available. Otherwise, the closest smaller image will be upscaled and be
894    /// used instead.
895    ///
896    /// ## Parameters
897    /// - `surface`: an [`SDL_Surface`] structure representing the cursor image.
898    /// - `hot_x`: the x position of the cursor hot spot.
899    /// - `hot_y`: the y position of the cursor hot spot.
900    ///
901    /// ## Return value
902    /// Returns the new cursor on success or NULL on failure; call [`SDL_GetError()`]
903    ///   for more information.
904    ///
905    /// ## Thread safety
906    /// This function should only be called on the main thread.
907    ///
908    /// ## Availability
909    /// This function is available since SDL 3.2.0.
910    ///
911    /// ## See also
912    /// - [`SDL_AddSurfaceAlternateImage`]
913    /// - [`SDL_CreateAnimatedCursor`]
914    /// - [`SDL_CreateCursor`]
915    /// - [`SDL_CreateSystemCursor`]
916    /// - [`SDL_DestroyCursor`]
917    /// - [`SDL_SetCursor`]
918    pub fn SDL_CreateColorCursor(
919        surface: *mut SDL_Surface,
920        hot_x: ::core::ffi::c_int,
921        hot_y: ::core::ffi::c_int,
922    ) -> *mut SDL_Cursor;
923}
924
925unsafe extern "C" {
926    /// Create an animated color cursor.
927    ///
928    /// Animated cursors are composed of a sequential array of frames, specified as
929    /// surfaces and durations in an array of [`SDL_CursorFrameInfo`] structs. The hot
930    /// spot coordinates are universal to all frames, and all frames must have the
931    /// same dimensions.
932    ///
933    /// Frame durations are specified in milliseconds. A duration of 0 implies an
934    /// infinite frame time, and the animation will stop on that frame. To create a
935    /// one-shot animation, set the duration of the last frame in the sequence to
936    /// 0.
937    ///
938    /// If this function is passed surfaces with alternate representations added
939    /// with [`SDL_AddSurfaceAlternateImage()`], the surfaces will be interpreted as
940    /// the content to be used for 100% display scale, and the alternate
941    /// representations will be used for high DPI situations. For example, if the
942    /// original surfaces are 32x32, then on a 2x macOS display or 200% display
943    /// scale on Windows, a 64x64 version of the image will be used, if available.
944    /// If a matching version of the image isn't available, the closest larger size
945    /// image will be downscaled to the appropriate size and be used instead, if
946    /// available. Otherwise, the closest smaller image will be upscaled and be
947    /// used instead.
948    ///
949    /// If the underlying platform does not support animated cursors, this function
950    /// will fall back to creating a static color cursor using the first frame in
951    /// the sequence.
952    ///
953    /// ## Parameters
954    /// - `frames`: an array of cursor images composing the animation.
955    /// - `frame_count`: the number of frames in the sequence.
956    /// - `hot_x`: the x position of the cursor hot spot.
957    /// - `hot_y`: the y position of the cursor hot spot.
958    ///
959    /// ## Return value
960    /// Returns the new cursor on success or NULL on failure; call [`SDL_GetError()`]
961    ///   for more information.
962    ///
963    /// ## Thread safety
964    /// This function should only be called on the main thread.
965    ///
966    /// ## Availability
967    /// This function is available since SDL 3.4.0.
968    ///
969    /// ## See also
970    /// - [`SDL_AddSurfaceAlternateImage`]
971    /// - [`SDL_CreateCursor`]
972    /// - [`SDL_CreateColorCursor`]
973    /// - [`SDL_CreateSystemCursor`]
974    /// - [`SDL_DestroyCursor`]
975    /// - [`SDL_SetCursor`]
976    pub fn SDL_CreateAnimatedCursor(
977        frames: *mut SDL_CursorFrameInfo,
978        frame_count: ::core::ffi::c_int,
979        hot_x: ::core::ffi::c_int,
980        hot_y: ::core::ffi::c_int,
981    ) -> *mut SDL_Cursor;
982}
983
984unsafe extern "C" {
985    /// Create a system cursor.
986    ///
987    /// ## Parameters
988    /// - `id`: an [`SDL_SystemCursor`] enum value.
989    ///
990    /// ## Return value
991    /// Returns a cursor on success or NULL on failure; call [`SDL_GetError()`] for
992    ///   more information.
993    ///
994    /// ## Thread safety
995    /// This function should only be called on the main thread.
996    ///
997    /// ## Availability
998    /// This function is available since SDL 3.2.0.
999    ///
1000    /// ## See also
1001    /// - [`SDL_DestroyCursor`]
1002    pub fn SDL_CreateSystemCursor(id: SDL_SystemCursor) -> *mut SDL_Cursor;
1003}
1004
1005unsafe extern "C" {
1006    /// Set the active cursor.
1007    ///
1008    /// This function sets the currently active cursor to the specified one. If the
1009    /// cursor is currently visible, the change will be immediately represented on
1010    /// the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
1011    /// this is desired for any reason.
1012    ///
1013    /// ## Parameters
1014    /// - `cursor`: a cursor to make active.
1015    ///
1016    /// ## Return value
1017    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1018    ///   information.
1019    ///
1020    /// ## Thread safety
1021    /// This function should only be called on the main thread.
1022    ///
1023    /// ## Availability
1024    /// This function is available since SDL 3.2.0.
1025    ///
1026    /// ## See also
1027    /// - [`SDL_GetCursor`]
1028    pub fn SDL_SetCursor(cursor: *mut SDL_Cursor) -> ::core::primitive::bool;
1029}
1030
1031unsafe extern "C" {
1032    /// Get the active cursor.
1033    ///
1034    /// This function returns a pointer to the current cursor which is owned by the
1035    /// library. It is not necessary to free the cursor with [`SDL_DestroyCursor()`].
1036    ///
1037    /// ## Return value
1038    /// Returns the active cursor or NULL if there is no mouse.
1039    ///
1040    /// ## Thread safety
1041    /// This function should only be called on the main thread.
1042    ///
1043    /// ## Availability
1044    /// This function is available since SDL 3.2.0.
1045    ///
1046    /// ## See also
1047    /// - [`SDL_SetCursor`]
1048    pub fn SDL_GetCursor() -> *mut SDL_Cursor;
1049}
1050
1051unsafe extern "C" {
1052    /// Get the default cursor.
1053    ///
1054    /// You do not have to call [`SDL_DestroyCursor()`] on the return value, but it is
1055    /// safe to do so.
1056    ///
1057    /// ## Return value
1058    /// Returns the default cursor on success or NULL on failure; call
1059    ///   [`SDL_GetError()`] for more information.
1060    ///
1061    /// ## Thread safety
1062    /// This function should only be called on the main thread.
1063    ///
1064    /// ## Availability
1065    /// This function is available since SDL 3.2.0.
1066    pub fn SDL_GetDefaultCursor() -> *mut SDL_Cursor;
1067}
1068
1069unsafe extern "C" {
1070    /// Free a previously-created cursor.
1071    ///
1072    /// Use this function to free cursor resources created with [`SDL_CreateCursor()`],
1073    /// [`SDL_CreateColorCursor()`] or [`SDL_CreateSystemCursor()`].
1074    ///
1075    /// ## Parameters
1076    /// - `cursor`: the cursor to free.
1077    ///
1078    /// ## Thread safety
1079    /// This function should only be called on the main thread.
1080    ///
1081    /// ## Availability
1082    /// This function is available since SDL 3.2.0.
1083    ///
1084    /// ## See also
1085    /// - [`SDL_CreateAnimatedCursor`]
1086    /// - [`SDL_CreateColorCursor`]
1087    /// - [`SDL_CreateCursor`]
1088    /// - [`SDL_CreateSystemCursor`]
1089    pub fn SDL_DestroyCursor(cursor: *mut SDL_Cursor);
1090}
1091
1092unsafe extern "C" {
1093    /// Show the cursor.
1094    ///
1095    /// ## Return value
1096    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1097    ///   information.
1098    ///
1099    /// ## Thread safety
1100    /// This function should only be called on the main thread.
1101    ///
1102    /// ## Availability
1103    /// This function is available since SDL 3.2.0.
1104    ///
1105    /// ## See also
1106    /// - [`SDL_CursorVisible`]
1107    /// - [`SDL_HideCursor`]
1108    pub fn SDL_ShowCursor() -> ::core::primitive::bool;
1109}
1110
1111unsafe extern "C" {
1112    /// Hide the cursor.
1113    ///
1114    /// ## Return value
1115    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1116    ///   information.
1117    ///
1118    /// ## Thread safety
1119    /// This function should only be called on the main thread.
1120    ///
1121    /// ## Availability
1122    /// This function is available since SDL 3.2.0.
1123    ///
1124    /// ## See also
1125    /// - [`SDL_CursorVisible`]
1126    /// - [`SDL_ShowCursor`]
1127    pub fn SDL_HideCursor() -> ::core::primitive::bool;
1128}
1129
1130unsafe extern "C" {
1131    /// Return whether the cursor is currently being shown.
1132    ///
1133    /// ## Return value
1134    /// Returns `true` if the cursor is being shown, or `false` if the cursor is
1135    ///   hidden.
1136    ///
1137    /// ## Thread safety
1138    /// This function should only be called on the main thread.
1139    ///
1140    /// ## Availability
1141    /// This function is available since SDL 3.2.0.
1142    ///
1143    /// ## See also
1144    /// - [`SDL_HideCursor`]
1145    /// - [`SDL_ShowCursor`]
1146    pub fn SDL_CursorVisible() -> ::core::primitive::bool;
1147}
1148
1149/// The structure used to identify an SDL cursor.
1150///
1151/// This is opaque data.
1152///
1153/// ## Availability
1154/// This struct is available since SDL 3.2.0.
1155#[repr(C)]
1156pub struct SDL_Cursor {
1157    _opaque: [::core::primitive::u8; 0],
1158}
1159
1160/// A bitmask of pressed mouse buttons, as reported by [`SDL_GetMouseState`], etc.
1161///
1162/// - Button 1: Left mouse button
1163/// - Button 2: Middle mouse button
1164/// - Button 3: Right mouse button
1165/// - Button 4: Side mouse button 1
1166/// - Button 5: Side mouse button 2
1167///
1168/// ## Availability
1169/// This datatype is available since SDL 3.2.0.
1170///
1171/// ## See also
1172/// - [`SDL_GetMouseState`]
1173/// - [`SDL_GetGlobalMouseState`]
1174/// - [`SDL_GetRelativeMouseState`]
1175///
1176/// ## Known values (`sdl3-sys`)
1177/// | Associated constant | Global constant | Description |
1178/// | ------------------- | --------------- | ----------- |
1179/// | [`LMASK`](SDL_MouseButtonFlags::LMASK) | [`SDL_BUTTON_LMASK`] | |
1180/// | [`MMASK`](SDL_MouseButtonFlags::MMASK) | [`SDL_BUTTON_MMASK`] | |
1181/// | [`RMASK`](SDL_MouseButtonFlags::RMASK) | [`SDL_BUTTON_RMASK`] | |
1182/// | [`X1MASK`](SDL_MouseButtonFlags::X1MASK) | [`SDL_BUTTON_X1MASK`] | |
1183/// | [`X2MASK`](SDL_MouseButtonFlags::X2MASK) | [`SDL_BUTTON_X2MASK`] | |
1184#[repr(transparent)]
1185#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
1186pub struct SDL_MouseButtonFlags(pub Uint32);
1187
1188impl ::core::cmp::PartialEq<Uint32> for SDL_MouseButtonFlags {
1189    #[inline(always)]
1190    fn eq(&self, other: &Uint32) -> bool {
1191        &self.0 == other
1192    }
1193}
1194
1195impl ::core::cmp::PartialEq<SDL_MouseButtonFlags> for Uint32 {
1196    #[inline(always)]
1197    fn eq(&self, other: &SDL_MouseButtonFlags) -> bool {
1198        self == &other.0
1199    }
1200}
1201
1202impl From<SDL_MouseButtonFlags> for Uint32 {
1203    #[inline(always)]
1204    fn from(value: SDL_MouseButtonFlags) -> Self {
1205        value.0
1206    }
1207}
1208
1209#[cfg(feature = "debug-impls")]
1210impl ::core::fmt::Debug for SDL_MouseButtonFlags {
1211    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1212        let mut first = true;
1213        let all_bits = 0;
1214        write!(f, "SDL_MouseButtonFlags(")?;
1215        let all_bits = all_bits | Self::LMASK.0;
1216        if (Self::LMASK != 0 || self.0 == 0) && *self & Self::LMASK == Self::LMASK {
1217            if !first {
1218                write!(f, " | ")?;
1219            }
1220            first = false;
1221            write!(f, "LMASK")?;
1222        }
1223        let all_bits = all_bits | Self::MMASK.0;
1224        if (Self::MMASK != 0 || self.0 == 0) && *self & Self::MMASK == Self::MMASK {
1225            if !first {
1226                write!(f, " | ")?;
1227            }
1228            first = false;
1229            write!(f, "MMASK")?;
1230        }
1231        let all_bits = all_bits | Self::RMASK.0;
1232        if (Self::RMASK != 0 || self.0 == 0) && *self & Self::RMASK == Self::RMASK {
1233            if !first {
1234                write!(f, " | ")?;
1235            }
1236            first = false;
1237            write!(f, "RMASK")?;
1238        }
1239        let all_bits = all_bits | Self::X1MASK.0;
1240        if (Self::X1MASK != 0 || self.0 == 0) && *self & Self::X1MASK == Self::X1MASK {
1241            if !first {
1242                write!(f, " | ")?;
1243            }
1244            first = false;
1245            write!(f, "X1MASK")?;
1246        }
1247        let all_bits = all_bits | Self::X2MASK.0;
1248        if (Self::X2MASK != 0 || self.0 == 0) && *self & Self::X2MASK == Self::X2MASK {
1249            if !first {
1250                write!(f, " | ")?;
1251            }
1252            first = false;
1253            write!(f, "X2MASK")?;
1254        }
1255
1256        if self.0 & !all_bits != 0 {
1257            if !first {
1258                write!(f, " | ")?;
1259            }
1260            write!(f, "{:#x}", self.0)?;
1261        } else if first {
1262            write!(f, "0")?;
1263        }
1264        write!(f, ")")
1265    }
1266}
1267
1268impl ::core::ops::BitAnd for SDL_MouseButtonFlags {
1269    type Output = Self;
1270
1271    #[inline(always)]
1272    fn bitand(self, rhs: Self) -> Self::Output {
1273        Self(self.0 & rhs.0)
1274    }
1275}
1276
1277impl ::core::ops::BitAndAssign for SDL_MouseButtonFlags {
1278    #[inline(always)]
1279    fn bitand_assign(&mut self, rhs: Self) {
1280        self.0 &= rhs.0;
1281    }
1282}
1283
1284impl ::core::ops::BitOr for SDL_MouseButtonFlags {
1285    type Output = Self;
1286
1287    #[inline(always)]
1288    fn bitor(self, rhs: Self) -> Self::Output {
1289        Self(self.0 | rhs.0)
1290    }
1291}
1292
1293impl ::core::ops::BitOrAssign for SDL_MouseButtonFlags {
1294    #[inline(always)]
1295    fn bitor_assign(&mut self, rhs: Self) {
1296        self.0 |= rhs.0;
1297    }
1298}
1299
1300impl ::core::ops::BitXor for SDL_MouseButtonFlags {
1301    type Output = Self;
1302
1303    #[inline(always)]
1304    fn bitxor(self, rhs: Self) -> Self::Output {
1305        Self(self.0 ^ rhs.0)
1306    }
1307}
1308
1309impl ::core::ops::BitXorAssign for SDL_MouseButtonFlags {
1310    #[inline(always)]
1311    fn bitxor_assign(&mut self, rhs: Self) {
1312        self.0 ^= rhs.0;
1313    }
1314}
1315
1316impl ::core::ops::Not for SDL_MouseButtonFlags {
1317    type Output = Self;
1318
1319    #[inline(always)]
1320    fn not(self) -> Self::Output {
1321        Self(!self.0)
1322    }
1323}
1324
1325impl SDL_MouseButtonFlags {
1326    pub const LMASK: Self = SDL_BUTTON_MASK(SDL_BUTTON_LEFT);
1327    pub const MMASK: Self = SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE);
1328    pub const RMASK: Self = SDL_BUTTON_MASK(SDL_BUTTON_RIGHT);
1329    pub const X1MASK: Self = SDL_BUTTON_MASK(SDL_BUTTON_X1);
1330    pub const X2MASK: Self = SDL_BUTTON_MASK(SDL_BUTTON_X2);
1331}
1332
1333pub const SDL_BUTTON_LMASK: SDL_MouseButtonFlags = SDL_MouseButtonFlags::LMASK;
1334pub const SDL_BUTTON_MMASK: SDL_MouseButtonFlags = SDL_MouseButtonFlags::MMASK;
1335pub const SDL_BUTTON_RMASK: SDL_MouseButtonFlags = SDL_MouseButtonFlags::RMASK;
1336pub const SDL_BUTTON_X1MASK: SDL_MouseButtonFlags = SDL_MouseButtonFlags::X1MASK;
1337pub const SDL_BUTTON_X2MASK: SDL_MouseButtonFlags = SDL_MouseButtonFlags::X2MASK;
1338
1339#[cfg(feature = "metadata")]
1340impl sdl3_sys::metadata::GroupMetadata for SDL_MouseButtonFlags {
1341    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
1342        &crate::metadata::mouse::METADATA_SDL_MouseButtonFlags;
1343}
1344
1345#[cfg(doc)]
1346use crate::everything::*;