diff --git a/.github/workflows/create-test-plan.py b/.github/workflows/create-test-plan.py index 522ea54ab..4751383b3 100755 --- a/.github/workflows/create-test-plan.py +++ b/.github/workflows/create-test-plan.py @@ -95,7 +95,6 @@ class JobSpec: msvc_project: Optional[str] = None msvc_arch: Optional[MsvcArch] = None clang_cl: bool = False - uwp: bool = False gdk: bool = False vita_gles: Optional[VitaGLES] = None @@ -112,7 +111,6 @@ JOB_SPECS = { "msvc-clang-x86": JobSpec(name="Windows (MSVC, clang-cl x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x86", msvc_arch=MsvcArch.X86, clang_cl=True, ), "msvc-arm32": JobSpec(name="Windows (MSVC, ARM)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm32", msvc_arch=MsvcArch.Arm32, ), "msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ), - "msvc-uwp-x64": JobSpec(name="UWP (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-UWP", msvc_arch=MsvcArch.X64, msvc_project="VisualC-WinRT/SDL-UWP.sln", uwp=True, ), "msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ), "ubuntu-20.04": JobSpec(name="Ubuntu 20.04", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04", ), "ubuntu-22.04": JobSpec(name="Ubuntu 22.04", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", ), @@ -358,10 +356,9 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta "-DCMAKE_EXE_LINKER_FLAGS=-DEBUG", "-DCMAKE_SHARED_LINKER_FLAGS=-DEBUG", )) - if spec.uwp: - job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>DLL'") - else: - job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>'") + + job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>'") + if spec.clang_cl: job.cmake_arguments.extend(( "-DCMAKE_C_COMPILER=clang-cl", @@ -398,14 +395,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta case MsvcArch.Arm64: job.msvc_vcvars = "x64_arm64" job.run_tests = False - if spec.uwp: - job.build_tests = False - job.cmake_arguments.extend(( - "-DCMAKE_SYSTEM_NAME=WindowsStore", - "-DCMAKE_SYSTEM_VERSION=10.0", - )) - job.msvc_project_flags.append("-p:WindowsTargetPlatformVersion=10.0.17763.0") - elif spec.gdk: + if spec.gdk: job.setup_gdk_folder = "VisualC-GDK" else: match spec.msvc_arch: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5716da4ce..9660786a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,7 +361,7 @@ cmake_dependent_option(SDL_STATIC "Build a static version of the library" ${SDL_ option(SDL_TEST_LIBRARY "Build the SDL3_test library" ON) dep_option(SDL_TESTS "Build the test directory" OFF SDL_TEST_LIBRARY OFF) -dep_option(SDL_INSTALL_TESTS "Install test-cases" OFF "NOT SDL_DISABLE_INSTALL;NOT SDL_FRAMEWORK;NOT WINDOWS_STORE" OFF) +dep_option(SDL_INSTALL_TESTS "Install test-cases" OFF "NOT SDL_DISABLE_INSTALL;NOT SDL_FRAMEWORK" OFF) dep_option(SDL_TESTS_LINK_SHARED "link tests to shared SDL library" "${SDL_SHARED}" "SDL_SHARED;SDL_STATIC" "${SDL_SHARED}") set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Timeout multiplier to account for really slow machines") @@ -428,11 +428,6 @@ if (LIBC_IS_GLIBC AND CMAKE_SIZEOF_VOID_P EQUAL 4) sdl_compile_definitions(PRIVATE "_TIME_BITS=64") endif() -if(WINDOWS_STORE) - sdl_compile_definitions(PRIVATE "SDL_BUILDING_WINRT=1" "WINAPI_FAMILY=WINAPI_FAMILY_APP") - sdl_compile_options(PRIVATE "$<$:/ZW>" "$<$:-EHsc>") -endif() - check_linker_supports_version_file(HAVE_WL_VERSION_SCRIPT) if(HAVE_WL_VERSION_SCRIPT) sdl_shared_link_options("-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/dynapi/SDL_dynapi.sym") @@ -1833,15 +1828,6 @@ elseif(WINDOWS) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/core/windows/*.c") sdl_glob_sources("${SDL3_SOURCE_DIR}/src/main/windows/*.c") - if(WINDOWS_STORE) - enable_language(CXX) - sdl_glob_sources( - "${SDL3_SOURCE_DIR}/src/core/winrt/*.c" - "${SDL3_SOURCE_DIR}/src/core/winrt/*.cpp" - "${SDL3_SOURCE_DIR}/src/main/winrt/*.cpp" - ) - endif() - if(TARGET SDL3-shared AND MSVC AND NOT SDL_LIBC) # Prevent codegen that would use the VC runtime libraries. target_compile_options(SDL3-shared PRIVATE $<$:/GS-> $<$:/Gs1048576>) @@ -1850,11 +1836,8 @@ elseif(WINDOWS) endif() endif() - if(WINDOWS_STORE) - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/misc/winrt/*.cpp") - else() - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/misc/windows/*.c") - endif() + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/misc/windows/*.c") + set(HAVE_SDL_MISC TRUE) # Check for DirectX @@ -1875,7 +1858,7 @@ elseif(WINDOWS) check_include_file(ddraw.h HAVE_DDRAW_H) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) - if(WINDOWS_STORE OR SDL_CPU_ARM32) + if(SDL_CPU_ARM32) # !!! FIXME: this should probably check if we're !(x86 or x86-64) instead of arm. set(HAVE_DINPUT_H 0) endif() check_include_file(dxgi.h HAVE_DXGI_H) @@ -1932,7 +1915,7 @@ elseif(WINDOWS) ) if(SDL_AUDIO) - if(HAVE_DSOUND_H AND NOT WINDOWS_STORE) + if(HAVE_DSOUND_H) set(SDL_AUDIO_DRIVER_DSOUND 1) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/directsound/*.c") set(HAVE_SDL_AUDIO TRUE) @@ -1942,27 +1925,15 @@ elseif(WINDOWS) set(SDL_AUDIO_DRIVER_WASAPI 1) set(HAVE_WASAPI TRUE) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/wasapi/*.c") - if(WINDOWS_STORE) - sdl_sources("${SDL3_SOURCE_DIR}/src/audio/wasapi/SDL_wasapi_winrt.cpp") - endif() set(HAVE_SDL_AUDIO TRUE) endif() endif() if(SDL_VIDEO) - if(WINDOWS_STORE) - set(SDL_VIDEO_DRIVER_WINRT 1) - sdl_glob_sources( - "${SDL3_SOURCE_DIR}/src/video/winrt/*.c" - "${SDL3_SOURCE_DIR}/src/video/winrt/*.cpp" - "${SDL3_SOURCE_DIR}/src/render/direct3d11/*.cpp" - ) - else() - set(SDL_VIDEO_DRIVER_WINDOWS 1) - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/windows/*.c") - endif() + set(SDL_VIDEO_DRIVER_WINDOWS 1) + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/windows/*.c") - if(SDL_RENDER_D3D AND HAVE_D3D9_H AND NOT WINDOWS_STORE) + if(SDL_RENDER_D3D AND HAVE_D3D9_H) set(SDL_VIDEO_RENDER_D3D 1) set(HAVE_RENDER_D3D TRUE) endif() @@ -1970,7 +1941,7 @@ elseif(WINDOWS) set(SDL_VIDEO_RENDER_D3D11 1) set(HAVE_RENDER_D3D11 TRUE) endif() - if(SDL_RENDER_D3D12 AND NOT WINDOWS_STORE) + if(SDL_RENDER_D3D12) set(SDL_VIDEO_RENDER_D3D12 1) set(HAVE_RENDER_D3D12 TRUE) endif() @@ -1980,60 +1951,36 @@ elseif(WINDOWS) set(SDL_THREAD_GENERIC_COND_SUFFIX 1) set(SDL_THREAD_GENERIC_RWLOCK_SUFFIX 1) set(SDL_THREAD_WINDOWS 1) - if(WINDOWS_STORE) - sdl_sources( - "${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_syscond.cpp" - "${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_sysmutex.cpp" - "${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_sysrwlock.cpp" - "${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_systhread.cpp" - "${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syssem.c" - ) - else() - sdl_sources( - "${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syscond.c" - "${SDL3_SOURCE_DIR}/src/thread/generic/SDL_sysrwlock.c" - "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syscond_cv.c" - "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c" - "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysrwlock_srw.c" - "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syssem.c" - "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systhread.c" - "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systls.c" - ) - endif() + sdl_sources( + "${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syscond.c" + "${SDL3_SOURCE_DIR}/src/thread/generic/SDL_sysrwlock.c" + "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syscond_cv.c" + "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c" + "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysrwlock_srw.c" + "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syssem.c" + "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systhread.c" + "${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systls.c" + ) set(HAVE_SDL_THREADS TRUE) - if(SDL_SENSOR AND HAVE_SENSORSAPI_H AND NOT WINDOWS_STORE) + if(SDL_SENSOR AND HAVE_SENSORSAPI_H) set(SDL_SENSOR_WINDOWS 1) set(HAVE_SDL_SENSORS TRUE) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/sensor/windows/*.c") endif() if(SDL_POWER) - if(WINDOWS_STORE) - set(SDL_POWER_WINRT 1) - sdl_sources("${SDL3_SOURCE_DIR}/src/power/winrt/SDL_syspower.cpp") - else() - set(SDL_POWER_WINDOWS 1) - sdl_sources("${SDL3_SOURCE_DIR}/src/power/windows/SDL_syspower.c") - set(HAVE_SDL_POWER TRUE) - endif() + set(SDL_POWER_WINDOWS 1) + sdl_sources("${SDL3_SOURCE_DIR}/src/power/windows/SDL_syspower.c") + set(HAVE_SDL_POWER TRUE) endif() - if(WINDOWS_STORE) - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/locale/winrt/*.c") - else() - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/locale/windows/*.c") - endif() + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/locale/windows/*.c") set(HAVE_SDL_LOCALE TRUE) set(SDL_FILESYSTEM_WINDOWS 1) - if(WINDOWS_STORE) - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/winrt/*.cpp") - sdl_sources("${SDL3_SOURCE_DIR}/src/filesystem/windows/SDL_sysfsops.c") - else() - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/windows/*.c") - endif() + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/windows/*.c") set(HAVE_SDL_FILESYSTEM TRUE) set(SDL_FSOPS_WINDOWS 1) @@ -2041,27 +1988,12 @@ elseif(WINDOWS) set(SDL_STORAGE_GENERIC 1) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/storage/generic/*.c") - if(NOT WINDOWS_STORE) - set(SDL_STORAGE_STEAM 1) - sdl_glob_sources("${SDL3_SOURCE_DIR}/src/storage/steam/*.c") - endif() + set(SDL_STORAGE_STEAM 1) + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/storage/steam/*.c") set(HAVE_SDL_STORAGE 1) # Libraries for Win32 native and MinGW - if(NOT WINDOWS_STORE) - sdl_link_dependency(base LIBS kernel32 user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32) - endif() - - if(WINDOWS_STORE) - sdl_link_dependency(windows - LIBS - vccorlib$<$:d>.lib - msvcrt$<$:d>.lib - LINK_OPTIONS - /nodefaultlib:vccorlib$<$:d> - /nodefaultlib:msvcrt$<$:d> - ) - endif() + sdl_link_dependency(base LIBS kernel32 user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32) set(SDL_TIME_WINDOWS 1) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/time/windows/*.c") @@ -2078,7 +2010,7 @@ elseif(WINDOWS) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/core/windows/*.c") if(SDL_VIDEO) - if(SDL_OPENGL AND NOT WINDOWS_STORE) + if(SDL_OPENGL) set(SDL_VIDEO_OPENGL 1) set(SDL_VIDEO_OPENGL_WGL 1) set(SDL_VIDEO_RENDER_OGL 1) @@ -2109,18 +2041,14 @@ elseif(WINDOWS) if(SDL_JOYSTICK) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/windows/*.c") - if(NOT WINDOWS_STORE) - set(SDL_JOYSTICK_RAWINPUT 1) - endif() + set(SDL_JOYSTICK_RAWINPUT 1) if(HAVE_DINPUT_H) set(SDL_JOYSTICK_DINPUT 1) sdl_link_dependency(joystick LIBS dinput8) endif() if(HAVE_XINPUT_H) - if(NOT WINDOWS_STORE) - set(SDL_JOYSTICK_XINPUT 1) - set(HAVE_XINPUT TRUE) - endif() + set(SDL_JOYSTICK_XINPUT 1) + set(HAVE_XINPUT TRUE) endif() if(HAVE_WINDOWS_GAMING_INPUT_H) set(SDL_JOYSTICK_WGI 1) @@ -2132,7 +2060,7 @@ elseif(WINDOWS) set(HAVE_SDL_JOYSTICK TRUE) if(SDL_HAPTIC) - if(HAVE_DINPUT_H AND NOT WINDOWS_STORE) + if(HAVE_DINPUT_H) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/haptic/windows/*.c") set(SDL_HAPTIC_DINPUT 1) set(HAVE_SDL_HAPTIC TRUE) @@ -2141,7 +2069,7 @@ elseif(WINDOWS) endif() if(SDL_CAMERA) - if(HAVE_MFAPI_H AND NOT WINDOWS_STORE) + if(HAVE_MFAPI_H) set(HAVE_CAMERA TRUE) set(SDL_CAMERA_DRIVER_MEDIAFOUNDATION 1) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/camera/mediafoundation/*.c") @@ -2922,7 +2850,7 @@ if (SDL_DIALOG) elseif(HAIKU) sdl_sources(${SDL3_SOURCE_DIR}/src/dialog/haiku/SDL_haikudialog.cc) set(HAVE_SDL_DIALOG TRUE) - elseif(WINDOWS AND NOT WINDOWS_STORE) + elseif(WINDOWS) sdl_sources(${SDL3_SOURCE_DIR}/src/dialog/windows/SDL_windowsdialog.c) set(HAVE_SDL_DIALOG TRUE) elseif(MACOS) @@ -2943,7 +2871,7 @@ if(SDL_VIDEO) endif() endif() -if(SDL_GPU AND NOT WINDOWS_STORE) +if(SDL_GPU) if(HAVE_D3D11_H) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/gpu/d3d11/*.c") set(SDL_GPU_D3D11 1) @@ -3316,7 +3244,7 @@ if(SDL_SHARED) ) endif() if(NOT SDL_LIBC) - if(MSVC AND (NOT MSVC_CLANG AND NOT WINDOWS_STORE)) + if(MSVC AND NOT MSVC_CLANG) # Don't try to link with the default set of libraries. # Note: The clang toolset for Visual Studio does not support /NODEFAULTLIB. target_link_options(SDL3-shared PRIVATE "/NODEFAULTLIB") diff --git a/VisualC-WinRT/SDL-UWP.sln b/VisualC-WinRT/SDL-UWP.sln deleted file mode 100644 index 86bd92dea..000000000 --- a/VisualC-WinRT/SDL-UWP.sln +++ /dev/null @@ -1,69 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.33027.164 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL3-UWP", "SDL-UWP.vcxproj", "{89E9B32E-A86A-47C3-A948-D2B1622925CE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testdraw", "testdraw\testdraw.vcxproj", "{95943BBE-F378-4068-A3FD-DAE1B8309B6E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.ActiveCfg = Debug|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.Build.0 = Debug|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.Build.0 = Debug|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.ActiveCfg = Debug|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.Build.0 = Debug|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.ActiveCfg = Debug|Win32 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.Build.0 = Debug|Win32 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.ActiveCfg = Release|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.Build.0 = Release|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.ActiveCfg = Release|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.Build.0 = Release|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.ActiveCfg = Release|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.Build.0 = Release|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.ActiveCfg = Release|Win32 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.Build.0 = Release|Win32 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM.ActiveCfg = Debug|ARM - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM.Build.0 = Debug|ARM - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM.Deploy.0 = Debug|ARM - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM64.Build.0 = Debug|ARM64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x64.ActiveCfg = Debug|x64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x64.Build.0 = Debug|x64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x64.Deploy.0 = Debug|x64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x86.ActiveCfg = Debug|Win32 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x86.Build.0 = Debug|Win32 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Debug|x86.Deploy.0 = Debug|Win32 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM.ActiveCfg = Release|ARM - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM.Build.0 = Release|ARM - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM.Deploy.0 = Release|ARM - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM64.ActiveCfg = Release|ARM64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM64.Build.0 = Release|ARM64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|ARM64.Deploy.0 = Release|ARM64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x64.ActiveCfg = Release|x64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x64.Build.0 = Release|x64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x64.Deploy.0 = Release|x64 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x86.ActiveCfg = Release|Win32 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x86.Build.0 = Release|Win32 - {95943BBE-F378-4068-A3FD-DAE1B8309B6E}.Release|x86.Deploy.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {30680F51-7BB9-41D0-A0D6-BC44A1557D87} - EndGlobalSection -EndGlobal diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj deleted file mode 100644 index a71477150..000000000 --- a/VisualC-WinRT/SDL-UWP.vcxproj +++ /dev/null @@ -1,932 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - Create - Create - Create - Create - Create - Create - Create - Create - - - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - Create - $(IntDir)$(TargetName)_cpp.pch - true - true - true - true - true - true - true - true - - - - - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing - - - - - - - - - - - - - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - true - true - true - true - true - true - true - true - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NotUsing - - - - - - - - - - - - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - true - true - true - true - true - true - true - true - - - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - true - true - true - true - true - true - true - true - - - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - true - true - true - true - true - true - true - true - - - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - true - true - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - true - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - $(IntDir)$(TargetName)_cpp.pch - - - - - - - {89e9b32e-a86a-47c3-a948-d2b1622925ce} - DynamicLibrary - SDL3-UWP - SDL3 - en-US - 14.0 - true - Windows Store - 8.2 - 10.0.16299.0 - 10.0.16299.0 - 10.0 - - - - DynamicLibrary - true - v142 - - - DynamicLibrary - true - v142 - - - DynamicLibrary - true - v142 - - - DynamicLibrary - true - v142 - - - DynamicLibrary - false - true - v142 - - - DynamicLibrary - false - true - v142 - - - DynamicLibrary - false - true - v142 - - - DynamicLibrary - false - true - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - false - false - SDL3 - $(SolutionDir)/../src;$(IncludePath) - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - Use - false - $(ProjectDir)\..\include;$(ProjectDir)\..\include\build_config;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - SDL_internal.h - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - $(TreatWarningsAsError) - - - - - - - diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters deleted file mode 100644 index e57ee7174..000000000 --- a/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ /dev/null @@ -1,979 +0,0 @@ - - - - - {fa0ff2df-c3d6-498a-96f1-1f88e7ce0da3} - - - {68e1b30b-19ed-4612-93e4-6260c5a979e5} - - - {00004a2523fc69c7128c60648c860000} - - - {0000318d975e0a2867ab1d5727bf0000} - - - {00009e5236c2ac679fe0bc30beb90000} - - - {000031d805439b865ff4550d2f620000} - - - {00004389761f0ae646deb5a3d65f0000} - - - {0000bc587ef6c558d75ce2e620cb0000} - - - {0000948771d0040a6a55997a7f1e0000} - - - {0000012051ca8361c8e1013aee1d0000} - - - {0000c99bfadbbcb05a474a8472910000} - - - {00006680a11742e2b280c6453be80000} - - - - - Header Files - - - API Headers - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - camera - - - camera - - - filesystem - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - main - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - camera\dummy - - - camera - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - dialog - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - filesystem - - - filesystem\windows - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - main\generic - - - main - - - Source Files - - - main\winrt - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - time - - - time\windows - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files - - - - - - Source Files - - - Source Files - - - Source Files - - - stdlib - - - Source Files - - - Source Files - - - diff --git a/VisualC-WinRT/testdraw/Assets/LockScreenLogo.scale-200.png b/VisualC-WinRT/testdraw/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 735f57adb..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/LockScreenLogo.scale-200.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Assets/SplashScreen.scale-200.png b/VisualC-WinRT/testdraw/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1fe..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/SplashScreen.scale-200.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Assets/Square150x150Logo.scale-200.png b/VisualC-WinRT/testdraw/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec1a..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Assets/Square44x44Logo.scale-200.png b/VisualC-WinRT/testdraw/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2ec..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/VisualC-WinRT/testdraw/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce97..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Assets/StoreLogo.png b/VisualC-WinRT/testdraw/Assets/StoreLogo.png deleted file mode 100644 index 7385b56c0..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/StoreLogo.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Assets/Wide310x150Logo.scale-200.png b/VisualC-WinRT/testdraw/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b39..000000000 Binary files a/VisualC-WinRT/testdraw/Assets/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/VisualC-WinRT/testdraw/Package.appxmanifest b/VisualC-WinRT/testdraw/Package.appxmanifest deleted file mode 100644 index 05a4c5750..000000000 --- a/VisualC-WinRT/testdraw/Package.appxmanifest +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - testdraw - Daniel - Assets\StoreLogo.png - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/VisualC-WinRT/testdraw/testdraw.vcxproj b/VisualC-WinRT/testdraw/testdraw.vcxproj deleted file mode 100644 index 86d985dba..000000000 --- a/VisualC-WinRT/testdraw/testdraw.vcxproj +++ /dev/null @@ -1,335 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - Debug - ARM64 - - - Release - ARM64 - - - - {95943bbe-f378-4068-a3fd-dae1b8309b6e} - DirectXApp - testdraw - en-US - 14.0 - true - Windows Store - 10.0.19041.0 - 10.0.17763.0 - 10.0 - false - - - - Application - true - v142 - - - Application - true - v142 - - - Application - true - v142 - true - - - Application - true - v142 - - - Application - false - true - v142 - true - - - Application - false - true - v142 - true - - - Application - false - true - v142 - true - - - Application - false - true - v142 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - _DEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - NDEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm64; $(VCInstallDir)\lib\arm64 - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - _DEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm64; $(VCInstallDir)\lib\arm64 - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - NDEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - _DEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - NDEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - _DEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) - %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - pch.h - $(IntDir)pch.pch - $(ProjectDir);$(IntermediateOutputPath);..\..\include - /bigobj %(AdditionalOptions) - 4453;28204 - NDEBUG;%(PreprocessorDefinitions) - false - NotUsing - - - - - $(TreatWarningsAsError) - - - - - - - - - - - - - - Designer - - - - - {89e9b32e-a86a-47c3-a948-d2b1622925ce} - - - - - - - - - - - - - - - true - true - true - true - true - true - true - true - - - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - diff --git a/VisualC-WinRT/testdraw/testdraw.vcxproj.filters b/VisualC-WinRT/testdraw/testdraw.vcxproj.filters deleted file mode 100644 index 2640e2a47..000000000 --- a/VisualC-WinRT/testdraw/testdraw.vcxproj.filters +++ /dev/null @@ -1,85 +0,0 @@ - - - - - 95943bbe-f378-4068-a3fd-dae1b8309b6e - - - dad3d573-ab33-428d-ae70-6098066c27e7 - bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png - - - e4caa635-e149-44c2-8915-48ffa6ac48f7 - - - Assets - - - Assets - - - Assets - - - Assets - - - Assets - - - Assets - - - - - Assets - - - - - - - - Content - - - Content - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - - - - - - - diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index 10b055a0f..95f252f38 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -3117,11 +3117,6 @@ typedef SDL_Colour, SDL_Color; + SDL_Color @@ @@ -- SDL_WinRTGetFSPathUTF8 -+ SDL_GetWinRTFSPath - (...) -@@ -@@ - SDL_iPhoneSetAnimationCallback + SDL_SetiOSAnimationCallback (...) @@ -3527,11 +3522,6 @@ typedef SDL_Colour, SDL_Color; (...) @@ @@ -- SDL_WinRTGetDeviceFamily -+ SDL_GetWinRTDeviceFamily - (...) -@@ -@@ - SDL_LinuxSetThreadPriority + SDL_SetLinuxThreadPriority (...) diff --git a/build-scripts/add-source-to-projects.pl b/build-scripts/add-source-to-projects.pl index 6d703dc36..5ba0a6975 100755 --- a/build-scripts/add-source-to-projects.pl +++ b/build-scripts/add-source-to-projects.pl @@ -591,7 +591,6 @@ foreach (@ARGV) { process_xcode($arg, 'Xcode/SDL/SDL.xcodeproj/project.pbxproj'); process_visualstudio($arg, 'VisualC/SDL/SDL.vcxproj'); process_visualstudio($arg, 'VisualC-GDK/SDL/SDL.vcxproj'); - process_visualstudio($arg, 'VisualC-WinRT/SDL-UWP.vcxproj'); } print("Done. Please run `git diff` and make sure this looks okay!\n"); diff --git a/build-scripts/rename_macros.py b/build-scripts/rename_macros.py index 913b10e5f..ba386cd41 100755 --- a/build-scripts/rename_macros.py +++ b/build-scripts/rename_macros.py @@ -129,7 +129,6 @@ RENAMED_MACROS = { "__VITA__": "SDL_PLATFORM_VITA", "__3DS__": "SDL_PLATFORM_3DS", # "__unix__": "SDL_PLATFORM_UNIX, - "__WINRT__": "SDL_PLATFORM_WINRT", "__XBOXSERIES__": "SDL_PLATFORM_XBOXSERIES", "__XBOXONE__": "SDL_PLATFORM_XBOXONE", "__WINDOWS__": "SDL_PLATFORM_WINDOWS", @@ -145,6 +144,7 @@ DEPRECATED_PLATFORM_MACROS = { "__NACL__", "__PNACL__", "__WINDOWS__", + "__WINRT__", "SDL_ALTIVEC_BLITTERS", "SDL_ARM_NEON_BLITTERS", "SDL_ARM_SIMD_BLITTERS", diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index faa79e657..e3766f0e1 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -21,12 +21,6 @@ endif() message(STATUS "CMAKE_SYSTEM_NAME= ${CMAKE_SYSTEM_NAME}") message(STATUS "CMAKE_SYSTEM_PROCESSOR= ${CMAKE_SYSTEM_PROCESSOR}") -if(WINDOWS_STORE) - enable_language(CXX) - add_compile_options("$<$:/ZW>") - set_source_files_properties(ain_cli.c main_gui.c PROPERTIES LANGUAGE CXX) -endif() - include(GenerateExportHeader) if(ANDROID) diff --git a/docs/README-migration.md b/docs/README-migration.md index 29a5bbce6..4be0642b9 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -836,6 +836,9 @@ The following hints have been removed: * SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING - SDL now properly handles the 0x406D1388 Exception if no debugger intercepts it, preventing its propagation. * SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS - Slim Reader/Writer Locks are always used if available * SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 - replaced with SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, defaulting to SDL_TRUE +* SDL_HINT_WINRT_HANDLE_BACK_BUTTON - WinRT support was removed in SDL3. +* SDL_HINT_WINRT_PRIVACY_POLICY_LABEL - WinRT support was removed in SDL3. +* SDL_HINT_WINRT_PRIVACY_POLICY_URL - WinRT support was removed in SDL3. * SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING * SDL_HINT_AUDIO_DEVICE_APP_NAME - replaced by either using the appname param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_NAME_STRING with SDL_SetAppMetadataProperty() @@ -1118,11 +1121,14 @@ Using it is really simple: Just `#include ` in the source file Several platform-specific entry point functions have been removed as unnecessary. If for some reason you explicitly need them, here are easy replacements: ```c -#define SDL_WinRTRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED) #define SDL_UIKitRunApp(ARGC, ARGV, MAIN_FUNC) SDL_RunApp(ARGC, ARGV, MAIN_FUNC, NULL) #define SDL_GDKRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED) ``` +The following functions have been removed: +* SDL_WinRTRunApp() - WinRT support was removed in SDL3. + + ## SDL_messagebox.h The buttonid field of SDL_MessageBoxButtonData has been renamed buttonID. @@ -1275,7 +1281,6 @@ The following platform preprocessor macros have been renamed: | `__VITA__` | `SDL_PLATFORM_VITA` | | `__WIN32__` | `SDL_PLATFORM_WIN32` | | `__WINGDK__` | `SDL_PLATFORM_WINGDK` | -| `__WINRT__` | `SDL_PLATFORM_WINRT` | | `__XBOXONE__` | `SDL_PLATFORM_XBOXONE` | | `__XBOXSERIES__` | `SDL_PLATFORM_XBOXSERIES` | @@ -1288,6 +1293,8 @@ The following platform preprocessor macros have been removed: * `__NACL__` * `__PNACL__` * `__WINDOWS__` +* `__WINRT__` + ## SDL_quit.h @@ -1850,10 +1857,12 @@ SDL_RequestAndroidPermission is no longer a blocking call; the caller now provid SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() have been renamed to SDL_SetiOSAnimationCallback() and SDL_SetiOSEventPump(), respectively. SDL2 has had macros to provide this new name with the old symbol since the introduction of the iPad, but now the correctly-named symbol is the only option. The following functions have been removed: +* SDL_GetWinRTFSPathUNICODE() - WinRT support was removed in SDL3. +* SDL_GetWinRTFSPathUTF8() - WinRT support was removed in SDL3. * SDL_RenderGetD3D11Device() - replaced with the "SDL.renderer.d3d11.device" property * SDL_RenderGetD3D12Device() - replaced with the "SDL.renderer.d3d12.device" property * SDL_RenderGetD3D9Device() - replaced with the "SDL.renderer.d3d9.device" property -* SDL_GetWinRTFSPathUNICODE() - Use SDL_GetWinRTFSPath() and SDL_iconv_string to convert from UTF-8 to UTF-16. +* SDL_WinRTGetDeviceFamily() - WinRT support was removed in SDL3. The following functions have been renamed: * SDL_AndroidBackButton() => SDL_SendAndroidBackButton() @@ -1874,8 +1883,6 @@ The following functions have been renamed: * SDL_LinuxSetThreadPriorityAndPolicy() => SDL_SetLinuxThreadPriorityAndPolicy(), returns SDL_bool * SDL_OnApplicationDidBecomeActive() => SDL_OnApplicationDidEnterForeground() * SDL_OnApplicationWillResignActive() => SDL_OnApplicationWillEnterBackground() -* SDL_WinRTGetDeviceFamily() => SDL_GetWinRTDeviceFamily() -* SDL_GetWinRTFSPathUTF8() => SDL_GetWinRTFSPath() * SDL_iOSSetAnimationCallback() => SDL_SetiOSAnimationCallback(), returns SDL_bool * SDL_iOSSetEventPump() => SDL_SetiOSEventPump() * SDL_iPhoneSetAnimationCallback() => SDL_SetiOSAnimationCallback(), returns SDL_bool diff --git a/docs/README-porting.md b/docs/README-porting.md index db6b61413..ada1d67cb 100644 --- a/docs/README-porting.md +++ b/docs/README-porting.md @@ -5,7 +5,7 @@ Porting The first thing you have to do when porting to a new platform, is look at include/SDL_platform.h and create an entry there for your operating system. -The standard format is "__PLATFORM__", where PLATFORM is the name of the OS. +The standard format is "SDL_PLATFORM_X", where X is the name of the OS. Ideally SDL_platform_defines.h will be able to auto-detect the system it's building on based on C preprocessor symbols. diff --git a/docs/README-windows.md b/docs/README-windows.md index daf80647f..ced972eeb 100644 --- a/docs/README-windows.md +++ b/docs/README-windows.md @@ -1,5 +1,11 @@ # Windows +## Old systems + +WinRT, Windows Phone, and UWP are no longer supported. + +All desktop Windows versions, back to Windows XP, are still supported. + ## LLVM and Intel C++ compiler support SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++ diff --git a/docs/README-winrt.md b/docs/README-winrt.md deleted file mode 100644 index 45ce80a4c..000000000 --- a/docs/README-winrt.md +++ /dev/null @@ -1,483 +0,0 @@ -WinRT -===== - -This port allows SDL applications to run on Microsoft's platforms that require -use of "Windows Runtime", aka. "WinRT", APIs. Microsoft may, in some cases, -refer to them as either "Windows Store", or for Windows 10, "UWP" apps. - -In the past, SDL has supported Windows RT 8.x, Windows Phone, etc, but in -modern times this port is focused on UWP apps, which run on Windows 10, -and modern Xbox consoles. - - -Requirements ------------- - -* Microsoft Visual C++ (aka Visual Studio) 2019. - - Free, "Community" or "Express" editions may be used, so long as they - include support for either "Windows Store" or "Windows Phone" apps. - "Express" versions marked as supporting "Windows Desktop" development - typically do not include support for creating WinRT apps, to note. - (The "Community" editions of Visual C++ do, however, support both - desktop/Win32 and WinRT development). -* A valid Microsoft account - This requirement is not imposed by SDL, but - rather by Microsoft's Visual C++ toolchain. This is required to launch or - debug apps. - - -Status ------- - -Here is a rough list of what works, and what doesn't: - -* What works: - * compilation via Visual C++ 2019. - * compile-time platform detection for SDL programs. The C/C++ #define, - `SDL_PLATFORM_WINRT`, will be set to 1 (by SDL) when compiling for WinRT. - * GPU-accelerated 2D rendering, via SDL_Renderer. - * OpenGL ES 2, via the ANGLE library (included separately from SDL) - * software rendering, via either SDL_Surface (optionally in conjunction with - SDL_GetWindowSurface() and SDL_UpdateWindowSurface()) or via the - SDL_Renderer APIs - * threads - * timers (via SDL_GetTicks(), SDL_AddTimer(), SDL_GetPerformanceCounter(), - SDL_GetPerformanceFrequency(), etc.) - * file I/O via SDL_IOStream - * mouse input (unsupported on Windows Phone) - * audio, via SDL's WASAPI backend (if you want to record, your app must - have "Microphone" capabilities enabled in its manifest, and the user must - not have blocked access. Otherwise, recording devices will fail to work, - presenting as a device disconnect shortly after opening it.) - * .DLL file loading. Libraries *MUST* be packaged inside applications. Loading - anything outside of the app is not supported. - * system path retrieval via SDL's filesystem APIs - * game controllers. Support is provided via the SDL_Joystick and - SDL_Gamepad APIs, and is backed by Microsoft's XInput API. Please - note, however, that Windows limits game-controller support in UWP apps to, - "Xbox compatible controllers" (many controllers that work in Win32 apps, - do not work in UWP, due to restrictions in UWP itself.) - * multi-touch input - * app events. SDL_APP_WILLENTER* and SDL_APP_DIDENTER* events get sent out as - appropriate. - * window events - * using Direct3D 11.x APIs outside of SDL. Non-XAML / Direct3D-only apps can - choose to render content directly via Direct3D, using SDL to manage the - internal WinRT window, as well as input and audio. (Use - the window properties to get the WinRT 'CoreWindow', and pass it into - IDXGIFactory2::CreateSwapChainForCoreWindow() as appropriate.) - -* What partially works: - * keyboard input. Most of WinRT's documented virtual keys are supported, as - well as many keys with documented hardware scancodes. Converting - SDL_Scancodes to or from SDL_Keycodes may not work, due to missing APIs - (MapVirtualKey()) in Microsoft's Windows Store / UWP APIs. - * SDL_main. WinRT uses a different signature for each app's main() function - and requires it to be implemented in C++, so SDL_main.h must be #include'd - in a C++ source file, that also must be compiled with /ZW. - -* What doesn't work: - * compilation with anything other than Visual C++ - * programmatically-created custom cursors. These don't appear to be supported - by WinRT. Different OS-provided cursors can, however, be created via - SDL_CreateSystemCursor() (unsupported on Windows Phone) - * SDL_WarpMouseInWindow() or SDL_WarpMouseGlobal(). This are not currently - supported by WinRT itself. - * joysticks and game controllers that either are not supported by - Microsoft's XInput API, or are not supported within UWP apps (many - controllers that work in Win32, do not work in UWP, due to restrictions in - UWP itself). - * turning off VSync when rendering on Windows Phone. Attempts to turn VSync - off on Windows Phone result either in Direct3D not drawing anything, or it - forcing VSync back on. As such, vsync will always get turned-on on Windows - Phone. This limitation is not present in non-Phone WinRT (such as Windows 8.x), - where turning off VSync appears to work. - * probably anything else that's not listed as supported - - - -Setup, High-Level Steps ------------------------ - -The steps for setting up a project for an SDL/WinRT app looks like the -following, at a high-level: - -1. create a new Visual C++ project using Microsoft's template for a, - "Direct3D App". -2. remove most of the files from the project. -3. make your app's project directly reference SDL/WinRT's own Visual C++ - project file, via use of Visual C++'s "References" dialog. This will setup - the linker, and will copy SDL's .dll files to your app's final output. -4. adjust your app's build settings, at minimum, telling it where to find SDL's - header files. -5. add files that contains a WinRT-appropriate main function, along with some - data to make sure mouse-cursor-hiding (via SDL_ShowCursor(SDL_DISABLE) calls) - work properly. -6. add SDL-specific app code. -7. build and run your app. - - -Setup, Detailed Steps ---------------------- - -### 1. Create a new project ### - -Create a new project using one of Visual C++'s templates for a plain, non-XAML, -"Direct3D App" (XAML support for SDL/WinRT is not yet ready for use). If you -don't see one of these templates, in Visual C++'s 'New Project' dialog, try -using the textbox titled, 'Search Installed Templates' to look for one. - - -### 2. Remove unneeded files from the project ### - -In the new project, delete any file that has one of the following extensions: - -- .cpp -- .h -- .hlsl - -When you are done, you should be left with a few files, each of which will be a -necessary part of your app's project. These files will consist of: - -- an .appxmanifest file, which contains metadata on your WinRT app. This is - similar to an Info.plist file on iOS, or an AndroidManifest.xml on Android. -- a few .png files, one of which is a splash screen (displayed when your app - launches), others are app icons. -- a .pfx file, used for code signing purposes. - - -### 3. Add references to SDL's project files ### - -SDL/WinRT can be built in multiple variations, spanning across three different -CPU architectures (x86, x64, and ARM) and two different configurations -(Debug and Release). WinRT and Visual C++ do not currently provide a means -for combining multiple variations of one library into a single file. -Furthermore, it does not provide an easy means for copying pre-built .dll files -into your app's final output (via Post-Build steps, for example). It does, -however, provide a system whereby an app can reference the MSVC projects of -libraries such that, when the app is built: - -1. each library gets built for the appropriate CPU architecture(s) and WinRT - platform(s). -2. each library's output, such as .dll files, get copied to the app's build - output. - -To set this up for SDL/WinRT, you'll need to run through the following steps: - -1. open up the Solution Explorer inside Visual C++ (under the "View" menu, then - "Solution Explorer") -2. right click on your app's solution. -3. navigate to "Add", then to "Existing Project..." -4. find SDL/WinRT's Visual C++ project file and open it, in the `VisualC-WinRT` - directory. -5. once the project has been added, right-click on your app's project and - select, "References..." -6. click on the button titled, "Add New Reference..." -7. check the box next to SDL -8. click OK to close the dialog -9. SDL will now show up in the list of references. Click OK to close that - dialog. - -Your project is now linked to SDL's project, insofar that when the app is -built, SDL will be built as well, with its build output getting included with -your app. - - -### 4. Adjust Your App's Build Settings ### - -Some build settings need to be changed in your app's project. This guide will -outline the following: - -- making sure that the compiler knows where to find SDL's header files -- **Optional for C++, but NECESSARY for compiling C code:** telling the - compiler not to use Microsoft's C++ extensions for WinRT development. -- **Optional:** telling the compiler not generate errors due to missing - precompiled header files. - -To change these settings: - -1. right-click on the project -2. choose "Properties" -3. in the drop-down box next to "Configuration", choose, "All Configurations" -4. in the drop-down box next to "Platform", choose, "All Platforms" -5. in the left-hand list, expand the "C/C++" section - **Note:** If you don't see this section, you may have to add a .c or .cpp - Source file to the Project first. -6. select "General" -7. edit the "Additional Include Directories" setting, and add a path to SDL's - "include" directory -8. **Optional: to enable compilation of C code:** change the setting for - "Consume Windows Runtime Extension" from "Yes (/ZW)" to "No". If you're - working with a completely C++ based project, this step can usually be - omitted. -9. **Optional: to disable precompiled headers (which can produce - 'stdafx.h'-related build errors, if setup incorrectly:** in the left-hand - list, select "Precompiled Headers", then change the setting for "Precompiled - Header" from "Use (/Yu)" to "Not Using Precompiled Headers". -10. close the dialog, saving settings, by clicking the "OK" button - - -### 5. Add a WinRT-appropriate main function, and a blank-cursor image, to the app. ### - -A few files should be included directly in your app's MSVC project, specifically: -1. a WinRT-appropriate main function (which is different than main() functions on - other platforms) -2. a Win32-style cursor resource, used by SDL_ShowCursor() to hide the mouse cursor - (if and when the app needs to do so). *If this cursor resource is not - included, mouse-position reporting may fail if and when the cursor is - hidden, due to possible bugs/design-oddities in Windows itself.* - -To include these files for C/C++ projects: - -1. right-click on your project (again, in Visual C++'s Solution Explorer), - navigate to "Add", then choose "Existing Item...". -2. navigate to the directory containing SDL's source code, then into its - subdirectory, 'src/main/winrt/'. Select, then add, the following files: - - `SDL3-WinRTResources.rc` - - `SDL3-WinRTResource_BlankCursor.cur` -3. For the next step you need a C++ source file. - - If your standard main() function is implemented in a **C++** source file, - use that file. - - If your standard main() function is implemented in a **plain C** source file, - create an empty .cpp source file (e.g. `main.cpp`) that only contains the line - `#include ` and use that file instead. -4. Right click on the C++ source file from step 3 (as listed in your project), - then click on "Properties...". -5. in the drop-down box next to "Configuration", choose, "All Configurations" -6. in the drop-down box next to "Platform", choose, "All Platforms" -7. in the left-hand list, click on "C/C++" -8. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)". -9. click the OK button. This will close the dialog. - -**NOTE: C++/CX compilation is currently required in at least one file of your -app's project. This is to make sure that Visual C++'s linker builds a 'Windows -Metadata' file (.winmd) for your app. Not doing so can lead to build errors.** - -For non-C++ projects, you will need to call SDL_RunApp from your language's -main function, and generate SDL3-WinRTResources.res manually by using `rc` via -the Developer Command Prompt and including it as a within the -first block in your Visual Studio project file. - -### 6. Add app code and assets ### - -At this point, you can add in SDL-specific source code. Be sure to include a -C-style main function (ie: `int main(int argc, char *argv[])`). From there you -should be able to create a single `SDL_Window` (WinRT apps can only have one -window, at present), as well as an `SDL_Renderer`. Direct3D will be used to -draw content. Events are received via SDL's usual event functions -(`SDL_PollEvent`, etc.) If you have a set of existing source files and assets, -you can start adding them to the project now. If not, or if you would like to -make sure that you're setup correctly, some short and simple sample code is -provided below. - - -#### 6.A. ... when creating a new app #### - -If you are creating a new app (rather than porting an existing SDL-based app), -or if you would just like a simple app to test SDL/WinRT with before trying to -get existing code working, some working SDL/WinRT code is provided below. To -set this up: - -1. right click on your app's project -2. select Add, then New Item. An "Add New Item" dialog will show up. -3. from the left-hand list, choose "Visual C++" -4. from the middle/main list, choose "C++ File (.cpp)" -5. near the bottom of the dialog, next to "Name:", type in a name for your -source file, such as, "main.cpp". -6. click on the Add button. This will close the dialog, add the new file to -your project, and open the file in Visual C++'s text editor. -7. Copy and paste the following code into the new file, then save it. - -```c -#include -#include - -int main(int argc, char **argv) -{ - SDL_Window *window = NULL; - SDL_Renderer *renderer = NULL; - SDL_Event evt; - SDL_bool keep_going = SDL_TRUE; - - if (!SDL_Init(SDL_INIT_VIDEO)) { - return 1; - } else if (!SDL_CreateWindowAndRenderer("Hello SDL", 0, 0, SDL_WINDOW_FULLSCREEN, &window, &renderer)) { - return 1; - } - - while (keep_going) { - while (SDL_PollEvent(&evt)) { - if ((evt.type == SDL_EVENT_KEY_DOWN) && (evt.key.keysym.sym == SDLK_ESCAPE)) { - keep_going = SDL_FALSE; - } - } - - SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - } - - SDL_Quit(); - return 0; -} -``` - -#### 6.B. Adding code and assets #### - -If you have existing code and assets that you'd like to add, you should be able -to add them now. The process for adding a set of files is as such. - -1. right click on the app's project -2. select Add, then click on "New Item..." -3. open any source, header, or asset files as appropriate. Support for C and -C++ is available. - -Do note that WinRT only supports a subset of the APIs that are available to -Win32-based apps. Many portions of the Win32 API and the C runtime are not -available. - -A list of unsupported C APIs can be found at - - -General information on using the C runtime in WinRT can be found at - - -A list of supported Win32 APIs for WinRT apps can be found at -. To note, -the list of supported Win32 APIs for Windows Phone 8.0 is different. -That list can be found at - - - -### 7. Build and run your app ### - -Your app project should now be setup, and you should be ready to build your app. -To run it on the local machine, open the Debug menu and choose "Start -Debugging". This will build your app, then run your app full-screen. To switch -out of your app, press the Windows key. Alternatively, you can choose to run -your app in a window. To do this, before building and running your app, find -the drop-down menu in Visual C++'s toolbar that says, "Local Machine". Expand -this by clicking on the arrow on the right side of the list, then click on -Simulator. Once you do that, any time you build and run the app, the app will -launch in window, rather than full-screen. - - -#### 7.A. Running apps on older, ARM-based, "Windows RT" devices #### - -**These instructions do not include Windows Phone, despite Windows Phone -typically running on ARM processors.** They are specifically for devices -that use the "Windows RT" operating system, which was a modified version of -Windows 8.x that ran primarily on ARM-based tablet computers. - -To build and run the app on ARM-based, "Windows RT" devices, you'll need to: - -- install Microsoft's "Remote Debugger" on the device. Visual C++ installs and - debugs ARM-based apps via IP networks. -- change a few options on the development machine, both to make sure it builds - for ARM (rather than x86 or x64), and to make sure it knows how to find the - Windows RT device (on the network). - -Microsoft's Remote Debugger can be found at -. Please note -that separate versions of this debugger exist for different versions of Visual -C++, one each for MSVC 2015, 2013, and 2012. - -To setup Visual C++ to launch your app on an ARM device: - -1. make sure the Remote Debugger is running on your ARM device, and that it's on - the same IP network as your development machine. -2. from Visual C++'s toolbar, find a drop-down menu that says, "Win32". Click - it, then change the value to "ARM". -3. make sure Visual C++ knows the hostname or IP address of the ARM device. To - do this: - 1. open the app project's properties - 2. select "Debugging" - 3. next to "Machine Name", enter the hostname or IP address of the ARM - device - 4. if, and only if, you've turned off authentication in the Remote Debugger, - then change the setting for "Require Authentication" to No - 5. click "OK" -4. build and run the app (from Visual C++). The first time you do this, a - prompt will show up on the ARM device, asking for a Microsoft Account. You - do, unfortunately, need to log in here, and will need to follow the - subsequent registration steps in order to launch the app. After you do so, - if the app didn't already launch, try relaunching it again from within Visual - C++. - - -Troubleshooting ---------------- - -#### Build fails with message, "error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'" - -Try adding the following to your linker flags. In MSVC, this can be done by -right-clicking on the app project, navigating to Configuration Properties -> -Linker -> Command Line, then adding them to the Additional Options -section. - -* For Release builds / MSVC-Configurations, add: - - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib - -* For Debug builds / MSVC-Configurations, add: - - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib - - -#### Mouse-motion events fail to get sent, or SDL_GetMouseState() fails to return updated values - -This may be caused by a bug in Windows itself, whereby hiding the mouse -cursor can cause mouse-position reporting to fail. - -SDL provides a workaround for this, but it requires that an app links to a -set of Win32-style cursor image-resource files. A copy of suitable resource -files can be found in `src/main/winrt/`. Adding them to an app's Visual C++ -project file should be sufficient to get the app to use them. - - -#### SDL's Visual Studio project file fails to open, with message, "The system can't find the file specified." - -This can be caused for any one of a few reasons, which Visual Studio can -report, but won't always do so in an up-front manner. - -To help determine why this error comes up: - -1. open a copy of Visual Studio without opening a project file. This can be - accomplished via Windows' Start Menu, among other means. -2. show Visual Studio's Output window. This can be done by going to VS' - menu bar, then to View, and then to Output. -3. try opening the SDL project file directly by going to VS' menu bar, then - to File, then to Open, then to Project/Solution. When a File-Open dialog - appears, open the SDL project (such as the one in SDL's source code, in its - directory, VisualC-WinRT/UWP_VS2015/). -4. after attempting to open SDL's Visual Studio project file, additional error - information will be output to the Output window. - -If Visual Studio reports (via its Output window) that the project: - -"could not be loaded because it's missing install components. To fix this launch Visual Studio setup with the following selections: -Microsoft.VisualStudio.ComponentGroup.UWP.VC" - -... then you will need to re-launch Visual Studio's installer, and make sure that -the workflow for "Universal Windows Platform development" is checked, and that its -optional component, "C++ Universal Windows Platform tools" is also checked. While -you are there, if you are planning on targeting UWP / Windows 10, also make sure -that you check the optional component, "Windows 10 SDK (10.0.10240.0)". After -making sure these items are checked as-appropriate, install them. - -Once you install these components, try re-launching Visual Studio, and re-opening -the SDL project file. If you still get the error dialog, try using the Output -window, again, seeing what Visual Studio says about it. - - -#### Game controllers / joysticks aren't working! - -Windows only permits certain game controllers and joysticks to work within -WinRT / UWP apps. Even if a game controller or joystick works in a Win32 -app, that device is not guaranteed to work inside a WinRT / UWP app. - -According to Microsoft, "Xbox compatible controllers" should work inside -UWP apps, potentially with more working in the future. This includes, but -may not be limited to, Microsoft-made Xbox controllers and USB adapters. -(Source: https://social.msdn.microsoft.com/Forums/en-US/9064838b-e8c3-4c18-8a83-19bf0dfe150d/xinput-fails-to-detect-game-controllers?forum=wpdevelop) - - diff --git a/docs/README.md b/docs/README.md index a94fdd3cf..812d3ce65 100644 --- a/docs/README.md +++ b/docs/README.md @@ -48,7 +48,6 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd - [Raspberry Pi](README-raspberrypi.md) - [RISC OS](README-riscos.md) - [Windows GDK](README-gdk.md) -- [Windows UWP](README-winrt.md) - [Windows](README-windows.md) If you need help with the library, or just want to discuss SDL related diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index acbd1d112..e3527d087 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,12 +23,6 @@ if(NOT (MSVC AND SDL_CPU_ARM64)) find_package(OpenGL) endif() -if(WINDOWS_STORE) - cmake_minimum_required(VERSION 3.19) - # CMP0112: Target file component generator expressions do not add target dependencies. - cmake_policy(SET CMP0112 NEW) -endif() - set(SDL_EXAMPLE_EXECUTABLES) if(CMAKE_RUNTIME_OUTPUT_DIRECTORY) @@ -62,15 +56,6 @@ add_custom_target(copy-sdl-example-resources DEPENDS "${RESOURCE_FILES_BINDIR}" ) -if(WINDOWS_STORE) - add_library(sdl_example_main_callbacks_uwp OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/../test/main.cpp) - target_link_libraries(sdl_example_main_callbacks_uwp PRIVATE SDL3::Headers) - target_compile_options(sdl_example_main_callbacks_uwp PRIVATE "/ZW") - target_compile_definitions(sdl_example_main_callbacks_uwp PRIVATE "SDL_MAIN_USE_CALLBACKS") - - set_source_files_properties(${RESOURCE_FILES} PROPERTIES VS_DEPLOYENT_LOCATION "Assets") -endif() - macro(add_sdl_example_executable TARGET) cmake_parse_arguments(AST "BUILD_DEPENDENT" "" "SOURCES;DATAFILES" ${ARGN}) if(AST_UNPARSED_ARGUMENTS) @@ -80,28 +65,6 @@ macro(add_sdl_example_executable TARGET) message(FATAL_ERROR "add_sdl_example_executable needs at least one source") endif() set(EXTRA_SOURCES "") - if(WINDOWS_STORE) - set(uwp_bindir "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.dir") - if(NOT IS_DIRECTORY "${uwp_bindir}") - execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${uwp_bindir}") - endif() - string(REGEX REPLACE "[_]" "" SAFE_TARGET "${TARGET}") - file(GENERATE OUTPUT "${uwp_bindir}/${TARGET}.appxmanifest" - INPUT "${CMAKE_CURRENT_SOURCE_DIR}/../test/uwp/Package.appxmanifest.in" - TARGET "${TARGET}" - ) - set_property(SOURCE "${uwp_bindir}/${TARGET}.appxmanifest" PROPERTY VS_DEPLOYMENT_CONTENT 1) - - list(APPEND EXTRA_SOURCES "$") - - list(APPEND EXTRA_SOURCES - "${uwp_bindir}/${TARGET}.appxmanifest" - "${CMAKE_CURRENT_SOURCE_DIR}/../test/uwp/logo-50x50.png" - "${CMAKE_CURRENT_SOURCE_DIR}/../test/uwp/square-44x44.png" - "${CMAKE_CURRENT_SOURCE_DIR}/../test/uwp/square-150x150.png" - "${CMAKE_CURRENT_SOURCE_DIR}/../test/uwp/splash-620x300.png" - ) - endif() if(AST_DATAFILES) list(APPEND EXTRA_SOURCES ${DATAFILES}) endif() @@ -122,17 +85,6 @@ macro(add_sdl_example_executable TARGET) COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${AST_DATAFILES} $/sdl-${TARGET} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) - elseif(WINDOWS_STORE) - # MSVC does build the dependent targets (or POST_BUILD commands) when building an application - # after starting to debug. By copying the resources in a custom target, the files can be copied afterwards. - # FIXME: find out proper way to add assets to UWP package - cmake_minimum_required(VERSION 3.19) - add_custom_target(zzz-resources-copy-${TARGET} - COMMAND ${CMAKE_COMMAND} -E make_directory "$/AppX" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${AST_DATAFILES} "$/AppX" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - ) - add_dependencies(${TARGET} zzz-resources-copy-${TARGET}) else() add_dependencies(${TARGET} copy-sdl-example-resources) endif() @@ -156,20 +108,7 @@ macro(add_sdl_example_executable TARGET) endif() elseif(PSP) target_link_libraries(${TARGET} PRIVATE GL) - endif() - if(WINDOWS_STORE) - target_compile_definitions(${TARGET} PRIVATE "SDL_MAIN_NOIMPL") - set_property(TARGET ${TARGET} PROPERTY WIN32_EXECUTABLE TRUE) - set_property(TARGET ${TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${uwp_bindir}") - target_link_options(${TARGET} PRIVATE - -nodefaultlib:vccorlib$<$:d> - -nodefaultlib:msvcrt$<$:d> - vccorlib$<$:d>.lib - msvcrt$<$:d>.lib - ) - endif() - - if(EMSCRIPTEN) + elseif(EMSCRIPTEN) set_property(TARGET ${TARGET} PROPERTY SUFFIX ".html") endif() diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h index ff5ba0273..2a38fc04b 100644 --- a/include/SDL3/SDL_begin_code.h +++ b/include/SDL3/SDL_begin_code.h @@ -53,7 +53,7 @@ /* Some compilers use a special export keyword */ #ifndef SDL_DECLSPEC -# if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_CYGWIN) || defined(SDL_PLATFORM_GDK) +# if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_CYGWIN) || defined(SDL_PLATFORM_GDK) # ifdef DLL_EXPORT # define SDL_DECLSPEC __declspec(dllexport) # else @@ -70,7 +70,7 @@ /* By default SDL uses the C calling convention */ #ifndef SDLCALL -#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) && !defined(__GNUC__) +#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(__GNUC__) #define SDLCALL __cdecl #else #define SDLCALL diff --git a/include/SDL3/SDL_filesystem.h b/include/SDL3/SDL_filesystem.h index 5faa244b8..553f56b6c 100644 --- a/include/SDL3/SDL_filesystem.h +++ b/include/SDL3/SDL_filesystem.h @@ -143,19 +143,19 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetPrefPath(const char *org, const char * * * The folders supported per platform are: * - * | | Windows | WinRT/UWP |macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten | - * | ----------- | ------- | --------- |--------- | ---- | ---------- | ----- | ---------- | - * | HOME | X | X | X | | X | X | X | - * | DESKTOP | X | X | X | | X | X | | - * | DOCUMENTS | X | X | X | | X | | | - * | DOWNLOADS | Vista+ | X | X | | X | | | - * | MUSIC | X | X | X | | X | | | - * | PICTURES | X | X | X | | X | | | - * | PUBLICSHARE | | | X | | X | | | - * | SAVEDGAMES | Vista+ | | | | | | | - * | SCREENSHOTS | Vista+ | X | | | | | | - * | TEMPLATES | X | X | X | | X | | | - * | VIDEOS | X | X | X* | | X | | | + * | | Windows | macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten | + * | ----------- | ------- | --------- | ---- | ---------- | ----- | ---------- | + * | HOME | X | X | | X | X | X | + * | DESKTOP | X | X | | X | X | | + * | DOCUMENTS | X | X | | X | | | + * | DOWNLOADS | Vista+ | X | | X | | | + * | MUSIC | X | X | | X | | | + * | PICTURES | X | X | | X | | | + * | PUBLICSHARE | | X | | X | | | + * | SAVEDGAMES | Vista+ | | | | | | + * | SCREENSHOTS | Vista+ | | | | | | + * | TEMPLATES | X | X | | X | | | + * | VIDEOS | X | X* | | X | | | * * Note that on macOS/iOS, the Videos folder is called "Movies". * diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h index 708c329db..6a376f0c4 100644 --- a/include/SDL3/SDL_hints.h +++ b/include/SDL3/SDL_hints.h @@ -3938,119 +3938,6 @@ extern "C" { */ #define SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE "SDL_WINDOWS_ERASE_BACKGROUND_MODE" -/** - * A variable controlling whether back-button-press events on Windows Phone to - * be marked as handled. - * - * Windows Phone devices typically feature a Back button. When pressed, the OS - * will emit back-button-press events, which apps are expected to handle in an - * appropriate manner. If apps do not explicitly mark these events as - * 'Handled', then the OS will invoke its default behavior for unhandled - * back-button-press events, which on Windows Phone 8 and 8.1 is to terminate - * the app (and attempt to switch to the previous app, or to the device's home - * screen). - * - * Setting the SDL_HINT_WINRT_HANDLE_BACK_BUTTON hint to "1" will cause SDL to - * mark back-button-press events as Handled, if and when one is sent to the - * app. - * - * Internally, Windows Phone sends back button events as parameters to special - * back-button-press callback functions. Apps that need to respond to - * back-button-press events are expected to register one or more callback - * functions for such, shortly after being launched (during the app's - * initialization phase). After the back button is pressed, the OS will invoke - * these callbacks. If the app's callback(s) do not explicitly mark the event - * as handled by the time they return, or if the app never registers one of - * these callback, the OS will consider the event un-handled, and it will - * apply its default back button behavior (terminate the app). - * - * SDL registers its own back-button-press callback with the Windows Phone OS. - * This callback will emit a pair of SDL key-press events (SDL_EVENT_KEY_DOWN - * and SDL_EVENT_KEY_UP), each with a scancode of SDL_SCANCODE_AC_BACK, after - * which it will check the contents of the hint, - * SDL_HINT_WINRT_HANDLE_BACK_BUTTON. If the hint's value is set to "1", the - * back button event's Handled property will get set to 'true'. If the hint's - * value is set to something else, or if it is unset, SDL will leave the - * event's Handled property alone. (By default, the OS sets this property to - * 'false', to note.) - * - * SDL apps can either set SDL_HINT_WINRT_HANDLE_BACK_BUTTON well before a - * back button is pressed, or can set it in direct-response to a back button - * being pressed. - * - * In order to get notified when a back button is pressed, SDL apps should - * register a callback function with SDL_AddEventWatch(), and have it listen - * for SDL_EVENT_KEY_DOWN events that have a scancode of SDL_SCANCODE_AC_BACK. - * (Alternatively, SDL_EVENT_KEY_UP events can be listened-for. Listening for - * either event type is suitable.) Any value of - * SDL_HINT_WINRT_HANDLE_BACK_BUTTON set by such a callback, will be applied - * to the OS' current back-button-press event. - * - * More details on back button behavior in Windows Phone apps can be found at - * the following page, on Microsoft's developer site: - * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx - * - * \since This hint is available since SDL 3.0.0. - */ -#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON" - -/** - * A variable specifying the label text for a WinRT app's privacy policy link. - * - * Network-enabled WinRT apps must include a privacy policy. On Windows 8, - * 8.1, and RT, Microsoft mandates that this policy be available via the - * Windows Settings charm. SDL provides code to add a link there, with its - * label text being set via the optional hint, - * SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. - * - * Please note that a privacy policy's contents are not set via this hint. A - * separate hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the - * actual text of the policy. - * - * The contents of this hint should be encoded as a UTF8 string. - * - * The default value is "Privacy Policy". - * - * For additional information on linking to a privacy policy, see the - * documentation for SDL_HINT_WINRT_PRIVACY_POLICY_URL. - * - * This hint should be set before SDL is initialized. - * - * \since This hint is available since SDL 3.0.0. - */ -#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_WINRT_PRIVACY_POLICY_LABEL" - -/** - * A variable specifying the URL to a WinRT app's privacy policy. - * - * All network-enabled WinRT apps must make a privacy policy available to its - * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be - * available in the Windows Settings charm, as accessed from within the app. - * SDL provides code to add a URL-based link there, which can point to the - * app's privacy policy. - * - * To setup a URL to an app's privacy policy, set - * SDL_HINT_WINRT_PRIVACY_POLICY_URL before calling any SDL_Init() functions. - * The contents of the hint should be a valid URL. For example, - * "http://www.example.com". - * - * The default value is "", which will prevent SDL from adding a privacy - * policy link to the Settings charm. This hint should only be set during app - * init. - * - * The label text of an app's "Privacy Policy" link may be customized via - * another hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. - * - * Please note that on Windows Phone, Microsoft does not provide standard UI - * for displaying a privacy policy link, and as such, - * SDL_HINT_WINRT_PRIVACY_POLICY_URL will not get used on that platform. - * Network-enabled phone apps should display their privacy policy through some - * other, in-app means. - * - * \since This hint is available since SDL 3.0.0. - */ -#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_WINRT_PRIVACY_POLICY_URL" - /** * A variable controlling whether X11 windows are marked as override-redirect. * diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h index 12e8ffdca..a5a877bf5 100644 --- a/include/SDL3/SDL_main.h +++ b/include/SDL3/SDL_main.h @@ -48,20 +48,6 @@ */ #define SDL_MAIN_AVAILABLE - #elif defined(SDL_PLATFORM_WINRT) - /* On WinRT, SDL provides a main function that initializes CoreApplication, - creating an instance of IFrameworkView in the process. - - Ideally, #include'ing SDL_main.h is enough to get a main() function working. - However, that requires the source file your main() is in to be compiled - as C++ *and* with the /ZW compiler flag. If that's not feasible, add an - otherwise empty .cpp file that only contains `#include ` - and build that with /ZW (still include SDL_main.h in your other file with main()!). - In XAML apps, instead the function SDL_RunApp() must be called with a pointer - to the Direct3D-hosted XAML control passed in as the "reserved" argument. - */ - #define SDL_MAIN_NEEDED - #elif defined(SDL_PLATFORM_GDK) /* On GDK, SDL provides a main function that initializes the game runtime. @@ -591,7 +577,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); /* platforms which main (-equivalent) can be implemented in plain C */ #include - #elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */ + #elif 0 /* C++ platforms (currently none, this used to be here for WinRT, but is left for future platforms that might arrive. */ #ifdef __cplusplus #include #else @@ -605,7 +591,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); #endif /* __GNUC__ */ #endif /* __cplusplus */ - #endif /* C++ platforms like SDL_PLATFORM_WINRT etc */ + #endif /* C++ platforms */ #endif #endif /* SDL_main_h_ */ diff --git a/include/SDL3/SDL_main_impl.h b/include/SDL3/SDL_main_impl.h index ad122dfc5..d46518c07 100644 --- a/include/SDL3/SDL_main_impl.h +++ b/include/SDL3/SDL_main_impl.h @@ -126,70 +126,6 @@ /* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */ - #elif defined(SDL_PLATFORM_WINRT) - - /* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */ - - #include - - /* At least one file in any SDL/WinRT app appears to require compilation - with C++/CX, otherwise a Windows Metadata file won't get created, and - an APPX0702 build error can appear shortly after linking. - - The following set of preprocessor code forces this file to be compiled - as C++/CX, which appears to cause Visual C++ 2012's build tools to - create this .winmd file, and will help allow builds of SDL/WinRT apps - to proceed without error. - - If other files in an app's project enable C++/CX compilation, then it might - be possible for the .cpp file including SDL_main.h to be compiled without /ZW, - for Visual C++'s build tools to create a winmd file, and for the app to - build without APPX0702 errors. In this case, if - SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then - the #error (to force C++/CX compilation) will be disabled. - - Please note that /ZW can be specified on a file-by-file basis. To do this, - right click on the file in Visual C++, click Properties, then change the - setting through the dialog that comes up. - */ - #ifndef SDL_WINRT_METADATA_FILE_AVAILABLE - #if !defined(__cplusplus) || (!defined(__cplusplus_winrt) && _MSVC_LANG < 202002L) - #error The C++ file that includes SDL_main.h must be compiled as C++ code with /ZW, otherwise build errors due to missing .winmd files can occur. - #endif - #endif - - /* Prevent MSVC++ from warning about threading models when defining our - custom WinMain. The threading model will instead be set via a direct - call to Windows::Foundation::Initialize (rather than via an attributed - function). - - To note, this warning (C4447) does not seem to come up unless this file - is compiled with C++/CX enabled (via the /ZW compiler flag). - */ - #ifdef _MSC_VER - #pragma warning(disable : 4447) - /* Make sure the function to initialize the Windows Runtime gets linked in. */ - #pragma comment(lib, "runtimeobject.lib") - #endif - - #ifdef __cplusplus - extern "C" { - #endif - int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) - { - return SDL_RunApp(0, NULL, SDL_main, NULL); - } - #if _MSVC_LANG >= 202002L - int main(int argc, char** argv) { - return SDL_RunApp(argc, argv, SDL_main, NULL); - } - #endif - #ifdef __cplusplus - } /* extern "C" */ - #endif - - /* end of WinRT impl */ - #elif defined(SDL_PLATFORM_NGAGE) /* same typedef as in ngage SDKs e32def.h */ typedef signed int TInt; diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index 2795191ce..de5e69842 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -625,8 +625,6 @@ #define SDL_LinuxSetThreadPriorityAndPolicy SDL_SetLinuxThreadPriorityAndPolicy #define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidEnterForeground #define SDL_OnApplicationWillResignActive SDL_OnApplicationWillEnterBackground -#define SDL_WinRTGetDeviceFamily SDL_GetWinRTDeviceFamily -#define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPath #define SDL_iOSSetAnimationCallback SDL_SetiOSAnimationCallback #define SDL_iOSSetEventPump SDL_SetiOSEventPump #define SDL_iPhoneSetAnimationCallback SDL_SetiOSAnimationCallback @@ -1251,8 +1249,6 @@ #define SDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy_renamed_SDL_SetLinuxThreadPriorityAndPolicy #define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidBecomeActive_renamed_SDL_OnApplicationDidEnterForeground #define SDL_OnApplicationWillResignActive SDL_OnApplicationWillResignActive_renamed_SDL_OnApplicationWillEnterBackground -#define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_renamed_SDL_GetWinRTDeviceFamily -#define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPathUTF8_renamed_SDL_GetWinRTFSPath #define SDL_iOSSetAnimationCallback SDL_iOSSetAnimationCallback_renamed_SDL_SetiOSAnimationCallback #define SDL_iOSSetEventPump SDL_iOSSetEventPump_renamed_SDL_SetiOSEventPump #define SDL_iPhoneSetAnimationCallback SDL_iPhoneSetAnimationCallback_renamed_SDL_iOSSetAnimationCallback diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h index e7f91cf94..ea717cc8d 100644 --- a/include/SDL3/SDL_platform_defines.h +++ b/include/SDL3/SDL_platform_defines.h @@ -173,7 +173,7 @@ #endif #if WINAPI_FAMILY_WINRT -#define SDL_PLATFORM_WINRT 1 +#error Windows RT/UWP is no longer supported in SDL #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */ #define SDL_PLATFORM_WINGDK 1 #elif defined(_GAMING_XBOX_XBOXONE) diff --git a/include/SDL3/SDL_system.h b/include/SDL3/SDL_system.h index 17ac0a105..789da2846 100644 --- a/include/SDL3/SDL_system.h +++ b/include/SDL3/SDL_system.h @@ -559,90 +559,6 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int #endif /* SDL_PLATFORM_ANDROID */ -/* - * Platform specific functions for WinRT - */ -#ifdef SDL_PLATFORM_WINRT - -/** - * WinRT / Windows Phone path types - * - * \since This enum is available since SDL 3.0.0. - */ -typedef enum SDL_WinRT_Path -{ - /** The installed app's root directory. - Files here are likely to be read-only. */ - SDL_WINRT_PATH_INSTALLED_LOCATION, - - /** The app's local data store. Files may be written here */ - SDL_WINRT_PATH_LOCAL_FOLDER, - - /** The app's roaming data store. Unsupported on Windows Phone. - Files written here may be copied to other machines via a network - connection. - */ - SDL_WINRT_PATH_ROAMING_FOLDER, - - /** The app's temporary data store. Unsupported on Windows Phone. - Files written here may be deleted at any time. */ - SDL_WINRT_PATH_TEMP_FOLDER -} SDL_WinRT_Path; - - -/** - * WinRT Device Family - * - * \since This enum is available since SDL 3.0.0. - */ -typedef enum SDL_WinRT_DeviceFamily -{ - /** Unknown family */ - SDL_WINRT_DEVICEFAMILY_UNKNOWN, - - /** Desktop family*/ - SDL_WINRT_DEVICEFAMILY_DESKTOP, - - /** Mobile family (for example smartphone) */ - SDL_WINRT_DEVICEFAMILY_MOBILE, - - /** XBox family */ - SDL_WINRT_DEVICEFAMILY_XBOX, -} SDL_WinRT_DeviceFamily; - - -/** - * Retrieve a WinRT defined path on the local file system. - * - * Not all paths are available on all versions of Windows. This is especially - * true on Windows Phone. Check the documentation for the given SDL_WinRT_Path - * for more information on which path types are supported where. - * - * Documentation on most app-specific path types on WinRT can be found on - * MSDN, at the URL: - * - * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx - * - * \param pathType the type of path to retrieve, one of SDL_WinRT_Path. - * \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if - * the path is not available for any reason; call SDL_GetError() for - * more information. - * - * \since This function is available since SDL 3.0.0. - */ -extern SDL_DECLSPEC const char * SDLCALL SDL_GetWinRTFSPath(SDL_WinRT_Path pathType); - -/** - * Detects the device family of WinRT platform at runtime. - * - * \returns a value from the SDL_WinRT_DeviceFamily enum. - * - * \since This function is available since SDL 3.0.0. - */ -extern SDL_DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_GetWinRTDeviceFamily(); - -#endif /* SDL_PLATFORM_WINRT */ - /** * Query if the current device is a tablet. * diff --git a/include/SDL3/SDL_thread.h b/include/SDL3/SDL_thread.h index 0fdc8a027..4a613efbf 100644 --- a/include/SDL3/SDL_thread.h +++ b/include/SDL3/SDL_thread.h @@ -36,7 +36,7 @@ #include #include -#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(SDL_PLATFORM_WINRT) +#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) #include /* _beginthreadex() and _endthreadex() */ #endif @@ -263,7 +263,7 @@ extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithProperties(SDL_Prop /* The real implementation, hidden from the wiki, so it can show this as real functions that don't have macro magic. */ #ifndef SDL_WIKI_DOCUMENTATION_SECTION -# if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(SDL_PLATFORM_WINRT) +# if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) # ifndef SDL_BeginThreadFunction # define SDL_BeginThreadFunction _beginthreadex # endif diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index e4d57c5d7..27f9fddab 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -1215,11 +1215,6 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window) * - `SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER`: the EGLSurface associated with * the window * - * On UWP: - * - * - `SDL_PROP_WINDOW_WINRT_WINDOW_POINTER`: the IInspectable CoreWindow - * associated with the window - * * On Windows: * * - `SDL_PROP_WINDOW_WIN32_HWND_POINTER`: the HWND associated with the window @@ -1286,7 +1281,6 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window #define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display" #define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window" #define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface" -#define SDL_PROP_WINDOW_WINRT_WINDOW_POINTER "SDL.window.winrt.window" #define SDL_PROP_WINDOW_WIN32_HWND_POINTER "SDL.window.win32.hwnd" #define SDL_PROP_WINDOW_WIN32_HDC_POINTER "SDL.window.win32.hdc" #define SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER "SDL.window.win32.instance" diff --git a/include/build_config/SDL_build_config.h b/include/build_config/SDL_build_config.h index beaceb584..eca4268cb 100644 --- a/include/build_config/SDL_build_config.h +++ b/include/build_config/SDL_build_config.h @@ -33,8 +33,6 @@ /* Add any platform that doesn't build using the configure system. */ #if defined(SDL_PLATFORM_WIN32) #include "SDL_build_config_windows.h" -#elif defined(SDL_PLATFORM_WINRT) -#include "SDL_build_config_winrt.h" #elif defined(SDL_PLATFORM_WINGDK) #include "SDL_build_config_wingdk.h" #elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) diff --git a/include/build_config/SDL_build_config.h.cmake b/include/build_config/SDL_build_config.h.cmake index e117409bb..c8732f748 100644 --- a/include/build_config/SDL_build_config.h.cmake +++ b/include/build_config/SDL_build_config.h.cmake @@ -396,7 +396,6 @@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@ #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ -#cmakedefine SDL_VIDEO_DRIVER_WINRT @SDL_VIDEO_DRIVER_WINRT@ #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@ @@ -457,7 +456,6 @@ #cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@ #cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@ #cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@ -#cmakedefine SDL_POWER_WINRT @SDL_POWER_WINRT@ #cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@ #cmakedefine SDL_POWER_UIKIT @SDL_POWER_UIKIT@ #cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@ diff --git a/include/build_config/SDL_build_config_windows.h b/include/build_config/SDL_build_config_windows.h index 772952196..a64d1d2dd 100644 --- a/include/build_config/SDL_build_config_windows.h +++ b/include/build_config/SDL_build_config_windows.h @@ -242,9 +242,7 @@ typedef unsigned int uintptr_t; #define SDL_JOYSTICK_GAMEINPUT 1 #endif #define SDL_JOYSTICK_HIDAPI 1 -#ifndef SDL_PLATFORM_WINRT #define SDL_JOYSTICK_RAWINPUT 1 -#endif #define SDL_JOYSTICK_VIRTUAL 1 #ifdef HAVE_WINDOWS_GAMING_INPUT_H #define SDL_JOYSTICK_WGI 1 diff --git a/include/build_config/SDL_build_config_winrt.h b/include/build_config/SDL_build_config_winrt.h deleted file mode 100644 index 7ee64a66f..000000000 --- a/include/build_config/SDL_build_config_winrt.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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_build_config_winrt_h_ -#define SDL_build_config_winrt_h_ -#define SDL_build_config_h_ - -#include - -/* Make sure the Windows SDK's NTDDI_VERSION macro gets defined. This is used - by SDL to determine which version of the Windows SDK is being used. -*/ -#include - -/* Define possibly-undefined NTDDI values (used when compiling SDL against - older versions of the Windows SDK. -*/ -#ifndef NTDDI_WINBLUE -#define NTDDI_WINBLUE 0x06030000 -#endif -#ifndef NTDDI_WIN10 -#define NTDDI_WIN10 0x0A000000 -#endif - -/* This is a set of defines to configure the SDL features */ - -#ifdef __clang__ -# define HAVE_GCC_ATOMICS 1 -#endif - -/* Useful headers */ -#define HAVE_DXGI_H 1 -#if !SDL_WINAPI_FAMILY_PHONE -#define HAVE_XINPUT_H 1 -#endif - -#define HAVE_MMDEVICEAPI_H 1 -#define HAVE_AUDIOCLIENT_H 1 -#define HAVE_TPCSHRD_H 1 - -#define HAVE_LIBC 1 -#define HAVE_FLOAT_H 1 -#define HAVE_LIMITS_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_STDBOOL_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_STDIO_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_WCHAR_H 1 - -/* C library functions */ -#define HAVE_LIBC 1 -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 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 -#define HAVE__STRUPR 1 -#define HAVE_STRCHR 1 -#define HAVE_STRPBRK 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -/* #undef HAVE_STRTOLL */ -/* #undef HAVE_STRTOULL */ -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_VSNPRINTF 1 -/* TODO, WinRT: consider using ??_s versions of the following */ -/* #undef HAVE__STRLWR */ -/* #undef HAVE_ITOA */ -/* #undef HAVE__LTOA */ -/* #undef HAVE__ULTOA */ -/* #undef HAVE_SSCANF */ -#define HAVE_ACOS 1 -#define HAVE_ACOSF 1 -#define HAVE_ASIN 1 -#define HAVE_ASINF 1 -#define HAVE_ATAN 1 -#define HAVE_ATANF 1 -#define HAVE_ATAN2 1 -#define HAVE_ATAN2F 1 -#define HAVE_CEIL 1 -#define HAVE_CEILF 1 -#define HAVE__COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_EXP 1 -#define HAVE_EXPF 1 -#define HAVE_FABS 1 -#define HAVE_FABSF 1 -#define HAVE_FLOOR 1 -#define HAVE_FLOORF 1 -#define HAVE_FMOD 1 -#define HAVE_FMODF 1 -#define HAVE_ISINF 1 -#define HAVE_ISINF_FLOAT_MACRO 1 -#define HAVE_ISNAN 1 -#define HAVE_ISNAN_FLOAT_MACRO 1 -#define HAVE_LOG 1 -#define HAVE_LOGF 1 -#define HAVE_LOG10 1 -#define HAVE_LOG10F 1 -#define HAVE_LROUND 1 -#define HAVE_LROUNDF 1 -#define HAVE_MODF 1 -#define HAVE_MODFF 1 -#define HAVE_POW 1 -#define HAVE_POWF 1 -#define HAVE_ROUND 1 -#define HAVE_ROUNDF 1 -#define HAVE__SCALB 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_TRUNC 1 -#define HAVE_TRUNCF 1 -#define HAVE__FSEEKI64 1 - -#define HAVE_ROAPI_H 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_WASAPI 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#if SDL_WINAPI_FAMILY_PHONE -#define SDL_JOYSTICK_DISABLED 1 -#define SDL_HAPTIC_DISABLED 1 -#else -#define SDL_JOYSTICK_VIRTUAL 1 -#if (NTDDI_VERSION >= NTDDI_WIN10) -#define SDL_JOYSTICK_WGI 1 -#define SDL_HAPTIC_DISABLED 1 -#else -#define SDL_JOYSTICK_XINPUT 1 -#endif /* WIN10 */ -#endif - -/* WinRT doesn't have HIDAPI available */ -#define SDL_HIDAPI_DISABLED 1 - -/* Enable the dummy sensor driver */ -#define SDL_SENSOR_DUMMY 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 - -/* Enable various threading systems */ -#if (NTDDI_VERSION >= NTDDI_WINBLUE) -#define SDL_THREAD_GENERIC_COND_SUFFIX 1 -#define SDL_THREAD_GENERIC_RWLOCK_SUFFIX 1 -#define SDL_THREAD_WINDOWS 1 -#else -/* WinRT on Windows 8.0 and Windows Phone 8.0 don't support CreateThread() */ -#define SDL_THREAD_STDCPP 1 -#endif - -/* Enable RTC system */ -#define SDL_TIME_WINDOWS 1 - -/* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_WINRT 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ -#define SDL_VIDEO_OPENGL_ES2 1 -#define SDL_VIDEO_OPENGL_EGL 1 - -/* Enable appropriate renderer(s) */ -#define SDL_VIDEO_RENDER_D3D11 1 - -/* Disable D3D12 as it's not implemented for WinRT */ -/* #undef SDL_VIDEO_RENDER_D3D12 */ - -#ifdef SDL_VIDEO_OPENGL_ES2 -#define SDL_VIDEO_RENDER_OGL_ES2 1 -#endif - -/* Enable system power support */ -#define SDL_POWER_WINRT 1 - -/* Enable filesystem support */ -#define SDL_FILESYSTEM_WINDOWS 1 -#define SDL_FSOPS_WINDOWS 1 - -/* Enable the camera driver (src/camera/dummy/\*.c) */ /* !!! FIXME */ -#define SDL_CAMERA_DRIVER_DUMMY 1 - -#endif /* SDL_build_config_winrt_h_ */ diff --git a/src/SDL.c b/src/SDL.c index ef1d815d4..85308b2d2 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -23,7 +23,7 @@ #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "core/windows/SDL_windows.h" -#elif !defined(SDL_PLATFORM_WINRT) +#else #include // _exit(), etc. #endif @@ -694,8 +694,6 @@ const char *SDL_GetPlatform(void) return "Solaris"; #elif defined(SDL_PLATFORM_WIN32) return "Windows"; -#elif defined(SDL_PLATFORM_WINRT) - return "WinRT"; #elif defined(SDL_PLATFORM_WINGDK) return "WinGDK"; #elif defined(SDL_PLATFORM_XBOXONE) diff --git a/src/SDL_log.c b/src/SDL_log.c index 17e3ed964..016175ecb 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "core/windows/SDL_windows.h" #endif @@ -511,7 +511,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S } } -#if defined(SDL_PLATFORM_WIN32) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) +#if defined(SDL_PLATFORM_WIN32) && !defined(SDL_PLATFORM_GDK) enum { CONSOLE_UNATTACHED = 0, CONSOLE_ATTACHED_CONSOLE = 1, @@ -526,7 +526,7 @@ static HANDLE stderrHandle = NULL; static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) { -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) // Way too many allocations here, urgh // Note: One can't call SDL_SetError here, since that function itself logs. { @@ -535,7 +535,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority LPTSTR tstr; bool isstack; -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) +#if !defined(SDL_PLATFORM_GDK) BOOL attachResult; DWORD attachError; DWORD consoleMode; @@ -574,7 +574,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority } } } -#endif // !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) +#endif // !defined(SDL_PLATFORM_GDK) length = SDL_strlen(SDL_GetLogPriorityPrefix(priority)) + SDL_strlen(message) + 1 + 1 + 1; output = SDL_small_alloc(char, length, &isstack); (void)SDL_snprintf(output, length, "%s%s\r\n", SDL_GetLogPriorityPrefix(priority), message); @@ -583,7 +583,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority // Output to debugger OutputDebugString(tstr); -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) +#if !defined(SDL_PLATFORM_GDK) // Screen output to stderr, if console was attached. if (consoleAttached == CONSOLE_ATTACHED_CONSOLE) { if (!WriteConsole(stderrHandle, tstr, (DWORD)SDL_tcslen(tstr), &charsWritten, NULL)) { @@ -598,7 +598,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority OutputDebugString(TEXT("Error calling WriteFile\r\n")); } } -#endif // !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) +#endif // !defined(SDL_PLATFORM_GDK) SDL_free(tstr); SDL_small_free(output, isstack); diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 3ca84476b..6186443da 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_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 cf3b86b0a..9eaa32e87 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -325,12 +325,6 @@ static bool mgmtthrtask_CoTaskMemFree(void *userdata) return true; } -static bool mgmtthrtask_PlatformDeleteActivationHandler(void *userdata) -{ - WASAPI_PlatformDeleteActivationHandler(userdata); - return true; -} - static bool mgmtthrtask_CloseHandle(void *userdata) { CloseHandle((HANDLE) userdata); @@ -370,12 +364,6 @@ static void ResetWasapiDevice(SDL_AudioDevice *device) WASAPI_ProxyToManagementThread(mgmtthrtask_CoTaskMemFree, ptr, NULL); } - if (device->hidden->activation_handler) { - void *activation_handler = device->hidden->activation_handler; - device->hidden->activation_handler = NULL; - WASAPI_ProxyToManagementThread(mgmtthrtask_PlatformDeleteActivationHandler, activation_handler, NULL); - } - if (device->hidden->event) { HANDLE event = device->hidden->event; device->hidden->event = NULL; @@ -592,7 +580,7 @@ static bool mgmtthrtask_PrepDevice(void *userdata) IAudioClient *client = device->hidden->client; SDL_assert(client != NULL); -#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP. +#if defined(SDL_PLATFORM_GDK) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP. device->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); #else device->hidden->event = CreateEventW(NULL, 0, 0, NULL); diff --git a/src/audio/wasapi/SDL_wasapi.h b/src/audio/wasapi/SDL_wasapi.h index 107ddb53a..3d4744cf1 100644 --- a/src/audio/wasapi/SDL_wasapi.h +++ b/src/audio/wasapi/SDL_wasapi.h @@ -42,10 +42,9 @@ struct SDL_PrivateAudioData int framesize; bool device_lost; bool device_dead; - void *activation_handler; }; -// win32 and winrt implementations call into these. +// win32 implementation calls into these. bool WASAPI_PrepDevice(SDL_AudioDevice *device); void WASAPI_DisconnectDevice(SDL_AudioDevice *device); // don't hold the device lock when calling this! @@ -54,7 +53,7 @@ void WASAPI_DisconnectDevice(SDL_AudioDevice *device); // don't hold the device typedef bool (*ManagementThreadTask)(void *userdata); bool WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, bool *wait_until_complete); -// These are functions that are implemented differently for Windows vs WinRT. +// These are functions that are (were...?) implemented differently for various Windows versions. // UNLESS OTHERWISE NOTED THESE ALL HAPPEN ON THE MANAGEMENT THREAD. bool WASAPI_PlatformInit(void); void WASAPI_PlatformDeinit(void); @@ -63,7 +62,6 @@ void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevi bool WASAPI_ActivateDevice(SDL_AudioDevice *device); void WASAPI_PlatformThreadInit(SDL_AudioDevice *device); // this happens on the audio device thread, not the management thread. void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device); // this happens on the audio device thread, not the management thread. -void WASAPI_PlatformDeleteActivationHandler(void *handler); void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device); #ifdef __cplusplus diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index e548c9994..cd13115f2 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -20,13 +20,14 @@ */ #include "SDL_internal.h" -/* This is code that Windows uses to talk to WASAPI-related system APIs. +/* !!! FIXME: merge this all into SDL_wasapi.c, now that WinRT is gone. + This is code that Windows uses to talk to WASAPI-related system APIs. This is for non-WinRT desktop apps. The C++/CX implementation of these functions, exclusive to WinRT, are in SDL_wasapi_winrt.cpp. The code in SDL_wasapi.c is used by both standard Windows and WinRT builds to deal with audio and calls into these functions. */ -#if defined(SDL_AUDIO_DRIVER_WASAPI) && !defined(SDL_PLATFORM_WINRT) +#if defined(SDL_AUDIO_DRIVER_WASAPI) #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_immdevice.h" @@ -191,15 +192,9 @@ void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevi SDL_IMMDevice_EnumerateEndpoints(default_playback, default_recording); } -void WASAPI_PlatformDeleteActivationHandler(void *handler) -{ - // not asynchronous. - SDL_assert(!"This function should have only been called on WinRT."); -} - void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device) { SDL_IMMDevice_FreeDeviceHandle(device); } -#endif // SDL_AUDIO_DRIVER_WASAPI && !defined(SDL_PLATFORM_WINRT) +#endif // SDL_AUDIO_DRIVER_WASAPI diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp deleted file mode 100644 index 4b27df296..000000000 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 C++/CX code that the WinRT port uses to talk to WASAPI-related -// system APIs. The C implementation of these functions, for non-WinRT apps, -// is in SDL_wasapi_win32.c. The code in SDL_wasapi.c is used by both standard -// Windows and WinRT builds to deal with audio and calls into these functions. - -#if defined(SDL_AUDIO_DRIVER_WASAPI) && defined(SDL_PLATFORM_WINRT) - -#include -#include -#include -#include -#include -#include - -extern "C" { -#include "../../core/windows/SDL_windows.h" -#include "../SDL_sysaudio.h" -} - -#define COBJMACROS -#include -#include - -#include "SDL_wasapi.h" - -using namespace Windows::Devices::Enumeration; -using namespace Windows::Media::Devices; -using namespace Windows::Foundation; -using namespace Microsoft::WRL; - -static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0"; - - -static bool FindWinRTAudioDeviceCallback(SDL_AudioDevice *device, void *userdata) -{ - return (SDL_wcscmp((LPCWSTR) device->handle, (LPCWSTR) userdata) == 0); -} - -static SDL_AudioDevice *FindWinRTAudioDevice(LPCWSTR devid) -{ - return SDL_FindPhysicalAudioDeviceByCallback(FindWinRTAudioDeviceCallback, (void *) devid); -} - -class SDL_WasapiDeviceEventHandler -{ - public: - SDL_WasapiDeviceEventHandler(const bool _recording); - ~SDL_WasapiDeviceEventHandler(); - void OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ args); - void OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args); - void OnDeviceUpdated(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args); - void OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args); - void OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args); - void OnDefaultCaptureDeviceChanged(Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args); - void WaitForCompletion(); - - private: - SDL_Semaphore *completed_semaphore; - const bool recording; - DeviceWatcher ^ watcher; - Windows::Foundation::EventRegistrationToken added_handler; - Windows::Foundation::EventRegistrationToken removed_handler; - Windows::Foundation::EventRegistrationToken updated_handler; - Windows::Foundation::EventRegistrationToken completed_handler; - Windows::Foundation::EventRegistrationToken default_changed_handler; -}; - -SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const bool _recording) - : recording(_recording), completed_semaphore(SDL_CreateSemaphore(0)) -{ - if (!completed_semaphore) { - return; // uhoh. - } - - Platform::String ^ selector = _recording ? MediaDevice::GetAudioCaptureSelector() : MediaDevice::GetAudioRenderSelector(); - Platform::Collections::Vector properties; - properties.Append(SDL_PKEY_AudioEngine_DeviceFormat); - watcher = DeviceInformation::CreateWatcher(selector, properties.GetView()); - if (!watcher) - return; // uhoh. - - // !!! FIXME: this doesn't need a lambda here, I think, if I make SDL_WasapiDeviceEventHandler a proper C++/CX class. --ryan. - added_handler = watcher->Added += ref new TypedEventHandler([this](DeviceWatcher ^ sender, DeviceInformation ^ args) { OnDeviceAdded(sender, args); }); - removed_handler = watcher->Removed += ref new TypedEventHandler([this](DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) { OnDeviceRemoved(sender, args); }); - updated_handler = watcher->Updated += ref new TypedEventHandler([this](DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) { OnDeviceUpdated(sender, args); }); - completed_handler = watcher->EnumerationCompleted += ref new TypedEventHandler([this](DeviceWatcher ^ sender, Platform::Object ^ args) { OnEnumerationCompleted(sender, args); }); - if (recording) { - default_changed_handler = MediaDevice::DefaultAudioCaptureDeviceChanged += ref new TypedEventHandler([this](Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args) { OnDefaultCaptureDeviceChanged(sender, args); }); - } else { - default_changed_handler = MediaDevice::DefaultAudioRenderDeviceChanged += ref new TypedEventHandler([this](Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) { OnDefaultRenderDeviceChanged(sender, args); }); - } - watcher->Start(); -} - -SDL_WasapiDeviceEventHandler::~SDL_WasapiDeviceEventHandler() -{ - if (watcher) { - watcher->Added -= added_handler; - watcher->Removed -= removed_handler; - watcher->Updated -= updated_handler; - watcher->EnumerationCompleted -= completed_handler; - watcher->Stop(); - watcher = nullptr; - } - - if (completed_semaphore) { - SDL_DestroySemaphore(completed_semaphore); - completed_semaphore = nullptr; - } - - if (recording) { - MediaDevice::DefaultAudioCaptureDeviceChanged -= default_changed_handler; - } else { - MediaDevice::DefaultAudioRenderDeviceChanged -= default_changed_handler; - } -} - -void SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ info) -{ - /* You can have multiple endpoints on a device that are mutually exclusive ("Speakers" vs "Line Out" or whatever). - In a perfect world, things that are unplugged won't be in this collection. The only gotcha is probably for - phones and tablets, where you might have an internal speaker and a headphone jack and expect both to be - available and switch automatically. (!!! FIXME...?) */ - - SDL_assert(sender == this->watcher); - char *utf8dev = WIN_StringToUTF8W(info->Name->Data()); - if (utf8dev) { - SDL_AudioSpec spec; - SDL_zero(spec); - - Platform::Object ^ obj = info->Properties->Lookup(SDL_PKEY_AudioEngine_DeviceFormat); - if (obj) { - IPropertyValue ^ property = (IPropertyValue ^) obj; - Platform::Array ^ data; - property->GetUInt8Array(&data); - WAVEFORMATEXTENSIBLE fmt; - SDL_zero(fmt); - SDL_memcpy(&fmt, data->Data, SDL_min(data->Length, sizeof(WAVEFORMATEXTENSIBLE))); - spec.channels = (Uint8)fmt.Format.nChannels; - spec.freq = fmt.Format.nSamplesPerSec; - spec.format = SDL_WaveFormatExToSDLFormat((WAVEFORMATEX *)&fmt); - } - - LPWSTR devid = SDL_wcsdup(info->Id->Data()); - if (devid) { - SDL_AddAudioDevice(this->recording, utf8dev, spec.channels ? &spec : NULL, devid); - } - SDL_free(utf8dev); - } -} - -void SDL_WasapiDeviceEventHandler::OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ info) -{ - SDL_assert(sender == this->watcher); - WASAPI_DisconnectDevice(FindWinRTAudioDevice(info->Id->Data())); -} - -void SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args) -{ - SDL_assert(sender == this->watcher); -} - -void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args) -{ - SDL_assert(sender == this->watcher); - if (this->completed_semaphore) { - SDL_SignalSemaphore(this->completed_semaphore); - } -} - -void SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) -{ - SDL_assert(!this->recording); - SDL_DefaultAudioDeviceChanged(FindWinRTAudioDevice(args->Id->Data())); -} - -void SDL_WasapiDeviceEventHandler::OnDefaultCaptureDeviceChanged(Platform::Object ^ sender, DefaultAudioCaptureDeviceChangedEventArgs ^ args) -{ - SDL_assert(this->recording); - SDL_DefaultAudioDeviceChanged(FindWinRTAudioDevice(args->Id->Data())); -} - -void SDL_WasapiDeviceEventHandler::WaitForCompletion() -{ - if (this->completed_semaphore) { - SDL_WaitSemaphore(this->completed_semaphore); - SDL_DestroySemaphore(this->completed_semaphore); - this->completed_semaphore = nullptr; - } -} - -static SDL_WasapiDeviceEventHandler *playback_device_event_handler; -static SDL_WasapiDeviceEventHandler *recording_device_event_handler; - -bool WASAPI_PlatformInit(void) -{ - return true; -} - -static void StopWasapiHotplug(void) -{ - delete playback_device_event_handler; - playback_device_event_handler = nullptr; - delete recording_device_event_handler; - recording_device_event_handler = nullptr; -} - -void WASAPI_PlatformDeinit(void) -{ - StopWasapiHotplug(); -} - -void WASAPI_PlatformDeinitializeStart(void) -{ - StopWasapiHotplug(); -} - - -void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) -{ - Platform::String ^ defdevid; - - // DeviceWatchers will fire an Added event for each existing device at - // startup, so we don't need to enumerate them separately before - // listening for updates. - playback_device_event_handler = new SDL_WasapiDeviceEventHandler(false); - playback_device_event_handler->WaitForCompletion(); - defdevid = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Default); - if (defdevid) { - *default_playback = FindWinRTAudioDevice(defdevid->Data()); - } - - recording_device_event_handler = new SDL_WasapiDeviceEventHandler(true); - recording_device_event_handler->WaitForCompletion(); - defdevid = MediaDevice::GetDefaultAudioCaptureId(AudioDeviceRole::Default); - if (defdevid) { - *default_recording = FindWinRTAudioDevice(defdevid->Data()); - } -} - -class SDL_WasapiActivationHandler : public RuntimeClass, FtmBase, IActivateAudioInterfaceCompletionHandler> -{ -public: - SDL_WasapiActivationHandler() : completion_semaphore(SDL_CreateSemaphore(0)) { SDL_assert(completion_semaphore != NULL); } - STDMETHOD(ActivateCompleted)(IActivateAudioInterfaceAsyncOperation *operation); - void WaitForCompletion(); -private: - SDL_Semaphore *completion_semaphore; -}; - -void SDL_WasapiActivationHandler::WaitForCompletion() -{ - if (completion_semaphore) { - SDL_WaitSemaphore(completion_semaphore); - SDL_DestroySemaphore(completion_semaphore); - completion_semaphore = NULL; - } -} - -HRESULT -SDL_WasapiActivationHandler::ActivateCompleted(IActivateAudioInterfaceAsyncOperation *async) -{ - // Just set a flag, since we're probably in a different thread. We'll pick it up and init everything on our own thread to prevent races. - SDL_SignalSemaphore(completion_semaphore); - return S_OK; -} - -void WASAPI_PlatformDeleteActivationHandler(void *handler) -{ - ((SDL_WasapiActivationHandler *)handler)->Release(); -} - -bool WASAPI_ActivateDevice(SDL_AudioDevice *device) -{ - LPCWSTR devid = (LPCWSTR) device->handle; - SDL_assert(devid != NULL); - - ComPtr handler = Make(); - if (handler == nullptr) { - return SDL_SetError("Failed to allocate WASAPI activation handler"); - } - - handler.Get()->AddRef(); // we hold a reference after ComPtr destructs on return, causing a Release, and Release ourselves in WASAPI_PlatformDeleteActivationHandler(), etc. - device->hidden->activation_handler = handler.Get(); - - IActivateAudioInterfaceAsyncOperation *async = nullptr; - const HRESULT ret = ActivateAudioInterfaceAsync(devid, __uuidof(IAudioClient), nullptr, handler.Get(), &async); - - if (FAILED(ret) || async == nullptr) { - if (async != nullptr) { - async->Release(); - } - handler.Get()->Release(); - return WIN_SetErrorFromHRESULT("WASAPI can't activate requested audio endpoint", ret); - } - - // !!! FIXME: the problems in SDL2 that needed this to be synchronous are _probably_ solved by SDL3, and this can block indefinitely if a user prompt is shown to get permission to use a microphone. - handler.Get()->WaitForCompletion(); // block here until we have an answer, so this is synchronous to us after all. - - HRESULT activateRes = S_OK; - IUnknown *iunknown = nullptr; - const HRESULT getActivateRes = async->GetActivateResult(&activateRes, &iunknown); - async->Release(); - if (FAILED(getActivateRes)) { - return WIN_SetErrorFromHRESULT("Failed to get WASAPI activate result", getActivateRes); - } else if (FAILED(activateRes)) { - return WIN_SetErrorFromHRESULT("Failed to activate WASAPI device", activateRes); - } - - iunknown->QueryInterface(IID_PPV_ARGS(&device->hidden->client)); - if (!device->hidden->client) { - return SDL_SetError("Failed to query WASAPI client interface"); - } - - if (!WASAPI_PrepDevice(device)) { - return false; - } - - return true; -} - -void WASAPI_PlatformThreadInit(SDL_AudioDevice *device) -{ - // !!! FIXME: set this thread to "Pro Audio" priority. - SDL_SetThreadPriority(device->recording ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL); -} - -void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device) -{ - // !!! FIXME: set this thread to "Pro Audio" priority. -} - -void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device) -{ - SDL_free(device->handle); -} - -#endif // SDL_AUDIO_DRIVER_WASAPI && defined(SDL_PLATFORM_WINRT) diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c index daa2c40f2..81681502b 100644 --- a/src/core/SDL_core_unsupported.c +++ b/src/core/SDL_core_unsupported.c @@ -76,7 +76,7 @@ void SDL_GDKResumeGPU(SDL_GPUDevice *device) #endif -#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) +#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) SDL_DECLSPEC SDL_bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst); SDL_bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst) @@ -103,25 +103,6 @@ void SDL_UnregisterApp(void) #endif -#ifndef SDL_PLATFORM_WINRT - -// Returns SDL_WinRT_DeviceFamily enum -SDL_DECLSPEC int SDLCALL SDL_GetWinRTDeviceFamily(void); -int SDL_GetWinRTDeviceFamily(void) -{ - SDL_Unsupported(); - return 0; // SDL_WINRT_DEVICEFAMILY_UNKNOWN -} - -SDL_DECLSPEC const char *SDLCALL SDL_GetWinRTFSPath(int pathType); // SDL_WinRT_Path pathType -const char *SDL_GetWinRTFSPath(int pathType) -{ - (void)pathType; - SDL_Unsupported(); - return NULL; -} -#endif - #ifndef SDL_PLATFORM_ANDROID SDL_DECLSPEC void SDLCALL SDL_SendAndroidBackButton(void); diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c index 2758b633f..419cb7270 100644 --- a/src/core/windows/SDL_hid.c +++ b/src/core/windows/SDL_hid.c @@ -20,8 +20,6 @@ */ #include "SDL_internal.h" -#ifndef SDL_PLATFORM_WINRT - #include "SDL_hid.h" HidD_GetString_t SDL_HidD_GetManufacturerString; @@ -82,9 +80,7 @@ void WIN_UnloadHIDDLL(void) } } -#endif // !SDL_PLATFORM_WINRT - -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // CM_Register_Notification definitions @@ -253,4 +249,4 @@ void WIN_QuitDeviceNotification(void) { } -#endif // !SDL_PLATFORM_WINRT && !SDL_PLATFORM_XBOXONE && !SDL_PLATFORM_XBOXSERIES +#endif // !SDL_PLATFORM_XBOXONE && !SDL_PLATFORM_XBOXSERIES diff --git a/src/core/windows/SDL_hid.h b/src/core/windows/SDL_hid.h index afa00717b..50c5d38c0 100644 --- a/src/core/windows/SDL_hid.h +++ b/src/core/windows/SDL_hid.h @@ -25,8 +25,6 @@ #include "SDL_windows.h" -#ifndef SDL_PLATFORM_WINRT - typedef LONG NTSTATUS; typedef USHORT USAGE; typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA; @@ -208,9 +206,6 @@ extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps; extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength; extern HidP_GetData_t SDL_HidP_GetData; -#endif // !SDL_PLATFORM_WINRT - - void WIN_InitDeviceNotification(void); Uint64 WIN_GetLastDeviceNotification(void); void WIN_QuitDeviceNotification(void); diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 393cefea8..cc3c52959 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(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "SDL_windows.h" @@ -90,14 +90,7 @@ WIN_CoInitialize(void) If you need multi-threaded mode, call CoInitializeEx() before SDL_Init() */ -#ifdef SDL_PLATFORM_WINRT - /* DLudwig: On WinRT, it is assumed that COM was initialized in main(). - CoInitializeEx is available (not CoInitialize though), however - on WinRT, main() is typically declared with the [MTAThread] - attribute, which, AFAIK, should initialize COM. - */ - return S_OK; -#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) // On Xbox, there's no need to call CoInitializeEx (and it's not implemented) return S_OK; #else @@ -118,12 +111,9 @@ WIN_CoInitialize(void) void WIN_CoUninitialize(void) { -#ifndef SDL_PLATFORM_WINRT CoUninitialize(); -#endif } -#ifndef SDL_PLATFORM_WINRT FARPROC WIN_LoadComBaseFunction(const char *name) { static bool s_bLoaded; @@ -139,14 +129,10 @@ FARPROC WIN_LoadComBaseFunction(const char *name) return NULL; } } -#endif HRESULT WIN_RoInitialize(void) { -#ifdef SDL_PLATFORM_WINRT - return S_OK; -#else typedef HRESULT(WINAPI * RoInitialize_t)(RO_INIT_TYPE initType); RoInitialize_t RoInitializeFunc = (RoInitialize_t)WIN_LoadComBaseFunction("RoInitialize"); if (RoInitializeFunc) { @@ -166,21 +152,18 @@ WIN_RoInitialize(void) } else { return E_NOINTERFACE; } -#endif } void WIN_RoUninitialize(void) { -#ifndef SDL_PLATFORM_WINRT typedef void(WINAPI * RoUninitialize_t)(void); RoUninitialize_t RoUninitializeFunc = (RoUninitialize_t)WIN_LoadComBaseFunction("RoUninitialize"); if (RoUninitializeFunc) { RoUninitializeFunc(); } -#endif } -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) { OSVERSIONINFOEXW osvi; @@ -202,7 +185,7 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO #endif // apply some static variables so we only call into the Win32 API once per process for each check. -#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) #define CHECKWINVER(notdesktop_platform_result, test) return (notdesktop_platform_result); #else #define CHECKWINVER(notdesktop_platform_result, test) \ @@ -265,8 +248,8 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM. */ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) { -#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) - return WIN_StringToUTF8W(name); // No registry access on WinRT/UWP and Xbox, go with what we've got. +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + return WIN_StringToUTF8W(name); // No registry access on Xbox, go with what we've got. #else static const GUID nullguid = { 0 }; const unsigned char *ptr; @@ -318,7 +301,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) result = WIN_StringToUTF8(strw); SDL_free(strw); return result ? result : WIN_StringToUTF8(name); -#endif // if SDL_PLATFORM_WINRT / else +#endif } BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b) @@ -349,7 +332,7 @@ void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect) BOOL WIN_IsRectEmpty(const RECT *rect) { - // Calculating this manually because UWP and Xbox do not support Win32 IsRectEmpty. + // Calculating this manually because Xbox does not support Win32 IsRectEmpty. return (rect->right <= rect->left) || (rect->bottom <= rect->top); } @@ -389,4 +372,4 @@ int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, return WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar); } -#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) +#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index f83e21406..bc0aaf3e4 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -122,10 +122,8 @@ extern bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); // Sets an error message based on GetLastError(). Always return -1. extern bool WIN_SetError(const char *prefix); -#ifndef SDL_PLATFORM_WINRT // Load a function from combase.dll FARPROC WIN_LoadComBaseFunction(const char *name); -#endif // Wrap up the oddities of CoInitialize() into a common function. extern HRESULT WIN_CoInitialize(void); diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index 32d4722ef..76b5bd2c1 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -37,21 +37,17 @@ DWORD SDL_XInputVersion = 0; static HMODULE s_pXInputDLL = NULL; static int s_XInputDLLRefCount = 0; -#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) bool WIN_LoadXInputDLL(void) { /* Getting handles to system dlls (via LoadLibrary and its variants) is not - * supported on WinRT, thus, pointers to XInput's functions can't be + * supported on Xbox, thus, pointers to XInput's functions can't be * retrieved via GetProcAddress. * - * When on WinRT, assume that XInput is already loaded, and directly map + * When on Xbox, assume that XInput is already loaded, and directly map * its XInput.h-declared functions to the SDL_XInput* set of function * pointers. - * - * Side-note: XInputGetStateEx is not available for use in WinRT. - * This seems to mean that support for the guide button is not available - * in WinRT, unfortunately. */ SDL_XInputGetState = (XInputGetState_t)XInputGetState; SDL_XInputSetState = (XInputSetState_t)XInputSetState; @@ -68,7 +64,7 @@ void WIN_UnloadXInputDLL(void) { } -#else // !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) +#else // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) bool WIN_LoadXInputDLL(void) { @@ -136,7 +132,7 @@ void WIN_UnloadXInputDLL(void) } } -#endif // SDL_PLATFORM_WINRT +#endif // Ends C function definitions when using C++ #ifdef __cplusplus diff --git a/src/core/winrt/SDL_winrtapp_common.cpp b/src/core/winrt/SDL_winrtapp_common.cpp deleted file mode 100644 index be3558dea..000000000 --- a/src/core/winrt/SDL_winrtapp_common.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 - -int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL; - -extern "C" -SDL_WinRT_DeviceFamily SDL_GetWinRTDeviceFamily() -{ -#if NTDDI_VERSION >= NTDDI_WIN10 // !!! FIXME: I have no idea if this is the right test. This is a UWP API, I think. Older windows should...just return "mobile"? I don't know. --ryan. - Platform::String ^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily; - - if (deviceFamily->Equals("Windows.Desktop")) { - return SDL_WINRT_DEVICEFAMILY_DESKTOP; - } else if (deviceFamily->Equals("Windows.Mobile")) { - return SDL_WINRT_DEVICEFAMILY_MOBILE; - } else if (deviceFamily->Equals("Windows.Xbox")) { - return SDL_WINRT_DEVICEFAMILY_XBOX; - } -#endif - - return SDL_WINRT_DEVICEFAMILY_UNKNOWN; -} diff --git a/src/core/winrt/SDL_winrtapp_common.h b/src/core/winrt/SDL_winrtapp_common.h deleted file mode 100644 index 83cfd7762..000000000 --- a/src/core/winrt/SDL_winrtapp_common.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifndef SDL_winrtapp_common_h_ -#define SDL_winrtapp_common_h_ - -/* A pointer to the app's C-style main() function (which is a different - function than the WinRT app's actual entry point). - */ -extern int (*WINRT_SDLAppEntryPoint)(int, char **); - -#endif // SDL_winrtapp_common_h_ diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp deleted file mode 100644 index 7886a5b58..000000000 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -// Windows includes -#include "ppltasks.h" -using namespace concurrency; -using namespace Windows::ApplicationModel; -using namespace Windows::ApplicationModel::Core; -using namespace Windows::ApplicationModel::Activation; -using namespace Windows::Devices::Input; -using namespace Windows::Graphics::Display; -using namespace Windows::Foundation; -using namespace Windows::System; -using namespace Windows::UI::Core; -using namespace Windows::UI::Input; - -#if SDL_WINAPI_FAMILY_PHONE -using namespace Windows::Phone::UI::Input; -#endif - -// SDL includes -extern "C" { -#include "../../video/SDL_sysvideo.h" -#include "../../events/SDL_events_c.h" -#include "../../events/SDL_keyboard_c.h" -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_windowevents_c.h" -#include "../../render/SDL_sysrender.h" -#include "../windows/SDL_windows.h" -} - -#include "../../video/winrt/SDL_winrtevents_c.h" -#include "../../video/winrt/SDL_winrtvideo_cpp.h" -#include "SDL_winrtapp_common.h" -#include "SDL_winrtapp_direct3d.h" - -#ifdef SDL_VIDEO_RENDER_D3D11 -/* Calling IDXGIDevice3::Trim on the active Direct3D 11.x device is necessary - * when Windows 8.1 apps are about to get suspended. - */ -extern "C" void D3D11_Trim(SDL_Renderer *); -#endif - -// Compile-time debugging options: -// To enable, uncomment; to disable, comment them out. -// #define LOG_POINTER_EVENTS 1 -// #define LOG_WINDOW_EVENTS 1 -// #define LOG_ORIENTATION_EVENTS 1 - -// HACK, DLudwig: record a reference to the global, WinRT 'app'/view. -// SDL/WinRT will use this throughout its code. -// -// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something -// non-global, such as something created inside -// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside -// SDL_CreateWindow(). -SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr; - -ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource -{ - public: - virtual Windows::ApplicationModel::Core::IFrameworkView ^ CreateView(); -}; - -IFrameworkView ^ SDLApplicationSource::CreateView() -{ - // TODO, WinRT: see if this function (CreateView) can ever get called - // more than once. For now, just prevent it from ever assigning - // SDL_WinRTGlobalApp more than once. - SDL_assert(!SDL_WinRTGlobalApp); - SDL_WinRTApp ^ app = ref new SDL_WinRTApp(); - if (!SDL_WinRTGlobalApp) { - SDL_WinRTGlobalApp = app; - } - return app; -} - -bool SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)) -{ - WINRT_SDLAppEntryPoint = mainFunction; - auto direct3DApplicationSource = ref new SDLApplicationSource(); - CoreApplication::Run(direct3DApplicationSource); - return true; -} - -static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange() -{ - CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); - if (coreWindow) { - if (WINRT_GlobalSDLWindow) { - SDL_Window *window = WINRT_GlobalSDLWindow; - SDL_WindowData *data = window->internal; - - int x = (int)SDL_lroundf(data->coreWindow->Bounds.Left); - int y = (int)SDL_lroundf(data->coreWindow->Bounds.Top); - int w = (int)SDL_floorf(data->coreWindow->Bounds.Width); - int h = (int)SDL_floorf(data->coreWindow->Bounds.Height); - -#if SDL_WINAPI_FAMILY_PHONE && NTDDI_VERSION == NTDDI_WIN8 - /* WinPhone 8.0 always keeps its native window size in portrait, - regardless of orientation. This changes in WinPhone 8.1, - in which the native window's size changes along with - orientation. - - Attempt to emulate WinPhone 8.1's behavior on WinPhone 8.0, with - regards to window size. This fixes a rendering bug that occurs - when a WinPhone 8.0 app is rotated to either 90 or 270 degrees. - */ - const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); - switch (currentOrientation) { - case DisplayOrientations::Landscape: - case DisplayOrientations::LandscapeFlipped: - { - int tmp = w; - w = h; - h = tmp; - } break; - } -#endif - - const SDL_WindowFlags latestFlags = WINRT_DetectWindowFlags(window); - if (latestFlags & SDL_WINDOW_MAXIMIZED) { - SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); - } else { - SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); - } - - WINRT_UpdateWindowFlags(window, SDL_WINDOW_FULLSCREEN); - - /* The window can move during a resize event, such as when maximizing - or resizing from a corner */ - SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); - SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, w, h); - } - } -} - -SDL_WinRTApp::SDL_WinRTApp() : m_windowClosed(false), - m_windowVisible(true) -{ -} - -void SDL_WinRTApp::Initialize(CoreApplicationView ^ applicationView) -{ - applicationView->Activated += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnAppActivated); - - CoreApplication::Suspending += - ref new EventHandler(this, &SDL_WinRTApp::OnSuspending); - - CoreApplication::Resuming += - ref new EventHandler(this, &SDL_WinRTApp::OnResuming); - - CoreApplication::Exiting += - ref new EventHandler(this, &SDL_WinRTApp::OnExiting); - -#if NTDDI_VERSION >= NTDDI_WIN10 - /* HACK ALERT! Xbox One doesn't seem to detect gamepads unless something - gets registered to receive Win10's Windows.Gaming.Input.Gamepad.GamepadAdded - events. We'll register an event handler for these events here, to make - sure that gamepad detection works later on, if requested. - */ - Windows::Gaming::Input::Gamepad::GamepadAdded += - ref new Windows::Foundation::EventHandler( - this, &SDL_WinRTApp::OnGamepadAdded); -#endif -} - -#if NTDDI_VERSION > NTDDI_WIN8 -void SDL_WinRTApp::OnOrientationChanged(DisplayInformation ^ sender, Object ^ args) -#else -void SDL_WinRTApp::OnOrientationChanged(Object ^ sender) -#endif -{ -#if LOG_ORIENTATION_EVENTS == 1 - { - CoreWindow ^ window = CoreWindow::GetForCurrentThread(); - if (window) { - SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Bounds={%f,%f,%f,%f}\n", - __FUNCTION__, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), - window->Bounds.X, - window->Bounds.Y, - window->Bounds.Width, - window->Bounds.Height); - } else { - SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n", - __FUNCTION__, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences)); - } - } -#endif - - WINRT_ProcessWindowSizeChange(); - -#if SDL_WINAPI_FAMILY_PHONE - // HACK: Make sure that orientation changes - // lead to the Direct3D renderer's viewport getting updated: - // - // For some reason, this doesn't seem to need to be done on Windows 8.x, - // even when going from Landscape to LandscapeFlipped. It only seems to - // be needed on Windows Phone, at least when I tested on my devices. - // I'm not currently sure why this is, but it seems to work fine. -- David L. - // - // TODO, WinRT: do more extensive research into why orientation changes on Win 8.x don't need D3D changes, or if they might, in some cases - SDL_Window *window = WINRT_GlobalSDLWindow; - if (window) { - SDL_WindowData *data = window->internal; - int w = (int)SDL_floorf(data->coreWindow->Bounds.Width); - int h = (int)SDL_floorf(data->coreWindow->Bounds.Height); - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_RESIZED, w, h); - } -#endif -} - -void SDL_WinRTApp::SetWindow(CoreWindow ^ window) -{ -#if LOG_WINDOW_EVENTS == 1 - SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window bounds={%f, %f, %f,%f}\n", - __FUNCTION__, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), - window->Bounds.X, - window->Bounds.Y, - window->Bounds.Width, - window->Bounds.Height); -#endif - - window->SizeChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowSizeChanged); - - window->VisibilityChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnVisibilityChanged); - - window->Activated += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowActivated); - - window->Closed += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowClosed); - -#if !SDL_WINAPI_FAMILY_PHONE - window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); -#endif - - window->PointerPressed += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerPressed); - - window->PointerMoved += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerMoved); - - window->PointerReleased += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerReleased); - - window->PointerEntered += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerEntered); - - window->PointerExited += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerExited); - - window->PointerWheelChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerWheelChanged); - -#if !SDL_WINAPI_FAMILY_PHONE - // Retrieves relative-only mouse movements: - Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnMouseMoved); -#endif - - window->Dispatcher->AcceleratorKeyActivated += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnAcceleratorKeyActivated); - - window->CharacterReceived += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnCharacterReceived); - -#if NTDDI_VERSION >= NTDDI_WIN10 - Windows::UI::Core::SystemNavigationManager::GetForCurrentView()->BackRequested += - ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); -#elif SDL_WINAPI_FAMILY_PHONE - HardwareButtons::BackPressed += - ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); -#endif - -#if NTDDI_VERSION > NTDDI_WIN8 - DisplayInformation::GetForCurrentView()->OrientationChanged += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); -#else - DisplayProperties::OrientationChanged += - ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); -#endif - -#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) - // Make sure we know when a user has opened the app's settings pane. - // This is needed in order to display a privacy policy, which needs - // to be done for network-enabled apps, as per Windows Store requirements. - using namespace Windows::UI::ApplicationSettings; - SettingsPane::GetForCurrentView()->CommandsRequested += - ref new TypedEventHandler(this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); -#endif -} - -void SDL_WinRTApp::Load(Platform::String ^ entryPoint) -{ -} - -void SDL_WinRTApp::Run() -{ - SDL_SetMainReady(); - if (WINRT_SDLAppEntryPoint) { - // TODO, WinRT: pass the C-style main() a reasonably realistic - // representation of command line arguments. - int argc = 1; - char **argv = (char **)SDL_malloc(2 * sizeof(*argv)); - if (!argv) { - return; - } - argv[0] = SDL_strdup("WinRTApp"); - argv[1] = NULL; - WINRT_SDLAppEntryPoint(argc, argv); - SDL_free(argv[0]); - SDL_free(argv); - } -} - -static bool IsSDLWindowEventPending(SDL_EventType windowEventID) -{ - SDL_Event events[128]; - const int count = SDL_PeepEvents(events, sizeof(events) / sizeof(SDL_Event), SDL_PEEKEVENT, windowEventID, windowEventID); - return (count > 0); -} - -bool SDL_WinRTApp::ShouldWaitForAppResumeEvents() -{ - // Don't wait if the app is visible: - if (m_windowVisible) { - return false; - } - - /* Don't wait until the window-hide events finish processing. - * Do note that if an app-suspend event is sent (as indicated - * by SDL_EVENT_WILL_ENTER_BACKGROUND and SDL_EVENT_DID_ENTER_BACKGROUND - * events), then this code may be a moot point, as WinRT's - * own event pump (aka ProcessEvents()) will pause regardless - * of what we do here. This happens on Windows Phone 8, to note. - * Windows 8.x apps, on the other hand, may get a chance to run - * these. - */ - if (IsSDLWindowEventPending(SDL_EVENT_WINDOW_HIDDEN)) { - return false; - } else if (IsSDLWindowEventPending(SDL_EVENT_WINDOW_FOCUS_LOST)) { - return false; - } else if (IsSDLWindowEventPending(SDL_EVENT_WINDOW_MINIMIZED)) { - return false; - } - - return true; -} - -void SDL_WinRTApp::PumpEvents() -{ - if (!m_windowClosed) { - if (!ShouldWaitForAppResumeEvents()) { - /* This is the normal way in which events should be pumped. - * 'ProcessAllIfPresent' will make ProcessEvents() process anywhere - * from zero to N events, and will then return. - */ - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - } else { - /* This style of event-pumping, with 'ProcessOneAndAllPending', - * will cause anywhere from one to N events to be processed. If - * at least one event is processed, the call will return. If - * no events are pending, then the call will wait until one is - * available, and will not return (to the caller) until this - * happens! This should only occur when the app is hidden. - */ - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); - } - } -} - -void SDL_WinRTApp::Uninitialize() -{ -} - -#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) -void SDL_WinRTApp::OnSettingsPaneCommandsRequested( - Windows::UI::ApplicationSettings::SettingsPane ^ p, - Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^ args) -{ - using namespace Platform; - using namespace Windows::UI::ApplicationSettings; - using namespace Windows::UI::Popups; - - String ^ privacyPolicyURL = nullptr; // a URL to an app's Privacy Policy - String ^ privacyPolicyLabel = nullptr; // label/link text - const char *tmpHintValue = NULL; // SDL_GetHint-retrieved value, used immediately - wchar_t *tmpStr = NULL; // used for UTF8 to UCS2 conversion - - // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint): - tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL); - if (tmpHintValue && tmpHintValue[0] != '\0') { - // Convert the privacy policy's URL to UCS2: - tmpStr = WIN_UTF8ToString(tmpHintValue); - privacyPolicyURL = ref new String(tmpStr); - SDL_free(tmpStr); - - // Optionally retrieve custom label-text for the link. If this isn't - // available, a default value will be used instead. - tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_LABEL); - if (tmpHintValue && tmpHintValue[0] != '\0') { - tmpStr = WIN_UTF8ToString(tmpHintValue); - privacyPolicyLabel = ref new String(tmpStr); - SDL_free(tmpStr); - } else { - privacyPolicyLabel = ref new String(L"Privacy Policy"); - } - - // Register the link, along with a handler to be called if and when it is - // clicked: - auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel, - ref new UICommandInvokedHandler([=](IUICommand ^) { - Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL)); - })); - args->Request->ApplicationCommands->Append(cmd); - } -} -#endif // if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) - -void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow ^ sender, WindowSizeChangedEventArgs ^ args) -{ -#if LOG_WINDOW_EVENTS == 1 - SDL_Log("%s, size={%f,%f}, bounds={%f,%f,%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n", - __FUNCTION__, - args->Size.Width, args->Size.Height, - sender->Bounds.X, sender->Bounds.Y, sender->Bounds.Width, sender->Bounds.Height, - WINRT_DISPLAY_PROPERTY(CurrentOrientation), - WINRT_DISPLAY_PROPERTY(NativeOrientation), - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences), - (WINRT_GlobalSDLWindow ? "yes" : "no")); -#endif - - WINRT_ProcessWindowSizeChange(); -} - -void SDL_WinRTApp::OnVisibilityChanged(CoreWindow ^ sender, VisibilityChangedEventArgs ^ args) -{ -#if LOG_WINDOW_EVENTS == 1 - SDL_Log("%s, visible?=%s, bounds={%f,%f,%f,%f}, WINRT_GlobalSDLWindow?=%s\n", - __FUNCTION__, - (args->Visible ? "yes" : "no"), - sender->Bounds.X, sender->Bounds.Y, - sender->Bounds.Width, sender->Bounds.Height, - (WINRT_GlobalSDLWindow ? "yes" : "no")); -#endif - - m_windowVisible = args->Visible; - if (WINRT_GlobalSDLWindow) { - bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid; - SDL_WindowFlags latestWindowFlags = WINRT_DetectWindowFlags(WINRT_GlobalSDLWindow); - if (args->Visible) { - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_SHOWN, 0, 0); - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_FOCUS_GAINED, 0, 0); - if (latestWindowFlags & SDL_WINDOW_MAXIMIZED) { - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); - } else { - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_RESTORED, 0, 0); - } - } else { - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_HIDDEN, 0, 0); - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0); - SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); - } - - // HACK: Prevent SDL's window-hide handling code, which currently - // triggers a fake window resize (possibly erroneously), from - // marking the SDL window's surface as invalid. - // - // A better solution to this probably involves figuring out if the - // fake window resize can be prevented. - WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid; - } -} - -void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventArgs ^ args) -{ -#if LOG_WINDOW_EVENTS == 1 - SDL_Log("%s, WINRT_GlobalSDLWindow?=%s\n\n", - __FUNCTION__, - (WINRT_GlobalSDLWindow ? "yes" : "no")); -#endif - - /* There's no property in Win 8.x to tell whether a window is active or - not. [De]activation events are, however, sent to the app. We'll just - record those, in case the CoreWindow gets wrapped by an SDL_Window at - some future time. - */ - sender->CustomProperties->Insert("SDLHelperWindowActivationState", args->WindowActivationState); - - SDL_Window *window = WINRT_GlobalSDLWindow; - if (window) { - if (args->WindowActivationState != CoreWindowActivationState::Deactivated) { - SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SHOWN, 0, 0); - if (SDL_GetKeyboardFocus() != window) { - SDL_SetKeyboardFocus(window); - } - - /* Send a mouse-motion event as appropriate. - This doesn't work when called from OnPointerEntered, at least - not in WinRT CoreWindow apps (as OnPointerEntered doesn't - appear to be called after window-reactivation, at least not - in Windows 10, Build 10586.3 (November 2015 update, non-beta). - - Don't do it on WinPhone 8.0 though, as CoreWindow's 'PointerPosition' - property isn't available. - */ -#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION >= NTDDI_WINBLUE - Point cursorPos = WINRT_TransformCursorPosition(window, sender->PointerPosition, TransformToSDLWindowSize); - SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, cursorPos.X, cursorPos.Y); -#endif - - // TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) - // WIN_CheckAsyncMouseRelease(data); - - // TODO, WinRT: implement clipboard support, if possible - ///* - // * FIXME: Update keyboard state - // */ - // WIN_CheckClipboardUpdate(data->videodata); - - // HACK: Resetting the mouse-cursor here seems to fix - // https://bugzilla.libsdl.org/show_bug.cgi?id=3217, whereby a - // WinRT app's mouse cursor may switch to Windows' 'wait' cursor, - // after a user alt-tabs back into a full-screened SDL app. - // This bug does not appear to reproduce 100% of the time. - // It may be a bug in Windows itself (v.10.0.586.36, as tested, - // and the most-recent as of this writing). - SDL_SetCursor(NULL); - } else { - if (SDL_GetKeyboardFocus() == window) { - SDL_SetKeyboardFocus(NULL); - } - } - } -} - -void SDL_WinRTApp::OnWindowClosed(CoreWindow ^ sender, CoreWindowEventArgs ^ args) -{ -#if LOG_WINDOW_EVENTS == 1 - SDL_Log("%s\n", __FUNCTION__); -#endif - m_windowClosed = true; -} - -void SDL_WinRTApp::OnAppActivated(CoreApplicationView ^ applicationView, IActivatedEventArgs ^ args) -{ - CoreWindow::GetForCurrentThread()->Activate(); -} - -void SDL_WinRTApp::OnSuspending(Platform::Object ^ sender, SuspendingEventArgs ^ args) -{ - // Save app state asynchronously after requesting a deferral. Holding a deferral - // indicates that the application is busy performing suspending operations. Be - // aware that a deferral may not be held indefinitely. After about five seconds, - // the app will be forced to exit. - - // ... but first, let the app know it's about to go to the background. - // The separation of events may be important, given that the deferral - // runs in a separate thread. This'll make SDL_EVENT_WILL_ENTER_BACKGROUND - // the only event among the two that runs in the main thread. Given - // that a few WinRT operations can only be done from the main thread - // (things that access the WinRT CoreWindow are one example of this), - // this could be important. - SDL_SendAppEvent(SDL_EVENT_WILL_ENTER_BACKGROUND); - - SuspendingDeferral ^ deferral = args->SuspendingOperation->GetDeferral(); - create_task([this, deferral]() { - // Send an app did-enter-background event immediately to observers. - // CoreDispatcher::ProcessEvents, which is the backbone on which - // SDL_WinRTApp::PumpEvents is built, will not return to its caller - // once it sends out a suspend event. Any events posted to SDL's - // event queue won't get received until the WinRT app is resumed. - // SDL_AddEventWatch() may be used to receive app-suspend events on - // WinRT. - SDL_SendAppEvent(SDL_EVENT_DID_ENTER_BACKGROUND); - - // Let the Direct3D 11 renderer prepare for the app to be backgrounded. - // This is necessary for Windows 8.1, possibly elsewhere in the future. - // More details at: http://msdn.microsoft.com/en-us/library/windows/apps/Hh994929.aspx -#ifdef SDL_VIDEO_RENDER_D3D11 - if (WINRT_GlobalSDLWindow) { - SDL_Renderer *renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow); - if (renderer && (SDL_strcmp(renderer->name, "direct3d11") == 0)) { - D3D11_Trim(renderer); - } - } -#endif - - deferral->Complete(); - }); -} - -void SDL_WinRTApp::OnResuming(Platform::Object ^ sender, Platform::Object ^ args) -{ - // Restore any data or state that was unloaded on suspend. By default, data - // and state are persisted when resuming from suspend. Note that these events - // do not occur if the app was previously terminated. - SDL_SendAppEvent(SDL_EVENT_WILL_ENTER_FOREGROUND); - SDL_SendAppEvent(SDL_EVENT_DID_ENTER_FOREGROUND); -} - -void SDL_WinRTApp::OnExiting(Platform::Object ^ sender, Platform::Object ^ args) -{ - SDL_SendAppEvent(SDL_EVENT_TERMINATING); -} - -static void WINRT_LogPointerEvent(const char *header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint) -{ - Uint8 button, pressed; - Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint; - WINRT_GetSDLButtonForPointerPoint(pt, &button, &pressed); - SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d pressed=%d\n", - header, - pt->Position.X, pt->Position.Y, - transformedPoint.X, transformedPoint.Y, - pt->Properties->MouseWheelDelta, - pt->FrameId, - pt->PointerId, - button, - pressed); -} - -void SDL_WinRTApp::OnPointerPressed(CoreWindow ^ sender, PointerEventArgs ^ args) -{ -#if LOG_POINTER_EVENTS - WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); -#endif - - WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); -} - -void SDL_WinRTApp::OnPointerMoved(CoreWindow ^ sender, PointerEventArgs ^ args) -{ -#if LOG_POINTER_EVENTS - WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); -#endif - - WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); -} - -void SDL_WinRTApp::OnPointerReleased(CoreWindow ^ sender, PointerEventArgs ^ args) -{ -#if LOG_POINTER_EVENTS - WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); -#endif - - WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); -} - -void SDL_WinRTApp::OnPointerEntered(CoreWindow ^ sender, PointerEventArgs ^ args) -{ -#if LOG_POINTER_EVENTS - WINRT_LogPointerEvent("pointer entered", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); -#endif - - WINRT_ProcessPointerEnteredEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); -} - -void SDL_WinRTApp::OnPointerExited(CoreWindow ^ sender, PointerEventArgs ^ args) -{ -#if LOG_POINTER_EVENTS - WINRT_LogPointerEvent("pointer exited", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); -#endif - - WINRT_ProcessPointerExitedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); -} - -void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow ^ sender, PointerEventArgs ^ args) -{ -#if LOG_POINTER_EVENTS - WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); -#endif - - WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); -} - -void SDL_WinRTApp::OnMouseMoved(MouseDevice ^ mouseDevice, MouseEventArgs ^ args) -{ - WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args); -} - -void SDL_WinRTApp::OnAcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher ^ sender, Windows::UI::Core::AcceleratorKeyEventArgs ^ args) -{ - WINRT_ProcessAcceleratorKeyActivated(args); -} - -void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args) -{ - WINRT_ProcessCharacterReceivedEvent(WINRT_GlobalSDLWindow, args); -} - -template -static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args) -{ - SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_AC_BACK, SDL_PRESSED); - SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_AC_BACK, SDL_RELEASED); - - if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, false)) { - args->Handled = true; - } -} - -#if NTDDI_VERSION >= NTDDI_WIN10 -void SDL_WinRTApp::OnBackButtonPressed(Platform::Object ^ sender, Windows::UI::Core::BackRequestedEventArgs ^ args) - -{ - WINRT_OnBackButtonPressed(args); -} -#elif SDL_WINAPI_FAMILY_PHONE -void SDL_WinRTApp::OnBackButtonPressed(Platform::Object ^ sender, Windows::Phone::UI::Input::BackPressedEventArgs ^ args) - -{ - WINRT_OnBackButtonPressed(args); -} -#endif - -#if NTDDI_VERSION >= NTDDI_WIN10 -void SDL_WinRTApp::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ gamepad) -{ - /* HACK ALERT: Nothing needs to be done here, as this method currently - only exists to allow something to be registered with Win10's - GamepadAdded event, an operation that seems to be necessary to get - Xinput-based detection to work on Xbox One. - */ -} -#endif diff --git a/src/core/winrt/SDL_winrtapp_direct3d.h b/src/core/winrt/SDL_winrtapp_direct3d.h deleted file mode 100644 index 07e6f162d..000000000 --- a/src/core/winrt/SDL_winrtapp_direct3d.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 - -extern bool SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)); - -ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView -{ - public: - SDL_WinRTApp(); - - // IFrameworkView Methods. - virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView); - virtual void SetWindow(Windows::UI::Core::CoreWindow ^ window); - virtual void Load(Platform::String ^ entryPoint); - virtual void Run(); - virtual void Uninitialize(); - - internal : - // SDL-specific methods - void - PumpEvents(); - - protected: - bool ShouldWaitForAppResumeEvents(); - - // Event Handlers. - -#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) - void OnSettingsPaneCommandsRequested( - Windows::UI::ApplicationSettings::SettingsPane ^ p, - Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^ args); -#endif // if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) - -#if NTDDI_VERSION > NTDDI_WIN8 - void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation ^ sender, Platform::Object ^ args); -#else - void OnOrientationChanged(Platform::Object ^ sender); -#endif - void OnWindowSizeChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::WindowSizeChangedEventArgs ^ args); - void OnLogicalDpiChanged(Platform::Object ^ sender); - void OnAppActivated(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args); - void OnSuspending(Platform::Object ^ sender, Windows::ApplicationModel::SuspendingEventArgs ^ args); - void OnResuming(Platform::Object ^ sender, Platform::Object ^ args); - void OnExiting(Platform::Object ^ sender, Platform::Object ^ args); - void OnWindowActivated(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::WindowActivatedEventArgs ^ args); - void OnWindowClosed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CoreWindowEventArgs ^ args); - void OnVisibilityChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::VisibilityChangedEventArgs ^ args); - void OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - void OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - void OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - void OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - void OnPointerEntered(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - void OnPointerExited(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - void OnMouseMoved(Windows::Devices::Input::MouseDevice ^ mouseDevice, Windows::Devices::Input::MouseEventArgs ^ args); - void OnAcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher ^ sender, Windows::UI::Core::AcceleratorKeyEventArgs ^ args); - void OnCharacterReceived(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args); - -#if NTDDI_VERSION >= NTDDI_WIN10 - void OnBackButtonPressed(Platform::Object ^ sender, Windows::UI::Core::BackRequestedEventArgs ^ args); -#elif SDL_WINAPI_FAMILY_PHONE - void OnBackButtonPressed(Platform::Object ^ sender, Windows::Phone::UI::Input::BackPressedEventArgs ^ args); -#endif - -#if NTDDI_VERSION >= NTDDI_WIN10 - void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ gamepad); -#endif - - private: - bool m_windowClosed; - bool m_windowVisible; -}; - -extern SDL_WinRTApp ^ SDL_WinRTGlobalApp; diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp deleted file mode 100644 index 876c73a89..000000000 --- a/src/core/winrt/SDL_winrtapp_xaml.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -// Windows includes -#include -#include - -#if WINAPI_FAMILY == WINAPI_FAMILY_APP -#include -#endif - -// SDL includes -#include "../../video/winrt/SDL_winrtevents_c.h" -#include "../../video/winrt/SDL_winrtvideo_cpp.h" -#include "SDL_winrtapp_common.h" -#include "SDL_winrtapp_xaml.h" - -// SDL-internal globals: -bool WINRT_XAMLWasEnabled = false; - -#if WINAPI_FAMILY == WINAPI_FAMILY_APP -extern "C" ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative = NULL; -static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; -#endif - -/* - * Input event handlers (XAML) - */ -#if WINAPI_FAMILY == WINAPI_FAMILY_APP - -static void WINRT_OnPointerPressedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) -{ - WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); -} - -static void WINRT_OnPointerMovedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) -{ - WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); -} - -static void WINRT_OnPointerReleasedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) -{ - WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); -} - -static void WINRT_OnPointerWheelChangedViaXAML(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ args) -{ - WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); -} - -#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP - -/* - * XAML-to-SDL Rendering Callback - */ -#if WINAPI_FAMILY == WINAPI_FAMILY_APP - -static void WINRT_OnRenderViaXAML(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args) -{ - WINRT_CycleXAMLThread(); -} - -#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP - -/* - * SDL + XAML Initialization - */ - -bool SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable) -{ -#if SDL_WINAPI_FAMILY_PHONE - return SDL_SetError("XAML support is not yet available in Windows Phone."); -#else - // Declare C++/CX namespaces: - using namespace Platform; - using namespace Windows::Foundation; - using namespace Windows::UI::Core; - using namespace Windows::UI::Xaml; - using namespace Windows::UI::Xaml::Controls; - using namespace Windows::UI::Xaml::Input; - using namespace Windows::UI::Xaml::Media; - - // Make sure we have a valid XAML element (to draw onto): - if (!backgroundPanelAsIInspectable) { - return SDL_InvalidParamError("backgroundPanelAsIInspectable"); - } - - Platform::Object ^ backgroundPanel = reinterpret_cast((IInspectable *)backgroundPanelAsIInspectable); - SwapChainBackgroundPanel ^ swapChainBackgroundPanel = dynamic_cast(backgroundPanel); - if (!swapChainBackgroundPanel) { - return SDL_SetError("An unknown or unsupported type of XAML control was specified."); - } - - // Setup event handlers: - swapChainBackgroundPanel->PointerPressed += ref new PointerEventHandler(WINRT_OnPointerPressedViaXAML); - swapChainBackgroundPanel->PointerReleased += ref new PointerEventHandler(WINRT_OnPointerReleasedViaXAML); - swapChainBackgroundPanel->PointerWheelChanged += ref new PointerEventHandler(WINRT_OnPointerWheelChangedViaXAML); - swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML); - - // Setup for rendering: - IInspectable *panelInspectable = (IInspectable *)reinterpret_cast(swapChainBackgroundPanel); - panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative); - - WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler(WINRT_OnRenderViaXAML)); - - // Make sure the app is ready to call the SDL-centric main() function: - WINRT_SDLAppEntryPoint = mainFunction; - SDL_SetMainReady(); - - // Make sure video-init knows that we're initializing XAML: - bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled; - WINRT_XAMLWasEnabled = true; - - // Make sure video modes are detected now, while we still have access to the WinRT - // CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the - // SDL/WinRT thread. - if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) { - // SDL_InitSubSystem will, on error, set the SDL error. Let that propagate to - // the caller to here: - WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue; - return false; - } - - // All done, for now. - return true; -#endif // SDL_WINAPI_FAMILY_PHONE -} diff --git a/src/core/winrt/SDL_winrtapp_xaml.h b/src/core/winrt/SDL_winrtapp_xaml.h deleted file mode 100644 index 148e278dc..000000000 --- a/src/core/winrt/SDL_winrtapp_xaml.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifndef SDL_winrtapp_xaml_h_ -#define SDL_winrtapp_xaml_h_ - -#ifdef __cplusplus -extern bool WINRT_XAMLWasEnabled; -extern bool SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable); -#endif // ifdef __cplusplus - -#endif // SDL_winrtapp_xaml_h_ diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 4704bdc6e..9d7fc8988 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -23,7 +23,7 @@ #include "SDL_cpuinfo_c.h" -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "../core/windows/SDL_windows.h" #endif diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 2e8e23832..be52f2c29 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -49,8 +49,6 @@ #define SDL_DYNAMIC_API 0 #elif defined(SDL_PLATFORM_EMSCRIPTEN) // probably not useful on Emscripten. #define SDL_DYNAMIC_API 0 -#elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT // probably not useful on WinRT, given current .dll loading restrictions -#define SDL_DYNAMIC_API 0 #elif defined(SDL_PLATFORM_PS2) && SDL_PLATFORM_PS2 #define SDL_DYNAMIC_API 0 #elif defined(SDL_PLATFORM_PSP) && SDL_PLATFORM_PSP diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index e2259e16c..1b9d1b280 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -504,8 +504,6 @@ SDL3_0.0.0 { SDL_GetUserFolder; SDL_GetVersion; SDL_GetVideoDriver; - SDL_GetWinRTDeviceFamily; - SDL_GetWinRTFSPath; SDL_GetWindowAspectRatio; SDL_GetWindowBordersSize; SDL_GetWindowDisplayScale; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index a3ae76136..99d95a43b 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -529,8 +529,6 @@ #define SDL_GetUserFolder SDL_GetUserFolder_REAL #define SDL_GetVersion SDL_GetVersion_REAL #define SDL_GetVideoDriver SDL_GetVideoDriver_REAL -#define SDL_GetWinRTDeviceFamily SDL_GetWinRTDeviceFamily_REAL -#define SDL_GetWinRTFSPath SDL_GetWinRTFSPath_REAL #define SDL_GetWindowAspectRatio SDL_GetWindowAspectRatio_REAL #define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL #define SDL_GetWindowDisplayScale SDL_GetWindowDisplayScale_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index b80ddf874..d7364bc97 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -549,8 +549,6 @@ SDL_DYNAPI_PROC(SDL_Finger**,SDL_GetTouchFingers,(SDL_TouchID a, int *b),(a,b),r SDL_DYNAPI_PROC(const char*,SDL_GetUserFolder,(SDL_Folder a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetVersion,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return) -SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_GetWinRTDeviceFamily,(void),(),return) -SDL_DYNAPI_PROC(const char*,SDL_GetWinRTFSPath,(SDL_WinRT_Path a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowAspectRatio,(SDL_Window *a, float *b, float *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(float,SDL_GetWindowDisplayScale,(SDL_Window *a),(a),return) diff --git a/src/dynapi/SDL_dynapi_unsupported.h b/src/dynapi/SDL_dynapi_unsupported.h index ce6864c86..2402eaabb 100644 --- a/src/dynapi/SDL_dynapi_unsupported.h +++ b/src/dynapi/SDL_dynapi_unsupported.h @@ -37,10 +37,6 @@ typedef struct IDirect3DDevice9 IDirect3DDevice9; typedef struct XTaskQueueHandle XTaskQueueHandle; #endif -#ifndef SDL_PLATFORM_WINRT -typedef int SDL_WinRT_DeviceFamily; -typedef int SDL_WinRT_Path; -#endif #ifndef SDL_PLATFORM_GDK typedef struct XUserHandle XUserHandle; #endif diff --git a/src/file/SDL_iostream.c b/src/file/SDL_iostream.c index 59cb47225..f4378b869 100644 --- a/src/file/SDL_iostream.c +++ b/src/file/SDL_iostream.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "../core/windows/SDL_windows.h" #endif @@ -54,7 +54,7 @@ struct SDL_IOStream #include "../core/android/SDL_android.h" #endif -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) typedef struct IOStreamWindowsData { @@ -75,7 +75,7 @@ typedef struct IOStreamWindowsData static bool SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *filename, const char *mode) { -#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) UINT old_error_mode; #endif HANDLE h; @@ -108,7 +108,7 @@ static bool SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *f if (!iodata->data) { return false; } -#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // Do not open a dialog box if failure old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); @@ -116,17 +116,6 @@ static bool SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *f { LPWSTR str = WIN_UTF8ToStringW(filename); -#if defined(SDL_PLATFORM_WINRT) - CREATEFILE2_EXTENDED_PARAMETERS extparams; - SDL_zero(extparams); - extparams.dwSize = sizeof(extparams); - extparams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - h = CreateFile2(str, - (w_right | r_right), - (w_right) ? 0 : FILE_SHARE_READ, - (must_exist | truncate | a_mode), - &extparams); -#else h = CreateFileW(str, (w_right | r_right), (w_right) ? 0 : FILE_SHARE_READ, @@ -134,11 +123,10 @@ static bool SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *f (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, NULL); -#endif SDL_free(str); } -#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // restore old behavior SetErrorMode(old_error_mode); #endif @@ -522,18 +510,10 @@ static SDL_bool SDLCALL mem_close(void *userdata) #if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINDOWS) static bool IsRegularFileOrPipe(FILE *f) { - #ifdef SDL_PLATFORM_WINRT - struct __stat64 st; - if (_fstat64(_fileno(f), &st) < 0 || - !((st.st_mode & _S_IFMT) == _S_IFREG || (st.st_mode & _S_IFMT) == _S_IFIFO)) { - return false; - } - #else struct stat st; if (fstat(fileno(f), &st) < 0 || !(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) { return false; } - #endif return true; } #endif @@ -624,7 +604,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) } } -#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) IOStreamWindowsData *iodata = (IOStreamWindowsData *) SDL_malloc(sizeof (*iodata)); if (!iodata) { return NULL; @@ -655,10 +635,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) #elif defined(HAVE_STDIO_H) { - #if defined(SDL_PLATFORM_WINRT) - FILE *fp = NULL; - fopen_s(&fp, file, mode); - #elif defined(SDL_PLATFORM_3DS) + #if defined(SDL_PLATFORM_3DS) FILE *fp = N3DS_FileOpen(file, mode); #else FILE *fp = fopen(file, mode); diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp deleted file mode 100644 index fd73b0c6b..000000000 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -/* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all - */ - -#ifdef SDL_PLATFORM_WINRT - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -// System dependent filesystem routines - -extern "C" { -#include "../../core/windows/SDL_windows.h" -#include "../SDL_sysfilesystem.h" -} - -#include -#include - -using namespace std; -using namespace Windows::Storage; - -static const wchar_t *SDL_GetWinRTFSPathUNICODE(SDL_WinRT_Path pathType) -{ - switch (pathType) { - case SDL_WINRT_PATH_INSTALLED_LOCATION: - { - static wstring path; - if (path.empty()) { -#if defined(NTDDI_WIN10_19H1) && (NTDDI_VERSION >= NTDDI_WIN10_19H1) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Only PC supports mods - // Windows 1903 supports mods, via the EffectiveLocation API - if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) { - path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data(); - } else { - path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); - } -#else - path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); -#endif - } - return path.c_str(); - } - - case SDL_WINRT_PATH_LOCAL_FOLDER: - { - static wstring path; - if (path.empty()) { - path = ApplicationData::Current->LocalFolder->Path->Data(); - } - return path.c_str(); - } - -#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION > NTDDI_WIN8 - case SDL_WINRT_PATH_ROAMING_FOLDER: - { - static wstring path; - if (path.empty()) { - path = ApplicationData::Current->RoamingFolder->Path->Data(); - } - return path.c_str(); - } - - case SDL_WINRT_PATH_TEMP_FOLDER: - { - static wstring path; - if (path.empty()) { - path = ApplicationData::Current->TemporaryFolder->Path->Data(); - } - return path.c_str(); - } -#endif - - default: - break; - } - - SDL_Unsupported(); - return NULL; -} - -extern "C" const char *SDL_GetWinRTFSPath(SDL_WinRT_Path pathType) -{ - typedef unordered_map UTF8PathMap; - static UTF8PathMap utf8Paths; - - UTF8PathMap::iterator searchResult = utf8Paths.find(pathType); - if (searchResult != utf8Paths.end()) { - return searchResult->second.c_str(); - } - - const wchar_t *ucs2Path = SDL_GetWinRTFSPathUNICODE(pathType); - if (!ucs2Path) { - return NULL; - } - - char *utf8Path = WIN_StringToUTF8W(ucs2Path); - utf8Paths[pathType] = utf8Path; - SDL_free(utf8Path); - return SDL_GetPersistentString(utf8Paths[pathType].c_str()); -} - -extern "C" char *SDL_SYS_GetBasePath(void) -{ - const char *srcPath = SDL_GetWinRTFSPath(SDL_WINRT_PATH_INSTALLED_LOCATION); - size_t destPathLen; - char *destPath = NULL; - - if (!srcPath) { - SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError()); - return NULL; - } - - destPathLen = SDL_strlen(srcPath) + 2; - destPath = (char *)SDL_malloc(destPathLen); - if (!destPath) { - return NULL; - } - - SDL_snprintf(destPath, destPathLen, "%s\\", srcPath); - return destPath; -} - -extern "C" char *SDL_SYS_GetPrefPath(const char *org, const char *app) -{ - /* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and - * earlier is not available on WinRT or Windows Phone. WinRT provides - * a similar API, but SHGetFolderPath can't be called, at least not - * without violating Microsoft's app-store requirements. - */ - - const WCHAR *srcPath = NULL; - WCHAR path[MAX_PATH]; - char *result = NULL; - WCHAR *worg = NULL; - WCHAR *wapp = NULL; - size_t new_wpath_len = 0; - BOOL api_result = FALSE; - - if (!app) { - SDL_InvalidParamError("app"); - return NULL; - } - if (!org) { - org = ""; - } - - srcPath = SDL_GetWinRTFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER); - if (!srcPath) { - SDL_SetError("Unable to find a source path"); - return NULL; - } - - if (SDL_wcslen(srcPath) >= MAX_PATH) { - SDL_SetError("Path too long."); - return NULL; - } - SDL_wcslcpy(path, srcPath, SDL_arraysize(path)); - - worg = WIN_UTF8ToStringW(org); - if (!worg) { - return NULL; - } - - wapp = WIN_UTF8ToStringW(app); - if (!wapp) { - SDL_free(worg); - return NULL; - } - - new_wpath_len = SDL_wcslen(worg) + SDL_wcslen(wapp) + SDL_wcslen(path) + 3; - - if ((new_wpath_len + 1) > MAX_PATH) { - SDL_free(worg); - SDL_free(wapp); - SDL_SetError("Path too long."); - return NULL; - } - - if (*worg) { - SDL_wcslcat(path, L"\\", new_wpath_len + 1); - SDL_wcslcat(path, worg, new_wpath_len + 1); - SDL_free(worg); - } - - api_result = CreateDirectoryW(path, NULL); - if (api_result == FALSE) { - if (GetLastError() != ERROR_ALREADY_EXISTS) { - SDL_free(wapp); - WIN_SetError("Couldn't create a prefpath."); - return NULL; - } - } - - SDL_wcslcat(path, L"\\", new_wpath_len + 1); - SDL_wcslcat(path, wapp, new_wpath_len + 1); - SDL_free(wapp); - - api_result = CreateDirectoryW(path, NULL); - if (api_result == FALSE) { - if (GetLastError() != ERROR_ALREADY_EXISTS) { - WIN_SetError("Couldn't create a prefpath."); - return NULL; - } - } - - SDL_wcslcat(path, L"\\", new_wpath_len + 1); - - result = WIN_StringToUTF8W(path); - - return result; -} - -char *SDL_SYS_GetUserFolder(SDL_Folder folder) -{ - wstring wpath; - - switch (folder) { - #define CASEPATH(sym, var) case sym: wpath = Windows::Storage::UserDataPaths::GetDefault()->var->Data(); break - CASEPATH(SDL_FOLDER_HOME, Profile); - CASEPATH(SDL_FOLDER_DESKTOP, Desktop); - CASEPATH(SDL_FOLDER_DOCUMENTS, Documents); - CASEPATH(SDL_FOLDER_DOWNLOADS, Downloads); - CASEPATH(SDL_FOLDER_MUSIC, Music); - CASEPATH(SDL_FOLDER_PICTURES, Pictures); - CASEPATH(SDL_FOLDER_SCREENSHOTS, Screenshots); - CASEPATH(SDL_FOLDER_TEMPLATES, Templates); - CASEPATH(SDL_FOLDER_VIDEOS, Videos); - #undef CASEPATH - #define UNSUPPPORTED_CASEPATH(sym) SDL_SetError("The %s folder is unsupported on WinRT", #sym); return NULL; - UNSUPPPORTED_CASEPATH(SDL_FOLDER_PUBLICSHARE); - UNSUPPPORTED_CASEPATH(SDL_FOLDER_SAVEDGAMES); - #undef UNSUPPPORTED_CASEPATH - default: - SDL_SetError("Invalid SDL_Folder: %d", (int)folder); - return NULL; - }; - - wpath += L"\\"; - - return WIN_StringToUTF8W(wpath.c_str()); -} - -#endif // SDL_PLATFORM_WINRT diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index c3a98dacb..d7d173f47 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -6248,11 +6248,9 @@ static bool D3D12_INTERNAL_CreateSwapchain( swapchainDesc.Flags = 0; } -#ifndef SDL_PLATFORM_WINRT if (!IsWindow(dxgiHandle)) { return false; } -#endif // Create the swapchain! res = IDXGIFactory4_CreateSwapChainForHwnd( diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 5c43fbadf..1e37ea4c8 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -832,9 +832,6 @@ int SDL_GetJoystickPlayerIndexForID(SDL_JoystickID instance_id) */ static bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) { -#ifdef SDL_PLATFORM_WINRT - return true; -#else // printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes); if (joystick->naxes == 2) { @@ -843,7 +840,6 @@ static bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) } return SDL_VIDPIDInList(SDL_GetJoystickVendor(joystick), SDL_GetJoystickProduct(joystick), &zero_centered_devices); -#endif // SDL_PLATFORM_WINRT } static bool IsROGAlly(SDL_Joystick *joystick) diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index b87d34517..b05361063 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -686,13 +686,8 @@ static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) typedef HRESULT(WINAPI * WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER * hstringHeader, HSTRING * string); typedef HRESULT(WINAPI * RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void **factory); -#ifdef SDL_PLATFORM_WINRT - WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = WindowsCreateStringReference; - RoGetActivationFactory_t RoGetActivationFactoryFunc = RoGetActivationFactory; -#else WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = (WindowsCreateStringReference_t)WIN_LoadComBaseFunction("WindowsCreateStringReference"); RoGetActivationFactory_t RoGetActivationFactoryFunc = (RoGetActivationFactory_t)WIN_LoadComBaseFunction("RoGetActivationFactory"); -#endif if (WindowsCreateStringReferenceFunc && RoGetActivationFactoryFunc) { PCWSTR pNamespace = L"Windows.Gaming.Input.Gamepad"; HSTRING_HEADER hNamespaceStringHeader; diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index 55cf23daf..7aa5c6491 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -88,9 +88,8 @@ static struct WindowsGamingInputControllerState *controllers; } wgi; -/* WinRT headers in official Windows SDK contain only declarations, and we have to define these GUIDs ourselves. - * https://stackoverflow.com/a/55605485/1795050 - */ +// WinRT headers in official Windows SDK contain only declarations, and we have to define these GUIDs ourselves. +// https://stackoverflow.com/a/55605485/1795050 DEFINE_GUID(IID___FIEventHandler_1_Windows__CGaming__CInput__CRawGameController, 0x00621c22, 0x42e8, 0x529f, 0x92, 0x70, 0x83, 0x6b, 0x32, 0x93, 0x1d, 0x72); DEFINE_GUID(IID___x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics, 0x5c37b8c8, 0x37b1, 0x4ad8, 0x94, 0x58, 0x20, 0x0f, 0x1a, 0x30, 0x01, 0x8e); DEFINE_GUID(IID___x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics2, 0x52b5d744, 0xbb86, 0x445a, 0xb5, 0x9c, 0x59, 0x6f, 0x0e, 0x2a, 0x49, 0xdf); @@ -592,13 +591,6 @@ static bool WGI_JoystickInit(void) return SDL_SetError("RoInitialize() failed"); } -#ifdef SDL_PLATFORM_WINRT - wgi.CoIncrementMTAUsage = CoIncrementMTAUsage; - wgi.RoGetActivationFactory = RoGetActivationFactory; - wgi.WindowsCreateStringReference = WindowsCreateStringReference; - wgi.WindowsDeleteString = WindowsDeleteString; - wgi.WindowsGetStringRawBuffer = WindowsGetStringRawBuffer; -#else #define RESOLVE(x) wgi.x = (x##_t)WIN_LoadComBaseFunction(#x); if (!wgi.x) return WIN_SetError("GetProcAddress failed for " #x); RESOLVE(CoIncrementMTAUsage); RESOLVE(RoGetActivationFactory); @@ -606,9 +598,7 @@ static bool WGI_JoystickInit(void) RESOLVE(WindowsDeleteString); RESOLVE(WindowsGetStringRawBuffer); #undef RESOLVE -#endif // SDL_PLATFORM_WINRT -#ifndef SDL_PLATFORM_WINRT { /* There seems to be a bug in Windows where a dependency of WGI can be unloaded from memory prior to WGI itself. * This results in Windows_Gaming_Input!GameController::~GameController() invoking an unloaded DLL and crashing. @@ -623,7 +613,6 @@ static bool WGI_JoystickInit(void) } } } -#endif WGI_LoadRawGameControllerStatics(); diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 727ff7c28..1d724618b 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -36,7 +36,7 @@ #include "../../thread/SDL_systhread.h" #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_hid.h" -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include #endif @@ -79,7 +79,7 @@ void WINDOWS_RAWINPUTEnabledChanged(void) SetWindowsDeviceChanged(); } -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) typedef struct { @@ -211,9 +211,7 @@ static bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_ return (lastret != -1); } -#endif // !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - -#ifndef SDL_PLATFORM_WINRT +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static SDL_DeviceNotificationData s_notification_data; @@ -320,8 +318,6 @@ static void SDL_StopJoystickThread(void) s_joystickThread = NULL; } -#endif // !defined(SDL_PLATFORM_WINRT) - void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device) { device->send_add_event = true; @@ -348,7 +344,7 @@ static bool WINDOWS_JoystickInit(void) WIN_InitDeviceNotification(); -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, false); if (s_bJoystickThread) { if (!SDL_StartJoystickThread()) { @@ -639,7 +635,7 @@ void WINDOWS_JoystickQuit(void) } SYS_Joystick = NULL; -#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (s_bJoystickThread) { SDL_StopJoystickThread(); } else { diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index e4081af2e..b069a9c32 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -29,23 +29,13 @@ void *SDL_LoadObject(const char *sofile) { - void *handle; - LPWSTR wstr; - if (!sofile) { SDL_InvalidParamError("sofile"); return NULL; } - wstr = WIN_UTF8ToStringW(sofile); -#ifdef SDL_PLATFORM_WINRT - /* WinRT only publicly supports LoadPackagedLibrary() for loading .dll - files. LoadLibrary() is a private API, and not available for apps - (that can be published to MS' Windows Store.) - */ - handle = (void *)LoadPackagedLibrary(wstr, 0); -#else - handle = (void *)LoadLibrary(wstr); -#endif + + LPWSTR wstr = WIN_UTF8ToStringW(sofile); + void *handle = (void *)LoadLibrary(wstr); SDL_free(wstr); // Generate an error message if all loads failed diff --git a/src/locale/winrt/SDL_syslocale.c b/src/locale/winrt/SDL_syslocale.c deleted file mode 100644 index 1ad9756e5..000000000 --- a/src/locale/winrt/SDL_syslocale.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 - -#include "../SDL_syslocale.h" - -// using namespace Windows::Graphics::Display; -#include - -bool SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) -{ - WCHAR wbuffer[128] = L""; - int rc = 0; - - // !!! FIXME: do we not have GetUserPreferredUILanguages on WinPhone or UWP? -#if SDL_WINAPI_FAMILY_PHONE - rc = GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME, wbuffer, SDL_arraysize(wbuffer)); -#else - rc = GetSystemDefaultLocaleName(wbuffer, SDL_arraysize(wbuffer)); -#endif - - if (rc > 0) { - // Need to convert LPWSTR to LPSTR, that is wide char to char. - int i; - - if (((size_t)rc) >= (buflen - 1)) { - rc = (int)(buflen - 1); - } - for (i = 0; i < rc; i++) { - buf[i] = (char)wbuffer[i]; // assume this was ASCII anyhow. - } - } - return true; -} diff --git a/src/main/winrt/SDL3-WinRTResource_BlankCursor.cur b/src/main/winrt/SDL3-WinRTResource_BlankCursor.cur deleted file mode 100644 index c6556b8a7..000000000 Binary files a/src/main/winrt/SDL3-WinRTResource_BlankCursor.cur and /dev/null differ diff --git a/src/main/winrt/SDL3-WinRTResources.rc b/src/main/winrt/SDL3-WinRTResources.rc deleted file mode 100644 index a923a1196..000000000 --- a/src/main/winrt/SDL3-WinRTResources.rc +++ /dev/null @@ -1,2 +0,0 @@ -#include "winres.h" -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 5000 CURSOR "SDL3-WinRTResource_BlankCursor.cur" diff --git a/src/main/winrt/SDL_sysmain_runapp.cpp b/src/main/winrt/SDL_sysmain_runapp.cpp deleted file mode 100644 index a69509d01..000000000 --- a/src/main/winrt/SDL_sysmain_runapp.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 "../../core/winrt/SDL_winrtapp_direct3d.h" -#include "../../core/winrt/SDL_winrtapp_xaml.h" - -#include - -extern "C" -int SDL_RunApp(int, char**, SDL_main_func mainFunction, void * xamlBackgroundPanel) -{ - if (xamlBackgroundPanel) { - if (!SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel)) { - return 1; - } - } else { - if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) { - return 1; - } - if (!SDL_WinRTInitNonXAMLApp(mainFunction)) { - return 1; - } - } - return 0; -} - diff --git a/src/misc/winrt/SDL_sysurl.cpp b/src/misc/winrt/SDL_sysurl.cpp deleted file mode 100644 index 0026e615e..000000000 --- a/src/misc/winrt/SDL_sysurl.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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_sysurl.h" -#include "../../core/windows/SDL_windows.h" - -bool SDL_SYS_OpenURL(const char *url) -{ - WCHAR *wurl = WIN_UTF8ToStringW(url); - if (!wurl) { - return false; - } - auto strurl = ref new Platform::String(wurl); - SDL_free(wurl); - - auto uri = ref new Windows::Foundation::Uri(strurl); - Windows::System::Launcher::LaunchUriAsync(uri); - return true; // oh well, we're not waiting on an async task here. -} diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 255cecf38..b42e4f7f0 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -71,9 +71,6 @@ static SDL_GetPowerInfo_Impl implementations[] = { #ifdef SDL_POWER_N3DS // handles N3DS. SDL_GetPowerInfo_N3DS, #endif -#ifdef SDL_POWER_WINRT // handles WinRT - SDL_GetPowerInfo_WinRT, -#endif #ifdef SDL_POWER_EMSCRIPTEN // handles Emscripten SDL_GetPowerInfo_Emscripten, #endif diff --git a/src/power/SDL_syspower.h b/src/power/SDL_syspower.h index f62ebf6ab..3af0bacaa 100644 --- a/src/power/SDL_syspower.h +++ b/src/power/SDL_syspower.h @@ -38,7 +38,6 @@ bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *); bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *); bool SDL_GetPowerInfo_VITA(SDL_PowerState *, int *, int *); bool SDL_GetPowerInfo_N3DS(SDL_PowerState *, int *, int *); -bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *); // this one is static in SDL_power.c diff --git a/src/power/winrt/SDL_syspower.cpp b/src/power/winrt/SDL_syspower.cpp deleted file mode 100644 index 031e0073f..000000000 --- a/src/power/winrt/SDL_syspower.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifndef SDL_POWER_DISABLED -#if SDL_POWER_WINRT - -extern "C" bool -SDL_GetPowerInfo_WinRT(SDL_PowerState *state, int *seconds, int *percent) -{ - // TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement SDL_GetPowerInfo_WinRT as appropriate. - /* Notes: - - the Win32 function, GetSystemPowerStatus, is not available for use on WinRT - - Windows Phone 8 has a 'Battery' class, which is documented as available for C++ - - More info on WP8's Battery class can be found at http://msdn.microsoft.com/library/windowsphone/develop/jj207231 - */ - return false; -} - -#endif // SDL_POWER_WINRT -#endif // SDL_POWER_DISABLED diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 66fd7ab2e..af5ae6f70 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -24,9 +24,7 @@ #define COBJMACROS #include "../../core/windows/SDL_windows.h" -#ifndef SDL_PLATFORM_WINRT #include "../../video/windows/SDL_windowswindow.h" -#endif #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" #include "../../video/SDL_pixels_c.h" @@ -37,22 +35,6 @@ #include "SDL_shaders_d3d11.h" -#ifdef SDL_PLATFORM_WINRT - -#if NTDDI_VERSION > NTDDI_WIN8 -#include -#endif - -#include "SDL_render_winrt.h" - -#if WINAPI_FAMILY == WINAPI_FAMILY_APP -#include -// TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var -extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative; -#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP - -#endif // SDL_PLATFORM_WINRT - #if defined(_MSC_VER) && !defined(__clang__) #define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str #else @@ -222,14 +204,7 @@ typedef struct int currentVertexBuffer; } D3D11_RenderData; -/* Define D3D GUIDs here so we don't have to include uuid.lib. - * - * Fix for SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3437: - * The extra 'SDL_' was added to the start of each IID's name, in order - * to prevent build errors on both MinGW-w64 and WinRT/UWP. - * (SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3336 led to - * linker errors in WinRT/UWP builds.) - */ +// Define D3D GUIDs here so we don't have to include uuid.lib. #ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA #pragma GCC diagnostic push @@ -238,9 +213,6 @@ typedef struct static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; -#if defined(SDL_PLATFORM_WINRT) && NTDDI_VERSION > NTDDI_WIN8 -static const GUID SDL_IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } }; -#endif static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } }; static const GUID SDL_IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } }; static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } }; @@ -555,10 +527,6 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) // See if we need debug interfaces createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, false); -#ifdef SDL_PLATFORM_WINRT - CreateDXGIFactory2Func = CreateDXGIFactory2; - D3D11CreateDeviceFunc = D3D11CreateDevice; -#else data->hDXGIMod = SDL_LoadObject("dxgi.dll"); if (!data->hDXGIMod) { result = E_FAIL; @@ -585,7 +553,6 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) result = E_FAIL; goto done; } -#endif // SDL_PLATFORM_WINRT if (createDebug) { #ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__ @@ -897,13 +864,7 @@ static bool D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Re static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; -#ifdef SDL_PLATFORM_WINRT - IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); - const BOOL usingXAML = (!coreWindow); -#else IUnknown *coreWindow = NULL; - const BOOL usingXAML = FALSE; -#endif IDXGISwapChain3 *swapChain3 = NULL; HRESULT result = S_OK; @@ -928,19 +889,10 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency. -#if SDL_WINAPI_FAMILY_PHONE - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // On phone, only stretch and aspect-ratio stretch scaling are allowed. - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // On phone, no swap effects are supported. - // TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on -#else - if (usingXAML) { - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + if (WIN_IsWindows8OrGreater()) { + swapChainDesc.Scaling = DXGI_SCALING_NONE; } else { - if (WIN_IsWindows8OrGreater()) { - swapChainDesc.Scaling = DXGI_SCALING_NONE; - } else { - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; - } + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; } if (SDL_GetWindowFlags(renderer->window) & SDL_WINDOW_TRANSPARENT) { swapChainDesc.Scaling = DXGI_SCALING_STRETCH; @@ -948,7 +900,6 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) } else { swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect. } -#endif swapChainDesc.Flags = 0; if (coreWindow) { @@ -962,28 +913,6 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result); goto done; } - } else if (usingXAML) { - result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory, - (IUnknown *)data->d3dDevice, - &swapChainDesc, - NULL, - &data->swapChain); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForComposition"), result); - goto done; - } - -#if WINAPI_FAMILY == WINAPI_FAMILY_APP - result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *)data->swapChain); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ISwapChainBackgroundPanelNative::SetSwapChain"), result); - goto done; - } -#else - SDL_SetError(SDL_COMPOSE_ERROR("XAML support is not yet available for Windows Phone")); - result = E_FAIL; - goto done; -#endif } else { #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) HWND hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(renderer->window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); @@ -1102,11 +1031,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) /* The width and height of the swap chain must be based on the display's * non-rotated size. */ -#ifdef SDL_PLATFORM_WINRT - SDL_GetWindowSize(renderer->window, &w, &h); -#else SDL_GetWindowSizeInPixels(renderer->window, &w, &h); -#endif data->rotation = D3D11_GetCurrentRotation(); // SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); if (D3D11_IsDisplayRotated90Degrees(data->rotation)) { @@ -1116,8 +1041,6 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } if (data->swapChain) { - // IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. -#if !defined(SDL_PLATFORM_WINRT) || !SDL_WINAPI_FAMILY_PHONE // If the swap chain already exists, resize it. result = IDXGISwapChain_ResizeBuffers(data->swapChain, 0, @@ -1136,7 +1059,6 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::ResizeBuffers"), result); goto done; } -#endif } else { result = D3D11_CreateSwapChain(renderer, w, h); if (FAILED(result) || !data->swapChain) { @@ -1144,23 +1066,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } } -#if !SDL_WINAPI_FAMILY_PHONE - /* Set the proper rotation for the swap chain. - * - * To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary - * on Windows Phone 8.0, nor is it supported there. - * - * IDXGISwapChain1::SetRotation does seem to be available on Windows Phone 8.1, - * however I've yet to find a way to make it work. It might have something to - * do with IDXGISwapChain::ResizeBuffers appearing to not being available on - * Windows Phone 8.1 (it wasn't on Windows Phone 8.0), but I'm not 100% sure of this. - * The call doesn't appear to be entirely necessary though, and is a performance-related - * call, at least according to the following page on MSDN: - * http://code.msdn.microsoft.com/windowsapps/DXGI-swap-chain-rotation-21d13d71 - * -- David L. - * - * TODO, WinRT: reexamine the docs for IDXGISwapChain1::SetRotation, see if might be available, usable, and prudent-to-call on WinPhone 8.1 - */ + // Set the proper rotation for the swap chain. if (WIN_IsWindows8OrGreater()) { if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) { result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation); @@ -1170,7 +1076,6 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } } } -#endif result = IDXGISwapChain_GetBuffer(data->swapChain, 0, @@ -1213,26 +1118,6 @@ static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer) return D3D11_CreateWindowSizeDependentResources(renderer); } -void D3D11_Trim(SDL_Renderer *renderer) -{ -#ifdef SDL_PLATFORM_WINRT -#if NTDDI_VERSION > NTDDI_WIN8 - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - HRESULT result = S_OK; - IDXGIDevice3 *dxgiDevice = NULL; - - result = ID3D11Device_QueryInterface(data->d3dDevice, &SDL_IID_IDXGIDevice3, &dxgiDevice); - if (FAILED(result)) { - // WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice3", result); - return; - } - - IDXGIDevice3_Trim(dxgiDevice); - SAFE_RELEASE(dxgiDevice); -#endif -#endif -} - static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; @@ -1835,8 +1720,6 @@ static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, * have the ability to write a CPU-bound pixel buffer to a rectangular * subrect of a texture. Direct3D 11.1 can, however, write a pixel * buffer to an entire texture, hence the use of a staging texture. - * - * TODO, WinRT: consider avoiding the use of a staging texture in D3D11_LockTexture if/when the entire texture is being updated */ ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc); stagingTextureDesc.Width = rect->w; @@ -2183,7 +2066,6 @@ static bool D3D11_UpdateViewport(SDL_Renderer *renderer) orientationAlignedViewport.w = (float)viewport->w; orientationAlignedViewport.h = (float)viewport->h; } - // TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) d3dviewport.TopLeftX = orientationAlignedViewport.x; d3dviewport.TopLeftY = orientationAlignedViewport.y; @@ -2736,15 +2618,10 @@ static bool D3D11_RenderPresent(SDL_Renderer *renderer) SDL_zero(parameters); -#if SDL_WINAPI_FAMILY_PHONE - result = IDXGISwapChain_Present(data->swapChain, data->syncInterval, data->presentFlags); -#else /* The application may optionally specify "dirty" or "scroll" * rects to improve efficiency in certain scenarios. - * This option is not available on Windows Phone 8, to note. */ result = IDXGISwapChain1_Present1(data->swapChain, data->syncInterval, data->presentFlags, ¶meters); -#endif /* Discard the contents of the render target. * This is a valid operation only when the existing contents will be entirely @@ -2758,8 +2635,6 @@ static bool D3D11_RenderPresent(SDL_Renderer *renderer) if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { /* If the device was removed either by a disconnect or a driver upgrade, we * must recreate all device resources. - * - * TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvage debug info from users' machines */ if (result == DXGI_ERROR_DEVICE_REMOVED) { D3D11_HandleDeviceLost(renderer); @@ -2778,22 +2653,6 @@ static bool D3D11_SetVSync(SDL_Renderer *renderer, const int vsync) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; -#if SDL_WINAPI_FAMILY_PHONE - /* VSync is required in Windows Phone, at least for Win Phone 8.0 and 8.1. - * Failure to use it seems to either result in: - * - * - with the D3D11 debug runtime turned OFF, vsync seemingly gets turned - * off (framerate doesn't get capped), but nothing appears on-screen - * - * - with the D3D11 debug runtime turned ON, vsync gets automatically - * turned back on, and the following gets output to the debug console: - * - * DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ] - */ - if (vsync == 0) { - return SDL_Unsupported(); - } -#endif if (vsync < 0) { return SDL_Unsupported(); } diff --git a/src/render/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp deleted file mode 100644 index c148f9117..000000000 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_RENDER_D3D11 - -#include "../../video/winrt/SDL_winrtvideo_cpp.h" -extern "C" { -#include "../SDL_sysrender.h" -} - -#include -#include - -#if WINAPI_FAMILY == WINAPI_FAMILY_APP -#include -#endif - -using namespace Windows::UI::Core; -using namespace Windows::Graphics::Display; - -#include - -#include "SDL_render_winrt.h" - -extern "C" void * -D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer) -{ - IInspectable *window = (IInspectable *)SDL_GetPointerProperty(SDL_GetWindowProperties(renderer->window), SDL_PROP_WINDOW_WINRT_WINDOW_POINTER, NULL); - ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL; - if (!window || FAILED(window->QueryInterface(&coreWindow))) { - return NULL; - } - - IUnknown *coreWindowAsIUnknown = NULL; - coreWindow->QueryInterface(&coreWindowAsIUnknown); - coreWindow->Release(); - - return coreWindowAsIUnknown; -} - -extern "C" DXGI_MODE_ROTATION -D3D11_GetCurrentRotation() -{ - const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); - - switch (currentOrientation) { - -#if SDL_WINAPI_FAMILY_PHONE - // Windows Phone rotations - case DisplayOrientations::Landscape: - return DXGI_MODE_ROTATION_ROTATE90; - case DisplayOrientations::Portrait: - return DXGI_MODE_ROTATION_IDENTITY; - case DisplayOrientations::LandscapeFlipped: - return DXGI_MODE_ROTATION_ROTATE270; - case DisplayOrientations::PortraitFlipped: - return DXGI_MODE_ROTATION_ROTATE180; -#else - // Non-Windows-Phone rotations (ex: Windows 8, Windows RT) - case DisplayOrientations::Landscape: - return DXGI_MODE_ROTATION_IDENTITY; - case DisplayOrientations::Portrait: - return DXGI_MODE_ROTATION_ROTATE270; - case DisplayOrientations::LandscapeFlipped: - return DXGI_MODE_ROTATION_ROTATE180; - case DisplayOrientations::PortraitFlipped: - return DXGI_MODE_ROTATION_ROTATE90; -#endif // SDL_WINAPI_FAMILY_PHONE - } - - return DXGI_MODE_ROTATION_IDENTITY; -} - -#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/src/render/direct3d11/SDL_render_winrt.h b/src/render/direct3d11/SDL_render_winrt.h deleted file mode 100644 index 990f82139..000000000 --- a/src/render/direct3d11/SDL_render_winrt.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_RENDER_D3D11 - -#ifdef __cplusplus -extern "C" { -#endif - -void *D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer); -DXGI_MODE_ROTATION D3D11_GetCurrentRotation(); - -#ifdef __cplusplus -} -#endif - -#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 7a1bbb938..f78252447 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -2040,16 +2040,6 @@ static bool GLES2_SetVSync(SDL_Renderer *renderer, const int vsync) { int interval = 0; -#ifdef SDL_PLATFORM_WINRT - /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync - * is turned on. Not doing so will freeze the screen's contents to that - * of the first drawn frame. - */ - if (vsync == 0) { - return SDL_Unsupported(); - } -#endif - if (!SDL_GL_SetSwapInterval(vsync)) { return false; } diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index e673dddb4..a20acffd8 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -339,8 +339,8 @@ SDL_Thread *SDL_CreateThreadWithPropertiesRuntime(SDL_PropertiesID props, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread) { - // rather than check this in every backend, just make sure it's correct upfront. Only allow non-NULL if non-WinRT Windows, or Microsoft GDK. - #if (!defined(SDL_PLATFORM_WIN32) && !defined(SDL_PLATFORM_GDK)) || defined(SDL_PLATFORM_WINRT) + // rather than check this in every backend, just make sure it's correct upfront. Only allow non-NULL if Windows, or Microsoft GDK. + #if (!defined(SDL_PLATFORM_WIN32) && !defined(SDL_PLATFORM_GDK)) if (pfnBeginThread || pfnEndThread) { SDL_SetError("_beginthreadex/_endthreadex not supported on this platform"); return NULL; diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 9d96012ff..ec6107bb2 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -38,8 +38,6 @@ #include "vita/SDL_systhread_c.h" #elif defined(SDL_THREAD_N3DS) #include "n3ds/SDL_systhread_c.h" -#elif defined(SDL_THREAD_STDCPP) -#include "stdcpp/SDL_systhread_c.h" #elif defined(SDL_THREAD_NGAGE) #include "ngage/SDL_systhread_c.h" #else diff --git a/src/thread/stdcpp/SDL_syscond.cpp b/src/thread/stdcpp/SDL_syscond.cpp deleted file mode 100644 index 592092e63..000000000 --- a/src/thread/stdcpp/SDL_syscond.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -extern "C" { -} - -#include -#include -#include -#include - -#include "SDL_sysmutex_c.h" - -struct SDL_Condition -{ - std::condition_variable_any cpp_cond; -}; - -// Create a condition variable -extern "C" -SDL_Condition *SDL_CreateCondition(void) -{ - // Allocate and initialize the condition variable - try { - SDL_Condition *cond = new SDL_Condition; - return cond; - } catch (std::system_error &ex) { - SDL_SetError("unable to create a C++ condition variable: code=%d; %s", ex.code(), ex.what()); - return NULL; - } catch (std::bad_alloc &) { - SDL_OutOfMemory(); - return NULL; - } -} - -// Destroy a condition variable -extern "C" -void SDL_DestroyCondition(SDL_Condition *cond) -{ - if (cond) { - delete cond; - } -} - -// Restart one of the threads that are waiting on the condition variable -extern "C" -void SDL_SignalCondition(SDL_Condition *cond) -{ - if (!cond) { - return; - } - - cond->cpp_cond.notify_one(); -} - -// Restart all threads that are waiting on the condition variable -extern "C" -void SDL_BroadcastCondition(SDL_Condition *cond) -{ - if (!cond) { - return; - } - - cond->cpp_cond.notify_all(); -} - -extern "C" -SDL_bool SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS) -{ - if (!cond || !mutex) { - return true; - } - - try { - std::unique_lock cpp_lock(mutex->cpp_mutex, std::adopt_lock_t()); - if (timeoutNS < 0) { - cond->cpp_cond.wait(cpp_lock); - cpp_lock.release(); - return true; - } else { - auto wait_result = cond->cpp_cond.wait_for( - cpp_lock, - std::chrono::duration(timeoutNS)); - cpp_lock.release(); - if (wait_result == std::cv_status::timeout) { - return false; - } else { - return true; - } - } - } catch (std::system_error &) { - return false; - } -} diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp deleted file mode 100644 index 7a489b8f7..000000000 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -extern "C" { -#include "SDL_systhread_c.h" -} - -#include - -#include "SDL_sysmutex_c.h" -#include - -extern "C" -SDL_Mutex * SDL_CreateMutex(void) -{ - // Allocate and initialize the mutex - try { - SDL_Mutex *mutex = new SDL_Mutex; - return mutex; - } catch (std::system_error &ex) { - SDL_SetError("unable to create a C++ mutex: code=%d; %s", ex.code(), ex.what()); - } catch (std::bad_alloc &) { - SDL_OutOfMemory(); - } - return NULL; -} - -extern "C" -void SDL_DestroyMutex(SDL_Mutex *mutex) -{ - if (mutex) { - delete mutex; - } -} - -extern "C" -void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (mutex) { - try { - mutex->cpp_mutex.lock(); - } catch (std::system_error &/*ex*/) { - SDL_assert(!"Error trying to lock mutex"); // assume we're in a lot of trouble if this assert fails. - } - } -} - -extern "C" -SDL_bool SDL_TryLockMutex(SDL_Mutex *mutex) -{ - bool result = true; - if (mutex) { - result = mutex->cpp_mutex.try_lock(); - } - return result; -} - -// Unlock the mutex -extern "C" -void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (mutex) { - mutex->cpp_mutex.unlock(); - } -} - diff --git a/src/thread/stdcpp/SDL_sysmutex_c.h b/src/thread/stdcpp/SDL_sysmutex_c.h deleted file mode 100644 index c18f98740..000000000 --- a/src/thread/stdcpp/SDL_sysmutex_c.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 - -struct SDL_Mutex -{ - std::recursive_mutex cpp_mutex; -}; - diff --git a/src/thread/stdcpp/SDL_sysrwlock.cpp b/src/thread/stdcpp/SDL_sysrwlock.cpp deleted file mode 100644 index 1327a88b9..000000000 --- a/src/thread/stdcpp/SDL_sysrwlock.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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 -#include -#include - -struct SDL_RWLock -{ - std::shared_mutex cpp_mutex; - SDL_ThreadID write_owner; -}; - -extern "C" -SDL_RWLock *SDL_CreateRWLock(void) -{ - try { - SDL_RWLock *rwlock = new SDL_RWLock; - return rwlock; - } catch (std::system_error &ex) { - SDL_SetError("unable to create a C++ rwlock: code=%d; %s", ex.code(), ex.what()); - return NULL; - } catch (std::bad_alloc &) { - SDL_OutOfMemory(); - return NULL; - } -} - -extern "C" -void SDL_DestroyRWLock(SDL_RWLock *rwlock) -{ - if (rwlock) { - delete rwlock; - } -} - -extern "C" -void SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (rwlock) { - try { - rwlock->cpp_mutex.lock_shared(); - } catch (std::system_error &/*ex*/) { - SDL_assert(!"Error trying to lock rwlock for reading"); // assume we're in a lot of trouble if this assert fails. - //return SDL_SetError("unable to lock a C++ rwlock: code=%d; %s", ex.code(), ex.what()); - } - } -} - -extern "C" -void SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (rwlock) { - try { - rwlock->cpp_mutex.lock(); - rwlock->write_owner = SDL_GetCurrentThreadID(); - } catch (std::system_error &/*ex*/) { - SDL_assert(!"Error trying to lock rwlock for writing"); // assume we're in a lot of trouble if this assert fails. - //return SDL_SetError("unable to lock a C++ rwlock: code=%d; %s", ex.code(), ex.what()); - } - } -} - -extern "C" -SDL_bool SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) -{ - bool result = true; - if (rwlock) { - result = rwlock->cpp_mutex.try_lock_shared(); - } - return result; -} - -extern "C" -SDL_bool SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) -{ - bool result = true; - if (rwlock) { - result = rwlock->cpp_mutex.try_lock(); - if (result) { - rwlock->write_owner = SDL_GetCurrentThreadID(); - } - } - return result; -} - -extern "C" -void SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (rwlock) { - if (rwlock->write_owner == SDL_GetCurrentThreadID()) { - rwlock->write_owner = 0; - rwlock->cpp_mutex.unlock(); - } else { - rwlock->cpp_mutex.unlock_shared(); - } - } -} - diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp deleted file mode 100644 index c718d23dc..000000000 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -// Thread management routines for SDL - -extern "C" { -#include "../SDL_thread_c.h" -#include "../SDL_systhread.h" -} - -#include -#include - -#ifdef SDL_PLATFORM_WINRT -#include -#endif - -static void RunThread(void *args) -{ - SDL_RunThread((SDL_Thread *)args); -} - -extern "C" -bool SDL_SYS_CreateThread(SDL_Thread *thread, - SDL_FunctionPointer pfnBeginThread, - SDL_FunctionPointer pfnEndThread) -{ - try { - // !!! FIXME: no way to set a thread stack size here. - thread->handle = (void *)new std::thread(RunThread, thread); - return true; - } catch (std::system_error &ex) { - return SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code().value(), ex.what()); - } catch (std::bad_alloc &) { - return SDL_OutOfMemory(); - } -} - -extern "C" -void SDL_SYS_SetupThread(const char *name) -{ - // Do nothing. -} - -extern "C" -SDL_ThreadID SDL_GetCurrentThreadID(void) -{ - static_assert(sizeof(std::thread::id) <= sizeof(SDL_ThreadID), "std::thread::id must not be bigger than SDL_ThreadID"); - SDL_ThreadID thread_id{}; - const auto cpp_thread_id = std::this_thread::get_id(); - SDL_memcpy(&thread_id, &cpp_thread_id, sizeof(std::thread::id)); - return thread_id; -} - -extern "C" -bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) -{ -#ifdef SDL_PLATFORM_WINRT - int value; - - if (priority == SDL_THREAD_PRIORITY_LOW) { - value = THREAD_PRIORITY_LOWEST; - } else if (priority == SDL_THREAD_PRIORITY_HIGH) { - value = THREAD_PRIORITY_HIGHEST; - } else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) { - // FIXME: WinRT does not support TIME_CRITICAL! -flibit - SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "TIME_CRITICAL unsupported, falling back to HIGHEST"); - value = THREAD_PRIORITY_HIGHEST; - } else { - value = THREAD_PRIORITY_NORMAL; - } - if (!SetThreadPriority(GetCurrentThread(), value)) { - return WIN_SetError("SetThreadPriority()"); - } - return true; -#else - return SDL_Unsupported(); -#endif -} - -extern "C" -void SDL_SYS_WaitThread(SDL_Thread *thread) -{ - if (!thread) { - return; - } - - try { - std::thread *cpp_thread = (std::thread *)thread->handle; - if (cpp_thread) { - if (cpp_thread->joinable()) { - cpp_thread->join(); - } - delete cpp_thread; - thread->handle = nullptr; - } - } catch (std::system_error &) { - // An error occurred when joining the thread. SDL_WaitThread does not, - // however, seem to provide a means to report errors to its callers - // though! - } -} - -extern "C" -void SDL_SYS_DetachThread(SDL_Thread *thread) -{ - if (!thread) { - return; - } - - try { - std::thread *cpp_thread = (std::thread *)thread->handle; - if (cpp_thread) { - if (cpp_thread->joinable()) { - cpp_thread->detach(); - } - delete cpp_thread; - thread->handle = nullptr; - } - } catch (std::system_error &) { - // An error occurred when detaching the thread. SDL_DetachThread does not, - // however, seem to provide a means to report errors to its callers - // though! - } -} - -static thread_local SDL_TLSData *thread_local_storage; - -extern "C" -void SDL_SYS_InitTLSData(void) -{ -} - -extern "C" -SDL_TLSData * SDL_SYS_GetTLSData(void) -{ - return thread_local_storage; -} - -extern "C" -bool SDL_SYS_SetTLSData(SDL_TLSData *data) -{ - thread_local_storage = data; - return true; -} - -extern "C" -void SDL_SYS_QuitTLSData(void) -{ -} diff --git a/src/thread/stdcpp/SDL_systhread_c.h b/src/thread/stdcpp/SDL_systhread_c.h deleted file mode 100644 index b8bf7b78a..000000000 --- a/src/thread/stdcpp/SDL_systhread_c.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -// For a thread handle, use a void pointer to a std::thread -typedef void *SYS_ThreadHandle; diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index 7cd444e8e..1291c7e30 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -56,12 +56,6 @@ typedef struct CONDITION_VARIABLE } CONDITION_VARIABLE, *PCONDITION_VARIABLE; #endif -#ifdef SDL_PLATFORM_WINRT -#define pWakeConditionVariable WakeConditionVariable -#define pWakeAllConditionVariable WakeAllConditionVariable -#define pSleepConditionVariableSRW SleepConditionVariableSRW -#define pSleepConditionVariableCS SleepConditionVariableCS -#else typedef VOID(WINAPI *pfnWakeConditionVariable)(PCONDITION_VARIABLE); typedef VOID(WINAPI *pfnWakeAllConditionVariable)(PCONDITION_VARIABLE); typedef BOOL(WINAPI *pfnSleepConditionVariableSRW)(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG); @@ -71,7 +65,6 @@ static pfnWakeConditionVariable pWakeConditionVariable = NULL; static pfnWakeAllConditionVariable pWakeAllConditionVariable = NULL; static pfnSleepConditionVariableSRW pSleepConditionVariableSRW = NULL; static pfnSleepConditionVariableCS pSleepConditionVariableCS = NULL; -#endif typedef struct SDL_cond_cv { @@ -152,7 +145,6 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = { }; -#ifndef SDL_PLATFORM_WINRT // Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore static const SDL_cond_impl_t SDL_cond_impl_generic = { &SDL_CreateCondition_generic, @@ -161,7 +153,6 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = { &SDL_BroadcastCondition_generic, &SDL_WaitConditionTimeoutNS_generic, }; -#endif SDL_Condition *SDL_CreateCondition(void) { @@ -179,10 +170,6 @@ SDL_Condition *SDL_CreateCondition(void) SDL_assert(SDL_mutex_impl_active.Type != SDL_MUTEX_INVALID); } -#ifdef SDL_PLATFORM_WINRT - // Link statically on this platform - impl = &SDL_cond_impl_cv; -#else // Default to generic implementation, works with all mutex implementations impl = &SDL_cond_impl_generic; { @@ -198,7 +185,6 @@ SDL_Condition *SDL_CreateCondition(void) } } } -#endif SDL_copyp(&SDL_cond_impl_active, impl); } diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index f1e173076..251f85cf6 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -39,13 +39,6 @@ SDL_mutex_impl_t SDL_mutex_impl_active = { 0 }; * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer. */ -#ifdef SDL_PLATFORM_WINRT -// Functions are guaranteed to be available -#define pInitializeSRWLock InitializeSRWLock -#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive -#define pAcquireSRWLockExclusive AcquireSRWLockExclusive -#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive -#else typedef VOID(WINAPI *pfnInitializeSRWLock)(PSRWLOCK); typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK); typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK); @@ -54,7 +47,6 @@ static pfnInitializeSRWLock pInitializeSRWLock = NULL; static pfnReleaseSRWLockExclusive pReleaseSRWLockExclusive = NULL; static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL; static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL; -#endif static SDL_Mutex *SDL_CreateMutex_srw(void) { @@ -143,12 +135,8 @@ static SDL_Mutex *SDL_CreateMutex_cs(void) if (mutex) { // Initialize // On SMP systems, a non-zero spin count generally helps performance -#ifdef SDL_PLATFORM_WINRT - InitializeCriticalSectionEx(&mutex->cs, 2000, 0); -#else // This function always succeeds (void)InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000); -#endif } return (SDL_Mutex *)mutex; } @@ -194,9 +182,6 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = { SDL_Mutex *SDL_CreateMutex(void) { if (!SDL_mutex_impl_active.Create) { -#ifdef SDL_PLATFORM_WINRT - const SDL_mutex_impl_t *impl = &SDL_mutex_impl_srw; -#else const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs; // Try faster implementation for Windows 7 and newer @@ -212,7 +197,6 @@ SDL_Mutex *SDL_CreateMutex(void) impl = &SDL_mutex_impl_srw; } } -#endif // SDL_PLATFORM_WINRT // Copy instead of using pointer to save one level of indirection SDL_copyp(&SDL_mutex_impl_active, impl); diff --git a/src/thread/windows/SDL_sysrwlock_srw.c b/src/thread/windows/SDL_sysrwlock_srw.c index 8506d4cb0..10119520b 100644 --- a/src/thread/windows/SDL_sysrwlock_srw.c +++ b/src/thread/windows/SDL_sysrwlock_srw.c @@ -35,17 +35,6 @@ typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK); typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK); typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK); -#ifdef SDL_PLATFORM_WINRT -// Functions are guaranteed to be available -#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive -#define pInitializeSRWLock InitializeSRWLock -#define pReleaseSRWLockShared ReleaseSRWLockShared -#define pAcquireSRWLockShared AcquireSRWLockShared -#define pTryAcquireSRWLockShared TryAcquireSRWLockShared -#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive -#define pAcquireSRWLockExclusive AcquireSRWLockExclusive -#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive -#else static pfnInitializeSRWLock pInitializeSRWLock = NULL; static pfnReleaseSRWLockShared pReleaseSRWLockShared = NULL; static pfnAcquireSRWLockShared pAcquireSRWLockShared = NULL; @@ -53,7 +42,6 @@ static pfnTryAcquireSRWLockShared pTryAcquireSRWLockShared = NULL; static pfnReleaseSRWLockExclusive pReleaseSRWLockExclusive = NULL; static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL; static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL; -#endif typedef SDL_RWLock *(*pfnSDL_CreateRWLock)(void); typedef void (*pfnSDL_DestroyRWLock)(SDL_RWLock *); @@ -152,7 +140,6 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_srw = { &SDL_UnlockRWLock_srw }; -#ifndef SDL_PLATFORM_WINRT #include "../generic/SDL_sysrwlock_c.h" @@ -166,19 +153,12 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = { &SDL_TryLockRWLockForWriting_generic, &SDL_UnlockRWLock_generic }; -#endif SDL_RWLock *SDL_CreateRWLock(void) { if (!SDL_rwlock_impl_active.Create) { - const SDL_rwlock_impl_t *impl; - -#ifdef SDL_PLATFORM_WINRT - // Link statically on this platform - impl = &SDL_rwlock_impl_srw; -#else // Default to generic implementation, works with all mutex implementations - impl = &SDL_rwlock_impl_generic; + const SDL_rwlock_impl_t *impl = &SDL_rwlock_impl_generic; { HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { @@ -197,7 +177,6 @@ SDL_RWLock *SDL_CreateRWLock(void) } } } -#endif SDL_copyp(&SDL_rwlock_impl_active, impl); } diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index dcfd2c9f0..132e114ad 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -60,18 +60,11 @@ static SDL_sem_impl_t SDL_sem_impl_active = { 0 }; // APIs not available on WinPhone 8.1 // https://www.microsoft.com/en-us/download/details.aspx?id=47328 -#if !SDL_WINAPI_FAMILY_PHONE -#ifdef SDL_PLATFORM_WINRT -// Functions are guaranteed to be available -#define pWaitOnAddress WaitOnAddress -#define pWakeByAddressSingle WakeByAddressSingle -#else typedef BOOL(WINAPI *pfnWaitOnAddress)(volatile VOID *, PVOID, SIZE_T, DWORD); typedef VOID(WINAPI *pfnWakeByAddressSingle)(PVOID); static pfnWaitOnAddress pWaitOnAddress = NULL; static pfnWakeByAddressSingle pWakeByAddressSingle = NULL; -#endif typedef struct SDL_semaphore_atom { @@ -196,7 +189,6 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = { &SDL_GetSemaphoreValue_atom, &SDL_SignalSemaphore_atom, }; -#endif // !SDL_WINAPI_FAMILY_PHONE /** * Fallback Semaphore implementation using Kernel Semaphores @@ -217,12 +209,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value) sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem)); if (sem) { // Create the semaphore, with max value 32K -// !!! FIXME: CreateSemaphoreEx is available in Vista and later, so if XP support is dropped, we can lose this #ifdef. -#ifdef SDL_PLATFORM_WINRT - sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS); -#else sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL); -#endif sem->count = initial_value; if (!sem->id) { SDL_SetError("Couldn't create semaphore"); @@ -316,12 +303,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) // Default to fallback implementation const SDL_sem_impl_t *impl = &SDL_sem_impl_kern; -#if !SDL_WINAPI_FAMILY_PHONE if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, false)) { -#ifdef SDL_PLATFORM_WINRT - // Link statically on this platform - impl = &SDL_sem_impl_atom; -#else /* We already statically link to features from this Api * Set (e.g. WaitForSingleObject). Dynamically loading * API Sets is not explicitly documented but according to @@ -338,9 +320,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) impl = &SDL_sem_impl_atom; } } -#endif } -#endif // Copy instead of using pointer to save one level of indirection SDL_copyp(&SDL_sem_impl_active, impl); diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 92cea5d78..aeda019ae 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -109,7 +109,6 @@ void SDL_SYS_SetupThread(const char *name) { if (name) { PVOID exceptionHandlerHandle; -#ifndef SDL_PLATFORM_WINRT // !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. static pfnSetThreadDescription pSetThreadDescription = NULL; static HMODULE kernel32 = NULL; @@ -133,7 +132,6 @@ void SDL_SYS_SetupThread(const char *name) SDL_free(strw); } } -#endif /* Presumably some version of Visual Studio will understand SetThreadDescription(), but we still need to deal with older OSes and debuggers. Set it with the arcane diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 083008e52..1235a7ff4 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -27,18 +27,6 @@ #include "../SDL_thread_c.h" -#if WINAPI_FAMILY_WINRT -#include - -#ifndef TLS_OUT_OF_INDEXES -#define TLS_OUT_OF_INDEXES FLS_OUT_OF_INDEXES -#endif - -#define TlsAlloc() FlsAlloc(NULL) -#define TlsSetValue FlsSetValue -#define TlsGetValue FlsGetValue -#endif - static DWORD thread_local_storage = TLS_OUT_OF_INDEXES; static bool generic_local_storage = false; diff --git a/src/time/windows/SDL_systime.c b/src/time/windows/SDL_systime.c index 5dc6480fc..cf3389561 100644 --- a/src/time/windows/SDL_systime.c +++ b/src/time/windows/SDL_systime.c @@ -85,9 +85,6 @@ SDL_bool SDL_GetCurrentTime(SDL_Time *ticks) SDL_zero(ft); -#ifdef SDL_PLATFORM_WINRT - GetSystemTimePreciseAsFileTime(&ft); -#else static pfnGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime = NULL; static bool load_attempted = false; @@ -105,7 +102,6 @@ SDL_bool SDL_GetCurrentTime(SDL_Time *ticks) } else { GetSystemTimeAsFileTime(&ft); } -#endif *ticks = SDL_TimeFromWindows(ft.dwLowDateTime, ft.dwHighDateTime); diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 3cd1da3aa..8c93a46f3 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -522,8 +522,7 @@ static Uint32 tick_denominator_ns; static Uint32 tick_numerator_ms; static Uint32 tick_denominator_ms; -#if defined(SDL_TIMER_WINDOWS) && \ - !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#if defined(SDL_TIMER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include #define HAVE_TIME_BEGIN_PERIOD #endif diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 568cf62fa..087c0f3db 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -66,18 +66,8 @@ Uint64 SDL_GetPerformanceFrequency(void) void SDL_SYS_DelayNS(Uint64 ns) { /* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803. - * - * Sleep() is not publicly available to apps in early versions of WinRT. - * - * Visual C++ 2013 Update 4 re-introduced Sleep() for Windows 8.1 and - * Windows Phone 8.1. * * Use the compiler version to determine availability. - * - * NOTE #1: _MSC_FULL_VER == 180030723 for Visual C++ 2013 Update 3. - * NOTE #2: Visual C++ 2013, when compiling for Windows 8.0 and - * Windows Phone 8.0, uses the Visual C++ 2012 compiler to build - * apps and libraries. */ #ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION HANDLE timer = SDL_GetWaitableTimer(); @@ -97,7 +87,7 @@ void SDL_SYS_DelayNS(Uint64 ns) ns = max_delay; } -#if defined(SDL_PLATFORM_WINRT) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723) +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723) static HANDLE mutex = 0; if (!mutex) { mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS); diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 6d514fc55..53886b989 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_OPENGL_EGL -#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) #include "../core/windows/SDL_windows.h" #endif #ifdef SDL_VIDEO_DRIVER_ANDROID @@ -74,7 +74,7 @@ #define DEFAULT_OGL_ES_PVR "libGLES_CM.so" #define DEFAULT_OGL_ES "libGLESv1_CM.so" -#elif defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) +#elif defined(SDL_VIDEO_DRIVER_WINDOWS) // EGL AND OpenGL ES support via ANGLE #define DEFAULT_EGL "libEGL.dll" #define DEFAULT_OGL "opengl32.dll" @@ -301,14 +301,14 @@ static bool SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_ { void *egl_dll_handle = NULL, *opengl_dll_handle = NULL; const char *path = NULL; -#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) const char *d3dcompiler; #endif #ifdef SDL_VIDEO_DRIVER_RPI bool vc4 = (0 == access("/sys/module/vc4/", F_OK)); #endif -#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER); if (d3dcompiler) { if (SDL_strcasecmp(d3dcompiler, "none") != 0) { @@ -511,7 +511,6 @@ bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDis _this->egl_data->egl_display = EGL_NO_DISPLAY; -#ifndef SDL_PLATFORM_WINRT #ifndef SDL_VIDEO_DRIVER_VITA if (platform) { /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY @@ -564,7 +563,6 @@ bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDis *_this->gl_config.driver_path = '\0'; return SDL_SetError("Could not initialize EGL"); } -#endif // Get the EGL version with a valid egl_display, for EGL <= 1.4 SDL_EGL_GetVersion(_this); diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index d12818e4a..c9ac5c289 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -376,7 +376,7 @@ static bool scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, Ui #define CAST_uint32x2_t (uint32x2_t) #endif -#if defined(SDL_PLATFORM_WINRT) || defined(_MSC_VER) +#if defined(_MSC_VER) #ifdef SDL_NEON_INTRINSICS #undef CAST_uint8x8_t #undef CAST_uint32x2_t diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 56d0d18ce..f740292f4 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -498,7 +498,6 @@ typedef struct VideoBootStrap extern VideoBootStrap COCOA_bootstrap; extern VideoBootStrap X11_bootstrap; extern VideoBootStrap WINDOWS_bootstrap; -extern VideoBootStrap WINRT_bootstrap; extern VideoBootStrap HAIKU_bootstrap; extern VideoBootStrap UIKIT_bootstrap; extern VideoBootStrap Android_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b192e18e5..93719dd61 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -85,9 +85,6 @@ static VideoBootStrap *bootstrap[] = { #ifdef SDL_VIDEO_DRIVER_WINDOWS &WINDOWS_bootstrap, #endif -#ifdef SDL_VIDEO_DRIVER_WINRT - &WINRT_bootstrap, -#endif #ifdef SDL_VIDEO_DRIVER_HAIKU &HAIKU_bootstrap, #endif @@ -1750,10 +1747,6 @@ static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window) } } -#ifdef SDL_PLATFORM_WINRT -extern SDL_WindowFlags WINRT_DetectWindowFlags(SDL_Window *window); -#endif - static void SDL_RestoreMousePosition(SDL_Window *window) { float x, y; @@ -1851,35 +1844,6 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b } } } -#elif defined(SDL_PLATFORM_WINRT) && (NTDDI_VERSION < NTDDI_WIN10) - /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen - or not. The user can choose this, via OS-provided UI, but this can't - be set programmatically. - - Just look at what SDL's WinRT video backend code detected with regards - to fullscreen (being active, or not), and figure out a return/error code - from that. - */ - if (!!fullscreen == !(WINRT_DetectWindowFlags(window) & SDL_WINDOW_FULLSCREEN)) { - /* Uh oh, either: - 1. fullscreen was requested, and we're already windowed - 2. windowed-mode was requested, and we're already fullscreen - - WinRT 8.x can't resolve either programmatically, so we're - giving up. - */ - goto error; - } else { - /* Whatever was requested, fullscreen or windowed mode, is already - in-place. - */ - if (fullscreen) { - display->fullscreen_window = window; - } else { - display->fullscreen_window = NULL; - } - goto done; - } #endif if (display) { @@ -2453,17 +2417,6 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) } #endif -#if defined(SDL_PLATFORM_WINRT) && (NTDDI_VERSION < NTDDI_WIN10) - /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen - or not. The user can choose this, via OS-provided UI, but this can't - be set programmatically. - - Just look at what SDL's WinRT video backend code detected with regards - to fullscreen (being active, or not), and figure out a return/error code - from that. - */ - flags = window->flags; -#endif if (title) { SDL_SetWindowTitle(window, title); } @@ -5426,9 +5379,6 @@ int SDL_GetMessageBoxCount(void) #ifdef SDL_VIDEO_DRIVER_WINDOWS #include "windows/SDL_windowsmessagebox.h" #endif -#ifdef SDL_VIDEO_DRIVER_WINRT -#include "winrt/SDL_winrtmessagebox.h" -#endif #ifdef SDL_VIDEO_DRIVER_COCOA #include "cocoa/SDL_cocoamessagebox.h" #endif diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 220304917..472c5bf29 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -396,14 +396,10 @@ static bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) void *hDXGIMod = NULL; bool found = false; -#ifdef SDL_PLATFORM_WINRT - CreateDXGIFactoryFunc = CreateDXGIFactory1; -#else hDXGIMod = SDL_LoadObject("dxgi.dll"); if (hDXGIMod) { CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(hDXGIMod, "CreateDXGIFactory1"); } -#endif if (CreateDXGIFactoryFunc) { static const GUID SDL_IID_IDXGIFactory1 = { 0x770aae78, 0xf26f, 0x4dba, { 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87 } }; static const GUID SDL_IID_IDXGIOutput6 = { 0x068346e8, 0xaaec, 0x4b84, { 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1 } }; diff --git a/src/video/winrt/SDL_winrtevents.cpp b/src/video/winrt/SDL_winrtevents.cpp deleted file mode 100644 index 2543fb12b..000000000 --- a/src/video/winrt/SDL_winrtevents.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -/* - * Windows includes: - */ -#include -using namespace Windows::UI::Core; -using Windows::UI::Core::CoreCursor; - -/* - * SDL includes: - */ -#include "SDL_winrtevents_c.h" -#include "../../core/winrt/SDL_winrtapp_common.h" -#include "../../core/winrt/SDL_winrtapp_direct3d.h" -#include "../../core/winrt/SDL_winrtapp_xaml.h" - -extern "C" { -#include "../../thread/SDL_systhread.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_events_c.h" -} - -// Forward declarations -static void WINRT_YieldXAMLThread(); - -// Global event management - -void WINRT_PumpEvents(SDL_VideoDevice *_this) -{ - if (SDL_WinRTGlobalApp) { - SDL_WinRTGlobalApp->PumpEvents(); - } else if (WINRT_XAMLWasEnabled) { - WINRT_YieldXAMLThread(); - } -} - -// XAML Thread management - -enum SDL_XAMLAppThreadState -{ - ThreadState_NotLaunched = 0, - ThreadState_Running, - ThreadState_Yielding -}; - -static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched; -static SDL_Thread *_XAMLThread = nullptr; -static SDL_Mutex *_mutex = nullptr; -static SDL_Condition *_cond = nullptr; - -static void WINRT_YieldXAMLThread() -{ - SDL_LockMutex(_mutex); - SDL_assert(_threadState == ThreadState_Running); - _threadState = ThreadState_Yielding; - SDL_UnlockMutex(_mutex); - - SDL_SignalCondition(_cond); - - SDL_LockMutex(_mutex); - while (_threadState != ThreadState_Running) { - SDL_WaitCondition(_cond, _mutex); - } - SDL_UnlockMutex(_mutex); -} - -static int WINRT_XAMLThreadMain(void *userdata) -{ - // TODO, WinRT: pass the C-style main() a reasonably realistic - // representation of command line arguments. - int argc = 0; - char **argv = NULL; - return WINRT_SDLAppEntryPoint(argc, argv); -} - -void WINRT_CycleXAMLThread(void) -{ - switch (_threadState) { - case ThreadState_NotLaunched: - { - _cond = SDL_CreateCondition(); - - _mutex = SDL_CreateMutex(); - _threadState = ThreadState_Running; - _XAMLThread = SDL_CreateThread(WINRT_XAMLThreadMain, "SDL/XAML App Thread", nullptr); - - SDL_LockMutex(_mutex); - while (_threadState != ThreadState_Yielding) { - SDL_WaitCondition(_cond, _mutex); - } - SDL_UnlockMutex(_mutex); - - break; - } - - case ThreadState_Running: - { - SDL_assert(false); - break; - } - - case ThreadState_Yielding: - { - SDL_LockMutex(_mutex); - SDL_assert(_threadState == ThreadState_Yielding); - _threadState = ThreadState_Running; - SDL_UnlockMutex(_mutex); - - SDL_SignalCondition(_cond); - - SDL_LockMutex(_mutex); - while (_threadState != ThreadState_Yielding) { - SDL_WaitCondition(_cond, _mutex); - } - SDL_UnlockMutex(_mutex); - } - } -} - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtevents_c.h b/src/video/winrt/SDL_winrtevents_c.h deleted file mode 100644 index 2219190e8..000000000 --- a/src/video/winrt/SDL_winrtevents_c.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -extern "C" { -#include "../SDL_sysvideo.h" -} - -/* - * Internal-use, C-style functions: - */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void WINRT_InitTouch(SDL_VideoDevice *_this); -extern void WINRT_PumpEvents(SDL_VideoDevice *_this); - -#ifdef __cplusplus -} -#endif - -/* - * Internal-use, C++/CX functions: - */ -#ifdef __cplusplus_winrt - -// Pointers (Mice, Touch, etc.) -typedef enum -{ - NormalizeZeroToOne, - TransformToSDLWindowSize -} WINRT_CursorNormalizationType; -extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window *window, - Windows::Foundation::Point rawPosition, - WINRT_CursorNormalizationType normalization); -extern bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed); -extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); -extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); -extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); -extern void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); -extern void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); -extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); -extern void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args); - -// Keyboard -extern void WINRT_ProcessAcceleratorKeyActivated(Windows::UI::Core::AcceleratorKeyEventArgs ^ args); -extern void WINRT_ProcessCharacterReceivedEvent(SDL_Window *window, Windows::UI::Core::CharacterReceivedEventArgs ^ args); - -#if NTDDI_VERSION >= NTDDI_WIN10 -extern void WINTRT_InitialiseInputPaneEvents(SDL_VideoDevice *_this); -extern bool WINRT_HasScreenKeyboardSupport(SDL_VideoDevice *_this); -extern void WINRT_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); -extern void WINRT_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -extern bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); -#endif // NTDDI_VERSION >= ... - -// XAML Thread Management -extern void WINRT_CycleXAMLThread(void); - -#endif // ifdef __cplusplus_winrt diff --git a/src/video/winrt/SDL_winrtgamebar.cpp b/src/video/winrt/SDL_winrtgamebar.cpp deleted file mode 100644 index 2a6155e23..000000000 --- a/src/video/winrt/SDL_winrtgamebar.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -// Windows includes -#include -#include -#include - -// SDL includes -extern "C" { -#include "../SDL_sysvideo.h" -} -#include "SDL_winrtvideo_cpp.h" - -/* Game Bar events can come in off the main thread. Use the following - WinRT CoreDispatcher to deal with them on SDL's thread. -*/ -static Platform::WeakReference WINRT_MainThreadDispatcher; - -/* Win10's initial SDK (the 10.0.10240.0 release) does not include references - to Game Bar APIs, as the Game Bar was released via Win10 10.0.10586.0. - - Declare its WinRT/COM interface here, to allow compilation with earlier - Windows SDKs. -*/ -MIDL_INTERFACE("1DB9A292-CC78-4173-BE45-B61E67283EA7") -IGameBarStatics_ : public IInspectable -{ - public: - virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged( - __FIEventHandler_1_IInspectable * handler, - Windows::Foundation::EventRegistrationToken * token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_VisibilityChanged( - Windows::Foundation::EventRegistrationToken token) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_IsInputRedirectedChanged( - __FIEventHandler_1_IInspectable * handler, - Windows::Foundation::EventRegistrationToken * token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_IsInputRedirectedChanged( - Windows::Foundation::EventRegistrationToken token) = 0; - - virtual HRESULT STDMETHODCALLTYPE get_Visible( - boolean * value) = 0; - - virtual HRESULT STDMETHODCALLTYPE get_IsInputRedirected( - boolean * value) = 0; -}; - -// Declare the game bar's COM GUID -static GUID IID_IGameBarStatics_ = { MAKELONG(0xA292, 0x1DB9), 0xCC78, 0x4173, { 0xBE, 0x45, 0xB6, 0x1E, 0x67, 0x28, 0x3E, 0xA7 } }; - -/* Retrieves a pointer to the game bar, or NULL if it is not available. - If a pointer is returned, it's ->Release() method must be called - after the caller has finished using it. -*/ -static IGameBarStatics_ *WINRT_GetGameBar() -{ - const wchar_t *wClassName = L"Windows.Gaming.UI.GameBar"; - HSTRING hClassName; - IActivationFactory *pActivationFactory = NULL; - IGameBarStatics_ *pGameBar = NULL; - HRESULT hr; - - hr = ::WindowsCreateString(wClassName, (UINT32)SDL_wcslen(wClassName), &hClassName); - if (FAILED(hr)) { - goto done; - } - - hr = Windows::Foundation::GetActivationFactory(hClassName, &pActivationFactory); - if (FAILED(hr)) { - goto done; - } - - pActivationFactory->QueryInterface(IID_IGameBarStatics_, (void **)&pGameBar); - -done: - if (pActivationFactory) { - pActivationFactory->Release(); - } - if (hClassName) { - ::WindowsDeleteString(hClassName); - } - return pGameBar; -} - -static void WINRT_HandleGameBarIsInputRedirected_MainThread() -{ - IGameBarStatics_ *gameBar; - boolean isInputRedirected = 0; - if (!WINRT_MainThreadDispatcher) { - // The game bar event handler has been deregistered! - return; - } - gameBar = WINRT_GetGameBar(); - if (!gameBar) { - // Shouldn't happen, but just in case... - return; - } - if (SUCCEEDED(gameBar->get_IsInputRedirected(&isInputRedirected))) { - if (!isInputRedirected) { - /* Input-control is now back to the SDL app. Restore the cursor, - in case Windows does not (it does not in either Win10 - 10.0.10240.0 or 10.0.10586.0, maybe later version(s) too. - */ - SDL_Cursor *cursor = SDL_GetCursor(); - SDL_SetCursor(cursor); - } - } - gameBar->Release(); -} - -static void WINRT_HandleGameBarIsInputRedirected_NonMainThread(Platform::Object ^ o1, Platform::Object ^ o2) -{ - Windows::UI::Core::CoreDispatcher ^ dispatcher = WINRT_MainThreadDispatcher.Resolve(); - if (dispatcher) { - dispatcher->RunAsync( - Windows::UI::Core::CoreDispatcherPriority::Normal, - ref new Windows::UI::Core::DispatchedHandler(&WINRT_HandleGameBarIsInputRedirected_MainThread)); - } -} - -void WINRT_InitGameBar(SDL_VideoDevice *_this) -{ - SDL_VideoData *data = _this->internal; - IGameBarStatics_ *gameBar = WINRT_GetGameBar(); - if (gameBar) { - /* GameBar.IsInputRedirected events can come in via something other than - the main/SDL thread. - - Get a WinRT 'CoreDispatcher' that can be used to call back into the - SDL thread. - */ - WINRT_MainThreadDispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher; - Windows::Foundation::EventHandler ^ handler = - ref new Windows::Foundation::EventHandler(&WINRT_HandleGameBarIsInputRedirected_NonMainThread); - __FIEventHandler_1_IInspectable *pHandler = reinterpret_cast<__FIEventHandler_1_IInspectable *>(handler); - gameBar->add_IsInputRedirectedChanged(pHandler, &data->gameBarIsInputRedirectedToken); - gameBar->Release(); - } -} - -void WINRT_QuitGameBar(SDL_VideoDevice *_this) -{ - SDL_VideoData *data; - IGameBarStatics_ *gameBar; - if (!_this || !_this->internal) { - return; - } - gameBar = WINRT_GetGameBar(); - if (!gameBar) { - return; - } - data = _this->internal; - if (data->gameBarIsInputRedirectedToken.Value) { - gameBar->remove_IsInputRedirectedChanged(data->gameBarIsInputRedirectedToken); - data->gameBarIsInputRedirectedToken.Value = 0; - } - WINRT_MainThreadDispatcher = nullptr; - gameBar->Release(); -} - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtgamebar_cpp.h b/src/video/winrt/SDL_winrtgamebar_cpp.h deleted file mode 100644 index 3a3026464..000000000 --- a/src/video/winrt/SDL_winrtgamebar_cpp.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifndef SDL_winrtgamebar_h_ -#define SDL_winrtgamebar_h_ - -#ifdef __cplusplus -/* These are exported as C++ functions, rather than C, to fix a compilation - bug with MSVC 2013, for Windows 8.x builds. */ -extern void WINRT_InitGameBar(SDL_VideoDevice *_this); -extern void WINRT_QuitGameBar(SDL_VideoDevice *_this); -#endif - -#endif // SDL_winrtgamebar_h_ diff --git a/src/video/winrt/SDL_winrtkeyboard.cpp b/src/video/winrt/SDL_winrtkeyboard.cpp deleted file mode 100644 index 2caff1cf3..000000000 --- a/src/video/winrt/SDL_winrtkeyboard.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -// Windows-specific includes -#include -#include - -// SDL-specific includes -#include "SDL_winrtevents_c.h" - -extern "C" { -#include "../../events/scancodes_windows.h" -#include "../../events/SDL_keyboard_c.h" -} - -#include "SDL_winrtvideo_cpp.h" - -static SDL_Scancode WINRT_TranslateKeycode(Windows::System::VirtualKey virtualKey, const Windows::UI::Core::CorePhysicalKeyStatus& keyStatus, Uint16 *rawcode) -{ - SDL_Scancode code; - Uint8 index; - Uint16 scanCode = keyStatus.ScanCode | (keyStatus.IsExtendedKey ? 0xe000 : 0); - - /* Pause/Break key have a special scan code with 0xe1 prefix - * that is not properly reported under UWP. - * Use Pause scan code that is used in Win32. */ - if (virtualKey == Windows::System::VirtualKey::Pause) { - scanCode = 0xe046; - } - - // Pack scan code into one byte to make the index. - index = LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00); - code = windows_scancode_table[index]; - *rawcode = scanCode; - - return code; -} - -void WINRT_ProcessAcceleratorKeyActivated(Windows::UI::Core::AcceleratorKeyEventArgs ^ args) -{ - using namespace Windows::UI::Core; - - Uint8 state; - SDL_Scancode code; - Uint16 rawcode = 0; - - switch (args->EventType) { - case CoreAcceleratorKeyEventType::SystemKeyDown: - case CoreAcceleratorKeyEventType::KeyDown: - state = SDL_PRESSED; - break; - case CoreAcceleratorKeyEventType::SystemKeyUp: - case CoreAcceleratorKeyEventType::KeyUp: - state = SDL_RELEASED; - break; - default: - return; - } - - code = WINRT_TranslateKeycode(args->VirtualKey, args->KeyStatus, &rawcode); - SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, rawcode, code, state); -} - -void WINRT_ProcessCharacterReceivedEvent(SDL_Window *window, Windows::UI::Core::CharacterReceivedEventArgs ^ args) -{ - if (!window) { - return; - } - - SDL_WindowData *data = window->internal; - - if (SDL_TextInputActive(window)) { - /* Characters outside Unicode Basic Multilingual Plane (BMP) - * are coded as so called "surrogate pair" in two separate UTF-16 character events. - * Cache high surrogate until next character event. */ - if (IS_HIGH_SURROGATE(args->KeyCode)) { - data->high_surrogate = (WCHAR)args->KeyCode; - } else { - WCHAR utf16[] = { - data->high_surrogate ? data->high_surrogate : (WCHAR)args->KeyCode, - data->high_surrogate ? (WCHAR)args->KeyCode : L'\0', - L'\0' - }; - - char utf8[5]; - // doesn't need to be WIN_WideCharToMultiByte, since we don't care about WinXP support in WinRT. - int result = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16, -1, utf8, sizeof(utf8), NULL, NULL); - if (result > 0) { - SDL_SendKeyboardText(utf8); - } - - data->high_surrogate = L'\0'; - } - } else { - data->high_surrogate = L'\0'; - } -} - -#if NTDDI_VERSION >= NTDDI_WIN10 - -static bool WINRT_InputPaneVisible = false; - -void WINTRT_OnInputPaneShowing(Windows::UI::ViewManagement::InputPane ^ sender, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs ^ args) -{ - WINRT_InputPaneVisible = true; -} - -void WINTRT_OnInputPaneHiding(Windows::UI::ViewManagement::InputPane ^ sender, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs ^ args) -{ - WINRT_InputPaneVisible = false; -} - -void WINTRT_InitialiseInputPaneEvents(SDL_VideoDevice *_this) -{ - using namespace Windows::UI::ViewManagement; - InputPane ^ inputPane = InputPane::GetForCurrentView(); - if (inputPane) { - inputPane->Showing += ref new Windows::Foundation::TypedEventHandler(&WINTRT_OnInputPaneShowing); - inputPane->Hiding += ref new Windows::Foundation::TypedEventHandler(&WINTRT_OnInputPaneHiding); - } -} - -bool WINRT_HasScreenKeyboardSupport(SDL_VideoDevice *_this) -{ - return true; -} - -void WINRT_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) -{ - using namespace Windows::UI::ViewManagement; - InputPane ^ inputPane = InputPane::GetForCurrentView(); - if (inputPane) { - inputPane->TryShow(); - } -} - -void WINRT_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) -{ - using namespace Windows::UI::ViewManagement; - InputPane ^ inputPane = InputPane::GetForCurrentView(); - if (inputPane) { - inputPane->TryHide(); - } -} - -bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) -{ - using namespace Windows::UI::ViewManagement; - InputPane ^ inputPane = InputPane::GetForCurrentView(); - if (inputPane) { - switch (SDL_GetWinRTDeviceFamily()) { - case SDL_WINRT_DEVICEFAMILY_XBOX: - // Documentation recommends using inputPane->Visible - // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 - // This does not seem to work on latest UWP/Xbox. - // Workaround: Listen to Showing/Hiding events - if (WINRT_InputPaneVisible) { - return true; - } - break; - default: - // OccludedRect is recommend on universal apps per docs - // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 - Windows::Foundation::Rect rect = inputPane->OccludedRect; - if (rect.Width > 0 && rect.Height > 0) { - return true; - } - break; - } - } - return false; -} - -#endif // NTDDI_VERSION >= ... - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmessagebox.cpp b/src/video/winrt/SDL_winrtmessagebox.cpp deleted file mode 100644 index 59c025c45..000000000 --- a/src/video/winrt/SDL_winrtmessagebox.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -extern "C" { -#include "../../core/windows/SDL_windows.h" -} - -#include "SDL_winrtevents_c.h" - -#include -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::UI::Popups; - -static String ^ WINRT_UTF8ToPlatformString(const char *str) { - wchar_t *wstr = WIN_UTF8ToStringW(str); - String ^ rtstr = ref new String(wstr); - SDL_free(wstr); - return rtstr; -} - -extern "C" -bool WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) -{ -#if SDL_WINAPI_FAMILY_PHONE && NTDDI_VERSION == NTDDI_WIN8 - /* Sadly, Windows Phone 8 doesn't include the MessageDialog class that - * Windows 8.x/RT does, even though MSDN's reference documentation for - * Windows Phone 8 mentions it. - * - * The .NET runtime on Windows Phone 8 does, however, include a - * MessageBox class. Perhaps this could be called, somehow? - */ - return SDL_SetError("SDL_messagebox support is not available for Windows Phone 8.0"); -#else - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - -#if SDL_WINAPI_FAMILY_PHONE - const int maxbuttons = 2; - const char *platform = "Windows Phone 8.1+"; -#else - const int maxbuttons = 3; - const char *platform = "Windows 8.x"; -#endif - - if (messageboxdata->numbuttons > maxbuttons) { - return SDL_SetError("WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.", - maxbuttons, platform, messageboxdata->numbuttons); - } - - // Build a MessageDialog object and its buttons - MessageDialog ^ dialog = ref new MessageDialog(WINRT_UTF8ToPlatformString(messageboxdata->message)); - dialog->Title = WINRT_UTF8ToPlatformString(messageboxdata->title); - for (int i = 0; i < messageboxdata->numbuttons; ++i) { - const SDL_MessageBoxButtonData *sdlButton; - if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { - sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i]; - } else { - sdlButton = &messageboxdata->buttons[i]; - } - UICommand ^ button = ref new UICommand(WINRT_UTF8ToPlatformString(sdlButton->text)); - button->Id = IntPtr((int)((size_t)(sdlButton - messageboxdata->buttons))); - dialog->Commands->Append(button); - if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) { - dialog->CancelCommandIndex = i; - } - if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { - dialog->DefaultCommandIndex = i; - } - } - - // Display the MessageDialog, then wait for it to be closed - // TODO, WinRT: Find a way to redraw MessageDialog instances if a GPU device-reset occurs during the following event-loop - auto operation = dialog->ShowAsync(); - while (operation->Status == Windows::Foundation::AsyncStatus::Started) { - WINRT_PumpEvents(_this); - } - - // Retrieve results from the MessageDialog and process them accordingly - if (operation->Status != Windows::Foundation::AsyncStatus::Completed) { - return SDL_SetError("An unknown error occurred in displaying the WinRT MessageDialog"); - } - if (buttonID) { - IntPtr results = safe_cast(operation->GetResults()->Id); - int clicked_index = results.ToInt32(); - *buttonID = messageboxdata->buttons[clicked_index].buttonID; - } - return true; -#endif // if SDL_WINAPI_FAMILY_PHONE / else -} - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmessagebox.h b/src/video/winrt/SDL_winrtmessagebox.h deleted file mode 100644 index c34707f47..000000000 --- a/src/video/winrt/SDL_winrtmessagebox.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -extern bool WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmouse.cpp b/src/video/winrt/SDL_winrtmouse.cpp deleted file mode 100644 index a6e5adda4..000000000 --- a/src/video/winrt/SDL_winrtmouse.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -/* - * Windows includes: - */ -#include -#include -using namespace Windows::UI::Core; -using Windows::UI::Core::CoreCursor; - -/* - * SDL includes: - */ -extern "C" { -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_touch_c.h" -#include "../SDL_sysvideo.h" -} - -#include "../../core/winrt/SDL_winrtapp_direct3d.h" -#include "SDL_winrtvideo_cpp.h" -#include "SDL_winrtmouse_c.h" - -extern "C" bool WINRT_UsingRelativeMouseMode = false; - -static SDL_Cursor *WINRT_CreateSystemCursor(SDL_SystemCursor id) -{ - SDL_Cursor *cursor; - CoreCursorType cursorType = CoreCursorType::Arrow; - - switch (id) { - default: - SDL_assert(0); - return NULL; - case SDL_SYSTEM_CURSOR_DEFAULT: - cursorType = CoreCursorType::Arrow; - break; - case SDL_SYSTEM_CURSOR_TEXT: - cursorType = CoreCursorType::IBeam; - break; - case SDL_SYSTEM_CURSOR_WAIT: - cursorType = CoreCursorType::Wait; - break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: - cursorType = CoreCursorType::Cross; - break; - case SDL_SYSTEM_CURSOR_PROGRESS: - cursorType = CoreCursorType::Wait; - break; - case SDL_SYSTEM_CURSOR_NWSE_RESIZE: - cursorType = CoreCursorType::SizeNorthwestSoutheast; - break; - case SDL_SYSTEM_CURSOR_NESW_RESIZE: - cursorType = CoreCursorType::SizeNortheastSouthwest; - break; - case SDL_SYSTEM_CURSOR_EW_RESIZE: - cursorType = CoreCursorType::SizeWestEast; - break; - case SDL_SYSTEM_CURSOR_NS_RESIZE: - cursorType = CoreCursorType::SizeNorthSouth; - break; - case SDL_SYSTEM_CURSOR_MOVE: - cursorType = CoreCursorType::SizeAll; - break; - case SDL_SYSTEM_CURSOR_NOT_ALLOWED: - cursorType = CoreCursorType::UniversalNo; - break; - case SDL_SYSTEM_CURSOR_POINTER: - cursorType = CoreCursorType::Hand; - break; - case SDL_SYSTEM_CURSOR_NW_RESIZE: - cursorType = CoreCursorType::SizeNorthwestSoutheast; - break; - case SDL_SYSTEM_CURSOR_N_RESIZE: - cursorType = CoreCursorType::SizeNorthSouth; - break; - case SDL_SYSTEM_CURSOR_NE_RESIZE: - cursorType = CoreCursorType::SizeNortheastSouthwest; - break; - case SDL_SYSTEM_CURSOR_E_RESIZE: - cursorType = CoreCursorType::SizeWestEast; - break; - case SDL_SYSTEM_CURSOR_SE_RESIZE: - cursorType = CoreCursorType::SizeNorthwestSoutheast; - break; - case SDL_SYSTEM_CURSOR_S_RESIZE: - cursorType = CoreCursorType::SizeNorthSouth; - break; - case SDL_SYSTEM_CURSOR_SW_RESIZE: - cursorType = CoreCursorType::SizeNortheastSouthwest; - break; - case SDL_SYSTEM_CURSOR_W_RESIZE: - cursorType = CoreCursorType::SizeWestEast; - break; - } - - cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor) { - /* Create a pointer to a COM reference to a cursor. The extra - pointer is used (on top of the COM reference) to allow the cursor - to be referenced by the SDL_cursor's internal field, which is - a void pointer. - */ - CoreCursor ^ *theCursor = new CoreCursor ^ (nullptr); - *theCursor = ref new CoreCursor(cursorType, 0); - cursor->internal = (SDL_CursorData *)theCursor; - } - - return cursor; -} - -static SDL_Cursor *WINRT_CreateDefaultCursor() -{ - return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); -} - -static void WINRT_FreeCursor(SDL_Cursor *cursor) -{ - if (cursor->internal) { - CoreCursor ^ *theCursor = (CoreCursor ^ *)cursor->internal; - *theCursor = nullptr; // Release the COM reference to the CoreCursor - delete theCursor; // Delete the pointer to the COM reference - } - SDL_free(cursor); -} - -static bool WINRT_ShowCursor(SDL_Cursor *cursor) -{ - // TODO, WinRT, XAML: make WINRT_ShowCursor work when XAML support is enabled. - if (!CoreWindow::GetForCurrentThread()) { - return true; - } - - CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread(); - if (cursor) { - CoreCursor ^ *theCursor = (CoreCursor ^ *)cursor->internal; - coreWindow->PointerCursor = *theCursor; - } else { - // HACK ALERT: TL;DR - Hiding the cursor in WinRT/UWP apps is weird, and - // a Win32-style cursor resource file must be directly included in apps, - // otherwise hiding the cursor will cause mouse-motion data to never be - // received. - // - // Here's the lengthy explanation: - // - // There are two ways to hide a cursor in WinRT/UWP apps. - // Both involve setting the WinRT CoreWindow's (which is somewhat analogous - // to a Win32 HWND) 'PointerCursor' property. - // - // The first way to hide a cursor sets PointerCursor to nullptr. This - // is, arguably, the easiest to implement for an app. It does have an - // unfortunate side-effect: it'll prevent mouse-motion events from being - // sent to the app (via CoreWindow). - // - // The second way to hide a cursor sets PointerCursor to a transparent - // cursor. This allows mouse-motion events to be sent to the app, but is - // more difficult to set up, as: - // 1. WinRT/UWP, while providing a few stock cursors, does not provide - // a completely transparent cursor. - // 2. WinRT/UWP allows apps to provide custom-built cursors, but *ONLY* - // if they are linked directly inside the app, via Win32-style - // cursor resource files. APIs to create cursors at runtime are - // not provided to apps, and attempting to link-to or use Win32 - // cursor-creation APIs could cause an app to fail Windows Store - // certification. - // - // SDL can use either means of hiding the cursor. It provides a Win32-style - // set of cursor resource files in its source distribution, inside - // src/main/winrt/. If those files are linked to an SDL-for-WinRT/UWP app - // (by including them in a MSVC project, for example), SDL will attempt to - // use those, if and when the cursor is hidden via SDL APIs. If those - // files are not linked in, SDL will attempt to hide the cursor via the - // 'set PointerCursor to nullptr' means (which, if you recall, causes - // mouse-motion data to NOT be sent to the app!). - // - // Tech notes: - // - SDL's blank cursor resource uses a resource ID of 5000. - // - SDL's cursor resources consist of the following two files: - // - src/main/winrt/SDL3-WinRTResource_BlankCursor.cur -- cursor pixel data - // - src/main/winrt/SDL3-WinRTResources.rc -- declares the cursor resource, and its ID (of 5000) - // - - const unsigned int win32CursorResourceID = 5000; - CoreCursor ^ blankCursor = ref new CoreCursor(CoreCursorType::Custom, win32CursorResourceID); - - // Set 'PointerCursor' to 'blankCursor' in a way that shouldn't throw - // an exception if the app hasn't loaded that resource. - ABI::Windows::UI::Core::ICoreCursor *iblankCursor = reinterpret_cast(blankCursor); - ABI::Windows::UI::Core::ICoreWindow *icoreWindow = reinterpret_cast(coreWindow); - HRESULT hr = icoreWindow->put_PointerCursor(iblankCursor); - if (FAILED(hr)) { - // The app doesn't contain the cursor resource, or some other error - // occurred. Just use the other, but mouse-motion-preventing, means of - // hiding the cursor. - coreWindow->PointerCursor = nullptr; - } - } - return true; -} - -static bool WINRT_SetRelativeMouseMode(bool enabled) -{ - WINRT_UsingRelativeMouseMode = enabled; - return true; -} - -void WINRT_InitMouse(SDL_VideoDevice *_this) -{ - SDL_Mouse *mouse = SDL_GetMouse(); - - /* DLudwig, Dec 3, 2012: WinRT does not currently provide APIs for - the following features, AFAIK: - - custom cursors (multiple system cursors are, however, available) - - programmatically moveable cursors - */ - -#if !SDL_WINAPI_FAMILY_PHONE - // mouse->CreateCursor = WINRT_CreateCursor; - mouse->CreateSystemCursor = WINRT_CreateSystemCursor; - mouse->ShowCursor = WINRT_ShowCursor; - mouse->FreeCursor = WINRT_FreeCursor; - // mouse->WarpMouse = WINRT_WarpMouse; - mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode; - - SDL_SetDefaultCursor(WINRT_CreateDefaultCursor()); -#endif -} - -void WINRT_QuitMouse(SDL_VideoDevice *_this) -{ -} - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtmouse_c.h b/src/video/winrt/SDL_winrtmouse_c.h deleted file mode 100644 index bf41245b3..000000000 --- a/src/video/winrt/SDL_winrtmouse_c.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifndef SDL_winrtmouse_h_ -#define SDL_winrtmouse_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void WINRT_InitMouse(SDL_VideoDevice *_this); -extern void WINRT_QuitMouse(SDL_VideoDevice *_this); -extern bool WINRT_UsingRelativeMouseMode; - -#ifdef __cplusplus -} -#endif - -#endif // SDL_winrtmouse_h_ diff --git a/src/video/winrt/SDL_winrtopengles.cpp b/src/video/winrt/SDL_winrtopengles.cpp deleted file mode 100644 index 442014c9b..000000000 --- a/src/video/winrt/SDL_winrtopengles.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#if defined(SDL_VIDEO_DRIVER_WINRT) && defined(SDL_VIDEO_OPENGL_EGL) - -// EGL implementation of SDL OpenGL support - -#include "SDL_winrtvideo_cpp.h" -extern "C" { -#include "SDL_winrtopengles.h" -#include "../SDL_egl_c.h" -} - -// Windows includes -#include -using namespace Windows::UI::Core; - -// ANGLE/WinRT constants -static const int ANGLE_D3D_FEATURE_LEVEL_ANY = 0; -#define EGL_PLATFORM_ANGLE_ANGLE 0x3202 -#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 -#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 -#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 -#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B -#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F - -#define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B - -/* - * SDL/EGL top-level implementation - */ - -extern "C" -bool WINRT_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) -{ - SDL_VideoData *video_data = _this->internal; - - if (!SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0)) { - return false; - } - - // Load ANGLE/WinRT-specific functions - CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function)SDL_LoadFunction(_this->egl_data->opengl_dll_handle, "CreateWinrtEglWindow"); - if (CreateWinrtEglWindow) { - /* 'CreateWinrtEglWindow' was found, which means that an an older - * version of ANGLE/WinRT is being used. Continue setting up EGL, - * as appropriate to this version of ANGLE. - */ - - // Create an ANGLE/WinRT EGL-window - // TODO, WinRT: check for XAML usage before accessing the CoreWindow, as not doing so could lead to a crash - CoreWindow ^ native_win = CoreWindow::GetForCurrentThread(); - Microsoft::WRL::ComPtr cpp_win = reinterpret_cast(native_win); - HRESULT result = CreateWinrtEglWindow(cpp_win, ANGLE_D3D_FEATURE_LEVEL_ANY, &(video_data->winrtEglWindow)); - if (FAILED(result)) { - return false; - } - - /* Call eglGetDisplay and eglInitialize as appropriate. On other - * platforms, this would probably get done by SDL_EGL_LoadLibrary, - * however ANGLE/WinRT's current implementation (as of Mar 22, 2014) of - * eglGetDisplay requires that a C++ object be passed into it, so the - * call will be made in this file, a C++ file, instead. - */ - Microsoft::WRL::ComPtr cpp_display = video_data->winrtEglWindow; - _this->egl_data->egl_display = ((eglGetDisplay_Old_Function)_this->egl_data->eglGetDisplay)(cpp_display); - if (!_this->egl_data->egl_display) { - return SDL_EGL_SetError("Could not get Windows 8.0 EGL display", "eglGetDisplay"); - } - - if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { - return SDL_EGL_SetError("Could not initialize Windows 8.0 EGL", "eglInitialize"); - } - } else { - /* Declare some ANGLE/EGL initialization property-sets, as suggested by - * MSOpenTech's ANGLE-for-WinRT template apps: - */ - const EGLint defaultDisplayAttributes[] = { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, - EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, - EGL_TRUE, - EGL_NONE, - }; - - const EGLint fl9_3DisplayAttributes[] = { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, - 9, - EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, - 3, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, - EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, - EGL_TRUE, - EGL_NONE, - }; - - const EGLint warpDisplayAttributes[] = { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, - EGL_TRUE, - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, - EGL_TRUE, - EGL_NONE, - }; - - /* 'CreateWinrtEglWindow' was NOT found, which either means that a - * newer version of ANGLE/WinRT is being used, or that we don't have - * a valid copy of ANGLE. - * - * Try loading ANGLE as if it were the newer version. - */ - eglGetPlatformDisplayEXT_Function eglGetPlatformDisplayEXT = (eglGetPlatformDisplayEXT_Function)_this->egl_data->eglGetProcAddress("eglGetPlatformDisplayEXT"); - if (!eglGetPlatformDisplayEXT) { - return SDL_EGL_SetError("Could not retrieve ANGLE/WinRT display function(s)", "eglGetProcAddress"); - } - -#if !SDL_WINAPI_FAMILY_PHONE - /* Try initializing EGL at D3D11 Feature Level 10_0+ (which is not - * supported on WinPhone 8.x. - */ - _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); - if (!_this->egl_data->egl_display) { - return SDL_EGL_SetError("Could not get EGL display for Direct3D 10_0+", "eglGetPlatformDisplayEXT"); - } - - if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) -#endif - { - /* Try initializing EGL at D3D11 Feature Level 9_3, in case the - * 10_0 init fails, or we're on Windows Phone (which only supports - * 9_3). - */ - _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); - if (!_this->egl_data->egl_display) { - return SDL_EGL_SetError("Could not get EGL display for Direct3D 9_3", "eglGetPlatformDisplayEXT"); - } - - if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { - /* Try initializing EGL at D3D11 Feature Level 11_0 on WARP - * (a Windows-provided, software rasterizer) if all else fails. - */ - _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes); - if (!_this->egl_data->egl_display) { - return SDL_EGL_SetError("Could not get EGL display for Direct3D WARP", "eglGetPlatformDisplayEXT"); - } - - if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { - return SDL_EGL_SetError("Could not initialize WinRT 8.x+ EGL", "eglInitialize"); - } - } - } - } - - return true; -} - -extern "C" -void WINRT_GLES_UnloadLibrary(SDL_VideoDevice *_this) -{ - SDL_VideoData *video_data = _this->internal; - - // Release SDL's own COM reference to the ANGLE/WinRT IWinrtEglWindow - if (video_data->winrtEglWindow) { - video_data->winrtEglWindow->Release(); - video_data->winrtEglWindow = nullptr; - } - - // Perform the bulk of the unloading - SDL_EGL_UnloadLibrary(_this); -} - -extern "C" { -SDL_EGL_CreateContext_impl(WINRT) -SDL_EGL_SwapWindow_impl(WINRT) -SDL_EGL_MakeCurrent_impl(WINRT) -} - -#endif // SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/winrt/SDL_winrtopengles.h b/src/video/winrt/SDL_winrtopengles.h deleted file mode 100644 index 33fb8c49a..000000000 --- a/src/video/winrt/SDL_winrtopengles.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifndef SDL_winrtopengles_h_ -#define SDL_winrtopengles_h_ - -#if defined(SDL_VIDEO_DRIVER_WINRT) && defined(SDL_VIDEO_OPENGL_EGL) - -#include "../SDL_sysvideo.h" -#include "../SDL_egl_c.h" - -// OpenGLES functions -#define WINRT_GLES_GetAttribute SDL_EGL_GetAttribute -#define WINRT_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal -#define WINRT_GLES_SetSwapInterval SDL_EGL_SetSwapInterval -#define WINRT_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -#define WINRT_GLES_DestroyContext SDL_EGL_DestroyContext - -extern bool WINRT_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); -extern void WINRT_GLES_UnloadLibrary(SDL_VideoDevice *_this); -extern SDL_GLContext WINRT_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); -extern bool WINRT_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern bool WINRT_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); - -#ifdef __cplusplus - -/* Typedefs for ANGLE/WinRT's C++-based native-display and native-window types, - * which are used when calling eglGetDisplay and eglCreateWindowSurface. - */ -typedef Microsoft::WRL::ComPtr WINRT_EGLNativeWindowType_Old; - -/* Function pointer typedefs for 'old' ANGLE/WinRT's functions, which may - * require that C++ objects be passed in: - */ -typedef EGLDisplay(EGLAPIENTRY *eglGetDisplay_Old_Function)(WINRT_EGLNativeWindowType_Old); -typedef EGLSurface(EGLAPIENTRY *eglCreateWindowSurface_Old_Function)(EGLDisplay, EGLConfig, WINRT_EGLNativeWindowType_Old, const EGLint *); -typedef HRESULT(EGLAPIENTRY *CreateWinrtEglWindow_Old_Function)(Microsoft::WRL::ComPtr, int, IUnknown **result); - -#endif // __cplusplus - -/* Function pointer typedefs for 'new' ANGLE/WinRT functions, which, unlike - * the old functions, do not require C++ support and work with plain C. - */ -typedef EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplayEXT_Function)(EGLenum, void *, const EGLint *); - -#endif // SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL - -#endif // SDL_winrtopengles_h_ diff --git a/src/video/winrt/SDL_winrtpointerinput.cpp b/src/video/winrt/SDL_winrtpointerinput.cpp deleted file mode 100644 index efd5b0fc1..000000000 --- a/src/video/winrt/SDL_winrtpointerinput.cpp +++ /dev/null @@ -1,389 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -// SDL includes -#include "SDL_winrtevents_c.h" -#include "SDL_winrtmouse_c.h" -#include "SDL_winrtvideo_cpp.h" - -extern "C" { -#include "../SDL_sysvideo.h" -#include "../../events/SDL_events_c.h" -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_touch_c.h" -} - -// File-specific globals: -static SDL_TouchID WINRT_TouchID = 1; - -void WINRT_InitTouch(SDL_VideoDevice *_this) -{ - SDL_AddTouch(WINRT_TouchID, SDL_TOUCH_DEVICE_DIRECT, ""); -} - -// -// Applies necessary geometric transformations to raw cursor positions: -// -Windows::Foundation::Point -WINRT_TransformCursorPosition(SDL_Window *window, - Windows::Foundation::Point rawPosition, - WINRT_CursorNormalizationType normalization) -{ - using namespace Windows::UI::Core; - using namespace Windows::Graphics::Display; - - if (!window) { - return rawPosition; - } - - SDL_WindowData *windowData = window->internal; - if (windowData->coreWindow == nullptr) { - // For some reason, the window isn't associated with a CoreWindow. - // This might end up being the case as XAML support is extended. - // For now, if there's no CoreWindow attached to the SDL_Window, - // don't do any transforms. - - // TODO, WinRT: make sure touch input coordinate ranges are correct when using XAML support - return rawPosition; - } - - // The CoreWindow can only be accessed on certain thread(s). - SDL_assert(CoreWindow::GetForCurrentThread() != nullptr); - - CoreWindow ^ nativeWindow = windowData->coreWindow.Get(); - Windows::Foundation::Point outputPosition; - - // Compute coordinates normalized from 0..1. - // If the coordinates need to be sized to the SDL window, - // we'll do that after. -#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION > NTDDI_WIN8 - outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; - outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; -#else - switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation)) { - case DisplayOrientations::Portrait: - outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; - outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; - break; - case DisplayOrientations::PortraitFlipped: - outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); - outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); - break; - case DisplayOrientations::Landscape: - outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height; - outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); - break; - case DisplayOrientations::LandscapeFlipped: - outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); - outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width; - break; - default: - break; - } -#endif - - if (normalization == TransformToSDLWindowSize) { - outputPosition.X *= ((float32)window->w); - outputPosition.Y *= ((float32)window->h); - } - - return outputPosition; -} - -bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed) -{ - using namespace Windows::UI::Input; - -#if SDL_WINAPI_FAMILY_PHONE - *button = SDL_BUTTON_LEFT; - return true; -#else - switch (pt->Properties->PointerUpdateKind) { - case PointerUpdateKind::LeftButtonPressed: - case PointerUpdateKind::LeftButtonReleased: - *button = SDL_BUTTON_LEFT; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed); - return true; - - case PointerUpdateKind::RightButtonPressed: - case PointerUpdateKind::RightButtonReleased: - *button = SDL_BUTTON_RIGHT; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed); - return true; - - case PointerUpdateKind::MiddleButtonPressed: - case PointerUpdateKind::MiddleButtonReleased: - *button = SDL_BUTTON_MIDDLE; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed); - return true; - - case PointerUpdateKind::XButton1Pressed: - case PointerUpdateKind::XButton1Released: - *button = SDL_BUTTON_X1; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed); - return true; - - case PointerUpdateKind::XButton2Pressed: - case PointerUpdateKind::XButton2Released: - *button = SDL_BUTTON_X2; - *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed); - return true; - - default: - break; - } -#endif - - *button = 0; - *pressed = 0; - return false; -} - -// const char * -// WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind) -//{ -// using namespace Windows::UI::Input; -// -// switch (kind) -// { -// case PointerUpdateKind::Other: -// return "Other"; -// case PointerUpdateKind::LeftButtonPressed: -// return "LeftButtonPressed"; -// case PointerUpdateKind::LeftButtonReleased: -// return "LeftButtonReleased"; -// case PointerUpdateKind::RightButtonPressed: -// return "RightButtonPressed"; -// case PointerUpdateKind::RightButtonReleased: -// return "RightButtonReleased"; -// case PointerUpdateKind::MiddleButtonPressed: -// return "MiddleButtonPressed"; -// case PointerUpdateKind::MiddleButtonReleased: -// return "MiddleButtonReleased"; -// case PointerUpdateKind::XButton1Pressed: -// return "XButton1Pressed"; -// case PointerUpdateKind::XButton1Released: -// return "XButton1Released"; -// case PointerUpdateKind::XButton2Pressed: -// return "XButton2Pressed"; -// case PointerUpdateKind::XButton2Released: -// return "XButton2Released"; -// } -// -// return ""; -// } - -static bool WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^ pointerPoint) -{ -#if SDL_WINAPI_FAMILY_PHONE - return true; -#else - using namespace Windows::Devices::Input; - switch (pointerPoint->PointerDevice->PointerDeviceType) { - case PointerDeviceType::Touch: - case PointerDeviceType::Pen: - return true; - default: - return false; - } -#endif -} - -void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) -{ - if (!window) { - return; - } - - if (!WINRT_IsTouchEvent(pointerPoint)) { - Uint8 button, pressed; - WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed); - SDL_assert(pressed == 1); - SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_PRESSED, button); - } else { - Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); - Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); - - SDL_SendTouch(0, - WINRT_TouchID, - (SDL_FingerID)(pointerPoint->PointerId + 1), - window, - true, - normalizedPoint.X, - normalizedPoint.Y, - pointerPoint->Properties->Pressure); - } -} - -void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) -{ - if (!window || WINRT_UsingRelativeMouseMode) { - return; - } - - Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); - Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); - - if (!WINRT_IsTouchEvent(pointerPoint)) { - // For some odd reason Moved events are used for multiple mouse buttons - Uint8 button, pressed; - if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) { - SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, pressed, button); - } - - SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, false, windowPoint.X, windowPoint.Y); - } else { - SDL_SendTouchMotion(0, - WINRT_TouchID, - (SDL_FingerID)(pointerPoint->PointerId + 1), - window, - normalizedPoint.X, - normalizedPoint.Y, - pointerPoint->Properties->Pressure); - } -} - -void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) -{ - if (!window) { - return; - } - - if (!WINRT_IsTouchEvent(pointerPoint)) { - Uint8 button, pressed; - WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed); - SDL_assert(pressed == 0); - SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, SDL_RELEASED, button); - } else { - Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); - - SDL_SendTouch(0, - WINRT_TouchID, - (SDL_FingerID)(pointerPoint->PointerId + 1), - window, - false, - normalizedPoint.X, - normalizedPoint.Y, - pointerPoint->Properties->Pressure); - } -} - -void WINRT_ProcessPointerEnteredEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) -{ - if (!window) { - return; - } - - if (!WINRT_IsTouchEvent(pointerPoint)) { - SDL_SetMouseFocus(window); - } -} - -void WINRT_ProcessPointerExitedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) -{ - if (!window) { - return; - } - - if (!WINRT_IsTouchEvent(pointerPoint)) { - SDL_SetMouseFocus(NULL); - } -} - -void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint) -{ - if (!window) { - return; - } - - float motion = (float)pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA; - SDL_SendMouseWheel(0, window, SDL_DEFAULT_MOUSE_ID, 0.0f, motion, SDL_MOUSEWHEEL_NORMAL); -} - -void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::MouseEventArgs ^ args) -{ - if (!window || !WINRT_UsingRelativeMouseMode) { - return; - } - - // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows - // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs' - // MouseDelta field often reports very large values. More information - // on this can be found at the following pages on MSDN: - // - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8 - // - https://connect.microsoft.com/VisualStudio/Feedback/details/756515 - // - // The values do not appear to be as large when running on some systems, - // most notably a Surface RT. Furthermore, the values returned by - // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved - // method, do not ever appear to be large, even when MouseEventArgs' - // MouseDelta is reporting to the contrary. - // - // On systems with the large-values behavior, it appears that the values - // get reported as if the screen's size is 65536 units in both the X and Y - // dimensions. This can be viewed by using Windows' now-private, "Raw Input" - // APIs. (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.) - // - // MSDN's documentation on MouseEventArgs' MouseDelta field (at - // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ), - // does not seem to indicate (to me) that its values should be so large. It - // says that its values should be a "change in screen location". I could - // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: - // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ), - // indicates that these values are in DIPs, which is the same unit used - // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint - // property. See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx - // for details.) - // - // To note, PointerMoved events are sent a 'RawPosition' value (via the - // CurrentPoint property in MouseEventArgs), however these do not seem - // to exhibit the same large-value behavior. - // - // The values passed via PointerMoved events can't always be used for relative - // mouse motion, unfortunately. Its values are bound to the cursor's position, - // which stops when it hits one of the screen's edges. This can be a problem in - // first person shooters, whereby it is normal for mouse motion to travel far - // along any one axis for a period of time. MouseMoved events do not have the - // screen-bounding limitation, and can be used regardless of where the system's - // cursor is. - // - // One possible workaround would be to programmatically set the cursor's - // position to the screen's center (when SDL's relative mouse mode is enabled), - // however WinRT does not yet seem to have the ability to set the cursor's - // position via a public API. Win32 did this via an API call, SetCursorPos, - // however WinRT makes this function be private. Apps that use it won't get - // approved for distribution in the Windows Store. I've yet to be able to find - // a suitable, store-friendly counterpart for WinRT. - // - // There may be some room for a workaround whereby OnPointerMoved's values - // are compared to the values from OnMouseMoved in order to detect - // when this bug is active. A suitable transformation could then be made to - // OnMouseMoved's values. - // - const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y); - const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize); - SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, true, mouseDeltaInSDLWindowCoords.X, mouseDeltaInSDLWindowCoords.Y); -} - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp deleted file mode 100644 index 7b551c76c..000000000 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ /dev/null @@ -1,846 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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" - -#ifdef SDL_VIDEO_DRIVER_WINRT - -/* WinRT SDL video driver implementation - - Initial work on this was done by David Ludwig (dludwig@pobox.com), and - was based off of SDL's "dummy" video driver. - */ - -// Standard C++11 includes -#include -#include - -// Windows includes -#include -#include -#include -#include -#include -using namespace Windows::ApplicationModel::Core; -using namespace Windows::Foundation; -using namespace Windows::Graphics::Display; -using namespace Windows::UI::Core; -using namespace Windows::UI::ViewManagement; - -// [re]declare Windows GUIDs locally, to limit the amount of external lib(s) SDL has to link to -static const GUID SDL_IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } }; -static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; - -// SDL includes -extern "C" { -#include "../../core/windows/SDL_windows.h" -#include "../../events/SDL_events_c.h" -#include "../../render/SDL_sysrender.h" -#include "../SDL_pixels_c.h" -#include "../SDL_sysvideo.h" -#include "SDL_winrtopengles.h" -#include "SDL_winrtmessagebox.h" -} - -#include "../../core/winrt/SDL_winrtapp_direct3d.h" -#include "../../core/winrt/SDL_winrtapp_xaml.h" -#include "SDL_winrtevents_c.h" -#include "SDL_winrtgamebar_cpp.h" -#include "SDL_winrtmouse_c.h" -#include "SDL_winrtvideo_cpp.h" - -// Initialization/Query functions -static bool WINRT_VideoInit(SDL_VideoDevice *_this); -static bool WINRT_InitModes(SDL_VideoDevice *_this); -static bool WINRT_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); -static void WINRT_VideoQuit(SDL_VideoDevice *_this); - -// Window functions -static bool WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); -static void WINRT_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); -static SDL_FullscreenResult WINRT_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); -static void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); - -// Misc functions -static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(SDL_VideoDevice *_this); -extern bool WINRT_SuspendScreenSaver(SDL_VideoDevice *_this); - -// SDL-internal globals: -SDL_Window *WINRT_GlobalSDLWindow = NULL; - -// WinRT driver bootstrap functions - -static void WINRT_DeleteDevice(SDL_VideoDevice *device) -{ - if (device->internal) { - SDL_VideoData *video_data = device->internal; - if (video_data->winrtEglWindow) { - video_data->winrtEglWindow->Release(); - } - SDL_free(video_data); - } - - SDL_free(device); -} - -static SDL_VideoDevice *WINRT_CreateDevice(void) -{ - SDL_VideoDevice *device; - SDL_VideoData *data; - - // Initialize all variables that we clean on shutdown - device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (!device) { - return NULL; - } - - data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (!data) { - SDL_free(device); - return NULL; - } - device->internal = data; - - // Set the function pointers - device->VideoInit = WINRT_VideoInit; - device->VideoQuit = WINRT_VideoQuit; - device->CreateSDLWindow = WINRT_CreateWindow; - device->SetWindowSize = WINRT_SetWindowSize; - device->SetWindowFullscreen = WINRT_SetWindowFullscreen; - device->DestroyWindow = WINRT_DestroyWindow; - device->SetDisplayMode = WINRT_SetDisplayMode; - device->PumpEvents = WINRT_PumpEvents; - device->SuspendScreenSaver = WINRT_SuspendScreenSaver; - -#if NTDDI_VERSION >= NTDDI_WIN10 - device->HasScreenKeyboardSupport = WINRT_HasScreenKeyboardSupport; - device->ShowScreenKeyboard = WINRT_ShowScreenKeyboard; - device->HideScreenKeyboard = WINRT_HideScreenKeyboard; - device->IsScreenKeyboardShown = WINRT_IsScreenKeyboardShown; - - WINTRT_InitialiseInputPaneEvents(device); -#endif - -#ifdef SDL_VIDEO_OPENGL_EGL - device->GL_LoadLibrary = WINRT_GLES_LoadLibrary; - device->GL_GetProcAddress = WINRT_GLES_GetProcAddress; - device->GL_UnloadLibrary = WINRT_GLES_UnloadLibrary; - device->GL_CreateContext = WINRT_GLES_CreateContext; - device->GL_MakeCurrent = WINRT_GLES_MakeCurrent; - device->GL_SetSwapInterval = WINRT_GLES_SetSwapInterval; - device->GL_GetSwapInterval = WINRT_GLES_GetSwapInterval; - device->GL_SwapWindow = WINRT_GLES_SwapWindow; - device->GL_DestroyContext = WINRT_GLES_DestroyContext; -#endif - device->free = WINRT_DeleteDevice; - - return device; -} - -VideoBootStrap WINRT_bootstrap = { - "winrt", "SDL WinRT video driver", - WINRT_CreateDevice, - WINRT_ShowMessageBox -}; - -static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue) -{ - SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0); - - /* HACK: prevent SDL from altering an app's .appxmanifest-set orientation - * from being changed on startup, by detecting when SDL_HINT_ORIENTATIONS - * is getting registered. - * - * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'. - */ - if ((!oldValue) && (!newValue)) { - return; - } - - // Start with no orientation flags, then add each in as they're parsed - // from newValue. - unsigned int orientationFlags = 0; - if (newValue) { - std::istringstream tokenizer(newValue); - while (!tokenizer.eof()) { - std::string orientationName; - std::getline(tokenizer, orientationName, ' '); - if (orientationName == "LandscapeLeft") { - orientationFlags |= (unsigned int)DisplayOrientations::LandscapeFlipped; - } else if (orientationName == "LandscapeRight") { - orientationFlags |= (unsigned int)DisplayOrientations::Landscape; - } else if (orientationName == "Portrait") { - orientationFlags |= (unsigned int)DisplayOrientations::Portrait; - } else if (orientationName == "PortraitUpsideDown") { - orientationFlags |= (unsigned int)DisplayOrientations::PortraitFlipped; - } - } - } - - // If no valid orientation flags were specified, use a reasonable set of defaults: - if (!orientationFlags) { - // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s). - orientationFlags = (unsigned int)(DisplayOrientations::Landscape | - DisplayOrientations::LandscapeFlipped | - DisplayOrientations::Portrait | - DisplayOrientations::PortraitFlipped); - } - - // Set the orientation/rotation preferences. Please note that this does - // not constitute a 100%-certain lock of a given set of possible - // orientations. According to Microsoft's documentation on WinRT [1] - // when a device is not capable of being rotated, Windows may ignore - // the orientation preferences, and stick to what the device is capable of - // displaying. - // - // [1] Documentation on the 'InitialRotationPreference' setting for a - // Windows app's manifest file describes how some orientation/rotation - // preferences may be ignored. See - // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx - // for details. Microsoft's "Display orientation sample" also gives an - // outline of how Windows treats device rotation - // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93). - WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations)orientationFlags; -} - -bool WINRT_VideoInit(SDL_VideoDevice *_this) -{ - SDL_VideoData *internal = _this->internal; - if (!WINRT_InitModes(_this)) { - return false; - } - - // Register the hint, SDL_HINT_ORIENTATIONS, with SDL. - // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly. - SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL); - - WINRT_InitMouse(_this); - WINRT_InitTouch(_this); - WINRT_InitGameBar(_this); - if (internal) { - // Initialize screensaver-disabling support - internal->displayRequest = WINRT_CreateDisplayRequest(_this); - } - - // Assume we have a mouse and keyboard - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); - - return true; -} - -extern "C" SDL_PixelFormat D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat); - -static void WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC *dxgiMode, SDL_DisplayMode *sdlMode) -{ - SDL_zerop(sdlMode); - sdlMode->w = dxgiMode->Width; - sdlMode->h = dxgiMode->Height; - sdlMode->refresh_rate_numerator = dxgiMode->RefreshRate.Numerator; - sdlMode->refresh_rate_denominator = dxgiMode->RefreshRate.Denominator; - sdlMode->format = D3D11_DXGIFormatToSDLPixelFormat(dxgiMode->Format); -} - -static bool WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxgiAdapter1, int outputIndex) -{ - HRESULT hr; - IDXGIOutput *dxgiOutput = NULL; - DXGI_OUTPUT_DESC dxgiOutputDesc; - SDL_VideoDisplay display; - UINT numModes; - DXGI_MODE_DESC *dxgiModes = NULL; - bool result = false; - DXGI_MODE_DESC modeToMatch, closestMatch; - - SDL_zero(display); - - hr = dxgiAdapter1->EnumOutputs(outputIndex, &dxgiOutput); - if (FAILED(hr)) { - if (hr != DXGI_ERROR_NOT_FOUND) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIAdapter1::EnumOutputs failed", hr); - } - goto done; - } - - hr = dxgiOutput->GetDesc(&dxgiOutputDesc); - if (FAILED(hr)) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::GetDesc failed", hr); - goto done; - } - - SDL_zero(modeToMatch); - modeToMatch.Format = DXGI_FORMAT_B8G8R8A8_UNORM; - modeToMatch.Width = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left); - modeToMatch.Height = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top); - hr = dxgiOutput->FindClosestMatchingMode(&modeToMatch, &closestMatch, NULL); - if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) { - /* DXGI_ERROR_NOT_CURRENTLY_AVAILABLE gets returned by IDXGIOutput::FindClosestMatchingMode - when running under the Windows Simulator, which uses Remote Desktop (formerly known as Terminal - Services) under the hood. According to the MSDN docs for the similar function, - IDXGIOutput::GetDisplayModeList, DXGI_ERROR_NOT_CURRENTLY_AVAILABLE is returned if and - when an app is run under a Terminal Services session, hence the assumption. - - In this case, just add an SDL display mode, with approximated values. - */ - SDL_DisplayMode mode; - SDL_zero(mode); - display.name = SDL_strdup("Windows Simulator / Terminal Services Display"); - mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left); - mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top); - mode.format = D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM); - display.desktop_mode = mode; - } else if (FAILED(hr)) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr); - goto done; - } else { - display.name = WIN_StringToUTF8W(dxgiOutputDesc.DeviceName); - WINRT_DXGIModeToSDLDisplayMode(&closestMatch, &display.desktop_mode); - - hr = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, NULL); - if (FAILED(hr)) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::GetDisplayModeList [get mode list size] failed", hr); - goto done; - } - - dxgiModes = (DXGI_MODE_DESC *)SDL_calloc(numModes, sizeof(DXGI_MODE_DESC)); - if (!dxgiModes) { - goto done; - } - - hr = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, dxgiModes); - if (FAILED(hr)) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::GetDisplayModeList [get mode contents] failed", hr); - goto done; - } - - for (UINT i = 0; i < numModes; ++i) { - SDL_DisplayMode sdlMode; - WINRT_DXGIModeToSDLDisplayMode(&dxgiModes[i], &sdlMode); - SDL_AddFullscreenDisplayMode(&display, &sdlMode); - } - } - - if (SDL_AddVideoDisplay(&display, false) == 0) { - goto done; - } - - result = true; - -done: - if (dxgiModes) { - SDL_free(dxgiModes); - } - if (dxgiOutput) { - dxgiOutput->Release(); - } - if (display.name) { - SDL_free(display.name); - } - return result; -} - -static bool WINRT_AddDisplaysForAdapter(SDL_VideoDevice *_this, IDXGIFactory2 *dxgiFactory2, int adapterIndex) -{ - HRESULT hr; - IDXGIAdapter1 *dxgiAdapter1; - - hr = dxgiFactory2->EnumAdapters1(adapterIndex, &dxgiAdapter1); - if (FAILED(hr)) { - if (hr != DXGI_ERROR_NOT_FOUND) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory1::EnumAdapters1() failed", hr); - } - return false; - } - - for (int outputIndex = 0;; ++outputIndex) { - if (!WINRT_AddDisplaysForOutput(_this, dxgiAdapter1, outputIndex)) { - /* HACK: The Windows App Certification Kit 10.0 can fail, when - running the Store Apps' test, "Direct3D Feature Test". The - certification kit's error is: - - "Application App was not running at the end of the test. It likely crashed or was terminated for having become unresponsive." - - This was caused by SDL/WinRT's DXGI failing to report any - outputs. Attempts to get the 1st display-output from the - 1st display-adapter can fail, with IDXGIAdapter::EnumOutputs - returning DXGI_ERROR_NOT_FOUND. This could be a bug in Windows, - the Windows App Certification Kit, or possibly in SDL/WinRT's - display detection code. Either way, try to detect when this - happens, and use a hackish means to create a reasonable-as-possible - 'display mode'. -- DavidL - */ - if (adapterIndex == 0 && outputIndex == 0) { - SDL_VideoDisplay display; - SDL_DisplayMode mode; -#if SDL_WINRT_USE_APPLICATIONVIEW - ApplicationView ^ appView = ApplicationView::GetForCurrentView(); -#endif - CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread(); - SDL_zero(display); - SDL_zero(mode); - display.name = SDL_strdup("DXGI Display-detection Workaround"); - - /* HACK: ApplicationView's VisibleBounds property, appeared, via testing, to - give a better approximation of display-size, than did CoreWindow's - Bounds property, insofar that ApplicationView::VisibleBounds seems like - it will, at least some of the time, give the full display size (during the - failing test), whereas CoreWindow might not. -- DavidL - */ - -#if (NTDDI_VERSION >= NTDDI_WIN10) || (SDL_WINRT_USE_APPLICATIONVIEW && SDL_WINAPI_FAMILY_PHONE) - mode.w = (int)SDL_floorf(appView->VisibleBounds.Width); - mode.h = (int)SDL_floorf(appView->VisibleBounds.Height); -#else - /* On platform(s) that do not support VisibleBounds, such as Windows 8.1, - fall back to CoreWindow's Bounds property. - */ - mode.w = (int)SDL_floorf(coreWin->Bounds.Width); - mode.h = (int)SDL_floorf(coreWin->Bounds.Height); -#endif - mode.pixel_density = WINRT_DISPLAY_PROPERTY(LogicalDpi) / 96.0f; - mode.format = D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM); - - display.desktop_mode = mode; - bool error = (SDL_AddVideoDisplay(&display, false) == 0); - if (display.name) { - SDL_free(display.name); - } - if (error) { - return SDL_SetError("Failed to apply DXGI Display-detection workaround"); - } - } - - break; - } - } - - dxgiAdapter1->Release(); - return true; -} - -bool WINRT_InitModes(SDL_VideoDevice *_this) -{ - /* HACK: Initialize a single display, for whatever screen the app's - CoreApplicationView is on. - TODO, WinRT: Try initializing multiple displays, one for each monitor. - Appropriate WinRT APIs for this seem elusive, though. -- DavidL - */ - - HRESULT hr; - IDXGIFactory2 *dxgiFactory2 = NULL; - - hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2); - if (FAILED(hr)) { - return WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr); - } - - for (int adapterIndex = 0;; ++adapterIndex) { - if (!WINRT_AddDisplaysForAdapter(_this, dxgiFactory2, adapterIndex)) { - break; - } - } - - return true; -} - -static bool WINRT_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) -{ - return true; -} - -void WINRT_VideoQuit(SDL_VideoDevice *_this) -{ - SDL_VideoData *internal = _this->internal; - if (internal && internal->displayRequest) { - internal->displayRequest->Release(); - internal->displayRequest = NULL; - } - WINRT_QuitGameBar(_this); - WINRT_QuitMouse(_this); -} - -static const SDL_WindowFlags WINRT_DetectableFlags = SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_HIDDEN | SDL_WINDOW_MOUSE_FOCUS; - -extern "C" SDL_WindowFlags -WINRT_DetectWindowFlags(SDL_Window *window) -{ - SDL_WindowFlags latestFlags = 0; - SDL_WindowData *data = window->internal; - bool is_fullscreen = false; - -#if SDL_WINRT_USE_APPLICATIONVIEW - if (data->appView) { - is_fullscreen = data->appView->IsFullScreenMode; - } -#elif SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION == NTDDI_WIN8 - is_fullscreen = true; -#endif - - if (data->coreWindow.Get()) { - if (is_fullscreen) { - SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); - int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width); - int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height); - -#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION > NTDDI_WIN8 - // On all WinRT platforms, except for WinPhone 8.0, rotate the - // window size. This is needed to properly calculate - // fullscreen vs. maximized. - const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); - switch (currentOrientation) { -#if SDL_WINAPI_FAMILY_PHONE - case DisplayOrientations::Landscape: - case DisplayOrientations::LandscapeFlipped: -#else - case DisplayOrientations::Portrait: - case DisplayOrientations::PortraitFlipped: -#endif - { - int tmp = w; - w = h; - h = tmp; - } break; - } -#endif - - if (display->desktop_mode.w != w || display->desktop_mode.h != h) { - latestFlags |= SDL_WINDOW_MAXIMIZED; - } else { - latestFlags |= SDL_WINDOW_FULLSCREEN; - } - } - - if (data->coreWindow->Visible) { - latestFlags &= ~SDL_WINDOW_HIDDEN; - } else { - latestFlags |= SDL_WINDOW_HIDDEN; - } - -#if SDL_WINAPI_FAMILY_PHONE && NTDDI_VERSION < NTDDI_WINBLUE - // data->coreWindow->PointerPosition is not supported on WinPhone 8.0 - latestFlags |= SDL_WINDOW_MOUSE_FOCUS; -#else - if (data->coreWindow->Visible && data->coreWindow->Bounds.Contains(data->coreWindow->PointerPosition)) { - latestFlags |= SDL_WINDOW_MOUSE_FOCUS; - } -#endif - } - - return latestFlags; -} - -// TODO, WinRT: consider removing WINRT_UpdateWindowFlags, and just calling WINRT_DetectWindowFlags as-appropriate (with appropriate calls to SDL_SendWindowEvent) -void WINRT_UpdateWindowFlags(SDL_Window *window, SDL_WindowFlags mask) -{ - mask &= WINRT_DetectableFlags; - if (window) { - Uint32 apply = WINRT_DetectWindowFlags(window); - window->flags = (window->flags & ~mask) | (apply & mask); - } -} - -static bool WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow) -{ - /* WinRT does not appear to offer API(s) to determine window-activation state, - at least not that I am aware of in Win8 - Win10. As such, SDL tracks this - itself, via window-activation events. - - If there *is* an API to track this, it should probably get used instead - of the following hack (that uses "SDLHelperWindowActivationState"). - -- DavidL. - */ - if (coreWindow->CustomProperties->HasKey("SDLHelperWindowActivationState")) { - CoreWindowActivationState activationState = - safe_cast(coreWindow->CustomProperties->Lookup("SDLHelperWindowActivationState")); - return activationState != CoreWindowActivationState::Deactivated; - } - - /* Assume that non-SDL tracked windows are active, although this should - probably be avoided, if possible. - - This might not even be possible, in normal SDL use, at least as of - this writing (Dec 22, 2015; via latest hg.libsdl.org/SDL clone) -- DavidL - */ - return true; -} - -bool WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) -{ - // Make sure that only one window gets created, at least until multimonitor - // support is added. - if (WINRT_GlobalSDLWindow != NULL) { - return SDL_SetError("WinRT only supports one window"); - } - - SDL_WindowData *data = new SDL_WindowData; // use 'new' here as SDL_WindowData may use WinRT/C++ types - if (!data) { - return SDL_OutOfMemory(); - } - window->internal = data; - data->sdlWindow = window; - data->high_surrogate = L'\0'; - - /* To note, when XAML support is enabled, access to the CoreWindow will not - be possible, at least not via the SDL/XAML thread. Attempts to access it - from there will throw exceptions. As such, the SDL_WindowData's - 'coreWindow' field will only be set (to a non-null value) if XAML isn't - enabled. - */ - if (!WINRT_XAMLWasEnabled) { - data->coreWindow = CoreWindow::GetForCurrentThread(); -#if SDL_WINRT_USE_APPLICATIONVIEW - data->appView = ApplicationView::GetForCurrentView(); -#endif - } - SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WINRT_WINDOW_POINTER, reinterpret_cast(data->coreWindow.Get())); - - // Make note of the requested window flags, before they start getting changed. - const Uint32 requestedFlags = window->flags; - -#ifdef SDL_VIDEO_OPENGL_EGL - // Setup the EGL surface, but only if OpenGL ES 2 was requested. - if (!(window->flags & SDL_WINDOW_OPENGL)) { - // OpenGL ES 2 wasn't requested. Don't set up an EGL surface. - data->egl_surface = EGL_NO_SURFACE; - } else { - // OpenGL ES 2 was requested. Set up an EGL surface. - SDL_VideoData *video_data = _this->internal; - - /* Call SDL_EGL_ChooseConfig and eglCreateWindowSurface directly, - * rather than via SDL_EGL_CreateSurface, as older versions of - * ANGLE/WinRT may require that a C++ object, ComPtr, - * be passed into eglCreateWindowSurface. - */ - if (!SDL_EGL_ChooseConfig(_this)) { - // SDL_EGL_ChooseConfig failed, SDL_GetError() should have info - return false; - } - - if (video_data->winrtEglWindow) { // ... is the 'old' version of ANGLE/WinRT being used? - /* Attempt to create a window surface using older versions of - * ANGLE/WinRT: - */ - Microsoft::WRL::ComPtr cpp_winrtEglWindow = video_data->winrtEglWindow; - data->egl_surface = ((eglCreateWindowSurface_Old_Function)_this->egl_data->eglCreateWindowSurface)( - _this->egl_data->egl_display, - _this->egl_data->egl_config, - cpp_winrtEglWindow, NULL); - if (data->egl_surface == NULL) { - return SDL_EGL_SetError("unable to create EGL native-window surface", "eglCreateWindowSurface"); - } - } else if (data->coreWindow.Get() != nullptr) { - /* Attempt to create a window surface using newer versions of - * ANGLE/WinRT: - */ - IInspectable *coreWindowAsIInspectable = reinterpret_cast(data->coreWindow.Get()); - data->egl_surface = _this->egl_data->eglCreateWindowSurface( - _this->egl_data->egl_display, - _this->egl_data->egl_config, - (NativeWindowType)coreWindowAsIInspectable, - NULL); - if (data->egl_surface == NULL) { - return SDL_EGL_SetError("unable to create EGL native-window surface", "eglCreateWindowSurface"); - } - } else { - return SDL_SetError("No supported means to create an EGL window surface are available"); - } - } -#endif - - // Determine as many flags dynamically, as possible. - window->flags = - SDL_WINDOW_BORDERLESS | - SDL_WINDOW_RESIZABLE; - -#ifdef SDL_VIDEO_OPENGL_EGL - if (data->egl_surface) { - window->flags |= SDL_WINDOW_OPENGL; - } -#endif - - if (WINRT_XAMLWasEnabled) { - // TODO, WinRT: set SDL_Window size, maybe position too, from XAML control - window->x = 0; - window->y = 0; - window->flags &= ~SDL_WINDOW_HIDDEN; - SDL_SetMouseFocus(NULL); // TODO: detect this - SDL_SetKeyboardFocus(NULL); // TODO: detect this - } else { - /* WinRT 8.x apps seem to live in an environment where the OS controls the - app's window size, with some apps being fullscreen, depending on - user choice of various things. For now, just adapt the SDL_Window to - whatever Windows set-up as the native-window's geometry. - */ - window->x = (int)SDL_lroundf(data->coreWindow->Bounds.Left); - window->y = (int)SDL_lroundf(data->coreWindow->Bounds.Top); -#if NTDDI_VERSION < NTDDI_WIN10 - // On WinRT 8.x / pre-Win10, just use the size we were given. - window->w = (int)SDL_floorf(data->coreWindow->Bounds.Width); - window->h = (int)SDL_floorf(data->coreWindow->Bounds.Height); -#else - /* On Windows 10, we occasionally get control over window size. For windowed - mode apps, try this. - */ - bool didSetSize = false; - if ((requestedFlags & SDL_WINDOW_FULLSCREEN) == 0) { - const Windows::Foundation::Size size((float)window->w, (float)window->h); - didSetSize = data->appView->TryResizeView(size); - } - if (!didSetSize) { - /* We either weren't able to set the window size, or a request for - fullscreen was made. Get window-size info from the OS. - */ - window->w = (int)SDL_floorf(data->coreWindow->Bounds.Width); - window->h = (int)SDL_floorf(data->coreWindow->Bounds.Height); - } -#endif - - WINRT_UpdateWindowFlags( - window, - 0xffffffff // Update any window flag(s) that WINRT_UpdateWindow can handle - ); - - // Try detecting if the window is active - bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get()); - if (isWindowActive) { - SDL_SetKeyboardFocus(window); - } - } - - /* Make sure the WinRT app's IFramworkView can post events on - behalf of SDL: - */ - WINRT_GlobalSDLWindow = window; - - // All done! - return true; -} - -void WINRT_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) -{ -#if NTDDI_VERSION >= NTDDI_WIN10 - SDL_WindowData *data = window->internal; - const Windows::Foundation::Size size((float)window->floating.w, (float)window->floating.h); - if (data->appView->TryResizeView(size)) { - SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->floating.w, window->floating.h); - } -#endif -} - -SDL_FullscreenResult WINRT_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) -{ -#if NTDDI_VERSION >= NTDDI_WIN10 - SDL_WindowData *data = window->internal; - bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get()); - if (isWindowActive) { - if (fullscreen) { - if (!data->appView->IsFullScreenMode) { - if (data->appView->TryEnterFullScreenMode()) { - return SDL_FULLSCREEN_SUCCEEDED; - } else { - return SDL_FULLSCREEN_FAILED; - } - } - } else { - if (data->appView->IsFullScreenMode) { - data->appView->ExitFullScreenMode(); - } - } - } -#endif - - return SDL_FULLSCREEN_SUCCEEDED; -} - -void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) -{ - SDL_WindowData *data = window->internal; - - if (WINRT_GlobalSDLWindow == window) { - WINRT_GlobalSDLWindow = NULL; - } - - if (data) { - // Delete the internal window data: - delete data; - data = NULL; - window->internal = NULL; - } -} - -static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(SDL_VideoDevice *_this) -{ - // Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests - const wchar_t *wClassName = L"Windows.System.Display.DisplayRequest"; - HSTRING hClassName; - IActivationFactory *pActivationFactory = NULL; - IInspectable *pDisplayRequestRaw = nullptr; - ABI::Windows::System::Display::IDisplayRequest *pDisplayRequest = nullptr; - HRESULT hr; - - hr = ::WindowsCreateString(wClassName, (UINT32)SDL_wcslen(wClassName), &hClassName); - if (FAILED(hr)) { - goto done; - } - - hr = Windows::Foundation::GetActivationFactory(hClassName, &pActivationFactory); - if (FAILED(hr)) { - goto done; - } - - hr = pActivationFactory->ActivateInstance(&pDisplayRequestRaw); - if (FAILED(hr)) { - goto done; - } - - hr = pDisplayRequestRaw->QueryInterface(SDL_IID_IDisplayRequest, (void **)&pDisplayRequest); - if (FAILED(hr)) { - goto done; - } - -done: - if (pDisplayRequestRaw) { - pDisplayRequestRaw->Release(); - } - if (pActivationFactory) { - pActivationFactory->Release(); - } - if (hClassName) { - ::WindowsDeleteString(hClassName); - } - - return pDisplayRequest; -} - -bool WINRT_SuspendScreenSaver(SDL_VideoDevice *_this) -{ - SDL_VideoData *internal = _this->internal; - if (internal && internal->displayRequest) { - ABI::Windows::System::Display::IDisplayRequest *displayRequest = (ABI::Windows::System::Display::IDisplayRequest *)internal->displayRequest; - if (_this->suspend_screensaver) { - displayRequest->RequestActive(); - } else { - displayRequest->RequestRelease(); - } - } - return true; -} - -#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtvideo_cpp.h b/src/video/winrt/SDL_winrtvideo_cpp.h deleted file mode 100644 index 18fb58d82..000000000 --- a/src/video/winrt/SDL_winrtvideo_cpp.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 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. -*/ - -// Windows includes: -#include -#ifdef __cplusplus_winrt -#include -#endif - -// SDL includes: - -#if NTDDI_VERSION >= NTDDI_WINBLUE /* ApplicationView's functionality only becomes \ - useful for SDL in Win[Phone] 8.1 and up. \ - Plus, it is not available at all in WinPhone 8.0. */ -#define SDL_WINRT_USE_APPLICATIONVIEW 1 -#endif - -extern "C" { -#include "../SDL_sysvideo.h" -#include "../SDL_egl_c.h" -} - -// Private display data -struct SDL_VideoData -{ - /* An object created by ANGLE/WinRT (OpenGL ES 2 for WinRT) that gets - * passed to eglGetDisplay and eglCreateWindowSurface: - */ - IUnknown *winrtEglWindow; - - /* Event token(s), for unregistering WinRT event handler(s). - These are just a struct with a 64-bit integer inside them - */ - Windows::Foundation::EventRegistrationToken gameBarIsInputRedirectedToken; - - /* A WinRT DisplayRequest, used for implementing SDL_*ScreenSaver() functions. - * This is really a pointer to a 'ABI::Windows::System::Display::IDisplayRequest *', - * It's casted to 'IUnknown *', to help with building SDL. - */ - IUnknown *displayRequest; -}; - -/* The global, WinRT, SDL Window. - For now, SDL/WinRT only supports one window (due to platform limitations of - WinRT. -*/ -extern SDL_Window *WINRT_GlobalSDLWindow; - -/* Updates one or more SDL_Window flags, by querying the OS' native windowing APIs. - SDL_Window flags that can be updated should be specified in 'mask'. -*/ -extern void WINRT_UpdateWindowFlags(SDL_Window *window, SDL_WindowFlags mask); -extern "C" SDL_WindowFlags WINRT_DetectWindowFlags(SDL_Window *window); // detects flags w/o applying them - -// Display mode internals -// typedef struct -//{ -// Windows::Graphics::Display::DisplayOrientations currentOrientation; -// } SDL_DisplayModeData; - -#ifdef __cplusplus_winrt - -// A convenience macro to get a WinRT display property -#if NTDDI_VERSION > NTDDI_WIN8 -#define WINRT_DISPLAY_PROPERTY(NAME) (Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->NAME) -#else -#define WINRT_DISPLAY_PROPERTY(NAME) (Windows::Graphics::Display::DisplayProperties::NAME) -#endif - -// Converts DIPS to/from physical pixels -#define WINRT_DIPS_TO_PHYSICAL_PIXELS(DIPS) ((int)(0.5f + (((float)(DIPS) * (float)WINRT_DISPLAY_PROPERTY(LogicalDpi)) / 96.f))) -#define WINRT_PHYSICAL_PIXELS_TO_DIPS(PHYSPIX) (((float)(PHYSPIX)*96.f) / WINRT_DISPLAY_PROPERTY(LogicalDpi)) - -// Internal window data -struct SDL_WindowData -{ - SDL_Window *sdlWindow; - Platform::Agile coreWindow; -#ifdef SDL_VIDEO_OPENGL_EGL - EGLSurface egl_surface; -#endif -#if SDL_WINRT_USE_APPLICATIONVIEW - Windows::UI::ViewManagement::ApplicationView ^ appView; -#endif - WCHAR high_surrogate; -}; - -#endif // ifdef __cplusplus_winrt diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5df28471e..59735410d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,12 +32,6 @@ if(NOT (MSVC AND SDL_CPU_ARM64)) find_package(OpenGL) endif() -if(WINDOWS_STORE) - cmake_minimum_required(VERSION 3.19) - # CMP0112: Target file component generator expressions do not add target dependencies. - cmake_policy(SET CMP0112 NEW) -endif() - set(SDL_TEST_EXECUTABLES) add_library(sdltests_utils OBJECT @@ -49,7 +43,7 @@ file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt) option(SDLTEST_TRACKMEM "Run tests with --trackmem" OFF) -if(WIN32 AND NOT WINDOWS_STORE) +if(WIN32) option(SDLTEST_PROCDUMP "Run tests using sdlprocdump for minidump generation" OFF) add_executable(sdlprocdump win32/sdlprocdump.c) set_property(TARGET sdlprocdump PROPERTY C_STANDARD "90") @@ -107,19 +101,6 @@ define_property(TARGET PROPERTY SDL_NONINTERACTIVE BRIEF_DOCS "If true, target i define_property(TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argument(s) to run executable in non-interactive mode." FULL_DOCS "Argument(s) to run executable in non-interactive mode.") define_property(TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable.") -if(WINDOWS_STORE) - add_library(sdl_test_main_uwp OBJECT main.cpp) - target_link_libraries(sdl_test_main_uwp PRIVATE SDL3::Headers) - target_compile_options(sdl_test_main_uwp PRIVATE "/ZW") - - add_library(sdl_test_main_callbacks_uwp OBJECT main.cpp) - target_link_libraries(sdl_test_main_callbacks_uwp PRIVATE SDL3::Headers) - target_compile_options(sdl_test_main_callbacks_uwp PRIVATE "/ZW") - target_compile_definitions(sdl_test_main_callbacks_uwp PRIVATE "SDL_MAIN_USE_CALLBACKS") - - set_source_files_properties(${RESOURCE_FILES} PROPERTIES VS_DEPLOYENT_LOCATION "Assets") -endif() - macro(add_sdl_test_executable TARGET) cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;THREADS;NO_C90;MAIN_CALLBACKS;NOTRACKMEM" "" "DISABLE_THREADS_ARGS;NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ARGN}) if(AST_UNPARSED_ARGUMENTS) @@ -132,32 +113,6 @@ macro(add_sdl_test_executable TARGET) list(APPEND AST_SOURCES $) endif() set(EXTRA_SOURCES "") - if(WINDOWS_STORE) - set(uwp_bindir "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.dir") - if(NOT IS_DIRECTORY "${uwp_bindir}") - execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${uwp_bindir}") - endif() - string(REGEX REPLACE "[_]" "" SAFE_TARGET "${TARGET}") - file(GENERATE OUTPUT "${uwp_bindir}/${TARGET}.appxmanifest" - INPUT "${CMAKE_CURRENT_SOURCE_DIR}/uwp/Package.appxmanifest.in" - TARGET "${TARGET}" - ) - set_property(SOURCE "${uwp_bindir}/${TARGET}.appxmanifest" PROPERTY VS_DEPLOYMENT_CONTENT 1) - - if(AST_MAIN_CALLBACKS) - list(APPEND EXTRA_SOURCES "$") - else() - list(APPEND EXTRA_SOURCES "$") - endif() - - list(APPEND EXTRA_SOURCES - "${uwp_bindir}/${TARGET}.appxmanifest" - "uwp/logo-50x50.png" - "uwp/square-44x44.png" - "uwp/square-150x150.png" - "uwp/splash-620x300.png" - ) - endif() if(AST_NEEDS_RESOURCES) list(APPEND EXTRA_SOURCES ${RESOURCE_FILES}) endif() @@ -192,16 +147,6 @@ macro(add_sdl_test_executable TARGET) add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E make_directory $/sdl-${TARGET} COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILES} $/sdl-${TARGET}) - elseif(WINDOWS_STORE) - # MSVC does build the dependent targets (or POST_BUILD commands) when building an application - # after starting to debug. By copying the resources in a custom target, the files can be copied afterwards. - # FIXME: find out proper way to add assets to UWP package - cmake_minimum_required(VERSION 3.19) - add_custom_target(zzz-resources-copy-${TARGET} - COMMAND ${CMAKE_COMMAND} -E make_directory "$/AppX" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RESOURCE_FILES} "$/AppX" - ) - add_dependencies(${TARGET} zzz-resources-copy-${TARGET}) else() add_dependencies(${TARGET} copy-sdl-test-resources) endif() @@ -233,20 +178,7 @@ macro(add_sdl_test_executable TARGET) endif() elseif(PSP) target_link_libraries(${TARGET} PRIVATE GL) - endif() - if(WINDOWS_STORE) - target_compile_definitions(${TARGET} PRIVATE "SDL_MAIN_NOIMPL") - set_property(TARGET ${TARGET} PROPERTY WIN32_EXECUTABLE TRUE) - set_property(TARGET ${TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${uwp_bindir}") - target_link_options(${TARGET} PRIVATE - -nodefaultlib:vccorlib$<$:d> - -nodefaultlib:msvcrt$<$:d> - vccorlib$<$:d>.lib - msvcrt$<$:d>.lib - ) - endif() - - if(EMSCRIPTEN) + elseif(EMSCRIPTEN) set_property(TARGET ${TARGET} PROPERTY SUFFIX ".html") target_link_options(${TARGET} PRIVATE "SHELL:--pre-js ${CMAKE_CURRENT_SOURCE_DIR}/emscripten/pre.js") target_link_options(${TARGET} PRIVATE "-sEXIT_RUNTIME=1") diff --git a/test/uwp/Package.appxmanifest.in b/test/uwp/Package.appxmanifest.in deleted file mode 100644 index 8a5d43714..000000000 --- a/test/uwp/Package.appxmanifest.in +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - $ - libsdl.org - logo-50x50.png - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/uwp/logo-50x50.png b/test/uwp/logo-50x50.png deleted file mode 100644 index e7903b79f..000000000 Binary files a/test/uwp/logo-50x50.png and /dev/null differ diff --git a/test/uwp/splash-620x300.png b/test/uwp/splash-620x300.png deleted file mode 100644 index 0dde7737d..000000000 Binary files a/test/uwp/splash-620x300.png and /dev/null differ diff --git a/test/uwp/square-150x150.png b/test/uwp/square-150x150.png deleted file mode 100644 index 0931f4c85..000000000 Binary files a/test/uwp/square-150x150.png and /dev/null differ diff --git a/test/uwp/square-44x44.png b/test/uwp/square-44x44.png deleted file mode 100644 index f0bdcd224..000000000 Binary files a/test/uwp/square-44x44.png and /dev/null differ