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