diff --git a/VisualC-GDK/SDL.sln b/VisualC-GDK/SDL.sln new file mode 100644 index 000000000..a52c78dc9 --- /dev/null +++ b/VisualC-GDK/SDL.sln @@ -0,0 +1,67 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32414.318 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D69D5741-611F-4E14-8541-1FEE94F50B5A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "SDL\SDL.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "SDLmain\SDLmain.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsprite2", "tests\testsprite2\testsprite2.vcxproj", "{40FB7794-D3C3-4CFE-BCF4-A80C96635682}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2test", "SDLtest\SDLtest.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgamecontroller", "tests\testgamecontroller\testgamecontroller.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08305}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgdk", "tests\testgdk\testgdk.vcxproj", "{1C9A3F71-35A5-4C56-B292-F4375B3C3649}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64 + Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.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}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.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}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.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}.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 + {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}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.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}.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 + {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}.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 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {40FB7794-D3C3-4CFE-BCF4-A80C96635682} = {D69D5741-611F-4E14-8541-1FEE94F50B5A} + {55812185-D13C-4022-9C81-32E0F4A08305} = {D69D5741-611F-4E14-8541-1FEE94F50B5A} + {1C9A3F71-35A5-4C56-B292-F4375B3C3649} = {D69D5741-611F-4E14-8541-1FEE94F50B5A} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C320C9F2-1A8F-41D7-B02B-6338F872BCAD} + EndGlobalSection +EndGlobal diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj new file mode 100644 index 000000000..ffcb9c01a --- /dev/null +++ b/VisualC-GDK/SDL/SDL.vcxproj @@ -0,0 +1,521 @@ + + + + + Debug + Gaming.Desktop.x64 + + + Release + Gaming.Desktop.x64 + + + + SDL2 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + SDL + 10.0 + + + + DynamicLibrary + $(DefaultPlatformToolset) + + + DynamicLibrary + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + _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;vcruntimed.lib;msvcrtd.lib;ucrtd.lib;msvcprtd.lib;%(AdditionalDependencies) + true + Windows + 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;vcruntime.lib;msvcrt.lib;ucrt.lib;msvcprt.lib;%(AdditionalDependencies) + true + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters new file mode 100644 index 000000000..8258e5a12 --- /dev/null +++ b/VisualC-GDK/SDL/SDL.vcxproj.filters @@ -0,0 +1,1358 @@ + + + + + {395b3af0-33d0-411b-b153-de1676bf1ef8} + + + {5a3e3167-75be-414f-8947-a5306df372b2} + + + {546d9ed1-988e-49d3-b1a5-e5b3d19de6c1} + + + {a56247ff-5108-4960-ba6a-6814fd1554ec} + + + {8880dfad-2a06-4e84-ab6e-6583641ad2d1} + + + {2b996a7f-f3e9-4300-a97f-2c907bcd89a9} + + + {5713d682-2bc7-4da4-bcf0-262a98f142eb} + + + {5e27e19f-b3f8-4e2d-b323-b00b2040ec86} + + + {a3ab9cff-8495-4a5c-8af6-27e43199a712} + + + {377061e4-3856-4f05-b916-0d3b360df0f6} + + + {226a6643-1c65-4c7f-92aa-861313d974bb} + + + {ef859522-a7fe-4a00-a511-d6a9896adf5b} + + + {01fd2642-4493-4316-b548-fb829f4c9125} + + + {cce7558f-590a-4f0a-ac0d-e579f76e588e} + + + {7a53c9e4-d4bd-40ed-9265-1625df685121} + + + {4c7a051c-ce7c-426c-bf8c-9187827f9052} + + + {97e2f79f-311b-42ea-81b2-e801649fdd93} + + + {baf97c8c-7e90-41e5-bff8-14051b8d3956} + + + {45e50d3a-56c9-4352-b811-0c60c49a2431} + + + {9d86e0ef-d6f6-4db2-bfc5-b3529406fa8d} + + + {b35fa13c-6ed2-4680-8c56-c7d71b76ceab} + + + {61b61b31-9e26-4171-a3bb-b969f1889726} + + + {f63aa216-6ee7-4143-90d3-32be3787f276} + + + {90bee923-89df-417f-a6c3-3e260a7dd54d} + + + {4c8ad943-c2fb-4014-9ca3-041e0ad08426} + + + {e90fa293-2828-4927-8113-35bf561024a9} + + + {3d68ae70-a9ff-46cf-be69-069f0b02aca0} + + + {ebc2fca3-3c26-45e3-815e-3e0581d5e226} + + + {47c445a2-7014-4e15-9660-7c89a27dddcf} + + + {d008487d-6ed0-4251-848b-79a68e3c1459} + + + {c9e8273e-13ae-47dc-bef8-8ad8e64c9a3d} + + + {0b8e136d-56ae-47e7-9981-e863a57ac616} + + + {bf3febd3-9328-43e8-b196-0fd3be8177dd} + + + {1a62dc68-52d2-4c07-9d81-d94dfe1d0d12} + + + {e9f01b22-34b3-4380-ade6-0e96c74e9c90} + + + {f674f22f-7841-4f3a-974e-c36b2d4823fc} + + + {d7ad92de-4e55-4202-9b2b-1bd9a35fe4dc} + + + {8311d79d-9ad5-4369-99fe-b2fb2659d402} + + + {6c4dfb80-fdf9-497c-a6ff-3cd8f22efde9} + + + {4810e35c-33cb-4da2-bfaf-452da20d3c9a} + + + {2cf93f1d-81fd-4bdc-998c-5e2fa43988bc} + + + {5752b7ab-2344-4f38-95ab-b5d3bc150315} + + + {7a0eae3d-f113-4914-b926-6816d1929250} + + + {ee602cbf-96a2-4b0b-92a9-51d38a727411} + + + {a812185b-9060-4a1c-8431-be4f66894626} + + + {31c16cdf-adc4-4950-8293-28ba530f3882} + + + {add61b53-8144-47d6-bd67-3420a87c4905} + + + {e7cdcf36-b462-49c7-98b7-07ea7b3687f4} + + + {82588eef-dcaa-4f69-b2a9-e675940ce54c} + + + {560239c3-8fa1-4d23-a81a-b8408b2f7d3f} + + + {81711059-7575-4ece-9e68-333b63e992c4} + + + {1e44970f-7535-4bfb-b8a5-ea0cea0349e0} + + + {1dd91224-1176-492b-a2cb-e26153394db0} + + + {e3ecfe50-cf22-41d3-8983-2fead5164b47} + + + {5521d22f-1e52-47a6-8c52-06a3b6bdefd7} + + + {4755f3a6-49ac-46d6-86be-21f5c21f2197} + + + {f48c2b17-1bee-4fec-a7c8-24cf619abe08} + + + {3ab60a46-e18e-450a-a916-328fb8547e59} + + + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + API Headers + + + + + + API Headers + + + API Headers + + + API Headers + + + audio + + + audio + + + audio + + + audio + + + core\windows + + + core\windows + + + core\windows + + + core\windows + + + dynapi + + + dynapi + + + dynapi + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + haptic + + + haptic + + + joystick + + + joystick + + + joystick + + + joystick + + + joystick + + + libm + + + libm + + + hidapi\hidapi + + + locale + + + misc + + + audio\directsound + + + audio\disk + + + audio\dummy + + + audio\winmm + + + audio\wasapi + + + haptic\windows + + + haptic\windows + + + haptic\windows + + + joystick\hidapi + + + joystick\hidapi + + + joystick\windows + + + joystick\windows + + + joystick\windows + + + joystick\windows + + + joystick\virtual + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video\dummy + + + video\dummy + + + video\dummy + + + video\yuv2rgb + + + video\yuv2rgb + + + video\yuv2rgb + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + timer + + + thread + + + thread + + + thread\windows + + + thread\windows + + + thread\generic + + + sensor + + + sensor + + + sensor\dummy + + + sensor\windows + + + render + + + render + + + render + + + render\direct3d + + + render\direct3d11 + + + render\opengl + + + render\opengl + + + render\opengles2 + + + render\opengles2 + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + power + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + video\khronos\vulkan + + + + + + + render\direct3d12 + + + + API Headers + + + core\gdk + + + + + + + + + + + + + audio + + + audio + + + audio + + + audio + + + audio + + + audio + + + atomic + + + atomic + + + core\windows + + + core\windows + + + core\windows + + + cpuinfo + + + dynapi + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + events + + + file + + + filesystem\windows + + + haptic + + + hidapi + + + joystick + + + joystick + + + joystick + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + libm + + + loadso\windows + + + misc + + + misc\windows + + + locale\windows + + + locale + + + audio\directsound + + + audio\disk + + + audio\dummy + + + audio\winmm + + + audio\wasapi + + + audio\wasapi + + + haptic\windows + + + haptic\windows + + + haptic\windows + + + haptic\dummy + + + joystick\dummy + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\hidapi + + + joystick\windows + + + joystick\windows + + + joystick\windows + + + joystick\windows + + + joystick\windows + + + joystick\virtual + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video + + + video\dummy + + + video\dummy + + + video\dummy + + + video\yuv2rgb + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + video\windows + + + timer + + + timer\windows + + + thread + + + thread\windows + + + thread\windows + + + thread\windows + + + thread\windows + + + thread\windows + + + thread\generic + + + stdlib + + + stdlib + + + stdlib + + + stdlib + + + stdlib + + + stdlib + + + stdlib + + + stdlib + + + sensor + + + sensor\dummy + + + sensor\windows + + + render + + + render + + + render + + + render\direct3d + + + render\direct3d + + + render\direct3d11 + + + render\direct3d11 + + + render\opengl + + + render\opengl + + + render\opengles2 + + + render\opengles2 + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + render\software + + + power + + + + power\windows + + + render\direct3d12 + + + render\direct3d12 + + + stdlib + + + stdlib + + + core\gdk + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/SDLmain/SDLmain.vcxproj b/VisualC-GDK/SDLmain/SDLmain.vcxproj new file mode 100644 index 000000000..1d27a6333 --- /dev/null +++ b/VisualC-GDK/SDLmain/SDLmain.vcxproj @@ -0,0 +1,87 @@ + + + + + Debug + Gaming.Desktop.x64 + + + Release + Gaming.Desktop.x64 + + + + + + + SDL2main + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + SDLmain + 10.0 + + + + StaticLibrary + $(DefaultPlatformToolset) + + + StaticLibrary + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/SDLtest/SDLtest.vcxproj b/VisualC-GDK/SDLtest/SDLtest.vcxproj new file mode 100644 index 000000000..1487ad7a2 --- /dev/null +++ b/VisualC-GDK/SDLtest/SDLtest.vcxproj @@ -0,0 +1,102 @@ + + + + + Debug + Gaming.Desktop.x64 + + + Release + Gaming.Desktop.x64 + + + + SDL2test + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + SDLtest + 10.0 + + + + StaticLibrary + $(DefaultPlatformToolset) + + + StaticLibrary + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + Disabled + $(ProjectDir)/../../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + false + Level3 + OldStyle + true + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/clean.sh b/VisualC-GDK/clean.sh new file mode 100644 index 000000000..a23f06b54 --- /dev/null +++ b/VisualC-GDK/clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh +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 {} \; diff --git a/VisualC-GDK/logos/Logo100x100.png b/VisualC-GDK/logos/Logo100x100.png new file mode 100644 index 000000000..2d0333dbd Binary files /dev/null and b/VisualC-GDK/logos/Logo100x100.png differ diff --git a/VisualC-GDK/logos/Logo150x150.png b/VisualC-GDK/logos/Logo150x150.png new file mode 100644 index 000000000..046a8fb14 Binary files /dev/null and b/VisualC-GDK/logos/Logo150x150.png differ diff --git a/VisualC-GDK/logos/Logo44x44.png b/VisualC-GDK/logos/Logo44x44.png new file mode 100644 index 000000000..3ca25b565 Binary files /dev/null and b/VisualC-GDK/logos/Logo44x44.png differ diff --git a/VisualC-GDK/logos/Logo480x480.png b/VisualC-GDK/logos/Logo480x480.png new file mode 100644 index 000000000..11231500e Binary files /dev/null and b/VisualC-GDK/logos/Logo480x480.png differ diff --git a/VisualC-GDK/tests/testgamecontroller/MicrosoftGame.config b/VisualC-GDK/tests/testgamecontroller/MicrosoftGame.config new file mode 100644 index 000000000..6a9ea2bf8 --- /dev/null +++ b/VisualC-GDK/tests/testgamecontroller/MicrosoftGame.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgamecontroller/PackageLayout.xml b/VisualC-GDK/tests/testgamecontroller/PackageLayout.xml new file mode 100644 index 000000000..cda188c7c --- /dev/null +++ b/VisualC-GDK/tests/testgamecontroller/PackageLayout.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj new file mode 100644 index 000000000..1d90d6688 --- /dev/null +++ b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Gaming.Desktop.x64 + + + Release + Gaming.Desktop.x64 + + + + {55812185-D13C-4022-9C81-32E0F4A08305} + testgamecontroller + 10.0 + + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testgamecontroller.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + 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;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies) + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} + false + false + true + + + {da956fd3-e142-46f2-9dd5-c78bebb56b7a} + false + false + true + + + + + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + + + + + + + Document + + + + + + + + + + + + + + Document + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters new file mode 100644 index 000000000..b9ffafc1b --- /dev/null +++ b/VisualC-GDK/tests/testgamecontroller/testgamecontroller.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + + + + + + + + + logos + + + logos + + + logos + + + logos + + + + + + + + {5e858cf0-6fba-498d-b33d-11c8ecbb79c7} + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgdk/MicrosoftGame.config b/VisualC-GDK/tests/testgdk/MicrosoftGame.config new file mode 100644 index 000000000..f1ab0338e --- /dev/null +++ b/VisualC-GDK/tests/testgdk/MicrosoftGame.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgdk/PackageLayout.xml b/VisualC-GDK/tests/testgdk/PackageLayout.xml new file mode 100644 index 000000000..f09b2e577 --- /dev/null +++ b/VisualC-GDK/tests/testgdk/PackageLayout.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp new file mode 100644 index 000000000..377d48315 --- /dev/null +++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp @@ -0,0 +1,398 @@ +/* + 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. +*/ +/* testgdk: Basic tests of using task queue/xbl (with simple drawing) in GDK. + * NOTE: As of June 2022 GDK, login will only work if MicrosoftGame.config is + * configured properly. See README-gdk.md. + */ + +#include +#include +#include + +#include "SDL_test.h" +#include "SDL_test_common.h" +#include "../src/core/windows/SDL_windows.h" + +extern "C" { +#include "../test/testutils.h" +} + +#include + +#define NUM_SPRITES 100 +#define MAX_SPEED 1 + +static SDLTest_CommonState *state; +static int num_sprites; +static SDL_Texture **sprites; +static SDL_bool cycle_color; +static SDL_bool cycle_alpha; +static int cycle_direction = 1; +static int current_alpha = 0; +static int current_color = 0; +static int sprite_w, sprite_h; +static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND; + +int done; + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + SDL_free(sprites); + 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. + */ + if (rc != 0) { + exit(rc); + } +} + +void +UserLoggedIn(XUserHandle user) +{ + HRESULT hr; + char gamertag[128]; + hr = XUserGetGamertag(user, XUserGamertagComponent::UniqueModern, sizeof(gamertag), gamertag, NULL); + + if (SUCCEEDED(hr)) { + SDL_Log("User logged in: %s", gamertag); + } else { + SDL_Log("[GDK] UserLoggedIn -- XUserGetGamertag failed: 0x%08x.", hr); + } + + XUserCloseHandle(user); +} + +void +AddUserUICallback(XAsyncBlock *asyncBlock) +{ + HRESULT hr; + XUserHandle user = NULL; + + hr = XUserAddResult(asyncBlock, &user); + if (SUCCEEDED(hr)) { + uint64_t userId; + + hr = XUserGetId(user, &userId); + if (FAILED(hr)) { + /* If unable to get the user ID, it means the account is banned, etc. */ + SDL_Log("[GDK] AddUserSilentCallback -- XUserGetId failed: 0x%08x.", hr); + XUserCloseHandle(user); + + /* Per the docs, likely should call XUserResolveIssueWithUiAsync here. */ + } else { + UserLoggedIn(user); + } + } else { + SDL_Log("[GDK] AddUserUICallback -- XUserAddAsync failed: 0x%08x.", hr); + } + + delete asyncBlock; +} + +void +AddUserUI() +{ + HRESULT hr; + XAsyncBlock *asyncBlock = new XAsyncBlock; + + asyncBlock->context = NULL; + asyncBlock->queue = NULL; /* A null queue will use the global process task queue */ + asyncBlock->callback = &AddUserUICallback; + + hr = XUserAddAsync(XUserAddOptions::None, asyncBlock); + + if (FAILED(hr)) { + delete asyncBlock; + SDL_Log("[GDK] AddUserSilent -- failed: 0x%08x", hr); + } +} + +void +AddUserSilentCallback(XAsyncBlock *asyncBlock) +{ + HRESULT hr; + XUserHandle user = NULL; + + hr = XUserAddResult(asyncBlock, &user); + if (SUCCEEDED(hr)) { + uint64_t userId; + + hr = XUserGetId(user, &userId); + if (FAILED(hr)) { + /* If unable to get the user ID, it means the account is banned, etc. */ + SDL_Log("[GDK] AddUserSilentCallback -- XUserGetId failed: 0x%08x. Trying with UI.", hr); + XUserCloseHandle(user); + AddUserUI(); + } else { + UserLoggedIn(user); + } + } else { + SDL_Log("[GDK] AddUserSilentCallback -- XUserAddAsync failed: 0x%08x. Trying with UI.", hr); + AddUserUI(); + } + + delete asyncBlock; +} + +void +AddUserSilent() +{ + HRESULT hr; + XAsyncBlock *asyncBlock = new XAsyncBlock; + + asyncBlock->context = NULL; + asyncBlock->queue = NULL; /* A null queue will use the global process task queue */ + asyncBlock->callback = &AddUserSilentCallback; + + hr = XUserAddAsync(XUserAddOptions::AddDefaultUserSilently, asyncBlock); + + if (FAILED(hr)) { + delete asyncBlock; + SDL_Log("[GDK] AddUserSilent -- failed: 0x%08x", hr); + } +} + +int +LoadSprite(const char *file) +{ + int i; + + for (i = 0; i < state->num_windows; ++i) { + /* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */ + sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h); + if (!sprites[i]) { + return (-1); + } + if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError()); + SDL_DestroyTexture(sprites[i]); + return (-1); + } + } + + /* We're ready to roll. :) */ + return (0); +} + +void +DrawSprites(SDL_Renderer * renderer, SDL_Texture * sprite) +{ + SDL_Rect viewport, temp; + + /* Query the sizes */ + SDL_RenderGetViewport(renderer, &viewport); + + /* Cycle the color and alpha, if desired */ + if (cycle_color) { + current_color += cycle_direction; + if (current_color < 0) { + current_color = 0; + cycle_direction = -cycle_direction; + } + if (current_color > 255) { + current_color = 255; + cycle_direction = -cycle_direction; + } + SDL_SetTextureColorMod(sprite, 255, (Uint8) current_color, + (Uint8) current_color); + } + if (cycle_alpha) { + current_alpha += cycle_direction; + if (current_alpha < 0) { + current_alpha = 0; + cycle_direction = -cycle_direction; + } + if (current_alpha > 255) { + current_alpha = 255; + cycle_direction = -cycle_direction; + } + SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha); + } + + /* Draw a gray background */ + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); + SDL_RenderClear(renderer); + + /* Test points */ + SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0x00, 0xFF); + SDL_RenderDrawPoint(renderer, 0, 0); + SDL_RenderDrawPoint(renderer, viewport.w-1, 0); + SDL_RenderDrawPoint(renderer, 0, viewport.h-1); + SDL_RenderDrawPoint(renderer, viewport.w-1, viewport.h-1); + + /* Test horizontal and vertical lines */ + SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF); + SDL_RenderDrawLine(renderer, 1, 0, viewport.w-2, 0); + SDL_RenderDrawLine(renderer, 1, viewport.h-1, viewport.w-2, viewport.h-1); + SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h-2); + SDL_RenderDrawLine(renderer, viewport.w-1, 1, viewport.w-1, viewport.h-2); + + /* Test fill and copy */ + SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); + temp.x = 1; + temp.y = 1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderFillRect(renderer, &temp); + SDL_RenderCopy(renderer, sprite, NULL, &temp); + temp.x = viewport.w-sprite_w-1; + temp.y = 1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderFillRect(renderer, &temp); + SDL_RenderCopy(renderer, sprite, NULL, &temp); + temp.x = 1; + temp.y = viewport.h-sprite_h-1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderFillRect(renderer, &temp); + SDL_RenderCopy(renderer, sprite, NULL, &temp); + temp.x = viewport.w-sprite_w-1; + temp.y = viewport.h-sprite_h-1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderFillRect(renderer, &temp); + SDL_RenderCopy(renderer, sprite, NULL, &temp); + + /* Test diagonal lines */ + SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF); + SDL_RenderDrawLine(renderer, sprite_w, sprite_h, + viewport.w-sprite_w-2, viewport.h-sprite_h-2); + SDL_RenderDrawLine(renderer, viewport.w-sprite_w-2, sprite_h, + sprite_w, viewport.h-sprite_h-2); + + /* Update the screen! */ + SDL_RenderPresent(renderer); +} + +void +loop() +{ + int i; + SDL_Event event; + + /* Check for events */ + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &done); + } + for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; + DrawSprites(state->renderers[i], sprites[i]); + } +} + +int +main(int argc, char *argv[]) +{ + int i; + const char *icon = "icon.bmp"; + + /* Initialize parameters */ + num_sprites = NUM_SPRITES; + + /* Initialize test framework */ + state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); + if (!state) { + return 1; + } + + for (i = 1; i < argc;) { + int consumed; + + consumed = SDLTest_CommonArg(state, i); + if (consumed == 0) { + consumed = -1; + if (SDL_strcasecmp(argv[i], "--blend") == 0) { + if (argv[i + 1]) { + if (SDL_strcasecmp(argv[i + 1], "none") == 0) { + blendMode = SDL_BLENDMODE_NONE; + consumed = 2; + } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { + blendMode = SDL_BLENDMODE_BLEND; + consumed = 2; + } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { + blendMode = SDL_BLENDMODE_ADD; + consumed = 2; + } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { + blendMode = SDL_BLENDMODE_MOD; + consumed = 2; + } else if (SDL_strcasecmp(argv[i + 1], "sub") == 0) { + blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); + consumed = 2; + } + } + } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { + cycle_color = SDL_TRUE; + consumed = 1; + } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) { + cycle_alpha = SDL_TRUE; + consumed = 1; + } else if (SDL_isdigit(*argv[i])) { + num_sprites = SDL_atoi(argv[i]); + consumed = 1; + } else if (argv[i][0] != '-') { + icon = argv[i]; + consumed = 1; + } + } + if (consumed < 0) { + static const char *options[] = { + "[--blend none|blend|add|mod]", + "[--cyclecolor]", + "[--cyclealpha]", + "[num_sprites]", + "[icon.bmp]", + NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); + quit(1); + } + i += consumed; + } + if (!SDLTest_CommonInit(state)) { + quit(2); + } + + /* Create the windows, initialize the renderers, and load the textures */ + sprites = + (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); + if (!sprites) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); + quit(2); + } + for (i = 0; i < state->num_windows; ++i) { + SDL_Renderer *renderer = state->renderers[i]; + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); + SDL_RenderClear(renderer); + } + if (LoadSprite(icon) < 0) { + quit(2); + } + + /* Main render loop */ + done = 0; + + /* Try to add the default user silently */ + AddUserSilent(); + + while (!done) { + loop(); + } + + quit(0); + return 0; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/VisualC-GDK/tests/testgdk/testgdk.vcxproj b/VisualC-GDK/tests/testgdk/testgdk.vcxproj new file mode 100644 index 000000000..bcb57363d --- /dev/null +++ b/VisualC-GDK/tests/testgdk/testgdk.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Gaming.Desktop.x64 + + + Release + Gaming.Desktop.x64 + + + + {1C9A3F71-35A5-4C56-B292-F4375B3C3649} + testsprite2 + 10.0 + + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testsprite2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;../Microsoft.Xbox.Services.141.GDK.C.Thunks.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;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies) + + + + + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} + false + false + true + + + {da956fd3-e142-46f2-9dd5-c78bebb56b7a} + false + false + true + + + {da956fd3-e143-46f2-9fe5-c77bebc56b1a} + false + false + true + + + + + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + + + + + + + Document + + + + + Document + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters b/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters new file mode 100644 index 000000000..4a143d855 --- /dev/null +++ b/VisualC-GDK/tests/testgdk/testgdk.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + + + + + + + logos + + + logos + + + logos + + + logos + + + + + + + {c3c871f2-c7b7-4025-8ba4-037dde717fe1} + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testsprite2/MicrosoftGame.config b/VisualC-GDK/tests/testsprite2/MicrosoftGame.config new file mode 100644 index 000000000..6b76188a5 --- /dev/null +++ b/VisualC-GDK/tests/testsprite2/MicrosoftGame.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + 7325F784 + 0000000000000000 + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testsprite2/PackageLayout.xml b/VisualC-GDK/tests/testsprite2/PackageLayout.xml new file mode 100644 index 000000000..62ca97bbe --- /dev/null +++ b/VisualC-GDK/tests/testsprite2/PackageLayout.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj new file mode 100644 index 000000000..1d1c8870d --- /dev/null +++ b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Gaming.Desktop.x64 + + + Release + Gaming.Desktop.x64 + + + + {40FB7794-D3C3-4CFE-BCF4-A80C96635682} + testsprite2 + 10.0 + + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/testsprite2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + xgameruntime.lib;../Microsoft.Xbox.Services.141.GDK.C.Thunks.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;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies) + + + + + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} + false + false + true + + + {da956fd3-e142-46f2-9dd5-c78bebb56b7a} + false + false + true + + + {da956fd3-e143-46f2-9fe5-c77bebc56b1a} + false + false + true + + + + + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy "%(FullPath)" "$(ProjectDir)\" +copy "%(FullPath)" "$(OutDir)\" + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + + + + + + + Document + + + + + Document + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters new file mode 100644 index 000000000..19672bfad --- /dev/null +++ b/VisualC-GDK/tests/testsprite2/testsprite2.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + + + + + + + logos + + + logos + + + logos + + + logos + + + + + + + {c3c871f2-c7b7-4025-8ba4-037dde717fe1} + + + \ No newline at end of file diff --git a/docs/README-gdk.md b/docs/README-gdk.md new file mode 100644 index 000000000..a59213e77 --- /dev/null +++ b/docs/README-gdk.md @@ -0,0 +1,154 @@ +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. + + +Requirements +------------ + +* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested) +* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022)) +* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work. + + +Windows GDK Status +------ + +The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL. + +* Additionally, the GDK port adds the following: + * Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.) + * GDK-specific setup: + * Initializing/uninitializing the game runtime, and initializing Xbox Live services + * Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue. + + * An implementation on `WinMain` that performs the above GDK setup (you should link against SDL2main.lib, as in Windows x64). If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. + * Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`). + * You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak). + +* What doesn't work: + * Compilation with anything other than through the included Visual C++ solution file + +## VisualC-GDK Solution + +The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration: + +* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64. +* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs. +* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality. +* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live. + *NOTE*: As of the June 2022 GDK, you cannot test user logins without a valid Title ID and MSAAppId. You will need to manually change the identifiers in the `MicrosoftGame.config` to your valid IDs from Partner Center if you wish to test this. +* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality. + +If you set one of the test programs as a startup project, you can run it directly from Visual Studio. + +Windows GDK Setup, Detailed Steps +--------------------- + +These steps assume you already have a game using SDL that runs on Windows x64 along with a corresponding Visual Studio solution file for the x64 version. If you don't have this, it's easiest to use one of the test program vcxproj files in the `VisualC-GDK` directory as a starting point, though you will still need to do most of the steps below. + +### 1. Add a Gaming.Desktop.x64 Configuration ### + +In your game's existing Visual Studio Solution, go to Build > Configuration Manager. From the "Active solution platform" drop-down select "New...". From the drop-down list, select Gaming.Desktop.x64 and copy the settings from the x64 configuration. + +### 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`, `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. + +### 3. Configuring Project Settings ### + +While the Gaming.Desktop.x64 configuration sets most of the required settings, there are some additional items to configure for your game project under the Gaming.Desktop.x64 Configuration: + +* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced +* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are +* Under Linker > Input > Additional Dependencies, you need the following: + * `SDL2.lib` + * `SDL2main.lib` (unless not using) + * `xgameruntime.lib` + * `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib` +* Note that in general, the GDK libraries depend on the MSVC C/C++ runtime, so there is no way to remove this dependency from a GDK program that links against GDK. + +### 4. Setting up SDL_main ### + +Rather than using your own implementation of `WinMain`, it's recommended that you instead `#include "SDL_main.h"` and declare a standard main function. If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. + +### 5. Required DLLs ### + +The game will not launch in the debugger unless required DLLs are included in the directory that contains the game's .exe file. You need to make sure that the following files are copied into the directory: + +* Your SDL2.dll +* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll" + +You can either copy these in a post-build step, or you can add the dlls into the project and set its Configuration Properties > General > Item type to "Copy file," which will also copy them into the output directory. + +### 6. Setting up MicrosoftGame.config ### + +You can copy `VisualC-GDK/tests/testgdk/MicrosoftGame.config` and use that as a starting point in your project. Minimally, you will want to change the Executable Name attribute, the DefaultDisplayName, and the Description. + +This file must be copied into the same directory as the game's .exe file. As with the DLLs, you can either use a post-build step or the "Copy file" item type. + +For basic testing, you do not need to change anything else in `MicrosoftGame.config`. However, if you want to test any Xbox Live services (such as logging in users) _or_ publish a package, you will need to setup a Game app on Partner Center. + +Then, you need to set the following values to the values from Partner Center: + +* Identity tag - Name and Publisher attributes +* TitleId +* MSAAppId + +### 7. Adding Required Logos + +Several logo PNG files are required to be able to launch the game, even from the debugger. You can use the sample logos provided in `VisualC-GDK/logos`. As with the other files, they must be copied into the same directory as the game's .exe file. + + +### 8. Copying any Data Files ### + +When debugging GDK games, there is no way to specify a working directory. Therefore, any required game data must also be copied into the output directory, likely in a post-build step. + + +### 9. Build and Run from Visual Studio ### + +At this point, you should be able to build and run your game from the Visual Studio Debugger. If you get any linker errors, make sure you double-check that you referenced all the required libs. + +If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this: + +1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu +2. Switch the sandbox name with: + `XblPCSandbox SANDBOX.#` +3. (To switch back to the retail sandbox): + `XblPCSandbox RETAIL` + +### 10. Packaging and Installing Locally + +You can use one of the test program's `PackageLayout.xml` as a starting point. Minimally, you will need to change the exe to the correct name and also reference any required game data. As with the other data files, it's easiest if you have this copy to the output directory, although it's not a requirement as you can specify relative paths to files. + +To create the package: + +1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu +2. `cd` to the directory containing the `PackageLayout.xml` with the correct paths (if you use the local path as in the sample package layout, this would be from your .exe output directory) +3. `mkdir Package` to create an output directory +4. To package the file into the `Package` directory, use: + `makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package` +5. To install the package, use: + `wdapp install PACKAGENAME.msixvc` +6. Once the package is installed, you can run it from the start menu. +7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox. + + +Troubleshooting +--------------- + +#### Xbox Live Login does not work + +As of June 2022 GDK, you must have a valid Title Id and MSAAppId in order to test Xbox Live functionality such as user login. Make sure these are set correctly in the `MicrosoftGame.config`. This means that even testgdk will not let you login without setting these properties to valid values. + +Furthermore, confirm that your PC is set to the correct sandbox. + + +#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing + +Prior to June 2022 GDK, running from the Visual Studio debugger would still locally register the app (and it would appear on the start menu). To fix this, you have to uninstall it (it's simplest to right click on it from the start menu to uninstall it). diff --git a/docs/README.md b/docs/README.md index 15025efa9..99ec22879 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,6 +34,7 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd - [DirectFB](README-directfb.md) - [DynAPI](README-dynapi.md) - [Emscripten](README-emscripten.md) +- [GDK](README-gdk.md) - [Gesture](README-gesture.md) - [Git](README-git.md) - [iOS](README-ios.md) diff --git a/include/SDL_config.h b/include/SDL_config.h index 749988515..003467907 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -33,6 +33,8 @@ #include "SDL_config_windows.h" #elif defined(__WINRT__) #include "SDL_config_winrt.h" +#elif defined(__WINGDK__) +#include "SDL_config_wingdk.h" #elif defined(__MACOSX__) #include "SDL_config_macosx.h" #elif defined(__IPHONEOS__) diff --git a/include/SDL_config_wingdk.h b/include/SDL_config_wingdk.h new file mode 100644 index 000000000..d456024f2 --- /dev/null +++ b/include/SDL_config_wingdk.h @@ -0,0 +1,285 @@ +/* + 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 OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_WGL +#define SDL_VIDEO_OPENGL_WGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_OPENGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_EGL +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + +/* Enable Vulkan support */ +#define SDL_VIDEO_VULKAN 1 + +/* Enable system power support */ +#define SDL_POWER_WINDOWS 1 + +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + +#endif /* SDL_config_wingdk_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index fa22f3aa3..e31b139c7 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -79,7 +79,7 @@ _m_prefetch(void *__P) #if !defined(SDL_DISABLE_ARM_NEON_H) # if defined(__ARM_NEON) # include -# elif defined(__WINDOWS__) || defined(__WINRT__) +# elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__) /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ # if defined(_M_ARM) # include diff --git a/include/SDL_main.h b/include/SDL_main.h index a7679f278..ea1213610 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -51,6 +51,15 @@ */ #define SDL_MAIN_NEEDED +#elif defined(__GDK__) +/* On GDK, SDL provides a main function that initializes the game runtime. + + Please note that #include'ing SDL_main.h is not enough to get a main() + function working. You must either link against SDL2main or, if not possible, + call the SDL_GDKRunApp function from your entry point. +*/ +#define SDL_MAIN_NEEDED + #elif defined(__IPHONEOS__) /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. @@ -148,7 +157,7 @@ extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); */ extern DECLSPEC void SDLCALL SDL_SetMainReady(void); -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) /** * Register a win32 window class for SDL's use. @@ -192,7 +201,7 @@ extern DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void */ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__GDK__) */ #ifdef __WINRT__ @@ -227,6 +236,19 @@ extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_fun #endif /* __IPHONEOS__ */ +#ifdef __GDK__ + +/** + * Initialize and launch an SDL GDK application. + * + * \param mainFunction the SDL app's C-style main(), an SDL_main_func + * \param reserved reserved for future use; should be NULL + * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve + * more information on the failure. + */ +extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved); + +#endif /* __GDK__ */ #ifdef __cplusplus } diff --git a/include/SDL_platform.h b/include/SDL_platform.h index b70fb02fd..2b61605df 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -144,7 +144,7 @@ #endif #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) -/* Try to find out if we're compiling for WinRT or non-WinRT */ +/* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */ #if defined(_MSC_VER) && defined(__has_include) #if __has_include() #define HAVE_WINAPIFAMILY_H 1 @@ -169,6 +169,9 @@ #if WINAPI_FAMILY_WINRT #undef __WINRT__ #define __WINRT__ 1 +#elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */ +#undef __WINGDK__ +#define __WINGDK__ 1 #else #undef __WINDOWS__ #define __WINDOWS__ 1 @@ -179,6 +182,11 @@ #undef __WIN32__ #define __WIN32__ 1 #endif +/* This is to support generic "any GDK" separate from a platform-specific GDK */ +#if defined(__WINGDK__) || defined(__XBOXONEGDK__) || defined(__XBOXSERIESGDK__) +#undef __GDK__ +#define __GDK__ 1 +#endif #if defined(__PSP__) #undef __PSP__ #define __PSP__ 1 diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h index 30b69a806..3960f567c 100644 --- a/include/SDL_rwops.h +++ b/include/SDL_rwops.h @@ -98,7 +98,7 @@ typedef struct SDL_RWops { void *asset; } androidio; -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__GDK__) struct { SDL_bool append; diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index c0bc8aa1a..0da225627 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -259,7 +259,7 @@ typedef uint64_t Uint64; #ifndef SDL_PRIs64 #ifdef PRIs64 #define SDL_PRIs64 PRIs64 -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__GDK__) #define SDL_PRIs64 "I64d" #elif defined(__LINUX__) && defined(__LP64__) #define SDL_PRIs64 "ld" @@ -270,7 +270,7 @@ typedef uint64_t Uint64; #ifndef SDL_PRIu64 #ifdef PRIu64 #define SDL_PRIu64 PRIu64 -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__GDK__) #define SDL_PRIu64 "I64u" #elif defined(__LINUX__) && defined(__LP64__) #define SDL_PRIu64 "lu" @@ -281,7 +281,7 @@ typedef uint64_t Uint64; #ifndef SDL_PRIx64 #ifdef PRIx64 #define SDL_PRIx64 PRIx64 -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__GDK__) #define SDL_PRIx64 "I64x" #elif defined(__LINUX__) && defined(__LP64__) #define SDL_PRIx64 "lx" @@ -292,7 +292,7 @@ typedef uint64_t Uint64; #ifndef SDL_PRIX64 #ifdef PRIX64 #define SDL_PRIX64 PRIX64 -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__GDK__) #define SDL_PRIX64 "I64X" #elif defined(__LINUX__) && defined(__LP64__) #define SDL_PRIX64 "lX" diff --git a/include/SDL_system.h b/include/SDL_system.h index cf5c320f7..6780876b2 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -41,7 +41,7 @@ extern "C" { /* Platform specific functions for Windows */ -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam); @@ -55,6 +55,10 @@ typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsi */ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); +#endif /* defined(__WIN32__) || defined(__GDK__) */ + +#if defined(__WIN32__) || defined(__WINGDK__) + /** * Get the D3D9 adapter index that matches the specified display index. * @@ -102,6 +106,10 @@ typedef struct ID3D11Device ID3D11Device; */ extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * renderer); +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ + +#if defined(__WIN32__) || defined(__GDK__) + typedef struct ID3D12Device ID3D12Device; /** @@ -118,6 +126,10 @@ typedef struct ID3D12Device ID3D12Device; */ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* renderer); +#endif /* defined(__WIN32__) || defined(__GDK__) */ + +#if defined(__WIN32__) || defined(__WINGDK__) + /** * Get the DXGI Adapter and Output indices for the specified display index. * @@ -138,8 +150,7 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren */ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); -#endif /* __WIN32__ */ - +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ /* Platform specific functions for Linux */ #ifdef __LINUX__ @@ -580,6 +591,25 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void); extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); #endif +/* Functions used only by GDK */ +#if defined(__GDK__) +typedef struct XTaskQueueObject * XTaskQueueHandle; + +/** + * Gets a reference to the global async task queue handle for GDK, + * initializing if needed. + * + * Once you are done with the task queue, you should call XTaskQueueCloseHandle + * to reduce the reference count to avoid a resource leak. + * + * \param outTaskQueue a pointer to be filled in with task queue handle. + * \returns 0 if success, -1 if any error occurs. + * + */ +extern DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue); + +#endif + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/include/SDL_thread.h b/include/SDL_thread.h index 1e04a4f8f..7364f8137 100644 --- a/include/SDL_thread.h +++ b/include/SDL_thread.h @@ -35,7 +35,7 @@ #include "SDL_atomic.h" #include "SDL_mutex.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) #include /* _beginthreadex() and _endthreadex() */ #endif #if defined(__OS2__) /* for _beginthread() and _endthread() */ @@ -88,7 +88,7 @@ typedef enum { typedef int (SDLCALL * SDL_ThreadFunction) (void *data); -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) /** * \file SDL_thread.h * diff --git a/include/begin_code.h b/include/begin_code.h index b1b1a3a9b..6c2f096f8 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -51,7 +51,7 @@ /* Some compilers use a special export keyword */ #ifndef DECLSPEC -# if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__) +# if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__) || defined(__GDK__) # ifdef DLL_EXPORT # define DECLSPEC __declspec(dllexport) # else @@ -74,7 +74,7 @@ /* By default SDL uses the C calling convention */ #ifndef SDLCALL -#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#if (defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)) && !defined(__GNUC__) #define SDLCALL __cdecl #elif defined(__OS2__) || defined(__EMX__) #define SDLCALL _System diff --git a/src/SDL.c b/src/SDL.c index 0afaeb18c..d1326fb2e 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -20,7 +20,7 @@ */ #include "./SDL_internal.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) #include "core/windows/SDL_windows.h" #elif defined(__OS2__) #include /* _exit() */ @@ -89,7 +89,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_max, SDL_PATCHLEVEL <= 99); extern SDL_NORETURN void SDL_ExitProcess(int exitcode); SDL_NORETURN void SDL_ExitProcess(int exitcode) { -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) /* "if you do not know the state of all threads in your process, it is better to call TerminateProcess than ExitProcess" https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */ @@ -579,6 +579,8 @@ SDL_GetPlatform(void) return "Windows"; #elif __WINRT__ return "WinRT"; +#elif __WINGDK__ + return "WinGDK"; #elif __TVOS__ return "tvOS"; #elif __IPHONEOS__ @@ -630,6 +632,6 @@ _DllMainCRTStartup(HANDLE hModule, } #endif /* Building DLL */ -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__GDK__) */ /* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 02cd6b3fd..8153bf98a 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -20,7 +20,7 @@ */ #include "./SDL_internal.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) #include "core/windows/SDL_windows.h" #endif @@ -32,7 +32,7 @@ #include "SDL_assert_c.h" #include "video/SDL_sysvideo.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) #ifndef WS_OVERLAPPEDWINDOW #define WS_OVERLAPPEDWINDOW 0 #endif @@ -90,7 +90,7 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data) } } -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) #define ENDLINE "\r\n" #else #define ENDLINE "\n" diff --git a/src/SDL_log.c b/src/SDL_log.c index 88dd6af66..a00fa2880 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -20,7 +20,7 @@ */ #include "./SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) +#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) #include "core/windows/SDL_windows.h" #endif @@ -362,7 +362,7 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list } } -#if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__) +#if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) /* Flag tracking the attachment of the console: 0=unattached, 1=attached to a console, 2=attached to a file, -1=error */ static int consoleAttached = 0; @@ -374,7 +374,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) { -#if defined(__WIN32__) || defined(__WINRT__) +#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) /* Way too many allocations here, urgh */ /* Note: One can't call SDL_SetError here, since that function itself logs. */ { @@ -383,7 +383,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, LPTSTR tstr; SDL_bool isstack; -#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) +#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) BOOL attachResult; DWORD attachError; DWORD charsWritten; @@ -422,7 +422,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, } } } -#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */ +#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */ length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1; output = SDL_small_alloc(char, length, &isstack); @@ -432,7 +432,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, /* Output to debugger */ OutputDebugString(tstr); -#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) +#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) /* Screen output to stderr, if console was attached. */ if (consoleAttached == 1) { if (!WriteConsole(stderrHandle, tstr, (DWORD) SDL_tcslen(tstr), &charsWritten, NULL)) { @@ -447,7 +447,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, OutputDebugString(TEXT("Error calling WriteFile\r\n")); } } -#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */ +#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */ SDL_free(tstr); SDL_small_free(output, isstack); diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index f9877c3fe..53776d5e0 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -20,7 +20,7 @@ */ #include "../SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) +#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) #include "../core/windows/SDL_windows.h" #endif diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index 862ed9f5e..5b966aa31 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -519,7 +519,7 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) SDL_assert(client != NULL); -#ifdef __WINRT__ /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */ +#if defined(__WINRT__) || defined(__GDK__) /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */ this->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); #else this->hidden->event = CreateEventW(NULL, 0, 0, NULL); diff --git a/src/core/gdk/SDL_gdk.cpp b/src/core/gdk/SDL_gdk.cpp new file mode 100644 index 000000000..4058a9b8f --- /dev/null +++ b/src/core/gdk/SDL_gdk.cpp @@ -0,0 +1,177 @@ +/* + 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" + +#include "SDL_system.h" +#include "../windows/SDL_windows.h" +#include "SDL_messagebox.h" +#include "SDL_main.h" +#include +#include +#include /* CommandLineToArgvW() */ + +static XTaskQueueHandle GDK_GlobalTaskQueue; + +extern "C" DECLSPEC int +SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue) +{ + /* If this is the first call, first create the global task queue. */ + if (!GDK_GlobalTaskQueue) { + HRESULT hr; + + hr = XTaskQueueCreate(XTaskQueueDispatchMode::ThreadPool, + XTaskQueueDispatchMode::Manual, + &GDK_GlobalTaskQueue + ); + if (FAILED(hr)) { + SDL_SetError("[GDK] Could not create global task queue"); + return -1; + } + + /* The initial call gets the non-duplicated handle so they can clean it up */ + *outTaskQueue = GDK_GlobalTaskQueue; + } else { + /* Duplicate the global task queue handle into outTaskQueue */ + if (FAILED(XTaskQueueDuplicateHandle(GDK_GlobalTaskQueue, outTaskQueue))) { + SDL_SetError("[GDK] Unable to acquire global task queue"); + return -1; + } + } + + return 0; +} + +extern "C" void +GDK_DispatchTaskQueue(void) +{ + /* If there is no global task queue, don't do anything. + * This gives the option to opt-out for those who want to handle everything themselves. + */ + if (GDK_GlobalTaskQueue) { + /* Dispatch any callbacks which are ready. */ + while (XTaskQueueDispatch(GDK_GlobalTaskQueue, XTaskQueuePort::Completion, 0)) + ; + } +} + +/* Pop up an out of memory message, returns to Windows */ +extern "C" static BOOL +OutOfMemory(void) +{ + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL); + return FALSE; +} + +/* Gets the arguments with GetCommandLine, converts them to argc and argv + and calls SDL_main */ +extern "C" DECLSPEC int +SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) +{ + LPWSTR *argvw; + char **argv; + int i, argc, result; + HRESULT hr; + XTaskQueueHandle taskQueue; + + argvw = CommandLineToArgvW(GetCommandLineW(), &argc); + if (argvw == NULL) { + return OutOfMemory(); + } + + /* Note that we need to be careful about how we allocate/free memory here. + * If the application calls SDL_SetMemoryFunctions(), we can't rely on + * SDL_free() to use the same allocator after SDL_main() returns. + */ + + /* Parse it into argv and argc */ + argv = (char **) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); + if (!argv) { + return OutOfMemory(); + } + for (i = 0; i < argc; ++i) { + DWORD len; + char *arg = WIN_StringToUTF8W(argvw[i]); + if (!arg) { + return OutOfMemory(); + } + len = (DWORD) SDL_strlen(arg); + argv[i] = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1); + if (!argv[i]) { + return OutOfMemory(); + } + SDL_memcpy(argv[i], arg, len); + SDL_free(arg); + } + argv[i] = NULL; + LocalFree(argvw); + + hr = XGameRuntimeInitialize(); + + if (SUCCEEDED(hr) && SDL_GDKGetTaskQueue(&taskQueue) == 0) { + Uint32 titleid = 0; + char scidBuffer[64]; + XblInitArgs xblArgs; + + XTaskQueueSetCurrentProcessTaskQueue(taskQueue); + + /* Try to get the title ID and initialize Xbox Live */ + hr = XGameGetXboxTitleId(&titleid); + if (SUCCEEDED(hr)) { + SDL_zero(xblArgs); + xblArgs.queue = taskQueue; + SDL_snprintf(scidBuffer, 64, "00000000-0000-0000-0000-0000%08X", titleid); + xblArgs.scid = scidBuffer; + hr = XblInitialize(&xblArgs); + } else { + SDL_SetError("[GDK] Unable to get titleid. Will not call XblInitialize. Check MicrosoftGame.config!"); + } + + SDL_SetMainReady(); + + /* Run the application main() code */ + result = mainFunction(argc, argv); + + /* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */ + /* Terminate the task queue and dispatch any pending tasks */ + XTaskQueueTerminate(taskQueue, false, nullptr, nullptr); + while (XTaskQueueDispatch(taskQueue, XTaskQueuePort::Completion, 0)) + ; + + XTaskQueueCloseHandle(taskQueue); + + XGameRuntimeUninitialize(); + } else { +#ifdef __WINGDK__ + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "[GDK] Could not initialize - aborting", NULL); +#else + SDL_assert_always(0 && "[GDK] Could not initialize - aborting"); +#endif + result = -1; + } + + /* Free argv, to avoid memory leak */ + for (i = 0; i < argc; ++i) { + HeapFree(GetProcessHeap(), 0, argv[i]); + } + HeapFree(GetProcessHeap(), 0, argv); + + return result; +} diff --git a/src/core/gdk/SDL_gdk.h b/src/core/gdk/SDL_gdk.h new file mode 100644 index 000000000..628d3e621 --- /dev/null +++ b/src/core/gdk/SDL_gdk.h @@ -0,0 +1,24 @@ +/* + 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" + +/* This is called from WIN_PumpEvents on GDK */ +extern void GDK_DispatchTaskQueue(void); diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 50e128fcc..f5b2642f5 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) +#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) #include "SDL_windows.h" #include "SDL_error.h" @@ -338,6 +338,6 @@ WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) winrect->bottom = sdlrect->y + sdlrect->h - 1; } -#endif /* __WIN32__ || __WINRT__ */ +#endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 7b3b9bcfa..48f4d93b1 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -40,6 +40,16 @@ #define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ #endif #define WINVER _WIN32_WINNT +#elif defined(__WINGDK__) +#define WIN32_LEAN_AND_MEAN +#define STRICT +#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/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 9386d0ebb..8eb942bd3 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -24,7 +24,7 @@ #include "../SDL_internal.h" #endif -#if defined(__WIN32__) || defined(__WINRT__) +#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) #include "../core/windows/SDL_windows.h" #endif #if defined(__OS2__) @@ -456,7 +456,7 @@ CPU_haveNEON(void) query the OS kernel in a platform-specific way. :/ */ #if defined(SDL_CPUINFO_DISABLED) return 0; /* disabled */ -#elif (defined(__WINDOWS__) || defined(__WINRT__)) && (defined(_M_ARM) || defined(_M_ARM64)) +#elif (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64)) /* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */ /* Seems to have been removed */ # if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) @@ -671,7 +671,7 @@ SDL_GetCPUCount(void) sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0); } #endif -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) if (SDL_CPUCount <= 0) { SYSTEM_INFO info; GetSystemInfo(&info); @@ -912,11 +912,11 @@ SDL_GetCPUFeatures(void) SDL_CPUFeatures |= CPU_HAS_NEON; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } - if (CPU_haveLSX()) { + if (CPU_haveLSX()) { SDL_CPUFeatures |= CPU_HAS_LSX; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } - if (CPU_haveLASX()) { + if (CPU_haveLASX()) { SDL_CPUFeatures |= CPU_HAS_LASX; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 32); } @@ -1053,7 +1053,7 @@ SDL_GetSystemRAM(void) } } #endif -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) if (SDL_SystemRAM <= 0) { MEMORYSTATUSEX stat; stat.dwLength = sizeof(stat); diff --git a/src/dynapi/SDL2.exports b/src/dynapi/SDL2.exports index c928dc739..74098be67 100644 --- a/src/dynapi/SDL2.exports +++ b/src/dynapi/SDL2.exports @@ -849,3 +849,5 @@ ++'_SDL_HasLASX'.'SDL2.dll'.'SDL_HasLASX' ++'_SDL_RenderGetD3D12Device'.'SDL2.dll'.'SDL_RenderGetD3D12Device' ++'_SDL_utf8strnlen'.'SDL2.dll'.'SDL_utf8strnlen' +# ++'_SDL_GDKGetTaskQueue'.'SDL2.dll'.'SDL_GDKGetTaskQueue' +# ++'_SDL_GDKRunApp'.'SDL2.dll'.'SDL_GDKRunApp' diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 1083fd9ad..12d8554f4 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -875,3 +875,5 @@ #define SDL_HasLASX SDL_HasLASX_REAL #define SDL_RenderGetD3D12Device SDL_RenderGetD3D12Device_REAL #define SDL_utf8strnlen SDL_utf8strnlen_REAL +#define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_REAL +#define SDL_GDKRunApp SDL_GDKRunApp_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index db4fa1bb9..f0a2d0d8b 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -48,7 +48,7 @@ SDL_DYNAPI_PROC(int,SDL_snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF #undef SDL_CreateThread #endif -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return) #elif defined(__OS2__) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return) @@ -62,9 +62,12 @@ SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(FILE *a, SDL_bool b),(a,b),return) SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(void *a, SDL_bool b),(a,b),return) #endif -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) SDL_DYNAPI_PROC(int,SDL_RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),) +#endif + +#if defined(__WIN32__) || defined(__WINGDK__) SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return) SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return) #endif @@ -599,7 +602,7 @@ SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX,(void),(),return) SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),return) SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return) -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) SDL_DYNAPI_PROC(SDL_bool,SDL_DXGIGetOutputInfo,(int a,int *b, int *c),(a,b,c),return) #endif SDL_DYNAPI_PROC(SDL_bool,SDL_RenderIsClipEnabled,(SDL_Renderer *a),(a),return) @@ -620,7 +623,7 @@ SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return) SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),) SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return) -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),) #endif SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return) @@ -744,7 +747,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasColorKey,(SDL_Surface *a),(a),return) #undef SDL_CreateThreadWithStackSize #endif -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return) #elif defined(__OS2__) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return) @@ -854,7 +857,7 @@ SDL_DYNAPI_PROC(float,SDL_roundf,(float a),(a),return) SDL_DYNAPI_PROC(long,SDL_lround,(double a),(a),return) SDL_DYNAPI_PROC(long,SDL_lroundf,(float a),(a),return) SDL_DYNAPI_PROC(int,SDL_SoftStretchLinear,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return) -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) SDL_DYNAPI_PROC(ID3D11Device*,SDL_RenderGetD3D11Device,(SDL_Renderer *a),(a),return) #endif SDL_DYNAPI_PROC(int,SDL_UpdateNVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f),(a,b,c,d,e,f),return) @@ -948,7 +951,12 @@ SDL_DYNAPI_PROC(void,SDL_GUIDToString,(SDL_GUID a, char *b, int c),(a,b,c),) SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasLSX,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasLASX,(void),(),return) -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) SDL_DYNAPI_PROC(ID3D12Device*,SDL_RenderGetD3D12Device,(SDL_Renderer *a),(a),return) #endif SDL_DYNAPI_PROC(size_t,SDL_utf8strnlen,(const char *a, size_t b),(a,b),return) + +#if defined(__GDK__) +SDL_DYNAPI_PROC(int,SDL_GDKGetTaskQueue,(XTaskQueueHandle *a),(a),return) +SDL_DYNAPI_PROC(int,SDL_GDKRunApp,(SDL_main_func a, void *b),(a,b),return) +#endif diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 4f52d10a3..6e5ee319f 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -35,7 +35,7 @@ #include "SDL_syswm.h" #undef SDL_PRIs64 -#if defined(__WIN32__) && !defined(__CYGWIN__) +#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__) #define SDL_PRIs64 "I64d" #else #define SDL_PRIs64 "lld" diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index dfa9a6c42..90dcd38a4 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -28,7 +28,7 @@ #include "SDL_events_c.h" #include "../SDL_hints_c.h" #include "../video/SDL_sysvideo.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) #include "../core/windows/SDL_windows.h" // For GetDoubleClickTime() #endif #if defined(__OS2__) @@ -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 { -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) mouse->double_click_time = GetDoubleClickTime(); #elif defined(__OS2__) mouse->double_click_time = WinQuerySysValue(HWND_DESKTOP, SV_DBLCLKTIME); @@ -1069,7 +1069,7 @@ SDL_CaptureMouse(SDL_bool enabled) return SDL_Unsupported(); } -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) /* Windows mouse capture is tied to the current thread, and must be called * from the thread that created the window being captured. Since we update * the mouse capture state from the event processing, any application state @@ -1078,7 +1078,7 @@ SDL_CaptureMouse(SDL_bool enabled) if (!SDL_OnVideoThread()) { return SDL_SetError("SDL_CaptureMouse() must be called on the main thread"); } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ if (enabled && SDL_GetKeyboardFocus() == NULL) { return SDL_SetError("No window has focus"); diff --git a/src/events/SDL_sysevents.h b/src/events/SDL_sysevents.h index 1a48462be..a41df84d0 100644 --- a/src/events/SDL_sysevents.h +++ b/src/events/SDL_sysevents.h @@ -29,7 +29,7 @@ #define MUST_THREAD_EVENTS #endif -#ifdef __WIN32__ /* Windows doesn't allow a separate event thread */ +#if defined(__WIN32__) || defined(__GDK__) /* Windows doesn't allow a separate event thread */ #define CANT_THREAD_EVENTS #endif diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 0b4cc17b2..56f912566 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -30,7 +30,7 @@ #include "../SDL_internal.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) #include "../core/windows/SDL_windows.h" #endif @@ -62,7 +62,7 @@ #include "nacl_io/nacl_io.h" #endif -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) /* Functions to read/write Win32 API file pointers */ @@ -303,7 +303,7 @@ windows_file_close(SDL_RWops * context) } return 0; } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__GDK__) */ #ifdef HAVE_STDIO_H @@ -574,7 +574,7 @@ SDL_RWFromFile(const char *file, const char *mode) rwops->close = Android_JNI_FileClose; rwops->type = SDL_RWOPS_JNIFILE; -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__GDK__) rwops = SDL_AllocRW(); if (!rwops) return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index d65611779..718e5c192 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -37,7 +37,7 @@ #if !SDL_HIDAPI_DISABLED -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) #include "../core/windows/SDL_windows.h" #endif @@ -89,7 +89,7 @@ static struct SDL_bool m_bCanGetNotifications; Uint32 m_unLastDetect; -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) SDL_threadID m_nThreadID; WNDCLASSEXA m_wndClass; HWND m_hwndMsg; @@ -110,7 +110,7 @@ static struct } SDL_HIDAPI_discovery; -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) struct _DEV_BROADCAST_HDR { DWORD dbch_size; @@ -156,7 +156,7 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam return DefWindowProc(hwnd, message, wParam, lParam); } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ #if defined(__MACOSX__) @@ -219,7 +219,7 @@ HIDAPI_InitializeDiscovery() SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_FALSE; SDL_HIDAPI_discovery.m_unLastDetect = 0; -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) SDL_HIDAPI_discovery.m_nThreadID = SDL_ThreadID(); SDL_zero(SDL_HIDAPI_discovery.m_wndClass); @@ -246,7 +246,7 @@ HIDAPI_InitializeDiscovery() SDL_HIDAPI_discovery.m_hNotify = RegisterDeviceNotification( SDL_HIDAPI_discovery.m_hwndMsg, &devBroadcast, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); SDL_HIDAPI_discovery.m_bCanGetNotifications = ( SDL_HIDAPI_discovery.m_hNotify != 0 ); } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ #if defined(__MACOSX__) SDL_HIDAPI_discovery.m_notificationPort = IONotificationPortCreate(kIOMasterPortDefault); @@ -369,7 +369,7 @@ HIDAPI_UpdateDiscovery() return; } -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) #if 0 /* just let the usual SDL_PumpEvents loop dispatch these, fixing bug 4286. --ryan. */ /* We'll only get messages on the same thread that created the window */ if (SDL_ThreadID() == SDL_HIDAPI_discovery.m_nThreadID) { @@ -382,7 +382,7 @@ HIDAPI_UpdateDiscovery() } } #endif -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ #if defined(__MACOSX__) if (SDL_HIDAPI_discovery.m_notificationPort) { @@ -474,7 +474,7 @@ HIDAPI_ShutdownDiscovery() return; } -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) if (SDL_HIDAPI_discovery.m_hNotify) UnregisterDeviceNotification(SDL_HIDAPI_discovery.m_hNotify); @@ -578,7 +578,7 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; #include "mac/hid.c" #define HAVE_PLATFORM_BACKEND 1 #define udev_ctx 1 -#elif __WINDOWS__ +#elif __WINDOWS__ || __WINGDK__ #include "windows/hid.c" #define HAVE_PLATFORM_BACKEND 1 #define udev_ctx 1 diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 2472695a8..b667e8dcb 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -1019,7 +1019,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping) pchGUID[pFirstComma - pMapping] = '\0'; /* Convert old style GUIDs to the new style in 2.0.5 */ -#if __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[20], "504944564944", 12) == 0) { SDL_memcpy(&pchGUID[20], "000000000000", 12); diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index bfb204642..0eb600ac8 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -37,7 +37,7 @@ /* This is included in only one place because it has a large static list of controllers */ #include "controller_type.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) /* Needed for checking for input remapping programs */ #include "../core/windows/SDL_windows.h" @@ -2362,7 +2362,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) static SDL_bool SDL_IsPS4RemapperRunning(void) { -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) const char *mapper_processes[] = { "DS4Windows.exe", "InputMapper.exe", diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index b549ef6d6..35635b72a 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -156,7 +156,7 @@ SetInitState(SDL_DriverXboxOne_Context *ctx, SDL_XboxOneInitState state) static void SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size) { -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) /* The Windows driver is taking care of acks */ #else if ((data[1] & 0x30) == 0x30) { @@ -179,7 +179,7 @@ SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size) SDL_SetError("Couldn't send ack packet"); } } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__ */ } #if 0 @@ -912,7 +912,7 @@ HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOn switch (ctx->init_state) { case XBOX_ONE_INIT_STATE_START_NEGOTIATING: -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) /* The Windows driver is taking care of negotiation */ SetInitState(ctx, XBOX_ONE_INIT_STATE_COMPLETE); #else diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 38164b0f7..b0b9a505a 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -32,7 +32,7 @@ #include "SDL_hidapi_rumble.h" #include "../../SDL_hints_c.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) #include "../windows/SDL_rawinputjoystick_c.h" #endif diff --git a/src/main/gdk/SDL_gdk_main.c b/src/main/gdk/SDL_gdk_main.c new file mode 100644 index 000000000..4a25bbb18 --- /dev/null +++ b/src/main/gdk/SDL_gdk_main.c @@ -0,0 +1,41 @@ +/* + 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_config.h" + +/* Include this so we define UNICODE properly */ +#include "../../core/windows/SDL_windows.h" + +/* Include the SDL main definition header */ +#include "SDL.h" +#include "SDL_main.h" + +#ifdef main +# undef main +#endif /* main */ + +/* This is where execution begins */ +int WINAPI +WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) +{ + return SDL_GDKRunApp(SDL_main, NULL); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 3d0eac892..5344d0a55 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1775,7 +1775,7 @@ SDL_RenderDriver D3D_RenderDriver = { }; #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) /* This function needs to always exist on Windows, for the Dynamic API. */ IDirect3DDevice9 * SDL_RenderGetD3D9Device(SDL_Renderer * renderer) @@ -1799,6 +1799,6 @@ SDL_RenderGetD3D9Device(SDL_Renderer * renderer) return device; } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 49a193ab0..cd3dab4a2 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -672,7 +672,7 @@ done: return result; } -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) static DXGI_MODE_ROTATION D3D11_GetCurrentRotation() @@ -681,7 +681,7 @@ D3D11_GetCurrentRotation() return DXGI_MODE_ROTATION_IDENTITY; } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ static BOOL D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) @@ -827,7 +827,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) goto done; #endif } else { -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) SDL_SysWMinfo windowinfo; SDL_VERSION(&windowinfo.version); SDL_GetWindowWMInfo(renderer->window, &windowinfo); @@ -849,7 +849,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) #else SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to"); goto done; -#endif /* ifdef __WIN32__ / else */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) / else */ } data->swapEffect = swapChainDesc.SwapEffect; @@ -2473,7 +2473,7 @@ SDL_RenderDriver D3D11_RenderDriver = { #endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINGDK__) /* This function needs to always exist on Windows, for the Dynamic API. */ ID3D11Device * SDL_RenderGetD3D11Device(SDL_Renderer * renderer) @@ -2497,6 +2497,6 @@ SDL_RenderGetD3D11Device(SDL_Renderer * renderer) return device; } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__WINGDK__) */ /* 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 5fbe42b73..24c29f759 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -3042,7 +3042,7 @@ SDL_RenderDriver D3D12_RenderDriver = { #endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */ -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__GDK__) #ifdef __cplusplus extern "C" #endif @@ -3069,6 +3069,6 @@ SDL_RenderGetD3D12Device(SDL_Renderer * renderer) return device; } -#endif /* __WIN32__ */ +#endif /* defined(__WIN32__) || defined(__GDK__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index dbbb7ee52..73a5694dd 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1715,7 +1715,7 @@ GL_IsProbablyAccelerated(const GL_RenderData *data) /*const char *vendor = (const char *) data->glGetString(GL_VENDOR);*/ const char *renderer = (const char *) data->glGetString(GL_RENDERER); -#ifdef __WINDOWS__ +#if defined(__WINDOWS__) || defined(__WINGDK__) if (SDL_strcmp(renderer, "GDI Generic") == 0) { return SDL_FALSE; /* Microsoft's fallback software renderer. Fix your system! */ } diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index d5ffc147a..ade087265 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -32,7 +32,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net #if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__GDK__) #include "../../core/windows/SDL_windows.h" #endif diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index add833284..b74974c34 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -25,7 +25,7 @@ #include "../SDL_internal.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINGDK__) #include "../core/windows/SDL_windows.h" #endif @@ -35,7 +35,7 @@ #include "SDL_stdinc.h" -#if defined(__WIN32__) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV)) +#if (defined(__WIN32__) || defined(__WINGDK__)) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV)) /* Note this isn't thread-safe! */ static char *SDL_envmem = NULL; /* Ugh, memory leak */ static size_t SDL_envmemlen = 0; @@ -54,7 +54,7 @@ SDL_setenv(const char *name, const char *value, int overwrite) return setenv(name, value, overwrite); } -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__WINGDK__) int SDL_setenv(const char *name, const char *value, int overwrite) { @@ -187,7 +187,7 @@ SDL_getenv(const char *name) return getenv(name); } -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(__WINGDK__) char * SDL_getenv(const char *name) { diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index f3a4cbbee..bee60d506 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -131,7 +131,7 @@ static struct { "US-ASCII", ENCODING_ASCII }, { "8859-1", ENCODING_LATIN1 }, { "ISO-8859-1", ENCODING_LATIN1 }, -#if defined(__WIN32__) || defined(__OS2__) +#if defined(__WIN32__) || defined(__OS2__) || defined(__GDK__) { "WCHAR_T", ENCODING_UTF16LE }, #else { "WCHAR_T", ENCODING_UCS4NATIVE }, diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 084ece803..24fb48103 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1667,7 +1667,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation, * but it's important or window focus will get broken on windows! */ -#if !defined(__WIN32__) +#if !defined(__WIN32__) && !defined(__GDK__) if (window->flags & SDL_WINDOW_MINIMIZED) { window->flags &= ~SDL_WINDOW_MINIMIZED; } @@ -2534,7 +2534,7 @@ SDL_CreateWindowFramebuffer(SDL_Window * window) attempt_texture_framebuffer = SDL_FALSE; } - #if defined(__WIN32__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ + #if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE; } diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 6273a5a98..57c72afdf 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -53,6 +53,10 @@ #include "wmmsg.h" #endif +#ifdef __GDK__ +#include "../../core/gdk/SDL_gdk.h" +#endif + /* #define HIGHDPI_DEBUG */ /* Masks for processing the windows KEYDOWN and KEYUP messages */ @@ -1803,6 +1807,10 @@ WIN_PumpEvents(_THIS) /* Update mouse capture */ WIN_UpdateMouseCapture(); + +#ifdef __GDK__ + GDK_DispatchTaskQueue(); +#endif } diff --git a/test/testsprite2.c b/test/testsprite2.c index fa709e349..a91ddd86e 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -56,7 +56,12 @@ quit(int rc) SDL_free(positions); SDL_free(velocities); SDLTest_CommonQuit(state); - exit(rc); + /* 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. + */ + if (rc != 0) { + exit(rc); + } } int