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