1 2 // Copyright 2018 - 2021 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 } 52 else version(Windows) { 53 static if(sdlSupport >= SDLSupport.sdl201) { 54 int SDL_Direct3D9GetAdapterIndex(int displayIndex); 55 IDirect3DDevice9* SDL_RenderGetD3D9Device(SDL_Renderer* renderer); 56 } 57 static if(sdlSupport >= SDLSupport.sdl202) { 58 SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int* adapterIndex, int* outputIndex); 59 } 60 static if(sdlSupport >= SDLSupport.sdl204) { 61 void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void* userdata); 62 } 63 } 64 else version(linux) { 65 static if(sdlSupport >= SDLSupport.sdl209) { 66 int SDL_LinuxSetThreadPriority(long threadID, int priority); 67 } 68 } 69 } 70 } 71 else { 72 version(Android) { 73 extern(C) @nogc nothrow { 74 alias pSDL_AndroidGetJNIEnv = void* function(); 75 alias pSDL_AndroidGetActivity = void* function(); 76 alias pSDL_AndroidGetInternalStoragePath = const(char)* function(); 77 alias pSDL_AndroidGetExternalStorageState = int function(); 78 alias pSDL_AndroidGetExternalStoragePath = const(char)* function(); 79 } 80 81 __gshared { 82 pSDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv; 83 pSDL_AndroidGetActivity SDL_AndroidGetActivity; 84 85 pSDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath; 86 pSDL_AndroidGetExternalStorageState SDL_AndroidGetExternalStorageState; 87 pSDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath; 88 } 89 static if(sdlSupport >= SDLSupport.sdl208) { 90 extern(C) @nogc nothrow { 91 alias pSDL_IsAndroidTV = SDL_bool function(); 92 } 93 94 __gshared { 95 pSDL_IsAndroidTV SDL_IsAndroidTV; 96 } 97 } 98 static if(sdlSupport >= SDLSupport.sdl209) { 99 extern(C) @nogc nothrow { 100 alias pSDL_IsChromebook = SDL_bool function(); 101 alias pSDL_IsDeXMode = SDL_bool function(); 102 alias pSDL_AndroidBackButton = void function(); 103 } 104 105 __gshared { 106 pSDL_IsChromebook SDL_IsChromebook; 107 pSDL_IsDeXMode SDL_IsDeXMode; 108 pSDL_AndroidBackButton SDL_AndroidBackButton; 109 } 110 } 111 static if(sdlSupport >= SDLSupport.sdl2012) { 112 extern(C) @nogc nothrow { 113 alias pSDL_GetAndroidSDKVersion = int function(); 114 } 115 116 __gshared { 117 pSDL_GetAndroidSDKVersion SDL_GetAndroidSDKVersion; 118 } 119 } 120 static if(sdlSupport >= SDLSupport.sdl2014) { 121 extern(C) @nogc nothrow { 122 alias pSDL_AndroidRequestPermission = SDL_bool function(const(char)* permission); 123 } 124 __gshared { 125 pSDL_AndroidRequestPermission SDL_AndroidRequestPermission; 126 } 127 } 128 } 129 else version(Windows) { 130 static if(sdlSupport >= SDLSupport.sdl201) { 131 extern(C) @nogc nothrow { 132 alias pSDL_Direct3D9GetAdapterIndex = int function(int displayIndex); 133 alias pSDL_RenderGetD3D9Device = IDirect3DDevice9* function(SDL_Renderer* renderer); 134 } 135 136 __gshared { 137 pSDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex ; 138 pSDL_RenderGetD3D9Device SDL_RenderGetD3D9Device; 139 } 140 } 141 142 static if(sdlSupport >= SDLSupport.sdl202) { 143 extern(C) @nogc nothrow { 144 alias pSDL_DXGIGetOutputInfo = SDL_bool function(int displayIndex, int* adapterIndex, int* outputIndex); 145 } 146 147 __gshared { 148 pSDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo; 149 } 150 } 151 152 static if(sdlSupport >= SDLSupport.sdl204) { 153 extern(C) @nogc nothrow { 154 alias pSDL_SetWindowsMessageHook = void function(SDL_WindowsMessageHook callback, void* userdata); 155 } 156 157 __gshared { 158 pSDL_SetWindowsMessageHook SDL_SetWindowsMessageHook; 159 } 160 } 161 } 162 else version(linux) { 163 static if(sdlSupport >= SDLSupport.sdl209) { 164 extern(C) @nogc nothrow { 165 alias pSDL_LinuxSetThreadPriority = int function(long threadID, int priority); 166 } 167 168 __gshared { 169 pSDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority; 170 } 171 } 172 } 173 }