SDL_system.h 26 KB

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