SDL_system.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839
  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_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_GetDirect3D9AdapterIndex(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 0 on success or a negative error code on failure; call
  108. * SDL_GetError() for more information.
  109. *
  110. * \since This function is available since SDL 3.0.0.
  111. */
  112. extern SDL_DECLSPEC int SDLCALL SDL_GetDXGIOutputInfo(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 a negative error code on failure; call
  142. * SDL_GetError() for more information.
  143. *
  144. * \since This function is available since SDL 3.0.0.
  145. */
  146. extern SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
  147. /**
  148. * Sets the priority (not nice level) and scheduling policy for a thread.
  149. *
  150. * This uses setpriority() if possible, and RealtimeKit if available.
  151. *
  152. * \param threadID the Unix thread ID to change priority of.
  153. * \param sdlPriority the new SDL_ThreadPriority value.
  154. * \param schedPolicy the new scheduling policy (SCHED_FIFO, SCHED_RR,
  155. * SCHED_OTHER, etc...).
  156. * \returns 0 on success or a negative error code on failure; call
  157. * SDL_GetError() for more information.
  158. *
  159. * \since This function is available since SDL 3.0.0.
  160. */
  161. extern SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
  162. #endif /* SDL_PLATFORM_LINUX */
  163. /*
  164. * Platform specific functions for iOS
  165. */
  166. #ifdef SDL_PLATFORM_IOS
  167. /**
  168. * The prototype for an Apple iOS animation callback.
  169. *
  170. * This datatype is only useful on Apple iOS.
  171. *
  172. * After passing a function pointer of this type to
  173. * SDL_SetiOSAnimationCallback, the system will call that function pointer at
  174. * a regular interval.
  175. *
  176. * \param userdata what was passed as `callbackParam` to
  177. * SDL_SetiOSAnimationCallback as `callbackParam`.
  178. *
  179. * \since This datatype is available since SDL 3.0.0.
  180. *
  181. * \sa SDL_SetiOSAnimationCallback
  182. */
  183. typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata);
  184. /**
  185. * Use this function to set the animation callback on Apple iOS.
  186. *
  187. * The function prototype for `callback` is:
  188. *
  189. * ```c
  190. * void callback(void *callbackParam);
  191. * ```
  192. *
  193. * Where its parameter, `callbackParam`, is what was passed as `callbackParam`
  194. * to SDL_SetiOSAnimationCallback().
  195. *
  196. * This function is only available on Apple iOS.
  197. *
  198. * For more information see:
  199. *
  200. * https://wiki.libsdl.org/SDL3/README/ios
  201. *
  202. * Note that if you use the "main callbacks" instead of a standard C `main`
  203. * function, you don't have to use this API, as SDL will manage this for you.
  204. *
  205. * Details on main callbacks are here:
  206. *
  207. * https://wiki.libsdl.org/SDL3/README/main-functions
  208. *
  209. * \param window the window for which the animation callback should be set.
  210. * \param interval the number of frames after which **callback** will be
  211. * called.
  212. * \param callback the function to call for every frame.
  213. * \param callbackParam a pointer that is passed to `callback`.
  214. * \returns 0 on success or a negative error code on failure; call
  215. * SDL_GetError() for more information.
  216. *
  217. * \since This function is available since SDL 3.0.0.
  218. *
  219. * \sa SDL_SetiOSEventPump
  220. */
  221. extern SDL_DECLSPEC int SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
  222. /**
  223. * Use this function to enable or disable the SDL event pump on Apple iOS.
  224. *
  225. * This function is only available on Apple iOS.
  226. *
  227. * \param enabled SDL_TRUE to enable the event pump, SDL_FALSE to disable it.
  228. *
  229. * \since This function is available since SDL 3.0.0.
  230. *
  231. * \sa SDL_SetiOSAnimationCallback
  232. */
  233. extern SDL_DECLSPEC void SDLCALL SDL_SetiOSEventPump(SDL_bool enabled);
  234. #endif /* SDL_PLATFORM_IOS */
  235. /*
  236. * Platform specific functions for Android
  237. */
  238. #ifdef SDL_PLATFORM_ANDROID
  239. /**
  240. * Get the Android Java Native Interface Environment of the current thread.
  241. *
  242. * This is the JNIEnv one needs to access the Java virtual machine from native
  243. * code, and is needed for many Android APIs to be usable from C.
  244. *
  245. * The prototype of the function in SDL's code actually declare a void* return
  246. * type, even if the implementation returns a pointer to a JNIEnv. The
  247. * rationale being that the SDL headers can avoid including jni.h.
  248. *
  249. * \returns a pointer to Java native interface object (JNIEnv) to which the
  250. * current thread is attached, or NULL on failure; call
  251. * SDL_GetError() for more information.
  252. *
  253. * \threadsafety It is safe to call this function from any thread.
  254. *
  255. * \since This function is available since SDL 3.0.0.
  256. *
  257. * \sa SDL_GetAndroidActivity
  258. */
  259. extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void);
  260. /**
  261. * Retrieve the Java instance of the Android activity class.
  262. *
  263. * The prototype of the function in SDL's code actually declares a void*
  264. * return type, even if the implementation returns a jobject. The rationale
  265. * being that the SDL headers can avoid including jni.h.
  266. *
  267. * The jobject returned by the function is a local reference and must be
  268. * released by the caller. See the PushLocalFrame() and PopLocalFrame() or
  269. * DeleteLocalRef() functions of the Java native interface:
  270. *
  271. * https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html
  272. *
  273. * \returns the jobject representing the instance of the Activity class of the
  274. * Android application, or NULL on failure; call SDL_GetError() for
  275. * more information.
  276. *
  277. * \threadsafety It is safe to call this function from any thread.
  278. *
  279. * \since This function is available since SDL 3.0.0.
  280. *
  281. * \sa SDL_GetAndroidJNIEnv
  282. */
  283. extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void);
  284. /**
  285. * Query Android API level of the current device.
  286. *
  287. * - API level 35: Android 15 (VANILLA_ICE_CREAM)
  288. * - API level 34: Android 14 (UPSIDE_DOWN_CAKE)
  289. * - API level 33: Android 13 (TIRAMISU)
  290. * - API level 32: Android 12L (S_V2)
  291. * - API level 31: Android 12 (S)
  292. * - API level 30: Android 11 (R)
  293. * - API level 29: Android 10 (Q)
  294. * - API level 28: Android 9 (P)
  295. * - API level 27: Android 8.1 (O_MR1)
  296. * - API level 26: Android 8.0 (O)
  297. * - API level 25: Android 7.1 (N_MR1)
  298. * - API level 24: Android 7.0 (N)
  299. * - API level 23: Android 6.0 (M)
  300. * - API level 22: Android 5.1 (LOLLIPOP_MR1)
  301. * - API level 21: Android 5.0 (LOLLIPOP, L)
  302. * - API level 20: Android 4.4W (KITKAT_WATCH)
  303. * - API level 19: Android 4.4 (KITKAT)
  304. * - API level 18: Android 4.3 (JELLY_BEAN_MR2)
  305. * - API level 17: Android 4.2 (JELLY_BEAN_MR1)
  306. * - API level 16: Android 4.1 (JELLY_BEAN)
  307. * - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
  308. * - API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
  309. * - API level 13: Android 3.2 (HONEYCOMB_MR2)
  310. * - API level 12: Android 3.1 (HONEYCOMB_MR1)
  311. * - API level 11: Android 3.0 (HONEYCOMB)
  312. * - API level 10: Android 2.3.3 (GINGERBREAD_MR1)
  313. *
  314. * \returns the Android API level.
  315. *
  316. * \since This function is available since SDL 3.0.0.
  317. */
  318. extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
  319. /**
  320. * Query if the application is running on Android TV.
  321. *
  322. * \returns SDL_TRUE if this is Android TV, SDL_FALSE otherwise.
  323. *
  324. * \since This function is available since SDL 3.0.0.
  325. */
  326. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
  327. /**
  328. * Query if the application is running on a Chromebook.
  329. *
  330. * \returns SDL_TRUE if this is a Chromebook, SDL_FALSE otherwise.
  331. *
  332. * \since This function is available since SDL 3.0.0.
  333. */
  334. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
  335. /**
  336. * Query if the application is running on a Samsung DeX docking station.
  337. *
  338. * \returns SDL_TRUE if this is a DeX docking station, SDL_FALSE otherwise.
  339. *
  340. * \since This function is available since SDL 3.0.0.
  341. */
  342. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
  343. /**
  344. * Trigger the Android system back button behavior.
  345. *
  346. * \threadsafety It is safe to call this function from any thread.
  347. *
  348. * \since This function is available since SDL 3.0.0.
  349. */
  350. extern SDL_DECLSPEC void SDLCALL SDL_SendAndroidBackButton(void);
  351. /**
  352. * See the official Android developer guide for more information:
  353. * http://developer.android.com/guide/topics/data/data-storage.html
  354. *
  355. * \since This macro is available since SDL 3.0.0.
  356. */
  357. #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
  358. #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
  359. /**
  360. * Get the path used for internal storage for this Android application.
  361. *
  362. * This path is unique to your application and cannot be written to by other
  363. * applications.
  364. *
  365. * Your internal storage path is typically:
  366. * `/data/data/your.app.package/files`.
  367. *
  368. * This is a C wrapper over `android.content.Context.getFilesDir()`:
  369. *
  370. * https://developer.android.com/reference/android/content/Context#getFilesDir()
  371. *
  372. * This returns temporary memory which will be automatically freed later, and
  373. * can be claimed with SDL_ClaimTemporaryMemory().
  374. *
  375. * \returns the path used for internal storage or NULL on failure; call
  376. * SDL_GetError() for more information.
  377. *
  378. * \since This function is available since SDL 3.0.0.
  379. *
  380. * \sa SDL_GetAndroidExternalStorageState
  381. */
  382. extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidInternalStoragePath(void);
  383. /**
  384. * Get the current state of external storage for this Android application.
  385. *
  386. * The current state of external storage, a bitmask of these values:
  387. * `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`.
  388. *
  389. * If external storage is currently unavailable, this will return 0.
  390. *
  391. * \returns the current state of external storage, or 0 if external storage is
  392. * currently unavailable.
  393. *
  394. * \since This function is available since SDL 3.0.0.
  395. *
  396. * \sa SDL_GetAndroidExternalStoragePath
  397. */
  398. extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAndroidExternalStorageState(void);
  399. /**
  400. * Get the path used for external storage for this Android application.
  401. *
  402. * This path is unique to your application, but is public and can be written
  403. * to by other applications.
  404. *
  405. * Your external storage path is typically:
  406. * `/storage/sdcard0/Android/data/your.app.package/files`.
  407. *
  408. * This is a C wrapper over `android.content.Context.getExternalFilesDir()`:
  409. *
  410. * https://developer.android.com/reference/android/content/Context#getExternalFilesDir()
  411. *
  412. * This returns temporary memory which will be automatically freed later, and
  413. * can be claimed with SDL_ClaimTemporaryMemory().
  414. *
  415. * \returns the path used for external storage for this application on success
  416. * or NULL on failure; call SDL_GetError() for more information.
  417. *
  418. * \since This function is available since SDL 3.0.0.
  419. *
  420. * \sa SDL_GetAndroidExternalStorageState
  421. */
  422. extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void);
  423. /**
  424. * Get the path used for caching data for this Android application.
  425. *
  426. * This path is unique to your application, but is public and can be written
  427. * to by other applications.
  428. *
  429. * Your cache path is typically: `/data/data/your.app.package/cache/`.
  430. *
  431. * This is a C wrapper over `android.content.Context.getCacheDir()`:
  432. *
  433. * https://developer.android.com/reference/android/content/Context#getCacheDir()
  434. *
  435. * This returns temporary memory which will be automatically freed later, and
  436. * can be claimed with SDL_ClaimTemporaryMemory().
  437. *
  438. * \returns the path used for caches for this application on success or NULL
  439. * on failure; call SDL_GetError() for more information.
  440. *
  441. * \since This function is available since SDL 3.0.0.
  442. */
  443. extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void);
  444. typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, SDL_bool granted);
  445. /**
  446. * Request permissions at runtime, asynchronously.
  447. *
  448. * You do not need to call this for built-in functionality of SDL; recording
  449. * from a microphone or reading images from a camera, using standard SDL APIs,
  450. * will manage permission requests for you.
  451. *
  452. * This function never blocks. Instead, the app-supplied callback will be
  453. * called when a decision has been made. This callback may happen on a
  454. * different thread, and possibly much later, as it might wait on a user to
  455. * respond to a system dialog. If permission has already been granted for a
  456. * specific entitlement, the callback will still fire, probably on the current
  457. * thread and before this function returns.
  458. *
  459. * If the request submission fails, this function returns -1 and the callback
  460. * will NOT be called, but this should only happen in catastrophic conditions,
  461. * like memory running out. Normally there will be a yes or no to the request
  462. * through the callback.
  463. *
  464. * \param permission the permission to request.
  465. * \param cb the callback to trigger when the request has a response.
  466. * \param userdata an app-controlled pointer that is passed to the callback.
  467. * \returns zero if the request was submitted, -1 if there was an error
  468. * submitting. The result of the request is only ever reported
  469. * through the callback, not this return value.
  470. *
  471. * \threadsafety It is safe to call this function from any thread.
  472. *
  473. * \since This function is available since SDL 3.0.0.
  474. */
  475. extern SDL_DECLSPEC int SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
  476. /**
  477. * Shows an Android toast notification.
  478. *
  479. * Toasts are a sort of lightweight notification that are unique to Android.
  480. *
  481. * https://developer.android.com/guide/topics/ui/notifiers/toasts
  482. *
  483. * Shows toast in UI thread.
  484. *
  485. * For the `gravity` parameter, choose a value from here, or -1 if you don't
  486. * have a preference:
  487. *
  488. * https://developer.android.com/reference/android/view/Gravity
  489. *
  490. * \param message text message to be shown.
  491. * \param duration 0=short, 1=long.
  492. * \param gravity where the notification should appear on the screen.
  493. * \param xoffset set this parameter only when gravity >=0.
  494. * \param yoffset set this parameter only when gravity >=0.
  495. * \returns 0 on success or a negative error code on failure; call
  496. * SDL_GetError() for more information.
  497. *
  498. * \threadsafety It is safe to call this function from any thread.
  499. *
  500. * \since This function is available since SDL 3.0.0.
  501. */
  502. extern SDL_DECLSPEC int SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
  503. /**
  504. * Send a user command to SDLActivity.
  505. *
  506. * Override "boolean onUnhandledMessage(Message msg)" to handle the message.
  507. *
  508. * \param command user command that must be greater or equal to 0x8000.
  509. * \param param user parameter.
  510. * \returns 0 on success or a negative error code on failure; call
  511. * SDL_GetError() for more information.
  512. *
  513. * \threadsafety It is safe to call this function from any thread.
  514. *
  515. * \since This function is available since SDL 3.0.0.
  516. */
  517. extern SDL_DECLSPEC int SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
  518. #endif /* SDL_PLATFORM_ANDROID */
  519. /*
  520. * Platform specific functions for WinRT
  521. */
  522. #ifdef SDL_PLATFORM_WINRT
  523. /**
  524. * WinRT / Windows Phone path types
  525. *
  526. * \since This enum is available since SDL 3.0.0.
  527. */
  528. typedef enum SDL_WinRT_Path
  529. {
  530. /** The installed app's root directory.
  531. Files here are likely to be read-only. */
  532. SDL_WINRT_PATH_INSTALLED_LOCATION,
  533. /** The app's local data store. Files may be written here */
  534. SDL_WINRT_PATH_LOCAL_FOLDER,
  535. /** The app's roaming data store. Unsupported on Windows Phone.
  536. Files written here may be copied to other machines via a network
  537. connection.
  538. */
  539. SDL_WINRT_PATH_ROAMING_FOLDER,
  540. /** The app's temporary data store. Unsupported on Windows Phone.
  541. Files written here may be deleted at any time. */
  542. SDL_WINRT_PATH_TEMP_FOLDER
  543. } SDL_WinRT_Path;
  544. /**
  545. * WinRT Device Family
  546. *
  547. * \since This enum is available since SDL 3.0.0.
  548. */
  549. typedef enum SDL_WinRT_DeviceFamily
  550. {
  551. /** Unknown family */
  552. SDL_WINRT_DEVICEFAMILY_UNKNOWN,
  553. /** Desktop family*/
  554. SDL_WINRT_DEVICEFAMILY_DESKTOP,
  555. /** Mobile family (for example smartphone) */
  556. SDL_WINRT_DEVICEFAMILY_MOBILE,
  557. /** XBox family */
  558. SDL_WINRT_DEVICEFAMILY_XBOX,
  559. } SDL_WinRT_DeviceFamily;
  560. /**
  561. * Retrieve a WinRT defined path on the local file system.
  562. *
  563. * Not all paths are available on all versions of Windows. This is especially
  564. * true on Windows Phone. Check the documentation for the given SDL_WinRT_Path
  565. * for more information on which path types are supported where.
  566. *
  567. * Documentation on most app-specific path types on WinRT can be found on
  568. * MSDN, at the URL:
  569. *
  570. * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
  571. *
  572. * This returns temporary memory which will be automatically freed later, and
  573. * can be claimed with SDL_ClaimTemporaryMemory().
  574. *
  575. * \param pathType the type of path to retrieve, one of SDL_WinRT_Path.
  576. * \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if
  577. * the path is not available for any reason; call SDL_GetError() for
  578. * more information.
  579. *
  580. * \since This function is available since SDL 3.0.0.
  581. */
  582. extern SDL_DECLSPEC const char * SDLCALL SDL_GetWinRTFSPath(SDL_WinRT_Path pathType);
  583. /**
  584. * Detects the device family of WinRT platform at runtime.
  585. *
  586. * \returns a value from the SDL_WinRT_DeviceFamily enum.
  587. *
  588. * \since This function is available since SDL 3.0.0.
  589. */
  590. extern SDL_DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_GetWinRTDeviceFamily();
  591. #endif /* SDL_PLATFORM_WINRT */
  592. /**
  593. * Query if the current device is a tablet.
  594. *
  595. * If SDL can't determine this, it will return SDL_FALSE.
  596. *
  597. * \returns SDL_TRUE if the device is a tablet, SDL_FALSE otherwise.
  598. *
  599. * \since This function is available since SDL 3.0.0.
  600. */
  601. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
  602. /* Functions used by iOS app delegates to notify SDL about state changes. */
  603. /**
  604. * Let iOS apps with external event handling report
  605. * onApplicationWillTerminate.
  606. *
  607. * This functions allows iOS apps that have their own event handling to hook
  608. * into SDL to generate SDL events. This maps directly to an iOS-specific
  609. * event, but since it doesn't do anything iOS-specific internally, it is
  610. * available on all platforms, in case it might be useful for some specific
  611. * paradigm. Most apps do not need to use this directly; SDL's internal event
  612. * code will handle all this for windows created by SDL_CreateWindow!
  613. *
  614. * \threadsafety It is safe to call this function from any thread.
  615. *
  616. * \since This function is available since SDL 3.0.0.
  617. */
  618. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void);
  619. /**
  620. * Let iOS apps with external event handling report
  621. * onApplicationDidReceiveMemoryWarning.
  622. *
  623. * This functions allows iOS apps that have their own event handling to hook
  624. * into SDL to generate SDL events. This maps directly to an iOS-specific
  625. * event, but since it doesn't do anything iOS-specific internally, it is
  626. * available on all platforms, in case it might be useful for some specific
  627. * paradigm. Most apps do not need to use this directly; SDL's internal event
  628. * code will handle all this for windows created by SDL_CreateWindow!
  629. *
  630. * \threadsafety It is safe to call this function from any thread.
  631. *
  632. * \since This function is available since SDL 3.0.0.
  633. */
  634. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void);
  635. /**
  636. * Let iOS apps with external event handling report
  637. * onApplicationWillResignActive.
  638. *
  639. * This functions allows iOS apps that have their own event handling to hook
  640. * into SDL to generate SDL events. This maps directly to an iOS-specific
  641. * event, but since it doesn't do anything iOS-specific internally, it is
  642. * available on all platforms, in case it might be useful for some specific
  643. * paradigm. Most apps do not need to use this directly; SDL's internal event
  644. * code will handle all this for windows created by SDL_CreateWindow!
  645. *
  646. * \threadsafety It is safe to call this function from any thread.
  647. *
  648. * \since This function is available since SDL 3.0.0.
  649. */
  650. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterBackground(void);
  651. /**
  652. * Let iOS apps with external event handling report
  653. * onApplicationDidEnterBackground.
  654. *
  655. * This functions allows iOS apps that have their own event handling to hook
  656. * into SDL to generate SDL events. This maps directly to an iOS-specific
  657. * event, but since it doesn't do anything iOS-specific internally, it is
  658. * available on all platforms, in case it might be useful for some specific
  659. * paradigm. Most apps do not need to use this directly; SDL's internal event
  660. * code will handle all this for windows created by SDL_CreateWindow!
  661. *
  662. * \threadsafety It is safe to call this function from any thread.
  663. *
  664. * \since This function is available since SDL 3.0.0.
  665. */
  666. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void);
  667. /**
  668. * Let iOS apps with external event handling report
  669. * onApplicationWillEnterForeground.
  670. *
  671. * This functions allows iOS apps that have their own event handling to hook
  672. * into SDL to generate SDL events. This maps directly to an iOS-specific
  673. * event, but since it doesn't do anything iOS-specific internally, it is
  674. * available on all platforms, in case it might be useful for some specific
  675. * paradigm. Most apps do not need to use this directly; SDL's internal event
  676. * code will handle all this for windows created by SDL_CreateWindow!
  677. *
  678. * \threadsafety It is safe to call this function from any thread.
  679. *
  680. * \since This function is available since SDL 3.0.0.
  681. */
  682. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void);
  683. /**
  684. * Let iOS apps with external event handling report
  685. * onApplicationDidBecomeActive.
  686. *
  687. * This functions allows iOS apps that have their own event handling to hook
  688. * into SDL to generate SDL events. This maps directly to an iOS-specific
  689. * event, but since it doesn't do anything iOS-specific internally, it is
  690. * available on all platforms, in case it might be useful for some specific
  691. * paradigm. Most apps do not need to use this directly; SDL's internal event
  692. * code will handle all this for windows created by SDL_CreateWindow!
  693. *
  694. * \threadsafety It is safe to call this function from any thread.
  695. *
  696. * \since This function is available since SDL 3.0.0.
  697. */
  698. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterForeground(void);
  699. #ifdef SDL_PLATFORM_IOS
  700. /**
  701. * Let iOS apps with external event handling report
  702. * onApplicationDidChangeStatusBarOrientation.
  703. *
  704. * This functions allows iOS apps that have their own event handling to hook
  705. * into SDL to generate SDL events. This maps directly to an iOS-specific
  706. * event, but since it doesn't do anything iOS-specific internally, it is
  707. * available on all platforms, in case it might be useful for some specific
  708. * paradigm. Most apps do not need to use this directly; SDL's internal event
  709. * code will handle all this for windows created by SDL_CreateWindow!
  710. *
  711. * \threadsafety It is safe to call this function from any thread.
  712. *
  713. * \since This function is available since SDL 3.0.0.
  714. */
  715. extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
  716. #endif
  717. /*
  718. * Functions used only by GDK
  719. */
  720. #ifdef SDL_PLATFORM_GDK
  721. typedef struct XTaskQueueObject *XTaskQueueHandle;
  722. typedef struct XUser *XUserHandle;
  723. /**
  724. * Gets a reference to the global async task queue handle for GDK,
  725. * initializing if needed.
  726. *
  727. * Once you are done with the task queue, you should call
  728. * XTaskQueueCloseHandle to reduce the reference count to avoid a resource
  729. * leak.
  730. *
  731. * \param outTaskQueue a pointer to be filled in with task queue handle.
  732. * \returns 0 on success or a negative error code on failure; call
  733. * SDL_GetError() for more information.
  734. *
  735. * \since This function is available since SDL 3.0.0.
  736. */
  737. extern SDL_DECLSPEC int SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue);
  738. /**
  739. * Gets a reference to the default user handle for GDK.
  740. *
  741. * This is effectively a synchronous version of XUserAddAsync, which always
  742. * prefers the default user and allows a sign-in UI.
  743. *
  744. * \param outUserHandle a pointer to be filled in with the default user
  745. * handle.
  746. * \returns 0 if success or a negative error code on failure; call
  747. * SDL_GetError() for more information.
  748. *
  749. * \since This function is available since SDL 3.0.0.
  750. */
  751. extern SDL_DECLSPEC int SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle);
  752. #endif
  753. /* Ends C function definitions when using C++ */
  754. #ifdef __cplusplus
  755. }
  756. #endif
  757. #include <SDL3/SDL_close_code.h>
  758. #endif /* SDL_system_h_ */