Skip to content

Commit

Permalink
Added SDL 2.28.X support
Browse files Browse the repository at this point in the history
  • Loading branch information
ichordev committed Jul 5, 2023
1 parent bf5cb78 commit 8c94842
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ When linking with the static libraries, there is no runtime dependency on SDL. T
## Library Versions
These are the supported versions of each SDL_* library, along with the corresponding version identifiers to add to your dub configuration or pass to the compiler.

> __Note__
>
> If you have `SDL_THREAD_SAFETY_ANALYSIS` support enabled in SDL, you may use version identifier `SDL_ThreadSafetyAnalysis`.
> __Note__
>
> It is necessary to specify only a single version identifier per library. For example, `SDL_Image_204` by itself will activate the SDL_image binding.
Expand Down Expand Up @@ -249,6 +253,7 @@ These are the supported versions of each SDL_* library, along with the correspon
| 2.0.22 | `SDL_2022` |
| 2.24.X | `SDL_2_24` |
| 2.26.X | `SDL_2_26` |
| 2.28.X | `SDL_2_28` |

> __Warning__
>
Expand Down
2 changes: 2 additions & 0 deletions source/bindbc/sdl/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum SDLSupport: SDL_version{
v2_0_22 = SDL_version(2,0,22),
v2_24 = SDL_version(2,24,0),
v2_26 = SDL_version(2,26,0),
v2_26 = SDL_version(2,28,0),

deprecated("Please use `v2_0_0` instead") sdl200 = SDL_version(2,0,0),
deprecated("Please use `v2_0_1` instead") sdl201 = SDL_version(2,0,1),
Expand Down Expand Up @@ -58,6 +59,7 @@ enum staticBinding = (){
}();

enum sdlSupport = (){
version(SDL_2_28) return SDLSupport.v2_28;
version(SDL_2_26) return SDLSupport.v2_26;
else version(SDL_2_24) return SDLSupport.v2_24;
else version(SDL_2022) return SDLSupport.v2_0_22;
Expand Down
7 changes: 6 additions & 1 deletion source/sdl/hints.d
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum{
SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT = "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT",
SDL_HINT_NO_SIGNAL_HANDLERS = "SDL_NO_SIGNAL_HANDLERS",
SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 = "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4",

// Changed values from those introduced in 2.0.3
SDL_HINT_RENDER_DIRECT3D11_DEBUG = "SDL_RENDER_DIRECT3D11_DEBUG",
SDL_HINT_WINRT_PRIVACY_POLICY_URL = "SDL_WINRT_PRIVACY_POLICY_URL",
Expand Down Expand Up @@ -235,6 +235,11 @@ enum{
SDL_HINT_PS2_DYNAMIC_VSYNC = "SDL_PS2_DYNAMIC_VSYNC",
SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP = "SDL_VIDEO_WAYLAND_EMULATE_MOUSE_WARP",
}
static if(sdlSupport >= SDLSupport.v2_28)
enum{
SDL_HINT_ENABLE_SCREEN_KEYBOARD = "SDL_ENABLE_SCREEN_KEYBOARD",
SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS = "SDL_WINDOWS_ENABLE_MENU_MNEMONICS",
}

alias SDL_HintPriority = uint;
enum: SDL_HintPriority{
Expand Down
5 changes: 5 additions & 0 deletions source/sdl/joystick.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import bindbc.sdl.codegen;
import sdl.stdinc: SDL_bool;
import sdl.guid: SDL_GUID;

version(SDL_ThreadSafetyAnalysis){
import sdl.mutex: SDL_mutex;
extern extern(C) SDL_mutex* SDL_joystick_lock;
}

struct SDL_Joystick;

alias SDL_JoystickGUID = SDL_GUID;
Expand Down
5 changes: 5 additions & 0 deletions source/sdl/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ mixin(joinFnBinds((){
[q{int}, q{SDL_GDKRunApp}, q{SDL_main_func mainFunction, void* reserved}],
]);
}
static if(sdlSupport >= SDLSupport.v2_28){
ret ~= makeFnBinds([
[q{void}, q{SDL_GDKSuspendComplete}, q{}],
]);
}
}
return ret;
}()));
2 changes: 1 addition & 1 deletion source/sdl/mutex.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mixin(joinFnBinds((){
[q{void}, q{SDL_DestroySemaphore}, q{SDL_semaphore* sem}],
[q{int}, q{SDL_SemWait}, q{SDL_semaphore* sem}],
[q{int}, q{SDL_SemTryWait}, q{SDL_semaphore* sem}],
[q{int}, q{SDL_SemWaitTimeout}, q{SDL_semaphore* sem, uint ms}],
[q{int}, q{SDL_SemWaitTimeout}, q{SDL_semaphore* sem, uint timeout}],
[q{int}, q{SDL_SemPost}, q{SDL_semaphore* sem}],
[q{uint}, q{SDL_SemValue}, q{SDL_semaphore* sem}],

Expand Down
2 changes: 1 addition & 1 deletion source/sdl/power.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum: SDL_PowerState{
mixin(joinFnBinds((){
string[][] ret;
ret ~= makeFnBinds([
[q{SDL_PowerState}, q{SDL_GetPowerInfo}, q{int* secs, int* pct}],
[q{SDL_PowerState}, q{SDL_GetPowerInfo}, q{int* seconds, int* percent}],
]);
return ret;
}()));
10 changes: 10 additions & 0 deletions source/sdl/video.d
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ static if(sdlSupport >= SDLSupport.v2_0_9){
SDL_DISPLAYEVENT_CONNECTED = 2,
SDL_DISPLAYEVENT_DISCONNECTED = 3,
}
static if(sdlSupport >= SDLSupport.v2_28)
enum: SDL_DisplayEventID{
SDL_DISPLAYEVENT_MOVED = 4,
}
}

static if(sdlSupport >= SDLSupport.v2_0_9){
Expand Down Expand Up @@ -376,5 +380,11 @@ mixin(joinFnBinds((){
[q{void}, q{SDL_GetWindowSizeInPixels}, q{SDL_Window* window, int* w, int* h}],
]);
}
static if(sdlSupport >= SDLSupport.v2_28){
ret ~= makeFnBinds([
[q{SDL_bool}, q{SDL_HasWindowSurface}, q{SDL_Window* window}],
[q{int}, q{SDL_DestroyWindowSurface}, q{SDL_Window* window}],
]);
}
return ret;
}()));

0 comments on commit 8c94842

Please sign in to comment.