1 2 // Copyright 2018 - 2022 Michael D. Parker 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.sdl.bind.sdlsystem; 8 9 import bindbc.sdl.config; 10 import bindbc.sdl.bind.sdlrender : SDL_Renderer; 11 import bindbc.sdl.bind.sdlstdinc : SDL_bool; 12 13 version(Android) { 14 enum int SDL_ANDROID_EXTERNAL_STORAGE_READ = 0x01; 15 enum int SDL_ANDROID_EXTERNAL_STORAGE_WRITE = 0x02; 16 } 17 18 static if(sdlSupport >= SDLSupport.sdl201) { 19 version(Windows) struct IDirect3DDevice9; 20 } 21 22 static if(sdlSupport >= SDLSupport.sdl204) { 23 version(Windows) { 24 extern(C) nothrow alias SDL_WindowsMessageHook = void function(void*,void*,uint,ulong,long); 25 } 26 } 27 28 static if(staticBinding) { 29 extern(C) @nogc nothrow { 30 version(Android) { 31 void* SDL_AndroidGetJNIEnv(); 32 void* SDL_AndroidGetActivity(); 33 const(char)* SDL_AndroidGetInternalStoragePath(); 34 int SDL_AndroidGetExternalStorageState(); 35 const(char)* SDL_AndroidGetExternalStoragePath(); 36 37 static if(sdlSupport >= SDLSupport.sdl208) { 38 SDL_bool SDL_IsAndroidTV(); 39 } 40 static if(sdlSupport >= SDLSupport.sdl209) { 41 SDL_bool SDL_IsChromebook(); 42 SDL_bool SDL_IsDeXMode(); 43 void SDL_AndroidBackButton(); 44 } 45 static if(sdlSupport >= SDLSupport.sdl2012) { 46 int SDL_GetAndroidSDKVersion(); 47 } 48 static if(sdlSupport >= SDLSupport.sdl2014) { 49 SDL_bool SDL_AndroidRequestPermission(const(char)* permission); 50 } 51 static if(sdlSupport >= SDLSupport.sdl2016) { 52 int SDL_AndroidShowToast(const(char)* message, int duration, int gravity, int xoffset, int yoffset); 53 } 54 } 55 else version(Windows) { 56 static if(sdlSupport >= SDLSupport.sdl201) { 57 int SDL_Direct3D9GetAdapterIndex(int displayIndex); 58 IDirect3DDevice9* SDL_RenderGetD3D9Device(SDL_Renderer* renderer); 59 } 60 static if(sdlSupport >= SDLSupport.sdl202) { 61 SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int* adapterIndex, int* outputIndex); 62 } 63 static if(sdlSupport >= SDLSupport.sdl204) { 64 void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void* userdata); 65 } 66 static if(sdlSupport >= SDLSupport.sdl2016) { 67 void SDL_RenderGetD3D11Device(SDL_Renderer* renderer); 68 } 69 } 70 else version(linux) { 71 static if(sdlSupport >= SDLSupport.sdl209) { 72 int SDL_LinuxSetThreadPriority(long threadID, int priority); 73 } 74 static if(sdlSupport >= SDLSupport.sdl2018) { 75 int SDL_LinuxSetThreadPriorityAndPolicy(long threadID, int sdlPriority, int schedPolicy); 76 } 77 } 78 } 79 } 80 else { 81 version(Android) { 82 extern(C) @nogc nothrow { 83 alias pSDL_AndroidGetJNIEnv = void* function(); 84 alias pSDL_AndroidGetActivity = void* function(); 85 alias pSDL_AndroidGetInternalStoragePath = const(char)* function(); 86 alias pSDL_AndroidGetExternalStorageState = int function(); 87 alias pSDL_AndroidGetExternalStoragePath = const(char)* function(); 88 } 89 90 __gshared { 91 pSDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv; 92 pSDL_AndroidGetActivity SDL_AndroidGetActivity; 93 94 pSDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath; 95 pSDL_AndroidGetExternalStorageState SDL_AndroidGetExternalStorageState; 96 pSDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath; 97 } 98 static if(sdlSupport >= SDLSupport.sdl208) { 99 extern(C) @nogc nothrow { 100 alias pSDL_IsAndroidTV = SDL_bool function(); 101 } 102 103 __gshared { 104 pSDL_IsAndroidTV SDL_IsAndroidTV; 105 } 106 } 107 static if(sdlSupport >= SDLSupport.sdl209) { 108 extern(C) @nogc nothrow { 109 alias pSDL_IsChromebook = SDL_bool function(); 110 alias pSDL_IsDeXMode = SDL_bool function(); 111 alias pSDL_AndroidBackButton = void function(); 112 } 113 114 __gshared { 115 pSDL_IsChromebook SDL_IsChromebook; 116 pSDL_IsDeXMode SDL_IsDeXMode; 117 pSDL_AndroidBackButton SDL_AndroidBackButton; 118 } 119 } 120 static if(sdlSupport >= SDLSupport.sdl2012) { 121 extern(C) @nogc nothrow { 122 alias pSDL_GetAndroidSDKVersion = int function(); 123 } 124 125 __gshared { 126 pSDL_GetAndroidSDKVersion SDL_GetAndroidSDKVersion; 127 } 128 } 129 static if(sdlSupport >= SDLSupport.sdl2014) { 130 extern(C) @nogc nothrow { 131 alias pSDL_AndroidRequestPermission = SDL_bool function(const(char)* permission); 132 } 133 __gshared { 134 pSDL_AndroidRequestPermission SDL_AndroidRequestPermission; 135 } 136 } 137 static if(sdlSupport >= SDLSupport.sdl2016) { 138 extern(C) @nogc nothrow { 139 alias pSDL_AndroidShowToast = int function(const(char)* message, int duration, int gravity, int xoffset, int yoffset); 140 } 141 __gshared { 142 pSDL_AndroidShowToast SDL_AndroidShowToast; 143 } 144 } 145 } 146 else version(Windows) { 147 static if(sdlSupport >= SDLSupport.sdl201) { 148 extern(C) @nogc nothrow { 149 alias pSDL_Direct3D9GetAdapterIndex = int function(int displayIndex); 150 alias pSDL_RenderGetD3D9Device = IDirect3DDevice9* function(SDL_Renderer* renderer); 151 } 152 153 __gshared { 154 pSDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex ; 155 pSDL_RenderGetD3D9Device SDL_RenderGetD3D9Device; 156 } 157 } 158 159 static if(sdlSupport >= SDLSupport.sdl202) { 160 extern(C) @nogc nothrow { 161 alias pSDL_DXGIGetOutputInfo = SDL_bool function(int displayIndex, int* adapterIndex, int* outputIndex); 162 } 163 164 __gshared { 165 pSDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo; 166 } 167 } 168 169 static if(sdlSupport >= SDLSupport.sdl204) { 170 extern(C) @nogc nothrow { 171 alias pSDL_SetWindowsMessageHook = void function(SDL_WindowsMessageHook callback, void* userdata); 172 } 173 174 __gshared { 175 pSDL_SetWindowsMessageHook SDL_SetWindowsMessageHook; 176 } 177 } 178 179 static if(sdlSupport >= SDLSupport.sdl2016) { 180 extern(C) @nogc nothrow { 181 alias pSDL_RenderGetD3D11Device = void function(SDL_Renderer* renderer); 182 } 183 184 __gshared { 185 pSDL_RenderGetD3D11Device SDL_RenderGetD3D11Device; 186 } 187 } 188 } 189 else version(linux) { 190 static if(sdlSupport >= SDLSupport.sdl209) { 191 extern(C) @nogc nothrow { 192 alias pSDL_LinuxSetThreadPriority = int function(long threadID, int priority); 193 } 194 195 __gshared { 196 pSDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority; 197 } 198 } 199 200 static if(sdlSupport >= SDLSupport.sdl2018) { 201 extern(C) @nogc nothrow { 202 alias pSDL_LinuxSetThreadPriorityAndPolicy = int function(long threadID, int sdlPriority, int schedPolicy); 203 } 204 205 __gshared { 206 pSDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy; 207 } 208 } 209 } 210 }