sdl_system.odin 3.8 KB

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