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