From f317d619ccd22e60cebf1b09d716d3985359c981 Mon Sep 17 00:00:00 2001 From: chalonverse Date: Fri, 1 Jul 2022 13:59:14 -0700 Subject: [PATCH] Xbox GDKX support (#5869) * Xbox GDK support (14 squashed commits) * Added basic keyboard testing * Update readme * Code review fixes * Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput) --- .gitignore | 1 + VisualC-GDK/SDL.sln | 64 +++++ VisualC-GDK/SDL/SDL.vcxproj | 248 +++++++++++++++- VisualC-GDK/SDL/SDL.vcxproj.filters | 12 + VisualC-GDK/SDLmain/SDLmain.vcxproj | 124 ++++++++ VisualC-GDK/SDLtest/SDLtest.vcxproj | 124 ++++++++ VisualC-GDK/clean.sh | 2 + VisualC-GDK/logos/SplashScreenImage.png | Bin 0 -> 6599 bytes .../testgamecontroller.vcxproj | 263 ++++++++++++++++- .../testgamecontroller.vcxproj.filters | 26 +- .../{ => wingdk}/MicrosoftGame.config | 0 .../xboxone/MicrosoftGame.config | 35 +++ .../xboxseries/MicrosoftGame.config | 29 ++ VisualC-GDK/tests/testgdk/PackageLayout.xml | 1 + VisualC-GDK/tests/testgdk/src/testgdk.cpp | 106 ++++++- VisualC-GDK/tests/testgdk/testgdk.vcxproj | 236 +++++++++++++++- .../tests/testgdk/testgdk.vcxproj.filters | 27 +- .../testgdk/{ => wingdk}/MicrosoftGame.config | 0 .../testgdk/xboxone/MicrosoftGame.config | 29 ++ .../testgdk/xboxseries/MicrosoftGame.config | 29 ++ .../tests/testsprite2/testsprite2.vcxproj | 230 ++++++++++++++- .../testsprite2/testsprite2.vcxproj.filters | 26 +- .../{ => wingdk}/MicrosoftGame.config | 0 .../testsprite2/xboxone/MicrosoftGame.config | 29 ++ .../xboxseries/MicrosoftGame.config | 29 ++ docs/README-gdk.md | 4 +- include/SDL_config.h | 2 + include/SDL_config_xbox.h | 267 ++++++++++++++++++ include/SDL_platform.h | 8 +- src/SDL.c | 4 + src/core/windows/SDL_windows.c | 15 +- src/core/windows/SDL_windows.h | 14 + src/core/windows/SDL_xinput.c | 13 +- src/core/windows/SDL_xinput.h | 16 ++ src/dynapi/SDL_dynapi.c | 2 +- src/events/SDL_mouse.c | 2 +- src/file/SDL_rwops.c | 6 + src/filesystem/windows/SDL_sysfilesystem.c | 19 ++ src/haptic/SDL_syshaptic.h | 9 + src/haptic/windows/SDL_dinputhaptic_c.h | 9 + src/haptic/windows/SDL_windowshaptic.c | 9 + src/haptic/windows/SDL_windowshaptic_c.h | 10 + src/haptic/windows/SDL_xinputhaptic.c | 12 +- src/haptic/windows/SDL_xinputhaptic_c.h | 9 + src/joystick/SDL_joystick_c.h | 10 + src/joystick/SDL_sysjoystick.h | 10 + src/joystick/windows/SDL_dinputjoystick_c.h | 10 + src/joystick/windows/SDL_windowsjoystick.c | 52 +++- src/joystick/windows/SDL_windowsjoystick_c.h | 10 + src/joystick/windows/SDL_xinputjoystick.c | 21 +- src/joystick/windows/SDL_xinputjoystick_c.h | 10 + src/misc/windows/SDL_sysurl.c | 9 + src/render/direct3d12/SDL_render_d3d12.c | 84 +++++- .../direct3d12/SDL_render_d3d12_xbox.cpp | 27 ++ src/render/direct3d12/SDL_render_d3d12_xbox.h | 22 ++ src/render/direct3d12/SDL_shaders_d3d12.c | 10 +- .../direct3d12/SDL_shaders_d3d12_xboxone.cpp | 29 ++ .../SDL_shaders_d3d12_xboxseries.cpp | 29 ++ src/stdlib/SDL_malloc.c | 2 + src/test/SDL_test_common.c | 2 +- src/thread/SDL_systhread.h | 10 + src/timer/windows/SDL_systimer.c | 2 +- src/video/SDL_video.c | 2 +- src/video/windows/SDL_windowsclipboard.c | 2 +- src/video/windows/SDL_windowsevents.c | 34 ++- src/video/windows/SDL_windowsframebuffer.c | 2 +- src/video/windows/SDL_windowskeyboard.c | 2 +- src/video/windows/SDL_windowsmessagebox.c | 2 +- src/video/windows/SDL_windowsmodes.c | 2 +- src/video/windows/SDL_windowsmouse.c | 2 +- src/video/windows/SDL_windowsopengl.c | 2 +- src/video/windows/SDL_windowsopengles.c | 2 +- src/video/windows/SDL_windowsshape.c | 2 +- src/video/windows/SDL_windowsvideo.c | 57 ++++ src/video/windows/SDL_windowsvideo.h | 12 +- src/video/windows/SDL_windowswindow.c | 73 ++++- src/video/windows/SDL_windowswindow.h | 2 + 77 files changed, 2573 insertions(+), 74 deletions(-) create mode 100644 VisualC-GDK/logos/SplashScreenImage.png rename VisualC-GDK/tests/testgamecontroller/{ => wingdk}/MicrosoftGame.config (100%) create mode 100644 VisualC-GDK/tests/testgamecontroller/xboxone/MicrosoftGame.config create mode 100644 VisualC-GDK/tests/testgamecontroller/xboxseries/MicrosoftGame.config rename VisualC-GDK/tests/testgdk/{ => wingdk}/MicrosoftGame.config (100%) create mode 100644 VisualC-GDK/tests/testgdk/xboxone/MicrosoftGame.config create mode 100644 VisualC-GDK/tests/testgdk/xboxseries/MicrosoftGame.config rename VisualC-GDK/tests/testsprite2/{ => wingdk}/MicrosoftGame.config (100%) create mode 100644 VisualC-GDK/tests/testsprite2/xboxone/MicrosoftGame.config create mode 100644 VisualC-GDK/tests/testsprite2/xboxseries/MicrosoftGame.config create mode 100644 include/SDL_config_xbox.h create mode 100644 src/render/direct3d12/SDL_render_d3d12_xbox.cpp create mode 100644 src/render/direct3d12/SDL_render_d3d12_xbox.h create mode 100644 src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp create mode 100644 src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp diff --git a/.gitignore b/.gitignore index 1f5e7249f..3683beeb3 100644 --- a/.gitignore +++ b/.gitignore @@ -96,6 +96,7 @@ VisualC/visualtest/testsprite2.exe VisualC/visualtest/testsprite2_sample.actions VisualC/visualtest/testsprite2_sample.config VisualC/visualtest/testsprite2_sample.parameters +VisualC-GDK/**/Layout # for Android android-project/local.properties diff --git a/VisualC-GDK/SDL.sln b/VisualC-GDK/SDL.sln index a52c78dc9..258421950 100644 --- a/VisualC-GDK/SDL.sln +++ b/VisualC-GDK/SDL.sln @@ -19,39 +19,103 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64 + Debug|Gaming.Xbox.Scarlett.x64 = Debug|Gaming.Xbox.Scarlett.x64 + Debug|Gaming.Xbox.XboxOne.x64 = Debug|Gaming.Xbox.XboxOne.x64 Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64 + Release|Gaming.Xbox.Scarlett.x64 = Release|Gaming.Xbox.Scarlett.x64 + Release|Gaming.Xbox.XboxOne.x64 = Release|Gaming.Xbox.XboxOne.x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Desktop.x64.Deploy.0 = Debug|Gaming.Desktop.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Xbox.Scarlett.x64.Deploy.0 = Debug|Gaming.Xbox.Scarlett.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Gaming.Xbox.XboxOne.x64.Deploy.0 = Debug|Gaming.Xbox.XboxOne.x64 {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Desktop.x64.Deploy.0 = Release|Gaming.Desktop.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Xbox.Scarlett.x64.Deploy.0 = Release|Gaming.Xbox.Scarlett.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Gaming.Xbox.XboxOne.x64.Deploy.0 = Release|Gaming.Xbox.XboxOne.x64 {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Desktop.x64.Deploy.0 = Debug|Gaming.Desktop.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Xbox.Scarlett.x64.Deploy.0 = Debug|Gaming.Xbox.Scarlett.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Debug|Gaming.Xbox.XboxOne.x64.Deploy.0 = Debug|Gaming.Xbox.XboxOne.x64 {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Desktop.x64.Deploy.0 = Release|Gaming.Desktop.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Xbox.Scarlett.x64.Deploy.0 = Release|Gaming.Xbox.Scarlett.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 + {55812185-D13C-4022-9C81-32E0F4A08305}.Release|Gaming.Xbox.XboxOne.x64.Deploy.0 = Release|Gaming.Xbox.XboxOne.x64 {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Desktop.x64.Deploy.0 = Debug|Gaming.Desktop.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Xbox.Scarlett.x64.Deploy.0 = Debug|Gaming.Xbox.Scarlett.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Debug|Gaming.Xbox.XboxOne.x64.Deploy.0 = Debug|Gaming.Xbox.XboxOne.x64 {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Desktop.x64.Deploy.0 = Release|Gaming.Desktop.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Xbox.Scarlett.x64.Deploy.0 = Release|Gaming.Xbox.Scarlett.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649}.Release|Gaming.Xbox.XboxOne.x64.Deploy.0 = Release|Gaming.Xbox.XboxOne.x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj index 638264c65..c143597a0 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj +++ b/VisualC-GDK/SDL/SDL.vcxproj @@ -5,10 +5,26 @@ Debug Gaming.Desktop.x64 + + Debug + Gaming.Xbox.Scarlett.x64 + + + Debug + Gaming.Xbox.XboxOne.x64 + Release Gaming.Desktop.x64 + + Release + Gaming.Xbox.Scarlett.x64 + + + Release + Gaming.Xbox.XboxOne.x64 + SDL2 @@ -21,10 +37,26 @@ DynamicLibrary $(DefaultPlatformToolset) + + DynamicLibrary + $(DefaultPlatformToolset) + + + DynamicLibrary + $(DefaultPlatformToolset) + DynamicLibrary $(DefaultPlatformToolset) + + DynamicLibrary + $(DefaultPlatformToolset) + + + DynamicLibrary + $(DefaultPlatformToolset) + @@ -32,23 +64,59 @@ + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + @@ -78,6 +146,62 @@ true + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/SDL.tlb + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + DLL_EXPORT;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + false + Level3 + OldStyle + OnlyExplicitInline + true + + + _DEBUG;%(PreprocessorDefinitions) + + + setupapi.lib;winmm.lib;imm32.lib;version.lib;xgameruntime.lib;d3d12_xs.lib;uuid.lib;vcruntimed.lib;msvcrtd.lib;ucrtd.lib;msvcprtd.lib;%(AdditionalDependencies) + true + Windows + true + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/SDL.tlb + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + DLL_EXPORT;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + false + Level3 + OldStyle + OnlyExplicitInline + true + + + _DEBUG;%(PreprocessorDefinitions) + + + setupapi.lib;winmm.lib;imm32.lib;version.lib;xgameruntime.lib;d3d12_x.lib;uuid.lib;vcruntimed.lib;msvcrtd.lib;ucrtd.lib;msvcprtd.lib;%(AdditionalDependencies) + true + Windows + true + + NDEBUG;%(PreprocessorDefinitions) @@ -107,6 +231,64 @@ true + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/SDL.tlb + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + DLL_EXPORT;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + false + Level3 + ProgramDatabase + OnlyExplicitInline + true + + + NDEBUG;%(PreprocessorDefinitions) + + + setupapi.lib;winmm.lib;imm32.lib;version.lib;xgameruntime.lib;d3d12_xs.lib;uuid.lib;vcruntime.lib;msvcrt.lib;ucrt.lib;msvcprt.lib;%(AdditionalDependencies) + true + Windows + true + true + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/SDL.tlb + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + DLL_EXPORT;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + false + Level3 + ProgramDatabase + OnlyExplicitInline + true + + + NDEBUG;%(PreprocessorDefinitions) + + + setupapi.lib;winmm.lib;imm32.lib;version.lib;xgameruntime.lib;d3d12_x.lib;uuid.lib;vcruntime.lib;msvcrt.lib;ucrt.lib;msvcprt.lib;%(AdditionalDependencies) + true + Windows + true + true + true + + @@ -242,6 +424,7 @@ + @@ -264,6 +447,9 @@ + + + @@ -353,7 +539,16 @@ - + + CompileAsCpp + CompileAsCpp + CompileAsCpp + CompileAsCpp + stdcpp17 + stdcpp17 + stdcpp17 + stdcpp17 + @@ -371,8 +566,26 @@ - - + + CompileAsCpp + CompileAsCpp + CompileAsCpp + CompileAsCpp + stdcpp17 + stdcpp17 + stdcpp17 + stdcpp17 + + + stdcpp17 + stdcpp17 + stdcpp17 + stdcpp17 + CompileAsCpp + CompileAsCpp + CompileAsCpp + CompileAsCpp + @@ -392,9 +605,27 @@ - + + CompileAsCpp + CompileAsCpp + CompileAsCpp + CompileAsCpp + stdcpp17 + stdcpp17 + stdcpp17 + stdcpp17 + - + + stdcpp17 + stdcpp17 + stdcpp17 + stdcpp17 + CompileAsCpp + CompileAsCpp + CompileAsCpp + CompileAsCpp + @@ -423,7 +654,12 @@ - + + CompileAsCpp + CompileAsCpp + CompileAsCpp + CompileAsCpp + diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters index 02ca2947f..d005dead6 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj.filters +++ b/VisualC-GDK/SDL/SDL.vcxproj.filters @@ -836,6 +836,9 @@ core\gdk + + render\direct3d12 + @@ -1348,6 +1351,15 @@ core\gdk + + render\direct3d12 + + + render\direct3d12 + + + render\direct3d12 + diff --git a/VisualC-GDK/SDLmain/SDLmain.vcxproj b/VisualC-GDK/SDLmain/SDLmain.vcxproj index 1d27a6333..a2c05b1c3 100644 --- a/VisualC-GDK/SDLmain/SDLmain.vcxproj +++ b/VisualC-GDK/SDLmain/SDLmain.vcxproj @@ -5,10 +5,26 @@ Debug Gaming.Desktop.x64 + + Debug + Gaming.Xbox.Scarlett.x64 + + + Debug + Gaming.Xbox.XboxOne.x64 + Release Gaming.Desktop.x64 + + Release + Gaming.Xbox.Scarlett.x64 + + + Release + Gaming.Xbox.XboxOne.x64 + @@ -24,10 +40,26 @@ StaticLibrary $(DefaultPlatformToolset) + + StaticLibrary + $(DefaultPlatformToolset) + + + StaticLibrary + $(DefaultPlatformToolset) + StaticLibrary $(DefaultPlatformToolset) + + StaticLibrary + $(DefaultPlatformToolset) + + + StaticLibrary + $(DefaultPlatformToolset) + @@ -35,23 +67,59 @@ + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + @@ -67,6 +135,34 @@ true + + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + Level3 + OldStyle + true + + @@ -81,6 +177,34 @@ true + + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + false + Level3 + OldStyle + true + + diff --git a/VisualC-GDK/SDLtest/SDLtest.vcxproj b/VisualC-GDK/SDLtest/SDLtest.vcxproj index 1487ad7a2..c2e9348c3 100644 --- a/VisualC-GDK/SDLtest/SDLtest.vcxproj +++ b/VisualC-GDK/SDLtest/SDLtest.vcxproj @@ -5,10 +5,26 @@ Debug Gaming.Desktop.x64 + + Debug + Gaming.Xbox.Scarlett.x64 + + + Debug + Gaming.Xbox.XboxOne.x64 + Release Gaming.Desktop.x64 + + Release + Gaming.Xbox.Scarlett.x64 + + + Release + Gaming.Xbox.XboxOne.x64 + SDL2test @@ -21,10 +37,26 @@ StaticLibrary $(DefaultPlatformToolset) + + StaticLibrary + $(DefaultPlatformToolset) + + + StaticLibrary + $(DefaultPlatformToolset) + StaticLibrary $(DefaultPlatformToolset) + + StaticLibrary + $(DefaultPlatformToolset) + + + StaticLibrary + $(DefaultPlatformToolset) + @@ -32,23 +64,59 @@ + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + @@ -64,6 +132,34 @@ true + + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + Level3 + OldStyle + true + + @@ -78,6 +174,34 @@ true + + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + false + Level3 + OldStyle + true + + diff --git a/VisualC-GDK/clean.sh b/VisualC-GDK/clean.sh index a23f06b54..a026b71a3 100644 --- a/VisualC-GDK/clean.sh +++ b/VisualC-GDK/clean.sh @@ -2,3 +2,5 @@ find . -type f \( -name '*.user' -o -name '*.sdf' -o -name '*.ncb' -o -name '*.suo' \) -print -delete find . -type f \( -name '*.bmp' -o -name '*.wav' -o -name '*.dat' \) -print -delete find . -depth -type d \( -name Gaming.Desktop.x64 \) -exec rm -rv {} \; +find . -depth -type d \( -name Gaming.Xbox.Scarlett.x64 \) -exec rm -rv {} \; +find . -depth -type d \( -name Gaming.Xbox.XboxOne.x64 \) -exec rm -rv {} \; diff --git a/VisualC-GDK/logos/SplashScreenImage.png b/VisualC-GDK/logos/SplashScreenImage.png new file mode 100644 index 0000000000000000000000000000000000000000..def578f665e3ae62954bc864dd7f564641866681 GIT binary patch literal 6599 zcmeAS@N?(olHy`uVBq!ia0y~yU~gbxV6os}0*a(>3=?5sU~J8Fb`J1#c2+1T%1_J8 zNo8Qrm{>c}*5h!1NUMKvwyPGOn4sXvfVnyyT^3%V-3be~h(?tfRKD!Lutd?buuvq1 zo9~}am~70P($WG^mV@#F?&|8U;+h}#ExDj{jD7m|!h6>3zuz&pRLxwOcHCk?*0hOT z$B*RXx$^8=Bz!o8@r(DFE5a{Zd2Fst!-~CDFeRcghIn{il1L{KOjqYyfxZb(k zTzBqgyTTb$Ra$?{sW`KMty6xd-tIrgcD~qf!1%D6nyI^tnpk(P&UQm>Nv)3}g)V`n zr^GkuY0ueivHGc2_P3Mq5~s3HXRZt8RqS(Bnb5)^8Je?zhdc0=X^_v77dFox%9s4{ zEIRq*7K8F}8?69E%eoKtKWw8n8(2P6YfW-^aCDo!Tf+mr3oCAZ`@S*P+>hbEalz89 zf2LX)eD;a={8N4u7utUmCR&)~xn@3to%by^Dp819{aF}uj&zV3y+ugeuddDee=qagdv@!uMH9a^ec20)7tR8Y$YKTtJ!KGP ztXOJa1{7p3@$_|Nf5s-q#>Oe(@?EZzkx!g~L41R!i(^Q|tv3f58G%|FCj49fjsuh&M!{$ZjE2By2#kinXb6mkz-S1J zhQMeDjE2By2#kinXb6mkz_1R1hTF}|LLeVH{*V8z95Sr^I_kO65Eu=C(GVC7fzc2c c3L&tA^Xo1KMnOeOSCDHxUHx3vIVCg!0PLmbtpET3 literal 0 HcmV?d00001 diff --git a/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj index 1d90d6688..ca6473c8c 100644 --- a/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj +++ b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj @@ -5,10 +5,26 @@ Debug Gaming.Desktop.x64 + + Debug + Gaming.Xbox.Scarlett.x64 + + + Debug + Gaming.Xbox.XboxOne.x64 + Release Gaming.Desktop.x64 + + Release + Gaming.Xbox.Scarlett.x64 + + + Release + Gaming.Xbox.XboxOne.x64 + {55812185-D13C-4022-9C81-32E0F4A08305} @@ -20,10 +36,28 @@ Application $(DefaultPlatformToolset) + + Application + $(DefaultPlatformToolset) + true + + + Application + $(DefaultPlatformToolset) + true + Application $(DefaultPlatformToolset) + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + @@ -31,23 +65,59 @@ + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + @@ -72,6 +142,52 @@ xgameruntime.lib;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies) + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testgamecontroller.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testgamecontroller.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;%(AdditionalDependencies) + + _DEBUG;%(PreprocessorDefinitions) @@ -98,6 +214,58 @@ xgameruntime.lib;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies) + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/testgamecontroller.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/testgamecontroller.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + xgameruntime.lib;%(AdditionalDependencies) + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} @@ -115,43 +283,107 @@ Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" + + copy "%(FullPath)" "$(ProjectDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) @@ -159,8 +391,12 @@ - + Document + true + true + true + true @@ -175,8 +411,33 @@ Document + true + true + true + true + + + Document + true + true + true + true + + + + + Document + true + true + true + true + + + + + diff --git a/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters index b9ffafc1b..1124f2c6e 100644 --- a/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters +++ b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters @@ -21,13 +21,35 @@ logos - + + wingdk + + + wingdk + + + xboxseries + + + xboxone + + + logos + - {5e858cf0-6fba-498d-b33d-11c8ecbb79c7} + + {5790a250-283e-4f51-8f28-6a977d3c7a6c} + + + {a4d235e4-4017-4193-af62-ecb2ac249be4} + + + {e704dcb9-c83c-4c94-a139-b0f3e3f428f2} + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgamecontroller/MicrosoftGame.config b/VisualC-GDK/tests/testgamecontroller/wingdk/MicrosoftGame.config similarity index 100% rename from VisualC-GDK/tests/testgamecontroller/MicrosoftGame.config rename to VisualC-GDK/tests/testgamecontroller/wingdk/MicrosoftGame.config diff --git a/VisualC-GDK/tests/testgamecontroller/xboxone/MicrosoftGame.config b/VisualC-GDK/tests/testgamecontroller/xboxone/MicrosoftGame.config new file mode 100644 index 000000000..53695042f --- /dev/null +++ b/VisualC-GDK/tests/testgamecontroller/xboxone/MicrosoftGame.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgamecontroller/xboxseries/MicrosoftGame.config b/VisualC-GDK/tests/testgamecontroller/xboxseries/MicrosoftGame.config new file mode 100644 index 000000000..648fed1c5 --- /dev/null +++ b/VisualC-GDK/tests/testgamecontroller/xboxseries/MicrosoftGame.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgdk/PackageLayout.xml b/VisualC-GDK/tests/testgdk/PackageLayout.xml index f09b2e577..abee981bd 100644 --- a/VisualC-GDK/tests/testgdk/PackageLayout.xml +++ b/VisualC-GDK/tests/testgdk/PackageLayout.xml @@ -3,6 +3,7 @@ + diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp index 377d48315..ed69ecbea 100644 --- a/VisualC-GDK/tests/testgdk/src/testgdk.cpp +++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp @@ -44,11 +44,32 @@ static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND; int done; +static struct +{ + SDL_AudioSpec spec; + Uint8 *sound; /* Pointer to wave data */ + Uint32 soundlen; /* Length of wave data */ + int soundpos; /* Current play position */ +} wave; + +static SDL_AudioDeviceID device; + +static void +close_audio() +{ + if (device != 0) { + SDL_CloseAudioDevice(device); + device = 0; + } +} + /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void quit(int rc) { SDL_free(sprites); + close_audio(); + SDL_FreeWAV(wave.sound); SDLTest_CommonQuit(state); /* If rc is 0, just let main return normally rather than calling exit. * This allows testing of platforms where SDL_main is required and does meaningful cleanup. @@ -58,6 +79,51 @@ quit(int rc) } } +static void +open_audio() +{ + /* Initialize fillerup() variables */ + device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0); + if (!device) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_FreeWAV(wave.sound); + quit(2); + } + + /* Let the audio run */ + SDL_PauseAudioDevice(device, SDL_FALSE); +} + +static void +reopen_audio() +{ + close_audio(); + open_audio(); +} + +void SDLCALL +fillerup(void *unused, Uint8 *stream, int len) +{ + Uint8 *waveptr; + int waveleft; + + /* Set up the pointers */ + waveptr = wave.sound + wave.soundpos; + waveleft = wave.soundlen - wave.soundpos; + + /* Go! */ + while (waveleft <= len) { + SDL_memcpy(stream, waveptr, waveleft); + stream += waveleft; + len -= waveleft; + waveptr = wave.sound; + waveleft = wave.soundlen; + wave.soundpos = 0; + } + SDL_memcpy(stream, waveptr, len); + wave.soundpos += len; +} + void UserLoggedIn(XUserHandle user) { @@ -285,7 +351,17 @@ loop() /* Check for events */ while (SDL_PollEvent(&event)) { + if (event.type == SDL_KEYDOWN && !event.key.repeat) { + SDL_Log("Initial SDL_KEYDOWN: %s", SDL_GetScancodeName(event.key.keysym.scancode)); + } +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + /* On Xbox, ignore the keydown event because the features aren't supported */ + if (event.type != SDL_KEYDOWN) { + SDLTest_CommonEvent(state, &event, &done); + } +#else SDLTest_CommonEvent(state, &event, &done); +#endif } for (i = 0; i < state->num_windows; ++i) { if (state->windows[i] == NULL) @@ -299,12 +375,13 @@ main(int argc, char *argv[]) { int i; const char *icon = "icon.bmp"; + char *soundname = NULL; /* Initialize parameters */ num_sprites = NUM_SPRITES; /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); + state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO); if (!state) { return 1; } @@ -381,6 +458,31 @@ main(int argc, char *argv[]) quit(2); } + soundname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); + + if (soundname == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); + quit(1); + } + + /* Load the wave file into memory */ + if (SDL_LoadWAV(soundname, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", soundname, SDL_GetError()); + quit(1); + } + + wave.spec.callback = fillerup; + + /* Show the list of available drivers */ + SDL_Log("Available audio drivers:"); + for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { + SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); + } + + SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); + + open_audio(); + /* Main render loop */ done = 0; @@ -392,6 +494,8 @@ main(int argc, char *argv[]) } quit(0); + + SDL_free(soundname); return 0; } diff --git a/VisualC-GDK/tests/testgdk/testgdk.vcxproj b/VisualC-GDK/tests/testgdk/testgdk.vcxproj index bcb57363d..f024a89a5 100644 --- a/VisualC-GDK/tests/testgdk/testgdk.vcxproj +++ b/VisualC-GDK/tests/testgdk/testgdk.vcxproj @@ -5,10 +5,26 @@ Debug Gaming.Desktop.x64 + + Debug + Gaming.Xbox.Scarlett.x64 + + + Debug + Gaming.Xbox.XboxOne.x64 + Release Gaming.Desktop.x64 + + Release + Gaming.Xbox.Scarlett.x64 + + + Release + Gaming.Xbox.XboxOne.x64 + {1C9A3F71-35A5-4C56-B292-F4375B3C3649} @@ -20,10 +36,28 @@ Application $(DefaultPlatformToolset) + + Application + $(DefaultPlatformToolset) + true + + + Application + $(DefaultPlatformToolset) + true + Application $(DefaultPlatformToolset) + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + @@ -31,23 +65,59 @@ + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + @@ -76,6 +146,60 @@ + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testsprite2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testsprite2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + _DEBUG;%(PreprocessorDefinitions) @@ -106,6 +230,66 @@ + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/testsprite2.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/testsprite2.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} @@ -129,13 +313,29 @@ Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" copy "%(FullPath)" "$(OutDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" copy "%(FullPath)" "$(OutDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) @@ -143,13 +343,21 @@ copy "%(FullPath)" "$(OutDir)\" - + Document + true + true + true + true Document + true + true + true + true @@ -161,6 +369,32 @@ copy "%(FullPath)" "$(OutDir)\" + + + Document + true + true + true + true + + + + + Document + + + + + Document + true + true + true + true + + + + + diff --git a/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters b/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters index 4a143d855..b82a98985 100644 --- a/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters +++ b/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters @@ -6,7 +6,6 @@ - logos @@ -19,12 +18,36 @@ logos - + + wingdk + + + wingdk + + + xboxseries + + + + xboxone + + + logos + {c3c871f2-c7b7-4025-8ba4-037dde717fe1} + + {1678a80d-0ee8-4f48-bf89-9462d82dd98a} + + + {1b47b96b-507e-40ec-9c25-99b1a4d5b575} + + + {ac7aa2d5-f0f7-46eb-a548-5b6316f3b63b} + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgdk/MicrosoftGame.config b/VisualC-GDK/tests/testgdk/wingdk/MicrosoftGame.config similarity index 100% rename from VisualC-GDK/tests/testgdk/MicrosoftGame.config rename to VisualC-GDK/tests/testgdk/wingdk/MicrosoftGame.config diff --git a/VisualC-GDK/tests/testgdk/xboxone/MicrosoftGame.config b/VisualC-GDK/tests/testgdk/xboxone/MicrosoftGame.config new file mode 100644 index 000000000..a0583bde9 --- /dev/null +++ b/VisualC-GDK/tests/testgdk/xboxone/MicrosoftGame.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgdk/xboxseries/MicrosoftGame.config b/VisualC-GDK/tests/testgdk/xboxseries/MicrosoftGame.config new file mode 100644 index 000000000..964490182 --- /dev/null +++ b/VisualC-GDK/tests/testgdk/xboxseries/MicrosoftGame.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj index 1d1c8870d..651a346e5 100644 --- a/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj +++ b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj @@ -5,10 +5,26 @@ Debug Gaming.Desktop.x64 + + Debug + Gaming.Xbox.Scarlett.x64 + + + Debug + Gaming.Xbox.XboxOne.x64 + Release Gaming.Desktop.x64 + + Release + Gaming.Xbox.Scarlett.x64 + + + Release + Gaming.Xbox.XboxOne.x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682} @@ -20,10 +36,28 @@ Application $(DefaultPlatformToolset) + + Application + $(DefaultPlatformToolset) + true + + + Application + $(DefaultPlatformToolset) + true + Application $(DefaultPlatformToolset) + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + @@ -31,23 +65,59 @@ + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + @@ -76,6 +146,60 @@ + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testsprite2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testsprite2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + _DEBUG;%(PreprocessorDefinitions) @@ -106,6 +230,66 @@ + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/testsprite2.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/testsprite2.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + xgameruntime.lib;%(AdditionalDependencies) + + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} @@ -129,13 +313,29 @@ Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" copy "%(FullPath)" "$(OutDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) + Copying %(Filename)%(Extension) copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + copy "%(FullPath)" "$(ProjectDir)\" copy "%(FullPath)" "$(OutDir)\" $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) @@ -143,13 +343,21 @@ copy "%(FullPath)" "$(OutDir)\" - + Document + true + true + true + true Document + true + true + true + true @@ -161,6 +369,26 @@ copy "%(FullPath)" "$(OutDir)\" + + + Document + true + true + true + true + + + + + true + true + true + true + + + + + diff --git a/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters index 19672bfad..e945fe548 100644 --- a/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters +++ b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters @@ -6,7 +6,6 @@ - logos @@ -19,12 +18,35 @@ logos - + + wingdk + + + xboxseries + + + xboxone + + + wingdk + + + logos + {c3c871f2-c7b7-4025-8ba4-037dde717fe1} + + {c862dfc3-7803-4359-a31e-9dcda37e641a} + + + {1671e83d-25b3-4eb5-bed0-5c52c80f4e49} + + + {9bf62acf-6661-43f9-bde3-0de9e1db4290} + \ No newline at end of file diff --git a/VisualC-GDK/tests/testsprite2/MicrosoftGame.config b/VisualC-GDK/tests/testsprite2/wingdk/MicrosoftGame.config similarity index 100% rename from VisualC-GDK/tests/testsprite2/MicrosoftGame.config rename to VisualC-GDK/tests/testsprite2/wingdk/MicrosoftGame.config diff --git a/VisualC-GDK/tests/testsprite2/xboxone/MicrosoftGame.config b/VisualC-GDK/tests/testsprite2/xboxone/MicrosoftGame.config new file mode 100644 index 000000000..4e8810bbd --- /dev/null +++ b/VisualC-GDK/tests/testsprite2/xboxone/MicrosoftGame.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testsprite2/xboxseries/MicrosoftGame.config b/VisualC-GDK/tests/testsprite2/xboxseries/MicrosoftGame.config new file mode 100644 index 000000000..8e4431fd6 --- /dev/null +++ b/VisualC-GDK/tests/testsprite2/xboxseries/MicrosoftGame.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/docs/README-gdk.md b/docs/README-gdk.md index 0a0b509ff..5f6b18be3 100644 --- a/docs/README-gdk.md +++ b/docs/README-gdk.md @@ -3,7 +3,7 @@ GDK This port allows SDL applications to run via Microsoft's Game Development Kit (GDK). -At this time, only Windows GDK is supported. Xbox support is slated for the future. +Windows (GDK) and Xbox One/Xbox Series (GDKX) are supported. Although most of the Xbox code is included in the public SDL source code, NDA access is required for a small number of source files. If you have access to GDKX, these required Xbox files are posted on the GDK forums [here](https://forums.xboxlive.com/questions/130003/). Requirements @@ -56,7 +56,7 @@ In your game's existing Visual Studio Solution, go to Build > Configuration Mana ### 2. Build SDL2 and SDL2main for GDK ### -Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project. +Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project. *Alternatively*, you could setup your solution file to instead reference the SDL2/SDL2main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL2 and SDL2main would both be built when your game is built. diff --git a/include/SDL_config.h b/include/SDL_config.h index 003467907..f91cb47ec 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -35,6 +35,8 @@ #include "SDL_config_winrt.h" #elif defined(__WINGDK__) #include "SDL_config_wingdk.h" +#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#include "SDL_config_xbox.h" #elif defined(__MACOSX__) #include "SDL_config_macosx.h" #elif defined(__IPHONEOS__) diff --git a/include/SDL_config_xbox.h b/include/SDL_config_xbox.h new file mode 100644 index 000000000..4e68e9f98 --- /dev/null +++ b/include/SDL_config_xbox.h @@ -0,0 +1,267 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2022 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_wingdk_h_ +#define SDL_config_wingdk_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/* Windows GDK does not need Windows SDK version checks because it requires + * a recent version of the Windows 10 SDK. */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +/* At this time, only recent MSVC or clang are supported by Windows GDK */ +#if defined(__clang__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +typedef unsigned __int64 uintptr_t; +#define _UINTPTR_T_DEFINED +#endif +#else /* !__clang__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __clang__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +/* GDK only supports 64-bit */ +# define SIZEOF_VOIDP 8 + +#ifdef __clang__ +# define HAVE_GCC_ATOMICS 1 +#endif + +/*#define HAVE_DDRAW_H 1*/ +/*#define HAVE_DINPUT_H 1*/ +/*#define HAVE_DSOUND_H 1*/ +/* No SDK version checks needed for these because the SDK has to be new. */ +/* #define HAVE_DXGI_H 1 */ +#define HAVE_XINPUT_H 1 +/*#define HAVE_WINDOWS_GAMING_INPUT_H 1*/ +/*#define HAVE_D3D11_H 1*/ +/*#define HAVE_ROAPI_H 1*/ +#define HAVE_D3D12_H 1 +/*#define HAVE_SHELLSCALINGAPI_H 1*/ +#define HAVE_MMDEVICEAPI_H 1 +#define HAVE_AUDIOCLIENT_H 1 +/*#define HAVE_TPCSHRD_H 1*/ +/*#define HAVE_SENSORSAPI_H 1*/ +#if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600) +#define HAVE_IMMINTRIN_H 1 +#elif defined(__has_include) && (defined(__i386__) || defined(__x86_64)) +# if __has_include() +# define HAVE_IMMINTRIN_H 1 +# endif +#endif + +/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ +#ifdef HAVE_LIBC +/* Useful headers */ +#define STDC_HEADERS 1 +#define HAVE_CTYPE_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_BSEARCH 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +/* These functions have security warnings, so we won't use them */ +/* #undef HAVE__STRUPR */ +/* #undef HAVE__STRLWR */ +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +/* #undef HAVE_STRTOK_R */ +/* These functions have security warnings, so we won't use them */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__ULTOA */ +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE__WCSICMP 1 +#define HAVE__WCSNICMP 1 +#define HAVE__WCSDUP 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE_COS 1 +#define HAVE_EXP 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_FMOD 1 +#define HAVE_LOG 1 +#define HAVE_LOG10 1 +#define HAVE_POW 1 +#define HAVE_SIN 1 +#define HAVE_SQRT 1 +#define HAVE_TAN 1 +#define HAVE_ACOSF 1 +#define HAVE_ASINF 1 +#define HAVE_ATANF 1 +#define HAVE_ATAN2F 1 +#define HAVE_CEILF 1 +#define HAVE__COPYSIGN 1 +#define HAVE_COSF 1 +#define HAVE_EXPF 1 +#define HAVE_FABSF 1 +#define HAVE_FLOORF 1 +#define HAVE_FMODF 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10F 1 +#define HAVE_POWF 1 +#define HAVE_SINF 1 +#define HAVE_SQRTF 1 +#define HAVE_TANF 1 +#if defined(_MSC_VER) +/* These functions were added with the VC++ 2013 C runtime library */ +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_VSSCANF 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 +#define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 +#define HAVE_TRUNC 1 +#define HAVE_TRUNCF 1 +#define HAVE__FSEEKI64 1 +#ifdef _USE_MATH_DEFINES +#define HAVE_M_PI 1 +#endif +#else +#define HAVE_M_PI 1 +#endif +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H) +#define SDL_AUDIO_DRIVER_WASAPI 1 +#endif +/*#define SDL_AUDIO_DRIVER_DSOUND 1*/ +/*#define SDL_AUDIO_DRIVER_WINMM 1*/ +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +/*#define SDL_JOYSTICK_DINPUT 1*/ +/*#define SDL_JOYSTICK_HIDAPI 1*/ +/*#define SDL_JOYSTICK_RAWINPUT 1*/ +#define SDL_JOYSTICK_VIRTUAL 1 +#ifdef HAVE_WINDOWS_GAMING_INPUT_H +#define SDL_JOYSTICK_WGI 1 +#endif +#define SDL_JOYSTICK_XINPUT 1 +/*#define SDL_HAPTIC_DINPUT 1*/ +#define SDL_HAPTIC_XINPUT 1 + +/* Enable the sensor driver */ +#ifdef HAVE_SENSORSAPI_H +#define SDL_SENSOR_WINDOWS 1 +#else +#define SDL_SENSOR_DUMMY 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_GENERIC_COND_SUFFIX 1 +#define SDL_THREAD_WINDOWS 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 + +/* #ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 1 +#endif*/ +#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H) +#define SDL_VIDEO_RENDER_D3D11 1 +#endif +#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H) +#define SDL_VIDEO_RENDER_D3D12 1 +#endif + +/* Enable system power support */ +/*#define SDL_POWER_WINDOWS 1*/ +#define SDL_POWER_HARDWIRED 1 + +/* Enable filesystem support */ +/* #define SDL_FILESYSTEM_WINDOWS 1*/ +#define SDL_FILESYSTEM_XBOX 1 + +/* Disable IME as not supported yet (TODO: Xbox IME?) */ +#define SDL_DISABLE_WINDOWS_IME 1 + +#endif /* SDL_config_wingdk_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_platform.h b/include/SDL_platform.h index 2b61605df..f1f6f8b06 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -172,6 +172,12 @@ #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */ #undef __WINGDK__ #define __WINGDK__ 1 +#elif defined(_GAMING_XBOX_XBOXONE) +#undef __XBOXONE__ +#define __XBOXONE__ 1 +#elif defined(_GAMING_XBOX_SCARLETT) +#undef __XBOXSERIES__ +#define __XBOXSERIES__ 1 #else #undef __WINDOWS__ #define __WINDOWS__ 1 @@ -183,7 +189,7 @@ #define __WIN32__ 1 #endif /* This is to support generic "any GDK" separate from a platform-specific GDK */ -#if defined(__WINGDK__) || defined(__XBOXONEGDK__) || defined(__XBOXSERIESGDK__) +#if defined(__WINGDK__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) #undef __GDK__ #define __GDK__ 1 #endif diff --git a/src/SDL.c b/src/SDL.c index d1326fb2e..59602d623 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -581,6 +581,10 @@ SDL_GetPlatform(void) return "WinRT"; #elif __WINGDK__ return "WinGDK"; +#elif __XBOXONE__ + return "Xbox One"; +#elif __XBOXSERIES__ + return "Xbox Series"; #elif __TVOS__ return "tvOS"; #elif __IPHONEOS__ diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index f5b2642f5..4ec9dbb64 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -96,6 +96,9 @@ WIN_CoInitialize(void) attribute, which, AFAIK, should initialize COM. */ return S_OK; +#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) + /* On Xbox, there's no need to call CoInitializeEx (and it's not implemented) */ + return S_OK; #else HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (hr == RPC_E_CHANGED_MODE) { @@ -179,7 +182,7 @@ WIN_RoUninitialize(void) #endif } -#ifndef __WINRT__ +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) { @@ -203,7 +206,7 @@ IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServiceP BOOL WIN_IsWindowsVistaOrGreater(void) { -#ifdef __WINRT__ +#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0); @@ -212,7 +215,7 @@ BOOL WIN_IsWindowsVistaOrGreater(void) BOOL WIN_IsWindows7OrGreater(void) { -#ifdef __WINRT__ +#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0); @@ -221,7 +224,7 @@ BOOL WIN_IsWindows7OrGreater(void) BOOL WIN_IsWindows8OrGreater(void) { -#ifdef __WINRT__ +#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0); @@ -252,8 +255,8 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM. char * WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) { -#if __WINRT__ - return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP, go with what we've got. */ +#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) + return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */ #else static const GUID nullguid = { 0 }; const unsigned char *ptr; diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 48f4d93b1..e2d62edd5 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -50,6 +50,20 @@ #undef _WIN32_WINNT #define _WIN32_WINNT 0xA00 #define WINVER _WIN32_WINNT +#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef STRICT +#define STRICT +#endif +#ifndef UNICODE +#define UNICODE 1 +#endif +#undef WINVER +#undef _WIN32_WINNT +#define _WIN32_WINNT 0xA00 +#define WINVER _WIN32_WINNT #endif #include diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index fa67efcbb..8b9c26ef9 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -22,6 +22,10 @@ #include "SDL_xinput.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif XInputGetState_t SDL_XInputGetState = NULL; XInputSetState_t SDL_XInputSetState = NULL; @@ -33,7 +37,7 @@ static HANDLE s_pXInputDLL = 0; static int s_XInputDLLRefCount = 0; -#ifdef __WINRT__ +#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) int WIN_LoadXInputDLL(void) @@ -66,7 +70,7 @@ WIN_UnloadXInputDLL(void) { } -#else /* !__WINRT__ */ +#else /* !(defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) */ int WIN_LoadXInputDLL(void) @@ -136,4 +140,9 @@ WIN_UnloadXInputDLL(void) #endif /* __WINRT__ */ +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/windows/SDL_xinput.h b/src/core/windows/SDL_xinput.h index 1879e09ad..461d99b48 100644 --- a/src/core/windows/SDL_xinput.h +++ b/src/core/windows/SDL_xinput.h @@ -26,7 +26,13 @@ #include "SDL_windows.h" #ifdef HAVE_XINPUT_H +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +/* Xbox supports an XInput wrapper which is a C++-only header... */ +#include +using namespace XInputOnGameInput; +#else #include +#endif #endif /* HAVE_XINPUT_H */ #ifndef XUSER_MAX_COUNT @@ -147,6 +153,11 @@ #define BATTERY_LEVEL_FULL 0x03 #endif +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + /* typedef's for XInput structs we use */ #ifndef HAVE_XINPUT_GAMEPAD_EX @@ -243,6 +254,11 @@ extern XInputGetCapabilities_t SDL_XInputGetCapabilities; extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation; extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #define XINPUTGETSTATE SDL_XInputGetState #define XINPUTSETSTATE SDL_XInputSetState #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 7d8590d6e..d3f7f612b 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -291,7 +291,7 @@ static void dynapi_warn(const char *msg) { const char *caption = "SDL Dynamic API Failure!"; /* SDL_ShowSimpleMessageBox() is a too heavy for here. */ - #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) + #if (defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONERROR); #elif defined(HAVE_STDIO_H) fprintf(stderr, "\n\n%s\n%s\n\n", caption, msg); diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 90dcd38a4..45dffc779 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -55,7 +55,7 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol if (hint && *hint) { mouse->double_click_time = SDL_atoi(hint); } else { -#if defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__WINGDK__) mouse->double_click_time = GetDoubleClickTime(); #elif defined(__OS2__) mouse->double_click_time = WinQuerySysValue(HWND_DESKTOP, SV_DBLCLKTIME); diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 56f912566..a93c2fb3c 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -75,7 +75,9 @@ static int SDLCALL windows_file_open(SDL_RWops * context, const char *filename, const char *mode) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) UINT old_error_mode; +#endif HANDLE h; DWORD r_right, w_right; DWORD must_exist, truncate; @@ -112,9 +114,11 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) if (!context->hidden.windowsio.buffer.data) { return SDL_OutOfMemory(); } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Do not open a dialog box if failure */ old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); +#endif { LPTSTR tstr = WIN_UTF8ToString(filename); @@ -125,8 +129,10 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode) SDL_free(tstr); } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* restore old behavior */ SetErrorMode(old_error_mode); +#endif if (h == INVALID_HANDLE_VALUE) { SDL_free(context->hidden.windowsio.buffer.data); diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index b57546c67..5d3099be6 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -172,4 +172,23 @@ SDL_GetPrefPath(const char *org, const char *app) #endif /* SDL_FILESYSTEM_WINDOWS */ +#ifdef SDL_FILESYSTEM_XBOX +#include "SDL_filesystem.h" +#include "SDL_error.h" +char * +SDL_GetBasePath(void) +{ + SDL_Unsupported(); + return NULL; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + SDL_Unsupported(); + return NULL; +} +#endif /* SDL_FILESYSTEM_XBOX */ + + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h index 9e5840957..d6ee3e1ac 100644 --- a/src/haptic/SDL_syshaptic.h +++ b/src/haptic/SDL_syshaptic.h @@ -26,6 +26,10 @@ #include "SDL_haptic.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif struct haptic_effect { @@ -203,6 +207,11 @@ extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic); */ extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* SDL_syshaptic_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/windows/SDL_dinputhaptic_c.h b/src/haptic/windows/SDL_dinputhaptic_c.h index e854971a0..60fa414cd 100644 --- a/src/haptic/windows/SDL_dinputhaptic_c.h +++ b/src/haptic/windows/SDL_dinputhaptic_c.h @@ -23,6 +23,10 @@ #include "SDL_haptic.h" #include "SDL_windowshaptic_c.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif extern int SDL_DINPUT_HapticInit(void); extern int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance); @@ -44,4 +48,9 @@ extern int SDL_DINPUT_HapticPause(SDL_Haptic * haptic); extern int SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic); extern int SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index 1be2fc487..475ae49c6 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -37,6 +37,10 @@ #include "SDL_dinputhaptic_c.h" #include "SDL_xinputhaptic_c.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif /* * Internal stuff. @@ -466,6 +470,11 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic) } } +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h index ec6e333ce..dcfb7022e 100644 --- a/src/haptic/windows/SDL_windowshaptic_c.h +++ b/src/haptic/windows/SDL_windowshaptic_c.h @@ -28,6 +28,11 @@ #include "../../core/windows/SDL_directx.h" #include "../../core/windows/SDL_xinput.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Haptic system hardware data. */ @@ -84,6 +89,11 @@ extern SDL_hapticlist_item *SDL_hapticlist; extern int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item); extern int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* SDL_windowshaptic_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c index 9212fbf32..2622fb7a7 100644 --- a/src/haptic/windows/SDL_xinputhaptic.c +++ b/src/haptic/windows/SDL_xinputhaptic.c @@ -35,6 +35,11 @@ #include "../../joystick/windows/SDL_windowsjoystick_c.h" #include "../../thread/SDL_systhread.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Internal stuff. */ @@ -45,7 +50,7 @@ int SDL_XINPUT_HapticInit(void) { if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) { - loaded_xinput = (WIN_LoadXInputDLL() == 0); + loaded_xinput = (WIN_LoadXInputDLL() == 0) ? SDL_TRUE : SDL_FALSE; } /* If the joystick subsystem is active, it will manage adding XInput haptic devices */ @@ -365,6 +370,11 @@ SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic) return (XINPUTSETSTATE(haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1; } +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #else /* !SDL_HAPTIC_XINPUT */ #include "../../core/windows/SDL_windows.h" diff --git a/src/haptic/windows/SDL_xinputhaptic_c.h b/src/haptic/windows/SDL_xinputhaptic_c.h index d0347e632..2fb5dd861 100644 --- a/src/haptic/windows/SDL_xinputhaptic_c.h +++ b/src/haptic/windows/SDL_xinputhaptic_c.h @@ -23,6 +23,10 @@ #include "SDL_haptic.h" #include "SDL_windowshaptic_c.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif extern int SDL_XINPUT_HapticInit(void); extern int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid); @@ -44,4 +48,9 @@ extern int SDL_XINPUT_HapticPause(SDL_Haptic * haptic); extern int SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic); extern int SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_joystick_c.h b/src/joystick/SDL_joystick_c.h index a52167dbb..0e50758ae 100644 --- a/src/joystick/SDL_joystick_c.h +++ b/src/joystick/SDL_joystick_c.h @@ -28,6 +28,11 @@ #include "SDL_gamecontroller.h" #include "SDL_joystick.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + struct _SDL_JoystickDriver; /* Initialization and shutdown functions */ @@ -187,6 +192,11 @@ typedef struct _SDL_GamepadMapping extern SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *out); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* SDL_joystick_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index 4215f4a51..d5c8c0e21 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -27,6 +27,11 @@ #include "SDL_joystick.h" #include "SDL_joystick_c.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + /* The SDL joystick structure */ typedef struct _SDL_JoystickAxisInfo { @@ -230,6 +235,11 @@ extern SDL_JoystickDriver SDL_PS2_JoystickDriver; extern SDL_JoystickDriver SDL_PSP_JoystickDriver; extern SDL_JoystickDriver SDL_VITA_JoystickDriver; +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* SDL_sysjoystick_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/windows/SDL_dinputjoystick_c.h b/src/joystick/windows/SDL_dinputjoystick_c.h index d0e583465..229569ec1 100644 --- a/src/joystick/windows/SDL_dinputjoystick_c.h +++ b/src/joystick/windows/SDL_dinputjoystick_c.h @@ -20,6 +20,11 @@ */ #include "../../SDL_internal.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + extern int SDL_DINPUT_JoystickInit(void); extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext); extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); @@ -30,4 +35,9 @@ extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick); extern void SDL_DINPUT_JoystickClose(SDL_Joystick * joystick); extern void SDL_DINPUT_JoystickQuit(void); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 463afd7e5..0b42ed6ee 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -41,7 +41,7 @@ #include "../SDL_sysjoystick.h" #include "../../thread/SDL_systhread.h" #include "../../core/windows/SDL_windows.h" -#if !defined(__WINRT__) +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include #endif @@ -63,6 +63,11 @@ #define CR_SUCCESS (0x00000000) +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_HANDLE(HCMNOTIFICATION); typedef HCMNOTIFICATION* PHCMNOTIFICATION; @@ -141,7 +146,7 @@ static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB, JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */ -#ifndef __WINRT__ +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static HMODULE cfgmgr32_lib_handle; static CM_Register_NotificationFunc CM_Register_Notification; static CM_Unregister_NotificationFunc CM_Unregister_Notification; @@ -327,7 +332,14 @@ SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex return (lastret != -1) ? SDL_TRUE : SDL_FALSE; } +#endif /* !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ + + +#if !defined(__WINRT__) + +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static SDL_DeviceNotificationData s_notification_data; +#endif /* Function/thread to scan the system for joysticks. */ static int SDLCALL @@ -338,13 +350,19 @@ SDL_JoystickThread(void *_data) SDL_zeroa(bOpenedXInputDevices); #endif +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (SDL_CreateDeviceNotification(&s_notification_data) < 0) { return -1; } +#endif SDL_LockMutex(s_mutexJoyStickEnum); while (s_bJoystickThreadQuit == SDL_FALSE) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (SDL_WaitForDeviceNotification(&s_notification_data, s_mutexJoyStickEnum) == SDL_FALSE) { +#else + { +#endif #if SDL_JOYSTICK_XINPUT /* WM_DEVICECHANGE not working, poll for new XINPUT controllers */ SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000); @@ -354,7 +372,7 @@ SDL_JoystickThread(void *_data) for (userId = 0; userId < XUSER_MAX_COUNT; userId++) { XINPUT_CAPABILITIES capabilities; const DWORD result = XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities); - const SDL_bool available = (result == ERROR_SUCCESS); + const SDL_bool available = (result == ERROR_SUCCESS) ? SDL_TRUE : SDL_FALSE; if (bOpenedXInputDevices[userId] != available) { s_bWindowsDeviceChanged = SDL_TRUE; bOpenedXInputDevices[userId] = available; @@ -367,9 +385,12 @@ SDL_JoystickThread(void *_data) #endif /* SDL_JOYSTICK_XINPUT */ } } + SDL_UnlockMutex(s_mutexJoyStickEnum); +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_CleanupDeviceNotification(&s_notification_data); +#endif return 1; } @@ -419,7 +440,7 @@ SDL_StopJoystickThread(void) s_joystickThread = NULL; } -#endif /* !__WINRT__ */ +#endif /* !defined(__WINRT__) */ void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device) { @@ -453,7 +474,7 @@ WINDOWS_JoystickInit(void) WINDOWS_JoystickDetect(); -#ifndef __WINRT__ +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_CreateDeviceNotificationFunc(); s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, SDL_FALSE); @@ -467,6 +488,14 @@ WINDOWS_JoystickInit(void) } } #endif + +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + /* On Xbox, force create the joystick thread for device detection (since other methods don't work */ + s_bJoystickThread = SDL_TRUE; + if (SDL_StartJoystickThread() < 0) { + return -1; + } +#endif return 0; } @@ -738,7 +767,7 @@ WINDOWS_JoystickQuit(void) } SYS_Joystick = NULL; -#ifndef __WINRT__ +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (s_bJoystickThread) { SDL_StopJoystickThread(); } else { @@ -748,6 +777,12 @@ WINDOWS_JoystickQuit(void) SDL_CleanupDeviceNotificationFunc(); #endif +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + if (s_bJoystickThread) { + SDL_StopJoystickThread(); + } +#endif + SDL_DINPUT_JoystickQuit(); SDL_XINPUT_JoystickQuit(); @@ -784,6 +819,11 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = WINDOWS_JoystickGetGamepadMapping }; +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #else #if SDL_JOYSTICK_RAWINPUT diff --git a/src/joystick/windows/SDL_windowsjoystick_c.h b/src/joystick/windows/SDL_windowsjoystick_c.h index d7e09abde..00e1cf101 100644 --- a/src/joystick/windows/SDL_windowsjoystick_c.h +++ b/src/joystick/windows/SDL_windowsjoystick_c.h @@ -27,6 +27,11 @@ #define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + typedef struct JoyStick_DeviceData { SDL_JoystickGUID guid; @@ -91,4 +96,9 @@ extern const DIDATAFORMAT SDL_c_dfDIJoystick2; extern void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 439957399..dcf2940ff 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -31,6 +31,11 @@ #include "SDL_rawinputjoystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Internal stuff. */ @@ -45,6 +50,8 @@ SDL_XInputUseOldJoystickMapping() /* TODO: remove this __WINRT__ block, but only after integrating with UWP/WinRT's HID API */ /* FIXME: Why are Win8/10 different here? -flibit */ return (NTDDI_VERSION < NTDDI_WIN10); +#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) + return SDL_FALSE; #else static int s_XInputUseOldJoystickMapping = -1; if (s_XInputUseOldJoystickMapping < 0) { @@ -126,7 +133,7 @@ GetXInputName(const Uint8 userid, BYTE SubType) static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) { -#ifndef __WINRT__ /* TODO: remove this ifndef __WINRT__ block, but only after integrating with UWP/WinRT's HID API */ +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* TODO: remove this ifndef __WINRT__ block, but only after integrating with UWP/WinRT's HID API */ PRAWINPUTDEVICELIST devices = NULL; UINT i, j, device_count = 0; @@ -386,7 +393,7 @@ SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde return SDL_SetError("Failed to obtain XInput device capabilities. Device disconnected?"); } SDL_zero(state); - joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS); + joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS) ? SDL_TRUE : SDL_FALSE; joystick->hwdata->userid = userId; /* The XInput API has a hard coded button/axis mapping, so we just match it */ @@ -541,6 +548,10 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) result = XINPUTGETBATTERYINFORMATION(joystick->hwdata->userid, BATTERY_DEVTYPE_GAMEPAD, &XBatteryInformation); } +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + /* XInputOnGameInput doesn't ever change dwPacketNumber, so have to just update every frame */ + UpdateXInputJoystickState(joystick, &XInputState, &XBatteryInformation); +#else /* only fire events if the data changed from last time */ if (XInputState.dwPacketNumber && XInputState.dwPacketNumber != joystick->hwdata->dwPacketNumber) { if (SDL_XInputUseOldJoystickMapping()) { @@ -550,6 +561,7 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) } joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber; } +#endif } void @@ -565,6 +577,11 @@ SDL_XINPUT_JoystickQuit(void) } } +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #else /* !SDL_JOYSTICK_XINPUT */ typedef struct JoyStick_DeviceData JoyStick_DeviceData; diff --git a/src/joystick/windows/SDL_xinputjoystick_c.h b/src/joystick/windows/SDL_xinputjoystick_c.h index c0a0600d7..1a8bfdcfe 100644 --- a/src/joystick/windows/SDL_xinputjoystick_c.h +++ b/src/joystick/windows/SDL_xinputjoystick_c.h @@ -22,6 +22,11 @@ #include "../../core/windows/SDL_xinput.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + extern SDL_bool SDL_XINPUT_Enabled(void); extern int SDL_XINPUT_JoystickInit(void); extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext); @@ -32,4 +37,9 @@ extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick); extern void SDL_XINPUT_JoystickClose(SDL_Joystick * joystick); extern void SDL_XINPUT_JoystickQuit(void); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/misc/windows/SDL_sysurl.c b/src/misc/windows/SDL_sysurl.c index 12903db8f..6cfe7de60 100644 --- a/src/misc/windows/SDL_sysurl.c +++ b/src/misc/windows/SDL_sysurl.c @@ -24,6 +24,14 @@ #include +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +int +SDL_SYS_OpenURL(const char *url) +{ + /* Not supported */ + return SDL_Unsupported(); +} +#else /* https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx */ int SDL_SYS_OpenURL(const char *url) @@ -49,6 +57,7 @@ SDL_SYS_OpenURL(const char *url) WIN_CoUninitialize(); return (rc > ((HINSTANCE) 32)) ? 0 : WIN_SetError("Couldn't open given URL."); } +#endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 9642b40a8..924466cc5 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -38,10 +38,17 @@ #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#include "SDL_render_d3d12_xbox.h" +#ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT +#define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT 256 +#endif +#else #include #include #include #include +#endif #include "SDL_shaders_d3d12.h" @@ -153,14 +160,18 @@ typedef struct { void *hDXGIMod; void *hD3D12Mod; +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + UINT64 frameToken; +#else IDXGIFactory6 *dxgiFactory; IDXGIAdapter4 *dxgiAdapter; + IDXGIDebug *dxgiDebug; + IDXGISwapChain4 *swapChain; +#endif ID3D12Device1 *d3dDevice; ID3D12Debug *debugInterface; - IDXGIDebug *dxgiDebug; ID3D12CommandQueue *commandQueue; ID3D12GraphicsCommandList2 *commandList; - IDXGISwapChain4 *swapChain; DXGI_SWAP_EFFECT swapEffect; /* Descriptor heaps */ @@ -231,7 +242,7 @@ typedef struct static const GUID SDL_IID_IDXGIFactory6 = { 0xc1b6694f, 0xff09, 0x44a9, { 0xb0, 0x3c, 0x77, 0x90, 0x0a, 0x0a, 0x1d, 0x17 } }; static const GUID SDL_IID_IDXGIAdapter4 = { 0x3c8d99d1, 0x4fbf, 0x4181, { 0xa8, 0x2c, 0xaf, 0x66, 0xbf, 0x7b, 0xd2, 0x4e } }; static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; -static const GUID SDL_IID_ID3D12Device5 = { 0x8b4f173b, 0x2fea, 0x4b80, { 0x8f, 0x58, 0x43, 0x07, 0x19, 0x1a, 0xb9, 0x5d } }; +static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e } }; static const GUID SDL_IID_IDXGISwapChain4 = { 0x3D585D5A, 0xBD4A, 0x489E, { 0xB1, 0xF4, 0x3D, 0xBC, 0xB6, 0x45, 0x2F, 0xFB } }; static const GUID SDL_IID_IDXGIDebug1 = { 0xc5a05f0c, 0x16f2, 0x4adf, { 0x9f, 0x4d, 0xa8, 0xc4, 0xd5, 0x8a, 0xc5, 0x50 } }; static const GUID SDL_IID_IDXGIInfoQueue = { 0xD67441C7,0x672A,0x476f, { 0x9E,0x82,0xCD,0x55,0xB4,0x49,0x49,0xCE } }; @@ -307,8 +318,11 @@ D3D12_ReleaseAll(SDL_Renderer * renderer) if (data) { int i; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SAFE_RELEASE(data->dxgiFactory); SAFE_RELEASE(data->dxgiAdapter); + SAFE_RELEASE(data->swapChain); +#endif SAFE_RELEASE(data->d3dDevice); SAFE_RELEASE(data->debugInterface); SAFE_RELEASE(data->commandQueue); @@ -317,7 +331,6 @@ D3D12_ReleaseAll(SDL_Renderer * renderer) SAFE_RELEASE(data->textureRTVDescriptorHeap); SAFE_RELEASE(data->srvDescriptorHeap); SAFE_RELEASE(data->samplerDescriptorHeap); - SAFE_RELEASE(data->swapChain); SAFE_RELEASE(data->fence); for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { @@ -345,12 +358,14 @@ D3D12_ReleaseAll(SDL_Renderer * renderer) data->currentRenderTargetView.ptr = 0; data->currentSampler.ptr = 0; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Check for any leaks if in debug mode */ if (data->dxgiDebug) { DXGI_DEBUG_RLO_FLAGS rloFlags = (DXGI_DEBUG_RLO_FLAGS)(DXGI_DEBUG_RLO_SUMMARY | DXGI_DEBUG_RLO_IGNORE_INTERNAL); D3D_CALL(data->dxgiDebug, ReportLiveObjects, SDL_DXGI_DEBUG_ALL, rloFlags); SAFE_RELEASE(data->dxgiDebug); } +#endif /* Unload the D3D libraries. This should be done last, in order * to prevent IUnknown::Release() calls from crashing. @@ -700,10 +715,12 @@ D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, size_t size) static HRESULT D3D12_CreateDeviceResources(SDL_Renderer* renderer) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) typedef HRESULT(WINAPI* PFN_CREATE_DXGI_FACTORY)(UINT flags, REFIID riid, void** ppFactory); PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc; - D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata; PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc; +#endif + D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata; ID3D12Device* d3dDevice = NULL; HRESULT result = S_OK; UINT creationFlags = 0; @@ -728,6 +745,10 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) DXGI_FORMAT_R8_UNORM }; + /* See if we need debug interfaces */ + createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); + +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) data->hDXGIMod = SDL_LoadObject("dxgi.dll"); if (!data->hDXGIMod) { result = E_FAIL; @@ -752,9 +773,6 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) goto done; } - /* See if we need debug interfaces */ - createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); - if (createDebug) { PFN_D3D12_GET_DEBUG_INTERFACE D3D12GetDebugInterfaceFunc; @@ -766,7 +784,15 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) D3D12GetDebugInterfaceFunc(D3D_GUID(SDL_IID_ID3D12Debug), (void**)&data->debugInterface); D3D_CALL(data->debugInterface, EnableDebugLayer); } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + result = D3D12_XBOX_CreateDevice(&d3dDevice, createDebug); + if (FAILED(result)) { + /* SDL Error is set by D3D12_XBOX_CreateDevice */ + goto done; + } +#else if (createDebug) { #ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__ IDXGIInfoQueue *dxgiInfoQueue = NULL; @@ -818,7 +844,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) result = D3D12CreateDeviceFunc((IUnknown *)data->dxgiAdapter, D3D_FEATURE_LEVEL_11_0, /* Request minimum feature level 11.0 for maximum compatibility */ - D3D_GUID(SDL_IID_ID3D12Device5), + D3D_GUID(SDL_IID_ID3D12Device1), (void **)&d3dDevice ); if (FAILED(result)) { @@ -848,10 +874,11 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer) SAFE_RELEASE(infoQueue); } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ - result = D3D_CALL(d3dDevice, QueryInterface, D3D_GUID(SDL_IID_ID3D12Device5), (void **)&data->d3dDevice); + result = D3D_CALL(d3dDevice, QueryInterface, D3D_GUID(SDL_IID_ID3D12Device1), (void **)&data->d3dDevice); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device to ID3D12Device5"), result); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device to ID3D12Device1"), result); goto done; } @@ -1120,6 +1147,7 @@ D3D12_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRec return 0; } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static HRESULT D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h) { @@ -1187,6 +1215,7 @@ done: SAFE_RELEASE(swapChain); return result; } +#endif static HRESULT D3D12_UpdateForWindowSizeChange(SDL_Renderer * renderer); @@ -1246,6 +1275,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) h = tmp; } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (data->swapChain) { /* If the swap chain already exists, resize it. */ result = D3D_CALL(data->swapChain, ResizeBuffers, @@ -1283,9 +1313,17 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) } } } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ /* Get each back buffer render target and create render target views */ for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + result = D3D12_XBOX_CreateBackBufferTarget(data->d3dDevice, renderer->window->w, renderer->window->h, (void **) &data->renderTargets[i]); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12_XBOX_CreateBackBufferTarget"), result); + goto done; + } +#else result = D3D_CALL(data->swapChain, GetBuffer, i, D3D_GUID(SDL_IID_ID3D12Resource), @@ -1295,6 +1333,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::GetBuffer"), result); goto done; } +#endif SDL_zero(rtvDesc); rtvDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; @@ -1307,7 +1346,11 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) } /* Set back buffer index to current buffer */ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + data->currentBackBufferIndex = 0; +#else data->currentBackBufferIndex = D3D_CALL(data->swapChain, GetCurrentBackBufferIndex); +#endif /* Set the swap chain target immediately, so that a target is always set * even before we get to SetDrawState. Without this it's possible to hit @@ -1323,6 +1366,10 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) data->viewportDirty = SDL_TRUE; +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken); +#endif + done: return result; } @@ -2870,8 +2917,10 @@ static void D3D12_RenderPresent(SDL_Renderer * renderer) { D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) UINT syncInterval; UINT presentFlags; +#endif HRESULT result; /* Transition the render target to present state */ @@ -2885,6 +2934,9 @@ D3D12_RenderPresent(SDL_Renderer * renderer) result = D3D_CALL(data->commandList, Close); D3D_CALL(data->commandQueue, ExecuteCommandLists, 1, (ID3D12CommandList * const *)&data->commandList); +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + result = D3D12_XBOX_PresentFrame(data->commandQueue, data->frameToken, data->renderTargets[data->currentBackBufferIndex]); +#else if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { syncInterval = 1; presentFlags = 0; @@ -2897,6 +2949,7 @@ D3D12_RenderPresent(SDL_Renderer * renderer) * rects to improve efficiency in certain scenarios. */ result = D3D_CALL(data->swapChain, Present, syncInterval, presentFlags); +#endif if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { /* If the device was removed either by a disconnect or a driver upgrade, we @@ -2923,7 +2976,12 @@ D3D12_RenderPresent(SDL_Renderer * renderer) } data->fenceValue++; +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + data->currentBackBufferIndex++; + data->currentBackBufferIndex %= SDL_D3D12_NUM_BUFFERS; +#else data->currentBackBufferIndex = D3D_CALL(data->swapChain, GetCurrentBackBufferIndex); +#endif /* Reset the command allocator and command list, and transition back to render target */ D3D12_ResetCommandList(data); @@ -2932,6 +2990,10 @@ D3D12_RenderPresent(SDL_Renderer * renderer) D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET ); + +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken); +#endif } } diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp new file mode 100644 index 000000000..db71ebca2 --- /dev/null +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2022 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && (defined(__XBOXONE__) || defined(__XBOXSERIES__)) +#include "SDL_render_d3d12_xbox.h" + +#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." +#endif diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.h b/src/render/direct3d12/SDL_render_d3d12_xbox.h new file mode 100644 index 000000000..7afec9e48 --- /dev/null +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.h @@ -0,0 +1,22 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2022 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." diff --git a/src/render/direct3d12/SDL_shaders_d3d12.c b/src/render/direct3d12/SDL_shaders_d3d12.c index 85e4c55d3..2bb56d5d5 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12.c +++ b/src/render/direct3d12/SDL_shaders_d3d12.c @@ -20,11 +20,10 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_stdinc.h" -#define COBJMACROS #include "../../core/windows/SDL_windows.h" #include @@ -59,11 +58,6 @@ xxd --include */ -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP -#define D3D12_USE_SHADER_MODEL_4_0_level_9_3 -#else -#define D3D12_USE_SHADER_MODEL_4_0_level_9_1 -#endif /* The color-only-rendering pixel shader: @@ -6962,6 +6956,6 @@ void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECO outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp b/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp new file mode 100644 index 000000000..8af238ebf --- /dev/null +++ b/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2022 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) + +#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." + +#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp b/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp new file mode 100644 index 000000000..768ff6bec --- /dev/null +++ b/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2022 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) + +#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." + +#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index 72410b452..980120bc4 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -487,7 +487,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K #endif /* WIN32 */ #ifdef WIN32 +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #define HAVE_MMAP 1 #define HAVE_MORECORE 0 diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 93a0e7c74..44013f67a 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1196,7 +1196,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) } } -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Print the D3D9 adapter index */ adapterIndex = SDL_Direct3D9GetAdapterIndex( i ); SDL_Log("D3D9 Adapter Index: %d", adapterIndex); diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index fd4492c9b..ab6872c02 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -28,6 +28,11 @@ #include "SDL_thread.h" #include "SDL_thread_c.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + /* This function creates a thread, passing args to SDL_RunThread(), saves a system-dependent thread id in thread->id, and returns 0 on success. @@ -65,6 +70,11 @@ extern SDL_Thread * SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name, const size_t stacksize, void *data); +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* SDL_systhread_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 7972db131..52dea837f 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -41,7 +41,7 @@ static LARGE_INTEGER ticks_per_second; static void SDL_SetSystemTimerResolution(const UINT uPeriod) { -#ifndef __WINRT__ +#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static UINT timer_period = 0; if (uPeriod != timer_period) { diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 24fb48103..cda765588 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -4390,7 +4390,7 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) retval = 0; } #endif -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (retval == -1 && SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) && WIN_ShowMessageBox(messageboxdata, buttonid) == 0) { diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 09f33e25b..e961a2be4 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 57c72afdf..ac331273e 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -265,6 +265,7 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) return code; } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static SDL_bool WIN_ShouldIgnoreFocusClick() { @@ -460,6 +461,7 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) data->in_window_deactivation = SDL_FALSE; } } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ static BOOL WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) @@ -502,6 +504,7 @@ ShouldGenerateWindowCloseOnAltF4(void) return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE); } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* We want to generate mouse events from mouse and pen, and touch events from touchscreens */ #define MI_WP_SIGNATURE 0xFF515700 #define MI_WP_SIGNATURE_MASK 0xFFFFFF00 @@ -532,6 +535,7 @@ static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource() } return SDL_MOUSE_EVENT_SOURCE_MOUSE; } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ static SDL_WindowData * WIN_GetWindowDataFromHWND(HWND hwnd) @@ -550,6 +554,7 @@ WIN_GetWindowDataFromHWND(HWND hwnd) return NULL; } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) { @@ -635,6 +640,7 @@ static void WIN_CheckICMProfileChanged(SDL_Window* window) } } } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -657,10 +663,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Get the window data for the window */ data = WIN_GetWindowDataFromHWND(hwnd); +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (!data) { /* Fallback */ data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData")); } +#endif if (!data) { return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); } @@ -677,8 +685,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } #endif /* WMMSG_DEBUG */ +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata)) return 0; +#endif switch (msg) { @@ -692,6 +702,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } break; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) case WM_NCACTIVATE: { /* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */ @@ -941,6 +952,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ case WM_KEYDOWN: case WM_SYSKEYDOWN: @@ -1022,6 +1034,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #ifdef WM_INPUTLANGCHANGE case WM_INPUTLANGCHANGE: { @@ -1621,6 +1634,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } break; +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } /* If there's a window proc, assume it's going to handle messages */ @@ -1633,6 +1647,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static void WIN_UpdateClipCursorForWindows() { SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -1679,6 +1694,7 @@ static void WIN_UpdateMouseCapture() } } } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ /* A message hook called before TranslateMessage() */ static SDL_WindowsMessageHook g_WindowsMessageHook = NULL; @@ -1736,11 +1752,13 @@ WIN_SendWakeupEvent(_THIS, SDL_Window *window) void WIN_PumpEvents(_THIS) { - const Uint8 *keystate; MSG msg; DWORD end_ticks = GetTickCount() + 1; int new_messages = 0; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + const Uint8 *keystate; SDL_Window *focusWindow; +#endif if (g_WindowsEnableMessageLoop) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { @@ -1748,6 +1766,7 @@ WIN_PumpEvents(_THIS) g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam); } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Don't dispatch any mouse motion queued prior to or including the last mouse warp */ if (msg.message == WM_MOUSEMOVE && SDL_last_warp_time) { if (!SDL_TICKS_PASSED(msg.time, (SDL_last_warp_time + 1))) { @@ -1757,6 +1776,7 @@ WIN_PumpEvents(_THIS) /* This mouse message happened after the warp */ SDL_last_warp_time = 0; } +#endif !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */ TranslateMessage(&msg); @@ -1777,6 +1797,7 @@ WIN_PumpEvents(_THIS) } } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Windows loses a shift KEYUP event when you have both pressed at once and let go of one. You won't get a KEYUP until both are released, and that keyup will only be for the second key you released. Take heroic measures and check the keystate as of the last handled event, @@ -1807,6 +1828,7 @@ WIN_PumpEvents(_THIS) /* Update mouse capture */ WIN_UpdateMouseCapture(); +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ #ifdef __GDK__ GDK_DispatchTaskQueue(); @@ -1821,8 +1843,10 @@ HINSTANCE SDL_Instance = NULL; static void WIN_CleanRegisterApp(WNDCLASSEX wcex) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (wcex.hIcon) DestroyIcon(wcex.hIcon); if (wcex.hIconSm) DestroyIcon(wcex.hIconSm); +#endif SDL_free(SDL_Appname); SDL_Appname = NULL; } @@ -1831,9 +1855,11 @@ static void WIN_CleanRegisterApp(WNDCLASSEX wcex) int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { - const char *hint; WNDCLASSEX wcex; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + const char *hint; TCHAR path[MAX_PATH]; +#endif /* Only do this once... */ if (app_registered) { @@ -1865,6 +1891,7 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst) wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) hint = SDL_GetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON); if (hint && *hint) { wcex.hIcon = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); @@ -1878,6 +1905,7 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst) GetModuleFileName(SDL_Instance, path, MAX_PATH); ExtractIconEx(path, 0, &wcex.hIcon, &wcex.hIconSm, 1); } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ if (!RegisterClassEx(&wcex)) { WIN_CleanRegisterApp(wcex); @@ -1904,9 +1932,11 @@ SDL_UnregisterApp() wcex.hIcon = NULL; wcex.hIconSm = NULL; /* Check for any registered window classes. */ +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (GetClassInfoEx(SDL_Instance, SDL_Appname, &wcex)) { UnregisterClass(SDL_Appname, SDL_Instance); } +#endif WIN_CleanRegisterApp(wcex); } } diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index f41f9c09c..4076e6f52 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index f2deadc7b..e447a4a52 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "SDL_hints.h" diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 812f4536f..f30428186 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #ifdef HAVE_LIMITS_H #include diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 8fe46dee3..e56581f73 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "../../events/SDL_displayevents_c.h" diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index b13b75faf..a52c44079 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index a35d9728d..549b01bb1 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_loadso.h" #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index 493f1aff3..ff4c59418 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "SDL_windowsopengles.h" diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 7af545d94..ef716a506 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsshape.h" #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 32e21fb1f..6114808f4 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -65,6 +65,7 @@ UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const } } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) static void WIN_SuspendScreenSaver(_THIS) { if (_this->suspend_screensaver) { @@ -73,6 +74,11 @@ static void WIN_SuspendScreenSaver(_THIS) SetThreadExecutionState(ES_CONTINUOUS); } } +#endif + +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); +#endif /* Windows driver bootstrap functions */ @@ -83,12 +89,14 @@ WIN_DeleteDevice(SDL_VideoDevice * device) SDL_VideoData *data = (SDL_VideoData *) device->driverdata; SDL_UnregisterApp(); +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (data->userDLL) { SDL_UnloadObject(data->userDLL); } if (data->shcoreDLL) { SDL_UnloadObject(data->shcoreDLL); } +#endif if (device->wakeup_lock) { SDL_DestroyMutex(device->wakeup_lock); } @@ -119,6 +127,7 @@ WIN_CreateDevice(int devindex) device->driverdata = data; device->wakeup_lock = SDL_CreateMutex(); +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) data->userDLL = SDL_LoadObject("USER32.DLL"); if (data->userDLL) { data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT)) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); @@ -145,19 +154,24 @@ WIN_CreateDevice(int devindex) } else { SDL_ClearError(); } +#endif /* #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ /* Set the function pointers */ device->VideoInit = WIN_VideoInit; device->VideoQuit = WIN_VideoQuit; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) device->GetDisplayBounds = WIN_GetDisplayBounds; device->GetDisplayUsableBounds = WIN_GetDisplayUsableBounds; device->GetDisplayDPI = WIN_GetDisplayDPI; device->GetDisplayModes = WIN_GetDisplayModes; device->SetDisplayMode = WIN_SetDisplayMode; +#endif device->PumpEvents = WIN_PumpEvents; device->WaitEventTimeout = WIN_WaitEventTimeout; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) device->SendWakeupEvent = WIN_SendWakeupEvent; device->SuspendScreenSaver = WIN_SuspendScreenSaver; +#endif device->CreateSDLWindow = WIN_CreateWindow; device->CreateSDLWindowFrom = WIN_CreateWindowFrom; @@ -177,14 +191,17 @@ WIN_CreateDevice(int devindex) device->SetWindowResizable = WIN_SetWindowResizable; device->SetWindowAlwaysOnTop = WIN_SetWindowAlwaysOnTop; device->SetWindowFullscreen = WIN_SetWindowFullscreen; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) device->SetWindowGammaRamp = WIN_SetWindowGammaRamp; device->GetWindowICCProfile = WIN_GetWindowICCProfile; device->GetWindowGammaRamp = WIN_GetWindowGammaRamp; device->SetWindowMouseRect = WIN_SetWindowMouseRect; device->SetWindowMouseGrab = WIN_SetWindowMouseGrab; device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab; +#endif device->DestroyWindow = WIN_DestroyWindow; device->GetWindowWMInfo = WIN_GetWindowWMInfo; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer; @@ -196,6 +213,7 @@ WIN_CreateDevice(int devindex) device->shape_driver.CreateShaper = Win32_CreateShaper; device->shape_driver.SetWindowShape = Win32_SetWindowShape; device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; +#endif #if SDL_VIDEO_OPENGL_WGL device->GL_LoadLibrary = WIN_GL_LoadLibrary; @@ -229,6 +247,7 @@ WIN_CreateDevice(int devindex) device->Vulkan_GetDrawableSize = WIN_GL_GetDrawableSize; #endif +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) device->StartTextInput = WIN_StartTextInput; device->StopTextInput = WIN_StopTextInput; device->SetTextInputRect = WIN_SetTextInputRect; @@ -238,6 +257,7 @@ WIN_CreateDevice(int devindex) device->SetClipboardText = WIN_SetClipboardText; device->GetClipboardText = WIN_GetClipboardText; device->HasClipboardText = WIN_HasClipboardText; +#endif device->free = WIN_DeleteDevice; @@ -252,6 +272,7 @@ VideoBootStrap WINDOWS_bootstrap = { static BOOL WIN_DeclareDPIAwareUnaware(_THIS) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; if (data->SetProcessDpiAwarenessContext) { @@ -260,12 +281,14 @@ WIN_DeclareDPIAwareUnaware(_THIS) /* Windows 8.1 */ return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_DPI_UNAWARE)); } +#endif return FALSE; } static BOOL WIN_DeclareDPIAwareSystem(_THIS) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; if (data->SetProcessDpiAwarenessContext) { @@ -278,12 +301,14 @@ WIN_DeclareDPIAwareSystem(_THIS) /* Windows Vista */ return data->SetProcessDPIAware(); } +#endif return FALSE; } static BOOL WIN_DeclareDPIAwarePerMonitor(_THIS) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; if (data->SetProcessDpiAwarenessContext) { @@ -296,12 +321,16 @@ WIN_DeclareDPIAwarePerMonitor(_THIS) /* Older OS: fall back to system DPI aware */ return WIN_DeclareDPIAwareSystem(_this); } +#endif return FALSE; } static BOOL WIN_DeclareDPIAwarePerMonitorV2(_THIS) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + return FALSE; +#else SDL_VideoData* data = (SDL_VideoData*)_this->driverdata; /* Declare DPI aware (may have been done in external code or a manifest, as well) */ @@ -332,6 +361,7 @@ WIN_DeclareDPIAwarePerMonitorV2(_THIS) /* Older OS: fall back to per-monitor (or system) */ return WIN_DeclareDPIAwarePerMonitor(_this); } +#endif } #ifdef HIGHDPI_DEBUG @@ -402,17 +432,38 @@ WIN_VideoInit(_THIS) SDL_Log("DPI awareness: %s", WIN_GetDPIAwareness(_this)); #endif +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + /* For Xbox, we just need to create the single display */ + { + SDL_VideoDisplay display; + SDL_DisplayMode current_mode; + + SDL_zero(current_mode); + D3D12_XBOX_GetResolution(¤t_mode.w, ¤t_mode.h); + current_mode.refresh_rate = 60; + current_mode.format = SDL_PIXELFORMAT_ARGB8888; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + + SDL_AddVideoDisplay(&display, SDL_FALSE); + } +#else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ if (WIN_InitModes(_this) < 0) { return -1; } WIN_InitKeyboard(_this); WIN_InitMouse(_this); +#endif SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, UpdateWindowsEnableMessageLoop, NULL); SDL_AddHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL); +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) data->_SDL_WAKEUP = RegisterWindowMessageA("_SDL_WAKEUP"); +#endif return 0; } @@ -420,12 +471,15 @@ WIN_VideoInit(_THIS) void WIN_VideoQuit(_THIS) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) WIN_QuitModes(_this); WIN_QuitKeyboard(_this); WIN_QuitMouse(_this); +#endif } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #define D3D_DEBUG_INFO #include @@ -526,6 +580,7 @@ SDL_Direct3D9GetAdapterIndex(int displayIndex) return adapterIndex; } } +#endif /* !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ #if HAVE_DXGI_H #define CINTERFACE @@ -640,6 +695,7 @@ SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex) SDL_bool WIN_IsPerMonitorV2DPIAware(_THIS) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_VideoData* data = (SDL_VideoData*) _this->driverdata; if (data->AreDpiAwarenessContextsEqual && data->GetThreadDpiAwarenessContext) { @@ -647,6 +703,7 @@ WIN_IsPerMonitorV2DPIAware(_THIS) return (SDL_bool)data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, data->GetThreadDpiAwarenessContext()); } +#endif return SDL_FALSE; } diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index b477655c3..e07c34443 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -27,7 +27,7 @@ #include "../SDL_sysvideo.h" -#if defined(_MSC_VER) && (_MSC_VER >= 1500) +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include #else #include "SDL_msctf.h" @@ -41,11 +41,15 @@ #include "SDL_windowsclipboard.h" #include "SDL_windowsevents.h" + +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowskeyboard.h" #include "SDL_windowsmodes.h" #include "SDL_windowsmouse.h" #include "SDL_windowsopengl.h" #include "SDL_windowsopengles.h" +#endif + #include "SDL_windowswindow.h" #include "SDL_events.h" #include "SDL_loadso.h" @@ -330,6 +334,7 @@ typedef struct void *data; } TSFSink; +#ifndef SDL_DISABLE_WINDOWS_IME /* Definition from Win98DDK version of IMM.H */ typedef struct tagINPUTCONTEXT2 { HWND hWnd; @@ -353,6 +358,7 @@ typedef struct tagINPUTCONTEXT2 { DWORD fdwInit; DWORD dwReserve[3]; } INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2; +#endif /* !SDL_DISABLE_WINDOWS_IME */ /* Private display data */ @@ -362,6 +368,7 @@ typedef struct SDL_VideoData DWORD clipboard_count; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Xbox doesn't support user32/shcore*/ /* Touch input functions */ void* userDLL; BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); @@ -384,9 +391,11 @@ typedef struct SDL_VideoData UINT *dpiX, UINT *dpiY ); HRESULT (WINAPI *SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS dpiAwareness); +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ SDL_bool dpi_scaling_enabled; + #ifndef SDL_DISABLE_WINDOWS_IME SDL_bool ime_com_initialized; struct ITfThreadMgr *ime_threadmgr; SDL_bool ime_initialized; @@ -435,6 +444,7 @@ typedef struct SDL_VideoData TSFSink *ime_uielemsink; TSFSink *ime_ippasink; LONG ime_uicontext; +#endif /* !SDL_DISABLE_WINDOWS_IME */ BYTE pre_hook_key_state[256]; UINT _SDL_WAKEUP; diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 49cac8812..413c006e9 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -125,8 +125,10 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x { SDL_VideoData* videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->driverdata : NULL; RECT rect; - int dpi; + int dpi = 96; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) UINT frame_dpi; +#endif /* Client rect, in SDL screen coordinates */ *x = (use_current ? window->x : window->windowed.x); @@ -135,7 +137,9 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x *height = (use_current ? window->h : window->windowed.h); /* Convert client rect from SDL coordinates to pixels (no-op if DPI scaling not enabled) */ +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) WIN_ScreenPointFromSDL(x, y, &dpi); +#endif /* Note, use the guessed DPI returned from WIN_ScreenPointFromSDL rather than the cached one in data->scaling_dpi. @@ -158,6 +162,9 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x expanding the window client area to the previous window + chrome size, so shouldn't need to adjust the window size for the set styles. */ if (!(window->flags & SDL_WINDOW_BORDERLESS)) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + AdjustWindowRectEx(&rect, style, menu, 0); +#else if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. */ @@ -180,7 +187,8 @@ WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, frame_dpi); } else { AdjustWindowRectEx(&rect, style, menu, 0); - } + } +#endif } /* Final rect in Windows screen space, including the frame */ @@ -208,7 +216,11 @@ WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height BOOL menu; style = GetWindowLong(hwnd, GWL_STYLE); +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + menu = FALSE; +#else menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); +#endif WIN_AdjustWindowRectWithStyle(window, style, menu, x, y, width, height, use_current); } @@ -245,6 +257,9 @@ WIN_MouseRelativeModeCenterChanged(void *userdata, const char *name, const char static int WIN_GetScalingDPIForHWND(const SDL_VideoData *videodata, HWND hwnd) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + return 96; +#else /* DPI scaling not requested? */ if (!videodata->dpi_scaling_enabled) { return 96; @@ -277,6 +292,7 @@ WIN_GetScalingDPIForHWND(const SDL_VideoData *videodata, HWND hwnd) } return 96; } +#endif } static int @@ -293,7 +309,9 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre data->window = window; data->hwnd = hwnd; data->parent = parent; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) data->hdc = GetDC(hwnd); +#endif data->hinstance = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE); data->created = created; data->high_surrogate = 0; @@ -311,12 +329,14 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre window->driverdata = data; +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Associate the data with the window */ if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { ReleaseDC(hwnd, data->hdc); SDL_free(data); return WIN_SetError("SetProp() failed"); } +#endif /* Set up the window proc function */ #ifdef GWLP_WNDPROC @@ -357,6 +377,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre } } } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) { POINT point; point.x = 0; @@ -369,6 +390,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre window->y = y; } } +#endif { DWORD style = GetWindowLong(hwnd, GWL_STYLE); if (style & WS_VISIBLE) { @@ -403,16 +425,22 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre window->flags &= ~SDL_WINDOW_MINIMIZED; } } +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + window->flags |= SDL_WINDOW_INPUT_FOCUS; +#else if (GetFocus() == hwnd) { window->flags |= SDL_WINDOW_INPUT_FOCUS; SDL_SetKeyboardFocus(window); WIN_UpdateClipCursor(window); } +#endif +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Enable multi-touch */ if (videodata->RegisterTouchWindow) { videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM)); } +#endif /* Force the SDL_WINDOW_ALLOW_HIGHDPI window flag if we are doing DPI scaling */ if (videodata->dpi_scaling_enabled) { @@ -432,11 +460,13 @@ static void CleanupWindowData(_THIS, SDL_Window * window) if (data) { SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, WIN_MouseRelativeModeCenterChanged, data); +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (data->keyboard_hook) { UnhookWindowsHookEx(data->keyboard_hook); } ReleaseDC(data->hwnd, data->hdc); RemoveProp(data->hwnd, TEXT("SDL_WindowData")); +#endif if (data->created) { DestroyWindow(data->hwnd); if (data->parent) { @@ -538,6 +568,9 @@ WIN_CreateWindow(_THIS, SDL_Window * window) int WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + return -1; +#else HWND hwnd = (HWND) data; LPTSTR title; int titleLen; @@ -589,20 +622,24 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) } #endif return 0; +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } void WIN_SetWindowTitle(_THIS, SDL_Window * window) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; LPTSTR title = WIN_UTF8ToString(window->title); SetWindowText(hwnd, title); SDL_free(title); +#endif } void WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; HICON hicon = NULL; BYTE *icon_bmp; @@ -654,6 +691,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) /* Set the icon in the task manager (should we do this?) */ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) hicon); +#endif } void @@ -674,6 +712,21 @@ WIN_SetWindowSize(_THIS, SDL_Window * window) int WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + RECT rcClient; + + /* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left + * screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */ + GetClientRect(hwnd, &rcClient); + + *top = rcClient.top; + *left = rcClient.left; + *bottom = rcClient.bottom; + *right = rcClient.right; + + return 0; +#else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; RECT rcClient, rcWindow; POINT ptDiff; @@ -712,6 +765,7 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b *right = rcWindow.right - rcClient.right; return 0; +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } void @@ -740,6 +794,7 @@ WIN_HideWindow(_THIS, SDL_Window * window) void WIN_RaiseWindow(_THIS, SDL_Window * window) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* If desired, raise the window more forcefully. * Technique taken from http://stackoverflow.com/questions/916259/ . * Specifically, http://stackoverflow.com/a/34414846 . @@ -772,6 +827,7 @@ WIN_RaiseWindow(_THIS, SDL_Window * window) SetFocus(hwnd); SetActiveWindow(hwnd); } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } void @@ -850,6 +906,7 @@ WIN_RestoreWindow(_THIS, SDL_Window * window) void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; HWND hwnd = data->hwnd; @@ -932,8 +989,11 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, #ifdef HIGHDPI_DEBUG SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h); #endif + +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) { @@ -1063,6 +1123,7 @@ WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) WIN_UngrabKeyboard(window); } } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ void WIN_DestroyWindow(_THIS, SDL_Window * window) @@ -1165,6 +1226,7 @@ SDL_HelperWindowDestroy(void) } } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) void WIN_OnWindowEnter(_THIS, SDL_Window * window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; @@ -1277,10 +1339,14 @@ WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { return 0; /* just succeed, the real work is done elsewhere. */ } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ int WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) { +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) + return -1; +#else const SDL_WindowData *data = (SDL_WindowData *) window->driverdata; const HWND hwnd = data->hwnd; const LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); @@ -1309,6 +1375,7 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) } return 0; +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } /** @@ -1366,6 +1433,7 @@ WIN_ClientPointFromSDL(const SDL_Window *window, int *x, int *y) *y = MulDiv(*y, data->scaling_dpi, 96); } +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept) { @@ -1400,6 +1468,7 @@ WIN_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation) return 0; } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ #endif /* SDL_VIDEO_DRIVER_WINDOWS */ diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 6a5f25d72..8b3c1ff1d 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -25,6 +25,8 @@ #if SDL_VIDEO_OPENGL_EGL #include "../SDL_egl_c.h" +#else +#include "../SDL_sysvideo.h" #endif /* Set up for C function definitions, even when using C++ */