Skip to main content

sdl3_sys/generated/
system.rs

1//! Platform-specific SDL API functions. These are functions that deal with
2//! needs of specific operating systems, that didn't make sense to offer as
3//! platform-independent, generic APIs.
4//!
5//! Most apps can make do without these functions, but they can be useful for
6//! integrating with other parts of a specific system, adding platform-specific
7//! polish to an app, or solving problems that only affect one target.
8
9use super::stdinc::*;
10
11use super::error::*;
12
13use super::keyboard::*;
14
15use super::video::*;
16
17apply_cfg!(#[cfg(any(doc, windows))] => {
18    apply_cfg!(#[cfg(feature = "use-windows-sys-v0-59")] => {
19        #[cfg_attr(all(feature = "nightly", doc), doc(cfg(windows)))]
20        /// (`sdl3-sys`) Enable a `use-windows-sys-*` feature to alias this to `MSG` from the `windows-sys` crate. Otherwise it's an opaque struct.
21        pub type MSG = ::windows_sys_v0_59::Win32::UI::WindowsAndMessaging::MSG;
22    });
23
24    apply_cfg!(#[cfg(not(feature = "use-windows-sys-v0-59"))] => {
25        #[cfg_attr(all(feature = "nightly", doc), doc(cfg(windows)))]
26        /// (`sdl3-sys`) Enable a `use-windows-sys-*` feature to alias this to `MSG` from the `windows-sys` crate. Otherwise it's an opaque struct.
27        pub type MSG = tagMSG;
28
29    });
30
31    /// A callback to be used with [`SDL_SetWindowsMessageHook`].
32    ///
33    /// This callback may modify the message, and should return true if the message
34    /// should continue to be processed, or false to prevent further processing.
35    ///
36    /// As this is processing a message directly from the Windows event loop, this
37    /// callback should do the minimum required work and return quickly.
38    ///
39    /// ## Parameters
40    /// - `userdata`: the app-defined pointer provided to
41    ///   [`SDL_SetWindowsMessageHook`].
42    /// - `msg`: a pointer to a Win32 event structure to process.
43    ///
44    /// ## Return value
45    /// Returns true to let event continue on, false to drop it.
46    ///
47    /// ## Thread safety
48    /// This may only be called (by SDL) from the thread handling the
49    ///   Windows event loop.
50    ///
51    /// ## Availability
52    /// This datatype is available since SDL 3.2.0.
53    ///
54    /// ## See also
55    /// - [`SDL_SetWindowsMessageHook`]
56    /// - [`SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP`]
57    pub type SDL_WindowsMessageHook = ::core::option::Option<unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, msg: *mut MSG) -> ::core::primitive::bool>;
58
59    unsafe extern "C" {
60        /// Set a callback for every Windows message, run before TranslateMessage().
61        ///
62        /// The callback may modify the message, and should return true if the message
63        /// should continue to be processed, or false to prevent further processing.
64        ///
65        /// ## Parameters
66        /// - `callback`: the [`SDL_WindowsMessageHook`] function to call.
67        /// - `userdata`: a pointer to pass to every iteration of `callback`.
68        ///
69        /// ## Thread safety
70        /// This function should only be called on the main thread.
71        ///
72        /// ## Availability
73        /// This function is available since SDL 3.2.0.
74        ///
75        /// ## See also
76        /// - [`SDL_WindowsMessageHook`]
77        /// - [`SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP`]
78        pub fn SDL_SetWindowsMessageHook(callback: SDL_WindowsMessageHook, userdata: *mut ::core::ffi::c_void);
79    }
80
81    #[doc(hidden)]
82    #[repr(C)]
83    pub struct tagMSG { _opaque: [::core::primitive::u8; 0] }
84
85});
86
87apply_cfg!(#[cfg(any(any(doc, target_os = "windows"), any(doc, all(target_os = "windows", feature = "target-gdk"))))] => {
88    unsafe extern "C" {
89        /// Get the D3D9 adapter index that matches the specified display.
90        ///
91        /// The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
92        /// controls on which monitor a full screen application will appear.
93        ///
94        /// ## Parameters
95        /// - `displayID`: the instance of the display to query.
96        ///
97        /// ## Return value
98        /// Returns the D3D9 adapter index on success or -1 on failure; call
99        ///   [`SDL_GetError()`] for more information.
100        ///
101        /// ## Availability
102        /// This function is available since SDL 3.2.0.
103        pub fn SDL_GetDirect3D9AdapterIndex(displayID: SDL_DisplayID) -> ::core::ffi::c_int;
104    }
105
106    unsafe extern "C" {
107        /// Get the DXGI Adapter and Output indices for the specified display.
108        ///
109        /// The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
110        /// `EnumOutputs` respectively to get the objects required to create a DX10 or
111        /// DX11 device and swap chain.
112        ///
113        /// ## Parameters
114        /// - `displayID`: the instance of the display to query.
115        /// - `adapterIndex`: a pointer to be filled in with the adapter index.
116        /// - `outputIndex`: a pointer to be filled in with the output index.
117        ///
118        /// ## Return value
119        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
120        ///   information.
121        ///
122        /// ## Availability
123        /// This function is available since SDL 3.2.0.
124        pub fn SDL_GetDXGIOutputInfo(displayID: SDL_DisplayID, adapterIndex: *mut ::core::ffi::c_int, outputIndex: *mut ::core::ffi::c_int) -> ::core::primitive::bool;
125    }
126
127});
128
129apply_cfg!(#[cfg(feature = "use-x11-v2")] => {
130    #[cfg_attr(all(feature = "nightly", doc), doc(cfg(all())))]
131    /// (`sdl3-sys`) Enable either a `use-x11-*` or a `use-x11-dl-*` feature to alias this to `XEvent` from the `x11` or `x11-dl` crates, respectively. Otherwise it's an opaque struct.
132    pub type XEvent = ::x11_v2::xlib::XEvent;
133});
134
135apply_cfg!(#[cfg(all(not(feature = "use-x11-v2"), feature = "use-x11-dl-v2"))] => {
136    #[cfg_attr(all(feature = "nightly", doc), doc(cfg(all())))]
137    /// (`sdl3-sys`) Enable either a `use-x11-*` or a `use-x11-dl-*` feature to alias this to `XEvent` from the `x11` or `x11-dl` crates, respectively. Otherwise it's an opaque struct.
138    pub type XEvent = ::x11_dl_v2::xlib::XEvent;
139});
140
141apply_cfg!(#[cfg(not(any(feature = "use-x11-dl-v2", feature = "use-x11-v2")))] => {
142    #[cfg_attr(all(feature = "nightly", doc), doc(cfg(all())))]
143    /// (`sdl3-sys`) Enable either a `use-x11-*` or a `use-x11-dl-*` feature to alias this to `XEvent` from the `x11` or `x11-dl` crates, respectively. Otherwise it's an opaque struct.
144    pub type XEvent = _XEvent;
145
146});
147
148/// A callback to be used with [`SDL_SetX11EventHook`].
149///
150/// This callback may modify the event, and should return true if the event
151/// should continue to be processed, or false to prevent further processing.
152///
153/// As this is processing an event directly from the X11 event loop, this
154/// callback should do the minimum required work and return quickly.
155///
156/// ## Parameters
157/// - `userdata`: the app-defined pointer provided to [`SDL_SetX11EventHook`].
158/// - `xevent`: a pointer to an Xlib XEvent union to process.
159///
160/// ## Return value
161/// Returns true to let event continue on, false to drop it.
162///
163/// ## Thread safety
164/// This may only be called (by SDL) from the thread handling the
165///   X11 event loop.
166///
167/// ## Availability
168/// This datatype is available since SDL 3.2.0.
169///
170/// ## See also
171/// - [`SDL_SetX11EventHook`]
172pub type SDL_X11EventHook = ::core::option::Option<
173    unsafe extern "C" fn(
174        userdata: *mut ::core::ffi::c_void,
175        xevent: *mut XEvent,
176    ) -> ::core::primitive::bool,
177>;
178
179unsafe extern "C" {
180    /// Set a callback for every X11 event.
181    ///
182    /// The callback may modify the event, and should return true if the event
183    /// should continue to be processed, or false to prevent further processing.
184    ///
185    /// ## Parameters
186    /// - `callback`: the [`SDL_X11EventHook`] function to call.
187    /// - `userdata`: a pointer to pass to every iteration of `callback`.
188    ///
189    /// ## Thread safety
190    /// This function should only be called on the main thread.
191    ///
192    /// ## Availability
193    /// This function is available since SDL 3.2.0.
194    pub fn SDL_SetX11EventHook(callback: SDL_X11EventHook, userdata: *mut ::core::ffi::c_void);
195}
196
197apply_cfg!(#[cfg(any(doc, target_os = "linux"))] => {
198    unsafe extern "C" {
199        /// Sets the UNIX nice value for a thread.
200        ///
201        /// This uses setpriority() if possible, and RealtimeKit if available.
202        ///
203        /// ## Parameters
204        /// - `threadID`: the Unix thread ID to change priority of.
205        /// - `priority`: the new, Unix-specific, priority value.
206        ///
207        /// ## Return value
208        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
209        ///   information.
210        ///
211        /// ## Thread safety
212        /// It is safe to call this function from any thread.
213        ///
214        /// ## Availability
215        /// This function is available since SDL 3.2.0.
216        pub fn SDL_SetLinuxThreadPriority(threadID: Sint64, priority: ::core::ffi::c_int) -> ::core::primitive::bool;
217    }
218
219    unsafe extern "C" {
220        /// Sets the priority (not nice level) and scheduling policy for a thread.
221        ///
222        /// This uses setpriority() if possible, and RealtimeKit if available.
223        ///
224        /// ## Parameters
225        /// - `threadID`: the Unix thread ID to change priority of.
226        /// - `sdlPriority`: the new [`SDL_ThreadPriority`] value.
227        /// - `schedPolicy`: the new scheduling policy (SCHED_FIFO, SCHED_RR,
228        ///   SCHED_OTHER, etc...).
229        ///
230        /// ## Return value
231        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
232        ///   information.
233        ///
234        /// ## Thread safety
235        /// It is safe to call this function from any thread.
236        ///
237        /// ## Availability
238        /// This function is available since SDL 3.2.0.
239        pub fn SDL_SetLinuxThreadPriorityAndPolicy(threadID: Sint64, sdlPriority: ::core::ffi::c_int, schedPolicy: ::core::ffi::c_int) -> ::core::primitive::bool;
240    }
241
242});
243
244apply_cfg!(#[cfg(any(doc, target_os = "ios", target_os = "tvos", target_os = "visionos", target_os = "watchos"))] => {
245    /// The prototype for an Apple iOS animation callback.
246    ///
247    /// This datatype is only useful on Apple iOS.
248    ///
249    /// After passing a function pointer of this type to
250    /// [`SDL_SetiOSAnimationCallback`], the system will call that function pointer at
251    /// a regular interval.
252    ///
253    /// ## Parameters
254    /// - `userdata`: what was passed as `callbackParam` to
255    ///   [`SDL_SetiOSAnimationCallback`] as `callbackParam`.
256    ///
257    /// ## Availability
258    /// This datatype is available since SDL 3.2.0.
259    ///
260    /// ## See also
261    /// - [`SDL_SetiOSAnimationCallback`]
262    pub type SDL_iOSAnimationCallback = ::core::option::Option<unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void)>;
263
264    unsafe extern "C" {
265        /// Use this function to set the animation callback on Apple iOS.
266        ///
267        /// The function prototype for `callback` is:
268        ///
269        /// ```c
270        /// void callback(void *callbackParam);
271        /// ```
272        ///
273        /// Where its parameter, `callbackParam`, is what was passed as `callbackParam`
274        /// to [`SDL_SetiOSAnimationCallback()`].
275        ///
276        /// This function is only available on Apple iOS.
277        ///
278        /// For more information see:
279        ///
280        /// <https://wiki.libsdl.org/SDL3/README-ios>
281        ///
282        /// Note that if you use the "main callbacks" instead of a standard C `main`
283        /// function, you don't have to use this API, as SDL will manage this for you.
284        ///
285        /// Details on main callbacks are here:
286        ///
287        /// <https://wiki.libsdl.org/SDL3/README-main-functions>
288        ///
289        /// ## Parameters
290        /// - `window`: the window for which the animation callback should be set.
291        /// - `interval`: the number of frames after which **callback** will be
292        ///   called.
293        /// - `callback`: the function to call for every frame.
294        /// - `callbackParam`: a pointer that is passed to `callback`.
295        ///
296        /// ## Return value
297        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
298        ///   information.
299        ///
300        /// ## Thread safety
301        /// This function should only be called on the main thread.
302        ///
303        /// ## Availability
304        /// This function is available since SDL 3.2.0.
305        ///
306        /// ## See also
307        /// - [`SDL_SetiOSEventPump`]
308        pub fn SDL_SetiOSAnimationCallback(window: *mut SDL_Window, interval: ::core::ffi::c_int, callback: SDL_iOSAnimationCallback, callbackParam: *mut ::core::ffi::c_void) -> ::core::primitive::bool;
309    }
310
311    unsafe extern "C" {
312        /// Use this function to enable or disable the SDL event pump on Apple iOS.
313        ///
314        /// This function is only available on Apple iOS.
315        ///
316        /// ## Parameters
317        /// - `enabled`: true to enable the event pump, false to disable it.
318        ///
319        /// ## Thread safety
320        /// This function should only be called on the main thread.
321        ///
322        /// ## Availability
323        /// This function is available since SDL 3.2.0.
324        ///
325        /// ## See also
326        /// - [`SDL_SetiOSAnimationCallback`]
327        pub fn SDL_SetiOSEventPump(enabled: ::core::primitive::bool);
328    }
329
330});
331
332apply_cfg!(#[cfg(any(doc, target_os = "android"))] => {
333    unsafe extern "C" {
334        /// Get the Android Java Native Interface Environment of the current thread.
335        ///
336        /// This is the JNIEnv one needs to access the Java virtual machine from native
337        /// code, and is needed for many Android APIs to be usable from C.
338        ///
339        /// The prototype of the function in SDL's code actually declare a void* return
340        /// type, even if the implementation returns a pointer to a JNIEnv. The
341        /// rationale being that the SDL headers can avoid including jni.h.
342        ///
343        /// ## Return value
344        /// Returns a pointer to Java native interface object (JNIEnv) to which the
345        ///   current thread is attached, or NULL on failure; call
346        ///   [`SDL_GetError()`] for more information.
347        ///
348        /// ## Thread safety
349        /// It is safe to call this function from any thread.
350        ///
351        /// ## Availability
352        /// This function is available since SDL 3.2.0.
353        ///
354        /// ## See also
355        /// - [`SDL_GetAndroidActivity`]
356        pub fn SDL_GetAndroidJNIEnv() -> *mut ::core::ffi::c_void;
357    }
358
359    unsafe extern "C" {
360        /// Retrieve the Java instance of the Android activity class.
361        ///
362        /// The prototype of the function in SDL's code actually declares a void*
363        /// return type, even if the implementation returns a jobject. The rationale
364        /// being that the SDL headers can avoid including jni.h.
365        ///
366        /// The jobject returned by the function is a local reference and must be
367        /// released by the caller. See the PushLocalFrame() and PopLocalFrame() or
368        /// DeleteLocalRef() functions of the Java native interface:
369        ///
370        /// <https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html>
371        ///
372        /// ## Return value
373        /// Returns the jobject representing the instance of the Activity class of the
374        ///   Android application, or NULL on failure; call [`SDL_GetError()`] for
375        ///   more information.
376        ///
377        /// ## Thread safety
378        /// It is safe to call this function from any thread.
379        ///
380        /// ## Availability
381        /// This function is available since SDL 3.2.0.
382        ///
383        /// ## See also
384        /// - [`SDL_GetAndroidJNIEnv`]
385        pub fn SDL_GetAndroidActivity() -> *mut ::core::ffi::c_void;
386    }
387
388    unsafe extern "C" {
389        /// Query Android API level of the current device.
390        ///
391        /// - API level 35: Android 15 (VANILLA_ICE_CREAM)
392        /// - API level 34: Android 14 (UPSIDE_DOWN_CAKE)
393        /// - API level 33: Android 13 (TIRAMISU)
394        /// - API level 32: Android 12L (S_V2)
395        /// - API level 31: Android 12 (S)
396        /// - API level 30: Android 11 (R)
397        /// - API level 29: Android 10 (Q)
398        /// - API level 28: Android 9 (P)
399        /// - API level 27: Android 8.1 (O_MR1)
400        /// - API level 26: Android 8.0 (O)
401        /// - API level 25: Android 7.1 (N_MR1)
402        /// - API level 24: Android 7.0 (N)
403        /// - API level 23: Android 6.0 (M)
404        /// - API level 22: Android 5.1 (LOLLIPOP_MR1)
405        /// - API level 21: Android 5.0 (LOLLIPOP, L)
406        /// - API level 20: Android 4.4W (KITKAT_WATCH)
407        /// - API level 19: Android 4.4 (KITKAT)
408        /// - API level 18: Android 4.3 (JELLY_BEAN_MR2)
409        /// - API level 17: Android 4.2 (JELLY_BEAN_MR1)
410        /// - API level 16: Android 4.1 (JELLY_BEAN)
411        /// - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
412        /// - API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
413        /// - API level 13: Android 3.2 (HONEYCOMB_MR2)
414        /// - API level 12: Android 3.1 (HONEYCOMB_MR1)
415        /// - API level 11: Android 3.0 (HONEYCOMB)
416        /// - API level 10: Android 2.3.3 (GINGERBREAD_MR1)
417        ///
418        /// ## Return value
419        /// Returns the Android API level.
420        ///
421        /// ## Thread safety
422        /// It is safe to call this function from any thread.
423        ///
424        /// ## Availability
425        /// This function is available since SDL 3.2.0.
426        pub fn SDL_GetAndroidSDKVersion() -> ::core::ffi::c_int;
427    }
428
429    unsafe extern "C" {
430        /// Query if the application is running on a Chromebook.
431        ///
432        /// ## Return value
433        /// Returns true if this is a Chromebook, false otherwise.
434        ///
435        /// ## Thread safety
436        /// It is safe to call this function from any thread.
437        ///
438        /// ## Availability
439        /// This function is available since SDL 3.2.0.
440        pub fn SDL_IsChromebook() -> ::core::primitive::bool;
441    }
442
443    unsafe extern "C" {
444        /// Query if the application is running on a Samsung DeX docking station.
445        ///
446        /// ## Return value
447        /// Returns true if this is a DeX docking station, false otherwise.
448        ///
449        /// ## Thread safety
450        /// It is safe to call this function from any thread.
451        ///
452        /// ## Availability
453        /// This function is available since SDL 3.2.0.
454        pub fn SDL_IsDeXMode() -> ::core::primitive::bool;
455    }
456
457    unsafe extern "C" {
458        /// Trigger the Android system back button behavior.
459        ///
460        /// ## Thread safety
461        /// It is safe to call this function from any thread.
462        ///
463        /// ## Availability
464        /// This function is available since SDL 3.2.0.
465        pub fn SDL_SendAndroidBackButton();
466    }
467
468    /// See the official Android developer guide for more information:
469    /// <http://developer.android.com/guide/topics/data/data-storage.html>
470    ///
471    /// ## Availability
472    /// This macro is available since SDL 3.2.0.
473    pub const SDL_ANDROID_EXTERNAL_STORAGE_READ: Uint32 = (0x01 as Uint32);
474
475    /// See the official Android developer guide for more information:
476    /// <http://developer.android.com/guide/topics/data/data-storage.html>
477    ///
478    /// ## Availability
479    /// This macro is available since SDL 3.2.0.
480    pub const SDL_ANDROID_EXTERNAL_STORAGE_WRITE: Uint32 = (0x02 as Uint32);
481
482    unsafe extern "C" {
483        /// Get the path used for internal storage for this Android application.
484        ///
485        /// This path is unique to your application and cannot be written to by other
486        /// applications.
487        ///
488        /// Your internal storage path is typically:
489        /// `/data/data/your.app.package/files`.
490        ///
491        /// This is a C wrapper over `android.content.Context.getFilesDir()`:
492        ///
493        /// <https://developer.android.com/reference/android/content/Context#getFilesDir()>
494        ///
495        /// ## Return value
496        /// Returns the path used for internal storage or NULL on failure; call
497        ///   [`SDL_GetError()`] for more information.
498        ///
499        /// ## Availability
500        /// This function is available since SDL 3.2.0.
501        ///
502        /// ## See also
503        /// - [`SDL_GetAndroidExternalStoragePath`]
504        /// - [`SDL_GetAndroidCachePath`]
505        pub fn SDL_GetAndroidInternalStoragePath() -> *const ::core::ffi::c_char;
506    }
507
508    unsafe extern "C" {
509        /// Get the current state of external storage for this Android application.
510        ///
511        /// The current state of external storage, a bitmask of these values:
512        /// [`SDL_ANDROID_EXTERNAL_STORAGE_READ`], [`SDL_ANDROID_EXTERNAL_STORAGE_WRITE`].
513        ///
514        /// If external storage is currently unavailable, this will return 0.
515        ///
516        /// ## Return value
517        /// Returns the current state of external storage, or 0 if external storage is
518        ///   currently unavailable.
519        ///
520        /// ## Availability
521        /// This function is available since SDL 3.2.0.
522        ///
523        /// ## See also
524        /// - [`SDL_GetAndroidExternalStoragePath`]
525        pub fn SDL_GetAndroidExternalStorageState() -> Uint32;
526    }
527
528    unsafe extern "C" {
529        /// Get the path used for external storage for this Android application.
530        ///
531        /// This path is unique to your application, but is public and can be written
532        /// to by other applications.
533        ///
534        /// Your external storage path is typically:
535        /// `/storage/sdcard0/Android/data/your.app.package/files`.
536        ///
537        /// This is a C wrapper over `android.content.Context.getExternalFilesDir()`:
538        ///
539        /// <https://developer.android.com/reference/android/content/Context#getExternalFilesDir()>
540        ///
541        /// ## Return value
542        /// Returns the path used for external storage for this application on success
543        ///   or NULL on failure; call [`SDL_GetError()`] for more information.
544        ///
545        /// ## Availability
546        /// This function is available since SDL 3.2.0.
547        ///
548        /// ## See also
549        /// - [`SDL_GetAndroidExternalStorageState`]
550        /// - [`SDL_GetAndroidInternalStoragePath`]
551        /// - [`SDL_GetAndroidCachePath`]
552        pub fn SDL_GetAndroidExternalStoragePath() -> *const ::core::ffi::c_char;
553    }
554
555    unsafe extern "C" {
556        /// Get the path used for caching data for this Android application.
557        ///
558        /// This path is unique to your application, but is public and can be written
559        /// to by other applications.
560        ///
561        /// Your cache path is typically: `/data/data/your.app.package/cache/`.
562        ///
563        /// This is a C wrapper over `android.content.Context.getCacheDir()`:
564        ///
565        /// <https://developer.android.com/reference/android/content/Context#getCacheDir()>
566        ///
567        /// ## Return value
568        /// Returns the path used for caches for this application on success or NULL
569        ///   on failure; call [`SDL_GetError()`] for more information.
570        ///
571        /// ## Availability
572        /// This function is available since SDL 3.2.0.
573        ///
574        /// ## See also
575        /// - [`SDL_GetAndroidInternalStoragePath`]
576        /// - [`SDL_GetAndroidExternalStoragePath`]
577        pub fn SDL_GetAndroidCachePath() -> *const ::core::ffi::c_char;
578    }
579
580    /// Callback that presents a response from a [`SDL_RequestAndroidPermission`] call.
581    ///
582    /// ## Parameters
583    /// - `userdata`: an app-controlled pointer that is passed to the callback.
584    /// - `permission`: the Android-specific permission name that was requested.
585    /// - `granted`: true if permission is granted, false if denied.
586    ///
587    /// ## Availability
588    /// This datatype is available since SDL 3.2.0.
589    ///
590    /// ## See also
591    /// - [`SDL_RequestAndroidPermission`]
592    pub type SDL_RequestAndroidPermissionCallback = ::core::option::Option<unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, permission: *const ::core::ffi::c_char, granted: ::core::primitive::bool)>;
593
594    unsafe extern "C" {
595        /// Request permissions at runtime, asynchronously.
596        ///
597        /// You do not need to call this for built-in functionality of SDL; recording
598        /// from a microphone or reading images from a camera, using standard SDL APIs,
599        /// will manage permission requests for you.
600        ///
601        /// This function never blocks. Instead, the app-supplied callback will be
602        /// called when a decision has been made. This callback may happen on a
603        /// different thread, and possibly much later, as it might wait on a user to
604        /// respond to a system dialog. If permission has already been granted for a
605        /// specific entitlement, the callback will still fire, probably on the current
606        /// thread and before this function returns.
607        ///
608        /// If the request submission fails, this function returns -1 and the callback
609        /// will NOT be called, but this should only happen in catastrophic conditions,
610        /// like memory running out. Normally there will be a yes or no to the request
611        /// through the callback.
612        ///
613        /// For the `permission` parameter, choose a value from here:
614        ///
615        /// <https://developer.android.com/reference/android/Manifest.permission>
616        ///
617        /// ## Parameters
618        /// - `permission`: the permission to request.
619        /// - `cb`: the callback to trigger when the request has a response.
620        /// - `userdata`: an app-controlled pointer that is passed to the callback.
621        ///
622        /// ## Return value
623        /// Returns true if the request was submitted, false if there was an error
624        ///   submitting. The result of the request is only ever reported
625        ///   through the callback, not this return value.
626        ///
627        /// ## Thread safety
628        /// It is safe to call this function from any thread.
629        ///
630        /// ## Availability
631        /// This function is available since SDL 3.2.0.
632        pub fn SDL_RequestAndroidPermission(permission: *const ::core::ffi::c_char, cb: SDL_RequestAndroidPermissionCallback, userdata: *mut ::core::ffi::c_void) -> ::core::primitive::bool;
633    }
634
635    unsafe extern "C" {
636        /// Shows an Android toast notification.
637        ///
638        /// Toasts are a sort of lightweight notification that are unique to Android.
639        ///
640        /// <https://developer.android.com/guide/topics/ui/notifiers/toasts>
641        ///
642        /// Shows toast in UI thread.
643        ///
644        /// For the `gravity` parameter, choose a value from here, or -1 if you don't
645        /// have a preference:
646        ///
647        /// <https://developer.android.com/reference/android/view/Gravity>
648        ///
649        /// ## Parameters
650        /// - `message`: text message to be shown.
651        /// - `duration`: 0=short, 1=long.
652        /// - `gravity`: where the notification should appear on the screen.
653        /// - `xoffset`: set this parameter only when gravity >=0.
654        /// - `yoffset`: set this parameter only when gravity >=0.
655        ///
656        /// ## Return value
657        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
658        ///   information.
659        ///
660        /// ## Thread safety
661        /// It is safe to call this function from any thread.
662        ///
663        /// ## Availability
664        /// This function is available since SDL 3.2.0.
665        pub fn SDL_ShowAndroidToast(message: *const ::core::ffi::c_char, duration: ::core::ffi::c_int, gravity: ::core::ffi::c_int, xoffset: ::core::ffi::c_int, yoffset: ::core::ffi::c_int) -> ::core::primitive::bool;
666    }
667
668    unsafe extern "C" {
669        /// Send a user command to SDLActivity.
670        ///
671        /// Override "boolean onUnhandledMessage(Message msg)" to handle the message.
672        ///
673        /// ## Parameters
674        /// - `command`: user command that must be greater or equal to 0x8000.
675        /// - `param`: user parameter.
676        ///
677        /// ## Return value
678        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
679        ///   information.
680        ///
681        /// ## Thread safety
682        /// It is safe to call this function from any thread.
683        ///
684        /// ## Availability
685        /// This function is available since SDL 3.2.0.
686        pub fn SDL_SendAndroidMessage(command: Uint32, param: ::core::ffi::c_int) -> ::core::primitive::bool;
687    }
688
689});
690
691unsafe extern "C" {
692    /// Query if the current device is a tablet.
693    ///
694    /// If SDL can't determine this, it will return false.
695    ///
696    /// ## Return value
697    /// Returns true if the device is a tablet, false otherwise.
698    ///
699    /// ## Thread safety
700    /// It is safe to call this function from any thread.
701    ///
702    /// ## Availability
703    /// This function is available since SDL 3.2.0.
704    pub fn SDL_IsTablet() -> ::core::primitive::bool;
705}
706
707unsafe extern "C" {
708    /// Query if the current device is a TV.
709    ///
710    /// If SDL can't determine this, it will return false.
711    ///
712    /// ## Return value
713    /// Returns true if the device is a TV, false otherwise.
714    ///
715    /// ## Thread safety
716    /// It is safe to call this function from any thread.
717    ///
718    /// ## Availability
719    /// This function is available since SDL 3.2.0.
720    pub fn SDL_IsTV() -> ::core::primitive::bool;
721}
722
723/// Application sandbox environment.
724///
725/// ## Availability
726/// This enum is available since SDL 3.2.0.
727///
728/// ## Known values (`sdl3-sys`)
729/// | Associated constant | Global constant | Description |
730/// | ------------------- | --------------- | ----------- |
731/// | [`NONE`](SDL_Sandbox::NONE) | [`SDL_SANDBOX_NONE`] | |
732/// | [`UNKNOWN_CONTAINER`](SDL_Sandbox::UNKNOWN_CONTAINER) | [`SDL_SANDBOX_UNKNOWN_CONTAINER`] | |
733/// | [`FLATPAK`](SDL_Sandbox::FLATPAK) | [`SDL_SANDBOX_FLATPAK`] | |
734/// | [`SNAP`](SDL_Sandbox::SNAP) | [`SDL_SANDBOX_SNAP`] | |
735/// | [`MACOS`](SDL_Sandbox::MACOS) | [`SDL_SANDBOX_MACOS`] | |
736#[repr(transparent)]
737#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
738pub struct SDL_Sandbox(pub ::core::ffi::c_int);
739
740impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_Sandbox {
741    #[inline(always)]
742    fn eq(&self, other: &::core::ffi::c_int) -> bool {
743        &self.0 == other
744    }
745}
746
747impl ::core::cmp::PartialEq<SDL_Sandbox> for ::core::ffi::c_int {
748    #[inline(always)]
749    fn eq(&self, other: &SDL_Sandbox) -> bool {
750        self == &other.0
751    }
752}
753
754impl From<SDL_Sandbox> for ::core::ffi::c_int {
755    #[inline(always)]
756    fn from(value: SDL_Sandbox) -> Self {
757        value.0
758    }
759}
760
761#[cfg(feature = "debug-impls")]
762impl ::core::fmt::Debug for SDL_Sandbox {
763    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
764        #[allow(unreachable_patterns)]
765        f.write_str(match *self {
766            Self::NONE => "SDL_SANDBOX_NONE",
767            Self::UNKNOWN_CONTAINER => "SDL_SANDBOX_UNKNOWN_CONTAINER",
768            Self::FLATPAK => "SDL_SANDBOX_FLATPAK",
769            Self::SNAP => "SDL_SANDBOX_SNAP",
770            Self::MACOS => "SDL_SANDBOX_MACOS",
771
772            _ => return write!(f, "SDL_Sandbox({})", self.0),
773        })
774    }
775}
776
777impl SDL_Sandbox {
778    pub const NONE: Self = Self((0 as ::core::ffi::c_int));
779    pub const UNKNOWN_CONTAINER: Self = Self((1 as ::core::ffi::c_int));
780    pub const FLATPAK: Self = Self((2 as ::core::ffi::c_int));
781    pub const SNAP: Self = Self((3 as ::core::ffi::c_int));
782    pub const MACOS: Self = Self((4 as ::core::ffi::c_int));
783}
784
785pub const SDL_SANDBOX_NONE: SDL_Sandbox = SDL_Sandbox::NONE;
786pub const SDL_SANDBOX_UNKNOWN_CONTAINER: SDL_Sandbox = SDL_Sandbox::UNKNOWN_CONTAINER;
787pub const SDL_SANDBOX_FLATPAK: SDL_Sandbox = SDL_Sandbox::FLATPAK;
788pub const SDL_SANDBOX_SNAP: SDL_Sandbox = SDL_Sandbox::SNAP;
789pub const SDL_SANDBOX_MACOS: SDL_Sandbox = SDL_Sandbox::MACOS;
790
791impl SDL_Sandbox {
792    /// Initialize a `SDL_Sandbox` from a raw value.
793    #[inline(always)]
794    pub const fn new(value: ::core::ffi::c_int) -> Self {
795        Self(value)
796    }
797}
798
799impl SDL_Sandbox {
800    /// Get a copy of the inner raw value.
801    #[inline(always)]
802    pub const fn value(&self) -> ::core::ffi::c_int {
803        self.0
804    }
805}
806
807#[cfg(feature = "metadata")]
808impl sdl3_sys::metadata::GroupMetadata for SDL_Sandbox {
809    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
810        &crate::metadata::system::METADATA_SDL_Sandbox;
811}
812
813unsafe extern "C" {
814    /// Get the application sandbox environment, if any.
815    ///
816    /// ## Return value
817    /// Returns the application sandbox environment or [`SDL_SANDBOX_NONE`] if the
818    ///   application is not running in a sandbox environment.
819    ///
820    /// ## Availability
821    /// This function is available since SDL 3.2.0.
822    pub fn SDL_GetSandbox() -> SDL_Sandbox;
823}
824
825unsafe extern "C" {
826    /// Let iOS apps with external event handling report
827    /// onApplicationWillTerminate.
828    ///
829    /// This functions allows iOS apps that have their own event handling to hook
830    /// into SDL to generate SDL events. This maps directly to an iOS-specific
831    /// event, but since it doesn't do anything iOS-specific internally, it is
832    /// available on all platforms, in case it might be useful for some specific
833    /// paradigm. Most apps do not need to use this directly; SDL's internal event
834    /// code will handle all this for windows created by SDL_CreateWindow!
835    ///
836    /// ## Thread safety
837    /// It is safe to call this function from any thread.
838    ///
839    /// ## Availability
840    /// This function is available since SDL 3.2.0.
841    pub fn SDL_OnApplicationWillTerminate();
842}
843
844unsafe extern "C" {
845    /// Let iOS apps with external event handling report
846    /// onApplicationDidReceiveMemoryWarning.
847    ///
848    /// This functions allows iOS apps that have their own event handling to hook
849    /// into SDL to generate SDL events. This maps directly to an iOS-specific
850    /// event, but since it doesn't do anything iOS-specific internally, it is
851    /// available on all platforms, in case it might be useful for some specific
852    /// paradigm. Most apps do not need to use this directly; SDL's internal event
853    /// code will handle all this for windows created by SDL_CreateWindow!
854    ///
855    /// ## Thread safety
856    /// It is safe to call this function from any thread.
857    ///
858    /// ## Availability
859    /// This function is available since SDL 3.2.0.
860    pub fn SDL_OnApplicationDidReceiveMemoryWarning();
861}
862
863unsafe extern "C" {
864    /// Let iOS apps with external event handling report
865    /// onApplicationWillResignActive.
866    ///
867    /// This functions allows iOS apps that have their own event handling to hook
868    /// into SDL to generate SDL events. This maps directly to an iOS-specific
869    /// event, but since it doesn't do anything iOS-specific internally, it is
870    /// available on all platforms, in case it might be useful for some specific
871    /// paradigm. Most apps do not need to use this directly; SDL's internal event
872    /// code will handle all this for windows created by SDL_CreateWindow!
873    ///
874    /// ## Thread safety
875    /// It is safe to call this function from any thread.
876    ///
877    /// ## Availability
878    /// This function is available since SDL 3.2.0.
879    pub fn SDL_OnApplicationWillEnterBackground();
880}
881
882unsafe extern "C" {
883    /// Let iOS apps with external event handling report
884    /// onApplicationDidEnterBackground.
885    ///
886    /// This functions allows iOS apps that have their own event handling to hook
887    /// into SDL to generate SDL events. This maps directly to an iOS-specific
888    /// event, but since it doesn't do anything iOS-specific internally, it is
889    /// available on all platforms, in case it might be useful for some specific
890    /// paradigm. Most apps do not need to use this directly; SDL's internal event
891    /// code will handle all this for windows created by SDL_CreateWindow!
892    ///
893    /// ## Thread safety
894    /// It is safe to call this function from any thread.
895    ///
896    /// ## Availability
897    /// This function is available since SDL 3.2.0.
898    pub fn SDL_OnApplicationDidEnterBackground();
899}
900
901unsafe extern "C" {
902    /// Let iOS apps with external event handling report
903    /// onApplicationWillEnterForeground.
904    ///
905    /// This functions allows iOS apps that have their own event handling to hook
906    /// into SDL to generate SDL events. This maps directly to an iOS-specific
907    /// event, but since it doesn't do anything iOS-specific internally, it is
908    /// available on all platforms, in case it might be useful for some specific
909    /// paradigm. Most apps do not need to use this directly; SDL's internal event
910    /// code will handle all this for windows created by SDL_CreateWindow!
911    ///
912    /// ## Thread safety
913    /// It is safe to call this function from any thread.
914    ///
915    /// ## Availability
916    /// This function is available since SDL 3.2.0.
917    pub fn SDL_OnApplicationWillEnterForeground();
918}
919
920unsafe extern "C" {
921    /// Let iOS apps with external event handling report
922    /// onApplicationDidBecomeActive.
923    ///
924    /// This functions allows iOS apps that have their own event handling to hook
925    /// into SDL to generate SDL events. This maps directly to an iOS-specific
926    /// event, but since it doesn't do anything iOS-specific internally, it is
927    /// available on all platforms, in case it might be useful for some specific
928    /// paradigm. Most apps do not need to use this directly; SDL's internal event
929    /// code will handle all this for windows created by SDL_CreateWindow!
930    ///
931    /// ## Thread safety
932    /// It is safe to call this function from any thread.
933    ///
934    /// ## Availability
935    /// This function is available since SDL 3.2.0.
936    pub fn SDL_OnApplicationDidEnterForeground();
937}
938
939apply_cfg!(#[cfg(any(doc, target_os = "ios", target_os = "tvos", target_os = "visionos", target_os = "watchos"))] => {
940    unsafe extern "C" {
941        /// Let iOS apps with external event handling report
942        /// onApplicationDidChangeStatusBarOrientation.
943        ///
944        /// This functions allows iOS apps that have their own event handling to hook
945        /// into SDL to generate SDL events. This maps directly to an iOS-specific
946        /// event, but since it doesn't do anything iOS-specific internally, it is
947        /// available on all platforms, in case it might be useful for some specific
948        /// paradigm. Most apps do not need to use this directly; SDL's internal event
949        /// code will handle all this for windows created by SDL_CreateWindow!
950        ///
951        /// ## Thread safety
952        /// It is safe to call this function from any thread.
953        ///
954        /// ## Availability
955        /// This function is available since SDL 3.2.0.
956        pub fn SDL_OnApplicationDidChangeStatusBarOrientation();
957    }
958
959});
960
961apply_cfg!(#[cfg(any(doc, all(windows, feature = "target-gdk")))] => {
962    pub type XTaskQueueHandle = *mut XTaskQueueObject;
963
964    pub type XUserHandle = *mut XUser;
965
966    unsafe extern "C" {
967        /// Gets a reference to the global async task queue handle for GDK,
968        /// initializing if needed.
969        ///
970        /// Once you are done with the task queue, you should call
971        /// XTaskQueueCloseHandle to reduce the reference count to avoid a resource
972        /// leak.
973        ///
974        /// ## Parameters
975        /// - `outTaskQueue`: a pointer to be filled in with task queue handle.
976        ///
977        /// ## Return value
978        /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
979        ///   information.
980        ///
981        /// ## Availability
982        /// This function is available since SDL 3.2.0.
983        pub fn SDL_GetGDKTaskQueue(outTaskQueue: *mut XTaskQueueHandle) -> ::core::primitive::bool;
984    }
985
986    unsafe extern "C" {
987        /// Gets a reference to the default user handle for GDK.
988        ///
989        /// This is effectively a synchronous version of XUserAddAsync, which always
990        /// prefers the default user and allows a sign-in UI.
991        ///
992        /// ## Parameters
993        /// - `outUserHandle`: a pointer to be filled in with the default user
994        ///   handle.
995        ///
996        /// ## Return value
997        /// Returns true if success or false on failure; call [`SDL_GetError()`] for more
998        ///   information.
999        ///
1000        /// ## Availability
1001        /// This function is available since SDL 3.2.0.
1002        pub fn SDL_GetGDKDefaultUser(outUserHandle: *mut XUserHandle) -> ::core::primitive::bool;
1003    }
1004
1005    #[repr(C)]
1006    pub struct XTaskQueueObject { _opaque: [::core::primitive::u8; 0] }
1007
1008    #[repr(C)]
1009    pub struct XUser { _opaque: [::core::primitive::u8; 0] }
1010
1011});
1012
1013#[doc(hidden)]
1014#[repr(C)]
1015pub struct _XEvent {
1016    _opaque: [::core::primitive::u8; 0],
1017}
1018
1019#[cfg(doc)]
1020use crate::everything::*;