SDL_system.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  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_WIN32) || defined(SDL_PLATFORM_GDK)
  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_WIN32) || defined(SDL_PLATFORM_GDK) */
  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 a negative error code on
  90. * failure; call 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_Direct3D9GetAdapterIndex(SDL_DisplayID displayID);
  95. #endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
  96. #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
  97. /**
  98. * Get the DXGI Adapter and Output indices for the specified display.
  99. *
  100. * The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
  101. * `EnumOutputs` respectively to get the objects required to create a DX10 or
  102. * DX11 device and swap chain.
  103. *
  104. * \param displayID the instance of the display to query
  105. * \param adapterIndex a pointer to be filled in with the adapter index
  106. * \param outputIndex a pointer to be filled in with the output index
  107. * \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
  108. * for more information.
  109. *
  110. * \since This function is available since SDL 3.0.0.
  111. */
  112. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
  113. #endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
  114. /*
  115. * Platform specific functions for UNIX
  116. */
  117. typedef union _XEvent XEvent;
  118. typedef SDL_bool (SDLCALL *SDL_X11EventHook)(void *userdata, XEvent *xevent);
  119. /**
  120. * Set a callback for every X11 event.
  121. *
  122. * The callback may modify the event, and should return SDL_TRUE if the event
  123. * should continue to be processed, or SDL_FALSE to prevent further
  124. * processing.
  125. *
  126. * \param callback The SDL_X11EventHook function to call.
  127. * \param userdata a pointer to pass to every iteration of `callback`
  128. *
  129. * \since This function is available since SDL 3.0.0.
  130. */
  131. extern SDL_DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata);
  132. /* Platform specific functions for Linux*/
  133. #ifdef SDL_PLATFORM_LINUX
  134. /**
  135. * Sets the UNIX nice value for a thread.
  136. *
  137. * This uses setpriority() if possible, and RealtimeKit if available.
  138. *
  139. * \param threadID the Unix thread ID to change priority of.
  140. * \param priority The new, Unix-specific, priority value.
  141. * \returns 0 on success, or -1 on error.
  142. *
  143. * \since This function is available since SDL 3.0.0.
  144. */
  145. extern SDL_DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority);
  146. /**
  147. * Sets the priority (not nice level) and scheduling policy for a thread.
  148. *
  149. * This uses setpriority() if possible, and RealtimeKit if available.
  150. *
  151. * \param threadID The Unix thread ID to change priority of.
  152. * \param sdlPriority The new SDL_ThreadPriority value.
  153. * \param schedPolicy The new scheduling policy (SCHED_FIFO, SCHED_RR,
  154. * SCHED_OTHER, etc...)
  155. * \returns 0 on success or a negative error code on failure; call
  156. * SDL_GetError() for more information.
  157. *
  158. * \since This function is available since SDL 3.0.0.
  159. */
  160. extern SDL_DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
  161. #endif /* SDL_PLATFORM_LINUX */
  162. /*
  163. * Platform specific functions for iOS
  164. */
  165. #ifdef SDL_PLATFORM_IOS
  166. /**
  167. * The prototype for an Apple iOS animation callback.
  168. *
  169. * This datatype is only useful on Apple iOS.
  170. *
  171. * After passing a function pointer of this type to SDL_iOSSetAnimationCallback,
  172. * the system will call that function pointer at a regular interval.
  173. *
  174. * \param userdata what was passed as `callbackParam` to SDL_iOSSetAnimationCallback as `callbackParam`.
  175. *
  176. * \since This datatype is available since SDL 3.0.0.
  177. *
  178. * \sa SDL_iOSSetAnimationCallback
  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_iOSSetAnimationCallback().
  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 0 on success or a negative error code on failure; call
  212. * SDL_GetError() for more information.
  213. *
  214. * \since This function is available since SDL 3.0.0.
  215. *
  216. * \sa SDL_iOSSetEventPump
  217. */
  218. extern SDL_DECLSPEC int SDLCALL SDL_iOSSetAnimationCallback(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 SDL_TRUE to enable the event pump, SDL_FALSE to disable it
  225. *
  226. * \since This function is available since SDL 3.0.0.
  227. *
  228. * \sa SDL_iOSSetAnimationCallback
  229. */
  230. extern SDL_DECLSPEC void SDLCALL SDL_iOSSetEventPump(SDL_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 0 on error.
  248. *
  249. * \threadsafety It is safe to call this function from any thread.
  250. *
  251. * \since This function is available since SDL 3.0.0.
  252. *
  253. * \sa SDL_AndroidGetActivity
  254. */
  255. extern SDL_DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(void);
  256. /**
  257. * Retrieve the Java instance of the Android activity class.
  258. *
  259. * The prototype of the function in SDL's code actually declares a void*
  260. * return type, even if the implementation returns a jobject. The rationale
  261. * being that the SDL headers can avoid including jni.h.
  262. *
  263. * The jobject returned by the function is a local reference and must be
  264. * released by the caller. See the PushLocalFrame() and PopLocalFrame() or
  265. * DeleteLocalRef() functions of the Java native interface:
  266. *
  267. * https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html
  268. *
  269. * \returns the jobject representing the instance of the Activity class of the
  270. * Android application, or NULL on error.
  271. *
  272. * \threadsafety It is safe to call this function from any thread.
  273. *
  274. * \since This function is available since SDL 3.0.0.
  275. *
  276. * \sa SDL_AndroidGetJNIEnv
  277. */
  278. extern SDL_DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
  279. /**
  280. * Query Android API level of the current device.
  281. *
  282. * - API level 34: Android 14 (UPSIDE_DOWN_CAKE)
  283. * - API level 33: Android 13 (TIRAMISU)
  284. * - API level 32: Android 12L (S_V2)
  285. * - API level 31: Android 12 (S)
  286. * - API level 30: Android 11 (R)
  287. * - API level 29: Android 10 (Q)
  288. * - API level 28: Android 9 (P)
  289. * - API level 27: Android 8.1 (O_MR1)
  290. * - API level 26: Android 8.0 (O)
  291. * - API level 25: Android 7.1 (N_MR1)
  292. * - API level 24: Android 7.0 (N)
  293. * - API level 23: Android 6.0 (M)
  294. * - API level 22: Android 5.1 (LOLLIPOP_MR1)
  295. * - API level 21: Android 5.0 (LOLLIPOP, L)
  296. * - API level 20: Android 4.4W (KITKAT_WATCH)
  297. * - API level 19: Android 4.4 (KITKAT)
  298. * - API level 18: Android 4.3 (JELLY_BEAN_MR2)
  299. * - API level 17: Android 4.2 (JELLY_BEAN_MR1)
  300. * - API level 16: Android 4.1 (JELLY_BEAN)
  301. * - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
  302. * - API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
  303. * - API level 13: Android 3.2 (HONEYCOMB_MR2)
  304. * - API level 12: Android 3.1 (HONEYCOMB_MR1)
  305. * - API level 11: Android 3.0 (HONEYCOMB)
  306. * - API level 10: Android 2.3.3 (GINGERBREAD_MR1)
  307. *
  308. * \returns the Android API level.
  309. *
  310. * \since This function is available since SDL 3.0.0.
  311. */
  312. extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
  313. /**
  314. * Query if the application is running on Android TV.
  315. *
  316. * \returns SDL_TRUE if this is Android TV, SDL_FALSE otherwise.
  317. *
  318. * \since This function is available since SDL 3.0.0.
  319. */
  320. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
  321. /**
  322. * Query if the application is running on a Chromebook.
  323. *
  324. * \returns SDL_TRUE if this is a Chromebook, SDL_FALSE otherwise.
  325. *
  326. * \since This function is available since SDL 3.0.0.
  327. */
  328. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
  329. /**
  330. * Query if the application is running on a Samsung DeX docking station.
  331. *
  332. * \returns SDL_TRUE if this is a DeX docking station, SDL_FALSE otherwise.
  333. *
  334. * \since This function is available since SDL 3.0.0.
  335. */
  336. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
  337. /**
  338. * Trigger the Android system back button behavior.
  339. *
  340. * \threadsafety It is safe to call this function from any thread.
  341. *
  342. * \since This function is available since SDL 3.0.0.
  343. */
  344. extern SDL_DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
  345. /**
  346. * See the official Android developer guide for more information:
  347. * http://developer.android.com/guide/topics/data/data-storage.html
  348. *
  349. * \since This macro is available since SDL 3.0.0.
  350. */
  351. #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
  352. #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
  353. /**
  354. * Get the path used for internal storage for this application.
  355. *
  356. * This path is unique to your application and cannot be written to by other
  357. * applications.
  358. *
  359. * Your internal storage path is typically:
  360. * `/data/data/your.app.package/files`.
  361. *
  362. * The returned string follows the SDL_GetStringRule.
  363. *
  364. * \returns the path used for internal storage or NULL on failure; call
  365. * SDL_GetError() for more information.
  366. *
  367. * \since This function is available since SDL 3.0.0.
  368. *
  369. * \sa SDL_AndroidGetExternalStorageState
  370. */
  371. extern SDL_DECLSPEC const char *SDLCALL SDL_AndroidGetInternalStoragePath(void);
  372. /**
  373. * Get the current state of external storage.
  374. *
  375. * The current state of external storage, a bitmask of these values:
  376. * `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`.
  377. *
  378. * If external storage is currently unavailable, this will return 0.
  379. *
  380. * \param state filled with the current state of external storage. 0 if
  381. * external storage is currently unavailable.
  382. * \returns 0 on success or a negative error code on failure; call
  383. * SDL_GetError() for more information.
  384. *
  385. * \since This function is available since SDL 3.0.0.
  386. *
  387. * \sa SDL_AndroidGetExternalStoragePath
  388. */
  389. extern SDL_DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(Uint32 *state);
  390. /**
  391. * Get the path used for external storage for this application.
  392. *
  393. * This path is unique to your application, but is public and can be written
  394. * to by other applications.
  395. *
  396. * Your external storage path is typically:
  397. * `/storage/sdcard0/Android/data/your.app.package/files`.
  398. *
  399. * The returned string follows the SDL_GetStringRule.
  400. *
  401. * \returns the path used for external storage for this application on success
  402. * or NULL on failure; call SDL_GetError() for more information.
  403. *
  404. * \since This function is available since SDL 3.0.0.
  405. *
  406. * \sa SDL_AndroidGetExternalStorageState
  407. */
  408. extern SDL_DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void);
  409. typedef void (SDLCALL *SDL_AndroidRequestPermissionCallback)(void *userdata, const char *permission, SDL_bool granted);
  410. /**
  411. * Request permissions at runtime, asynchronously.
  412. *
  413. * You do not need to call this for built-in functionality of SDL; recording
  414. * from a microphone or reading images from a camera, using standard SDL APIs,
  415. * will manage permission requests for you.
  416. *
  417. * This function never blocks. Instead, the app-supplied callback will be
  418. * called when a decision has been made. This callback may happen on a
  419. * different thread, and possibly much later, as it might wait on a user to
  420. * respond to a system dialog. If permission has already been granted for a
  421. * specific entitlement, the callback will still fire, probably on the current
  422. * thread and before this function returns.
  423. *
  424. * If the request submission fails, this function returns -1 and the callback
  425. * will NOT be called, but this should only happen in catastrophic conditions,
  426. * like memory running out. Normally there will be a yes or no to the request
  427. * through the callback.
  428. *
  429. * \param permission The permission to request.
  430. * \param cb The callback to trigger when the request has a response.
  431. * \param userdata An app-controlled pointer that is passed to the callback.
  432. * \returns zero if the request was submitted, -1 if there was an error
  433. * submitting. The result of the request is only ever reported
  434. * through the callback, not this return value.
  435. *
  436. * \threadsafety It is safe to call this function from any thread.
  437. *
  438. * \since This function is available since SDL 3.0.0.
  439. */
  440. extern SDL_DECLSPEC int SDLCALL SDL_AndroidRequestPermission(const char *permission, SDL_AndroidRequestPermissionCallback cb, void *userdata);
  441. /**
  442. * Shows an Android toast notification.
  443. *
  444. * Toasts are a sort of lightweight notification that are unique to Android.
  445. *
  446. * https://developer.android.com/guide/topics/ui/notifiers/toasts
  447. *
  448. * Shows toast in UI thread.
  449. *
  450. * For the `gravity` parameter, choose a value from here, or -1 if you don't
  451. * have a preference:
  452. *
  453. * https://developer.android.com/reference/android/view/Gravity
  454. *
  455. * \param message text message to be shown
  456. * \param duration 0=short, 1=long
  457. * \param gravity where the notification should appear on the screen.
  458. * \param xoffset set this parameter only when gravity >=0
  459. * \param yoffset set this parameter only when gravity >=0
  460. * \returns 0 on success or a negative error code on failure; call
  461. * SDL_GetError() for more information.
  462. *
  463. * \threadsafety It is safe to call this function from any thread.
  464. *
  465. * \since This function is available since SDL 3.0.0.
  466. */
  467. extern SDL_DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
  468. /**
  469. * Send a user command to SDLActivity.
  470. *
  471. * Override "boolean onUnhandledMessage(Message msg)" to handle the message.
  472. *
  473. * \param command user command that must be greater or equal to 0x8000
  474. * \param param user parameter
  475. * \returns 0 on success or a negative error code on failure; call
  476. * SDL_GetError() for more information.
  477. *
  478. * \threadsafety It is safe to call this function from any thread.
  479. *
  480. * \since This function is available since SDL 3.0.0.
  481. */
  482. extern SDL_DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
  483. #endif /* SDL_PLATFORM_ANDROID */
  484. /*
  485. * Platform specific functions for WinRT
  486. */
  487. #ifdef SDL_PLATFORM_WINRT
  488. /**
  489. * WinRT / Windows Phone path types
  490. *
  491. * \since This enum is available since SDL 3.0.0.
  492. */
  493. typedef enum SDL_WinRT_Path
  494. {
  495. /** The installed app's root directory.
  496. Files here are likely to be read-only. */
  497. SDL_WINRT_PATH_INSTALLED_LOCATION,
  498. /** The app's local data store. Files may be written here */
  499. SDL_WINRT_PATH_LOCAL_FOLDER,
  500. /** The app's roaming data store. Unsupported on Windows Phone.
  501. Files written here may be copied to other machines via a network
  502. connection.
  503. */
  504. SDL_WINRT_PATH_ROAMING_FOLDER,
  505. /** The app's temporary data store. Unsupported on Windows Phone.
  506. Files written here may be deleted at any time. */
  507. SDL_WINRT_PATH_TEMP_FOLDER
  508. } SDL_WinRT_Path;
  509. /**
  510. * WinRT Device Family
  511. *
  512. * \since This enum is available since SDL 3.0.0.
  513. */
  514. typedef enum SDL_WinRT_DeviceFamily
  515. {
  516. /** Unknown family */
  517. SDL_WINRT_DEVICEFAMILY_UNKNOWN,
  518. /** Desktop family*/
  519. SDL_WINRT_DEVICEFAMILY_DESKTOP,
  520. /** Mobile family (for example smartphone) */
  521. SDL_WINRT_DEVICEFAMILY_MOBILE,
  522. /** XBox family */
  523. SDL_WINRT_DEVICEFAMILY_XBOX,
  524. } SDL_WinRT_DeviceFamily;
  525. /**
  526. * Retrieve a WinRT defined path on the local file system.
  527. *
  528. * Not all paths are available on all versions of Windows. This is especially
  529. * true on Windows Phone. Check the documentation for the given SDL_WinRT_Path
  530. * for more information on which path types are supported where.
  531. *
  532. * Documentation on most app-specific path types on WinRT can be found on
  533. * MSDN, at the URL:
  534. *
  535. * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
  536. *
  537. * The returned string follows the SDL_GetStringRule.
  538. *
  539. * \param pathType the type of path to retrieve, one of SDL_WinRT_Path
  540. * \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if
  541. * the path is not available for any reason; call SDL_GetError() for
  542. * more information.
  543. *
  544. * \since This function is available since SDL 3.0.0.
  545. */
  546. extern SDL_DECLSPEC const char * SDLCALL SDL_WinRTGetFSPath(SDL_WinRT_Path pathType);
  547. /**
  548. * Detects the device family of WinRT platform at runtime.
  549. *
  550. * \returns a value from the SDL_WinRT_DeviceFamily enum.
  551. *
  552. * \since This function is available since SDL 3.0.0.
  553. */
  554. extern SDL_DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
  555. #endif /* SDL_PLATFORM_WINRT */
  556. /**
  557. * Query if the current device is a tablet.
  558. *
  559. * If SDL can't determine this, it will return SDL_FALSE.
  560. *
  561. * \returns SDL_TRUE if the device is a tablet, SDL_FALSE otherwise.
  562. *
  563. * \since This function is available since SDL 3.0.0.
  564. */
  565. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
  566. /* Functions used by iOS app delegates to notify SDL about state changes. */
  567. /**
  568. * Let iOS apps with external event handling report
  569. * onApplicationWillTerminate.
  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_OnApplicationWillTerminate(void);
  583. /**
  584. * Let iOS apps with external event handling report
  585. * onApplicationDidReceiveMemoryWarning.
  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_OnApplicationDidReceiveMemoryWarning(void);
  599. /**
  600. * Let iOS apps with external event handling report
  601. * onApplicationWillResignActive.
  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_OnApplicationWillResignActive(void);
  615. /**
  616. * Let iOS apps with external event handling report
  617. * onApplicationDidEnterBackground.
  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_OnApplicationDidEnterBackground(void);
  631. /**
  632. * Let iOS apps with external event handling report
  633. * onApplicationWillEnterForeground.
  634. *
  635. * This functions allows iOS apps that have their own event handling to hook
  636. * into SDL to generate SDL events. This maps directly to an iOS-specific
  637. * event, but since it doesn't do anything iOS-specific internally, it is
  638. * available on all platforms, in case it might be useful for some specific
  639. * paradigm. Most apps do not need to use this directly; SDL's internal event
  640. * code will handle all this for windows created by SDL_CreateWindow!
  641. *
  642. * \threadsafety It is safe to call this function from any thread.
  643. *
  644. * \since This function is available since SDL 3.0.0.
  645. */
  646. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void);
  647. /**
  648. * Let iOS apps with external event handling report
  649. * onApplicationDidBecomeActive.
  650. *
  651. * This functions allows iOS apps that have their own event handling to hook
  652. * into SDL to generate SDL events. This maps directly to an iOS-specific
  653. * event, but since it doesn't do anything iOS-specific internally, it is
  654. * available on all platforms, in case it might be useful for some specific
  655. * paradigm. Most apps do not need to use this directly; SDL's internal event
  656. * code will handle all this for windows created by SDL_CreateWindow!
  657. *
  658. * \threadsafety It is safe to call this function from any thread.
  659. *
  660. * \since This function is available since SDL 3.0.0.
  661. */
  662. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void);
  663. #ifdef SDL_PLATFORM_IOS
  664. /**
  665. * Let iOS apps with external event handling report
  666. * onApplicationDidChangeStatusBarOrientation.
  667. *
  668. * This functions allows iOS apps that have their own event handling to hook
  669. * into SDL to generate SDL events. This maps directly to an iOS-specific
  670. * event, but since it doesn't do anything iOS-specific internally, it is
  671. * available on all platforms, in case it might be useful for some specific
  672. * paradigm. Most apps do not need to use this directly; SDL's internal event
  673. * code will handle all this for windows created by SDL_CreateWindow!
  674. *
  675. * \threadsafety It is safe to call this function from any thread.
  676. *
  677. * \since This function is available since SDL 3.0.0.
  678. */
  679. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
  680. #endif
  681. /*
  682. * Functions used only by GDK
  683. */
  684. #ifdef SDL_PLATFORM_GDK
  685. typedef struct XTaskQueueObject *XTaskQueueHandle;
  686. typedef struct XUser *XUserHandle;
  687. /**
  688. * Gets a reference to the global async task queue handle for GDK,
  689. * initializing if needed.
  690. *
  691. * Once you are done with the task queue, you should call
  692. * XTaskQueueCloseHandle to reduce the reference count to avoid a resource
  693. * leak.
  694. *
  695. * \param outTaskQueue a pointer to be filled in with task queue handle.
  696. * \returns 0 on success or a negative error code on failure; call
  697. * SDL_GetError() for more information.
  698. *
  699. * \since This function is available since SDL 3.0.0.
  700. */
  701. extern SDL_DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue);
  702. /**
  703. * Gets a reference to the default user handle for GDK.
  704. *
  705. * This is effectively a synchronous version of XUserAddAsync, which always
  706. * prefers the default user and allows a sign-in UI.
  707. *
  708. * \param outUserHandle a pointer to be filled in with the default user
  709. * handle.
  710. * \returns 0 if success, -1 if any error occurs.
  711. *
  712. * \since This function is available since SDL 3.0.0.
  713. */
  714. extern SDL_DECLSPEC int SDLCALL SDL_GDKGetDefaultUser(XUserHandle * outUserHandle);
  715. #endif
  716. /* Ends C function definitions when using C++ */
  717. #ifdef __cplusplus
  718. }
  719. #endif
  720. #include <SDL3/SDL_close_code.h>
  721. #endif /* SDL_system_h_ */