1 /+
2 +            Copyright 2022 – 2024 Aya Partridge
3 +          Copyright 2018 - 2022 Michael D. Parker
4 + Distributed under the Boost Software License, Version 1.0.
5 +     (See accompanying file LICENSE_1_0.txt or copy at
6 +           http://www.boost.org/LICENSE_1_0.txt)
7 +/
8 module sdl;
9 
10 import bindbc.sdl.config;
11 import bindbc.sdl.codegen;
12 
13 public import
14 	sdl.assert_,
15 	sdl.atomic,
16 	sdl.audio,
17 	sdl.bits,
18 	sdl.blendmode,
19 	sdl.clipboard,
20 	sdl.cpuinfo,
21 	sdl.endian,
22 	sdl.error,
23 	sdl.events,
24 	sdl.filesystem,
25 	sdl.gamecontroller,
26 	sdl.gesture,
27 	sdl.guid,
28 	sdl.hidapi,
29 	sdl.haptic,
30 	sdl.hints,
31 	sdl.joystick,
32 	sdl.keyboard,
33 	sdl.keycode,
34 	sdl.loadso,
35 	sdl.locale,
36 	sdl.log,
37 	sdl.messagebox,
38 	sdl.metal,
39 	sdl.misc,
40 	sdl.mouse,
41 	sdl.mutex,
42 	sdl.pixels,
43 	sdl.platform,
44 	sdl.power,
45 	sdl.rect,
46 	sdl.render,
47 	sdl.rwops,
48 	sdl.scancode,
49 	sdl.sensor,
50 	sdl.shape,
51 	sdl.stdinc,
52 	sdl.surface,
53 	sdl.system,
54 	sdl.syswm,
55 	sdl.thread,
56 	sdl.timer,
57 	sdl.touch,
58 	sdl.version_,
59 	sdl.video,
60 	sdl.vulkan;
61 
62 enum: uint{
63 	SDL_INIT_TIMER           = 0x0000_0001U,
64 	SDL_INIT_AUDIO           = 0x0000_0010U,
65 	SDL_INIT_VIDEO           = 0x0000_0020U,
66 	SDL_INIT_JOYSTICK        = 0x0000_0200U,
67 	SDL_INIT_HAPTIC          = 0x0000_1000U,
68 	SDL_INIT_GAMECONTROLLER  = 0x0000_2000U,
69 	SDL_INIT_EVENTS          = 0x0000_4000U,
70 	SDL_INIT_NOPARACHUTE     = 0x0010_0000U,
71 }
72 static if(sdlSupport >= SDLSupport.v2_0_9){
73 	enum: uint{
74 		SDL_INIT_SENSOR      = 0x0000_8000U,
75 		SDL_INIT_EVERYTHING  =
76 			SDL_INIT_TIMER    | SDL_INIT_AUDIO  | SDL_INIT_VIDEO |
77 			SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER |
78 			SDL_INIT_EVENTS   | SDL_INIT_SENSOR,
79 	}
80 }else{
81 	enum: uint{
82 		SDL_INIT_EVERYTHING  =
83 			SDL_INIT_TIMER    | SDL_INIT_AUDIO  | SDL_INIT_VIDEO |
84 			SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER |
85 			SDL_INIT_EVENTS,
86 	}
87 }
88 
89 mixin(joinFnBinds((){
90 	FnBind[] ret = [
91 		{q{int}, q{SDL_Init}, q{uint flags}},
92 		{q{int}, q{SDL_InitSubSystem}, q{uint flags}},
93 		{q{void}, q{SDL_QuitSubSystem}, q{uint flags}},
94 		{q{uint}, q{SDL_WasInit}, q{uint flags}},
95 		{q{void}, q{SDL_Quit}, q{}},
96 	];
97 	return ret;
98 }()));
99 
100 static if(!staticBinding):
101 import bindbc.loader;
102 
103 private{
104 	SharedLib lib;
105 	SDLSupport loadedVersion; //NOTE: get rid of these in 2.0.0
106 	enum libNamesCT = (){
107 		version(Windows){
108 			return [
109 				`SDL2.dll`,
110 			];
111 		}else version(OSX){
112 			return [
113 				`libSDL2.dylib`,
114 				`/opt/homebrew/lib/libSDL2.dylib`,
115 				`SDL2`,
116 				`/Library/Frameworks/SDL2.framework/SDL2`,
117 				`/System/Library/Frameworks/SDL2.framework/SDL2`,
118 			];
119 		}else version(Posix){
120 			return [
121 				`libSDL2.so`,
122 				`libSDL2-2.0.so`,
123 				`libSDL2-2.0.so.0`,
124 			];
125 		}else static assert(0, "BindBC-SDL does not have library search paths set up for this platform.");
126 	}();
127 }
128 
129 nothrow @nogc:
130 deprecated("Please use `SDL_GetVersion` instead")
131 	SDLSupport loadedSDLVersion(){ return loadedVersion; }
132 
133 mixin(bindbc.sdl.codegen.makeDynloadFns("", [
134 	__MODULE__,
135 	"sdl.assert_",
136 	"sdl.atomic",
137 	"sdl.audio",
138 	"sdl.blendmode",
139 	"sdl.clipboard",
140 	"sdl.cpuinfo",
141 	"sdl.error",
142 	"sdl.events",
143 	"sdl.filesystem",
144 	"sdl.gamecontroller",
145 	"sdl.gesture",
146 	"sdl.guid",
147 	"sdl.haptic",
148 	"sdl.hidapi",
149 	"sdl.hints",
150 	"sdl.joystick",
151 	"sdl.keyboard",
152 	"sdl.loadso",
153 	"sdl.locale",
154 	"sdl.log",
155 	"sdl.messagebox",
156 	"sdl.metal",
157 	"sdl.misc",
158 	"sdl.mouse",
159 	"sdl.mutex",
160 	"sdl.pixels",
161 	"sdl.platform",
162 	"sdl.power",
163 	"sdl.rect",
164 	"sdl.render",
165 	"sdl.rwops",
166 	"sdl.sensor",
167 	"sdl.shape",
168 	"sdl.stdinc",
169 	"sdl.surface",
170 	"sdl.system",
171 	"sdl.syswm",
172 	"sdl.thread",
173 	"sdl.timer",
174 	"sdl.touch",
175 	"sdl.version_",
176 	"sdl.video",
177 	"sdl.vulkan",
178 ]));