SDL_system.h 28 KB

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