SDL_system.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 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. * \file SDL_system.h
  20. *
  21. * Include file for platform specific SDL API functions
  22. */
  23. #ifndef SDL_system_h_
  24. #define SDL_system_h_
  25. #include "SDL_stdinc.h"
  26. #include "SDL_keyboard.h"
  27. #include "SDL_render.h"
  28. #include "SDL_video.h"
  29. #include "begin_code.h"
  30. /* Set up for C function definitions, even when using C++ */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Platform specific functions for Windows */
  35. #ifdef __WIN32__
  36. /**
  37. \brief Set a function that is called for every windows message, before TranslateMessage()
  38. */
  39. typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
  40. extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
  41. /**
  42. \brief Returns the D3D9 adapter index that matches the specified display index.
  43. This adapter index can be passed to IDirect3D9::CreateDevice and controls
  44. on which monitor a full screen application will appear.
  45. */
  46. extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
  47. typedef struct IDirect3DDevice9 IDirect3DDevice9;
  48. /**
  49. \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
  50. Once you are done using the device, you should release it to avoid a resource leak.
  51. */
  52. extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer);
  53. /**
  54. \brief Returns the DXGI Adapter and Output indices for the specified display index.
  55. These can be passed to EnumAdapters and EnumOutputs respectively to get the objects
  56. required to create a DX10 or DX11 device and swap chain.
  57. */
  58. extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
  59. #endif /* __WIN32__ */
  60. /* Platform specific functions for Linux */
  61. #ifdef __LINUX__
  62. /**
  63. \brief Sets the UNIX nice value for a thread, using setpriority() if possible, and RealtimeKit if available.
  64. \return 0 on success, or -1 on error.
  65. */
  66. extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority);
  67. #endif /* __LINUX__ */
  68. /* Platform specific functions for iOS */
  69. #ifdef __IPHONEOS__
  70. #define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
  71. extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
  72. #define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
  73. extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
  74. #endif /* __IPHONEOS__ */
  75. /* Platform specific functions for Android */
  76. #ifdef __ANDROID__
  77. /**
  78. \brief Get the JNI environment for the current thread
  79. This returns JNIEnv*, but the prototype is void* so we don't need jni.h
  80. */
  81. extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(void);
  82. /**
  83. \brief Get the SDL Activity object for the application
  84. This returns jobject, but the prototype is void* so we don't need jni.h
  85. The jobject returned by SDL_AndroidGetActivity is a local reference.
  86. It is the caller's responsibility to properly release it
  87. (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef)
  88. */
  89. extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
  90. /**
  91. \brief Return API level of the current device
  92. API level 30: Android 11
  93. API level 29: Android 10
  94. API level 28: Android 9
  95. API level 27: Android 8.1
  96. API level 26: Android 8.0
  97. API level 25: Android 7.1
  98. API level 24: Android 7.0
  99. API level 23: Android 6.0
  100. API level 22: Android 5.1
  101. API level 21: Android 5.0
  102. API level 20: Android 4.4W
  103. API level 19: Android 4.4
  104. API level 18: Android 4.3
  105. API level 17: Android 4.2
  106. API level 16: Android 4.1
  107. API level 15: Android 4.0.3
  108. API level 14: Android 4.0
  109. API level 13: Android 3.2
  110. API level 12: Android 3.1
  111. API level 11: Android 3.0
  112. API level 10: Android 2.3.3
  113. */
  114. extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
  115. /**
  116. \brief Return true if the application is running on Android TV
  117. */
  118. extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
  119. /**
  120. \brief Return true if the application is running on a Chromebook
  121. */
  122. extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
  123. /**
  124. \brief Return true is the application is running on a Samsung DeX docking station
  125. */
  126. extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
  127. /**
  128. \brief Trigger the Android system back button behavior.
  129. */
  130. extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
  131. /**
  132. See the official Android developer guide for more information:
  133. http://developer.android.com/guide/topics/data/data-storage.html
  134. */
  135. #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
  136. #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
  137. /**
  138. \brief Get the path used for internal storage for this application.
  139. This path is unique to your application and cannot be written to
  140. by other applications.
  141. */
  142. extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(void);
  143. /**
  144. \brief Get the current state of external storage, a bitmask of these values:
  145. SDL_ANDROID_EXTERNAL_STORAGE_READ
  146. SDL_ANDROID_EXTERNAL_STORAGE_WRITE
  147. If external storage is currently unavailable, this will return 0.
  148. */
  149. extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(void);
  150. /**
  151. \brief Get the path used for external storage for this application.
  152. This path is unique to your application, but is public and can be
  153. written to by other applications.
  154. */
  155. extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void);
  156. /**
  157. \brief Request permissions at runtime.
  158. This blocks the calling thread until the permission is granted or
  159. denied. Returns SDL_TRUE if the permission was granted.
  160. */
  161. extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permission);
  162. #endif /* __ANDROID__ */
  163. /* Platform specific functions for WinRT */
  164. #ifdef __WINRT__
  165. /**
  166. * \brief WinRT / Windows Phone path types
  167. */
  168. typedef enum
  169. {
  170. /** \brief The installed app's root directory.
  171. Files here are likely to be read-only. */
  172. SDL_WINRT_PATH_INSTALLED_LOCATION,
  173. /** \brief The app's local data store. Files may be written here */
  174. SDL_WINRT_PATH_LOCAL_FOLDER,
  175. /** \brief The app's roaming data store. Unsupported on Windows Phone.
  176. Files written here may be copied to other machines via a network
  177. connection.
  178. */
  179. SDL_WINRT_PATH_ROAMING_FOLDER,
  180. /** \brief The app's temporary data store. Unsupported on Windows Phone.
  181. Files written here may be deleted at any time. */
  182. SDL_WINRT_PATH_TEMP_FOLDER
  183. } SDL_WinRT_Path;
  184. /**
  185. * \brief WinRT Device Family
  186. */
  187. typedef enum
  188. {
  189. /** \brief Unknown family */
  190. SDL_WINRT_DEVICEFAMILY_UNKNOWN,
  191. /** \brief Desktop family*/
  192. SDL_WINRT_DEVICEFAMILY_DESKTOP,
  193. /** \brief Mobile family (for example smartphone) */
  194. SDL_WINRT_DEVICEFAMILY_MOBILE,
  195. /** \brief XBox family */
  196. SDL_WINRT_DEVICEFAMILY_XBOX,
  197. } SDL_WinRT_DeviceFamily;
  198. /**
  199. * \brief Retrieves a WinRT defined path on the local file system
  200. *
  201. * \note Documentation on most app-specific path types on WinRT
  202. * can be found on MSDN, at the URL:
  203. * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
  204. *
  205. * \param pathType The type of path to retrieve.
  206. * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL
  207. * if the path is not available for any reason. Not all paths are
  208. * available on all versions of Windows. This is especially true on
  209. * Windows Phone. Check the documentation for the given
  210. * SDL_WinRT_Path for more information on which path types are
  211. * supported where.
  212. */
  213. extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
  214. /**
  215. * \brief Retrieves a WinRT defined path on the local file system
  216. *
  217. * \note Documentation on most app-specific path types on WinRT
  218. * can be found on MSDN, at the URL:
  219. * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
  220. *
  221. * \param pathType The type of path to retrieve.
  222. * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
  223. * if the path is not available for any reason. Not all paths are
  224. * available on all versions of Windows. This is especially true on
  225. * Windows Phone. Check the documentation for the given
  226. * SDL_WinRT_Path for more information on which path types are
  227. * supported where.
  228. */
  229. extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
  230. /**
  231. * \brief Detects the device family of WinRT plattform on runtime
  232. *
  233. * \return Device family
  234. */
  235. extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
  236. #endif /* __WINRT__ */
  237. /**
  238. \brief Return true if the current device is a tablet.
  239. */
  240. extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
  241. /* Functions used by iOS application delegates to notify SDL about state changes */
  242. extern DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void);
  243. extern DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void);
  244. extern DECLSPEC void SDLCALL SDL_OnApplicationWillResignActive(void);
  245. extern DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void);
  246. extern DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void);
  247. extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void);
  248. #ifdef __IPHONEOS__
  249. extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
  250. #endif
  251. /* Ends C function definitions when using C++ */
  252. #ifdef __cplusplus
  253. }
  254. #endif
  255. #include "close_code.h"
  256. #endif /* SDL_system_h_ */
  257. /* vi: set ts=4 sw=4 expandtab: */