Skip to main content

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