sdl_system.odin 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == .Windows {
  4. foreign import lib "SDL2.lib"
  5. } else {
  6. foreign import lib "system:SDL2"
  7. }
  8. // General
  9. @(default_calling_convention="c", link_prefix="SDL_")
  10. foreign lib {
  11. IsTablet :: proc() -> bool ---
  12. /* Functions used by iOS application delegates to notify SDL about state changes */
  13. OnApplicationWillTerminate :: proc() ---
  14. OnApplicationDidReceiveMemoryWarning :: proc() ---
  15. OnApplicationWillResignActive :: proc() ---
  16. OnApplicationDidEnterBackground :: proc() ---
  17. OnApplicationWillEnterForeground :: proc() ---
  18. OnApplicationDidBecomeActive :: proc() ---
  19. // iPhoneOS
  20. OnApplicationDidChangeStatusBarOrientation :: proc() ---
  21. }
  22. // Windows & WinRT
  23. WindowsMessageHook :: proc "c" (userdata: rawptr, hWnd: rawptr, message: c.uint, wParam: u64, lParam: i64)
  24. IDirect3DDevice9 :: struct {}
  25. ID3D11Device :: struct {}
  26. @(default_calling_convention="c", link_prefix="SDL_")
  27. foreign lib {
  28. SetWindowsMessageHook :: proc(callback: WindowsMessageHook, userdata: rawptr) ---
  29. Direct3D9GetAdapterIndex :: proc(displayIndex: c.int) -> c.int ---
  30. RenderGetD3D9Device :: proc(renderer: ^Renderer) -> ^IDirect3DDevice9 ---
  31. RenderGetD3D11Device :: proc(renderer: ^Renderer) -> ^ID3D11Device ---
  32. DXGIGetOutputInfo :: proc(displayIndex: c.int, adapterIndex: ^c.int, outputIndex: ^c.int) -> bool ---
  33. }
  34. WinRT_Path :: enum c.int {
  35. /** \brief The installed app's root directory.
  36. Files here are likely to be read-only. */
  37. INSTALLED_LOCATION,
  38. /** \brief The app's local data store. Files may be written here */
  39. LOCAL_FOLDER,
  40. /** \brief The app's roaming data store. Unsupported on Windows Phone.
  41. Files written here may be copied to other machines via a network
  42. connection.
  43. */
  44. ROAMING_FOLDER,
  45. /** \brief The app's temporary data store. Unsupported on Windows Phone.
  46. Files written here may be deleted at any time. */
  47. TEMP_FOLDER,
  48. }
  49. WinRT_DeviceFamily :: enum {
  50. /** \brief Unknown family */
  51. UNKNOWN,
  52. /** \brief Desktop family*/
  53. DESKTOP,
  54. /** \brief Mobile family (for example smartphone) */
  55. MOBILE,
  56. /** \brief XBox family */
  57. XBOX,
  58. }
  59. @(default_calling_convention="c", link_prefix="SDL_")
  60. foreign lib {
  61. WinRTGetFSPathUNICODE :: proc(pathType: WinRT_Path) -> ^u16 ---
  62. WinRTGetFSPathUTF8 :: proc(pathType: WinRT_Path) -> cstring ---
  63. WinRTGetDeviceFamily :: proc() -> WinRT_DeviceFamily ---
  64. }
  65. // Linux
  66. @(default_calling_convention="c", link_prefix="SDL_")
  67. foreign lib {
  68. LinuxSetThreadPriority :: proc(threadID: i64, priority: c.int) -> c.int ---
  69. }
  70. // iOS
  71. iOSSetAnimationCallback :: iPhoneSetAnimationCallback
  72. iOSSetEventPump :: iPhoneSetEventPump
  73. @(default_calling_convention="c", link_prefix="SDL_")
  74. foreign lib {
  75. iPhoneSetAnimationCallback :: proc(window: ^Window, interval: c.int, callback: proc "c" (rawptr), callbackParam: rawptr) -> c.int ---
  76. iPhoneSetEventPump :: proc(enabled: bool) ---
  77. }
  78. // Android
  79. ANDROID_EXTERNAL_STORAGE_READ :: 0x01
  80. ANDROID_EXTERNAL_STORAGE_WRITE :: 0x02
  81. @(default_calling_convention="c", link_prefix="SDL_")
  82. foreign lib {
  83. AndroidGetJNIEnv :: proc() -> rawptr ---
  84. AndroidGetActivity :: proc() -> rawptr ---
  85. GetAndroidSDKVersion :: proc() -> c.int ---
  86. IsAndroidTV :: proc() -> bool ---
  87. IsChromebook :: proc() -> bool ---
  88. IsDeXMode :: proc() -> bool ---
  89. AndroidBackButton :: proc() ---
  90. AndroidGetInternalStoragePath :: proc() -> cstring ---
  91. AndroidGetExternalStorageState :: proc() -> c.int ---
  92. AndroidGetExternalStoragePath :: proc() -> cstring ---
  93. AndroidRequestPermission :: proc(permission: cstring) -> bool ---
  94. AndroidShowToast :: proc(message: cstring, duration, gravity, xoffset, yoffset: c.int) -> c.int ---
  95. }