SDL_system.h 29 KB

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