SDL_system.h 26 KB

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