diff --git a/.gitmodules b/.gitmodules index 01e2ced8b6..d27084a9a6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,8 @@ url = https://github.com/KhronosGroup/SPIRV-Cross.git branch = master shallow = true +[submodule "SDL"] + path = Externals/SDL/SDL + url = https://github.com/libsdl-org/SDL.git + branch = main + shallow = true diff --git a/CMakeLists.txt b/CMakeLists.txt index ae835b0f39..e3602d8bc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,8 @@ option(OPROFILING "Enable profiling" OFF) # TODO: Add DSPSpy option(DSPTOOL "Build dsptool" OFF) -# Enable SDL for default on operating systems that aren't Android, Linux or Windows. -if(NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT MSVC) +# Enable SDL for default on operating systems that aren't Android or Linux. +if(NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") option(ENABLE_SDL "Enables SDL as a generic controller backend" ON) else() option(ENABLE_SDL "Enables SDL as a generic controller backend" OFF) @@ -612,6 +612,23 @@ if(UNIX) add_definitions(-DUSE_MEMORYWATCHER=1) endif() +if(ENABLE_SDL) + find_package(SDL2) + + if(SDL2_FOUND) + message(STATUS "Using system SDL2") + else() + message(STATUS "Using static SDL2 from Externals") + set(SDL_SHARED OFF) + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) + set(SDL_STATIC ON) + set(SDL_STATIC_ENABLED_BY_DEFAULT ON) + add_subdirectory(Externals/SDL/SDL) + set(SDL2_FOUND TRUE) + endif() + add_definitions(-DHAVE_SDL2=1) +endif() + if(ENABLE_ANALYTICS) message(STATUS "Enabling analytics collection (subject to end-user opt-in)") add_definitions(-DUSE_ANALYTICS=1) diff --git a/Externals/ExternalsReferenceAll.props b/Externals/ExternalsReferenceAll.props index f3a19282e4..2566a4a4a0 100644 --- a/Externals/ExternalsReferenceAll.props +++ b/Externals/ExternalsReferenceAll.props @@ -94,5 +94,8 @@ {1bea10f3-80ce-4bc4-9331-5769372cdf99} + + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA} + diff --git a/Externals/SDL/SDL b/Externals/SDL/SDL new file mode 160000 index 0000000000..cd2dcf54af --- /dev/null +++ b/Externals/SDL/SDL @@ -0,0 +1 @@ +Subproject commit cd2dcf54afaa6d640abf8b83855f6c4b5cda457d diff --git a/Externals/SDL/SDL2.vcxproj b/Externals/SDL/SDL2.vcxproj new file mode 100644 index 0000000000..ebc599029a --- /dev/null +++ b/Externals/SDL/SDL2.vcxproj @@ -0,0 +1,412 @@ + + + + + + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA} + + + + + + + + + + + + + + SDL\include;%(AdditionalIncludeDirectories) + HAVE_LIBC=1;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 8cb5919edf..2e7e546c78 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -493,6 +493,7 @@ + @@ -1104,6 +1105,7 @@ + diff --git a/Source/Core/InputCommon/CMakeLists.txt b/Source/Core/InputCommon/CMakeLists.txt index 06f959a91a..9cca78b65d 100644 --- a/Source/Core/InputCommon/CMakeLists.txt +++ b/Source/Core/InputCommon/CMakeLists.txt @@ -174,32 +174,12 @@ if(UNIX) ) endif() -if(ENABLE_SDL) - find_package(SDL2) - if(SDL2_FOUND) - message(STATUS "Using shared SDL2") - set(SDL_TARGET SDL2::SDL2) - else() - # SDL2 not found, try SDL - find_package(SDL) - if(SDL_FOUND) - message(STATUS "Using shared SDL") - add_library(System_SDL INTERFACE) - target_include_directories(System_SDL INTERFACE ${SDL_INCLUDE_DIR}) - target_link_libraries(System_SDL INTERFACE ${SDL_LIBRARY}) - set(SDL_TARGET System_SDL) - endif() - endif() - if(SDL_TARGET AND TARGET ${SDL_TARGET}) - target_sources(inputcommon PRIVATE - ControllerInterface/SDL/SDL.cpp - ControllerInterface/SDL/SDL.h - ) - target_link_libraries(inputcommon PRIVATE ${SDL_TARGET}) - target_compile_definitions(inputcommon PRIVATE "CIFACE_USE_SDL=1") - else() - message(STATUS "SDL NOT found, disabling SDL input") - endif() +if(SDL2_FOUND) + target_sources(inputcommon PRIVATE + ControllerInterface/SDL/SDL.cpp + ControllerInterface/SDL/SDL.h + ) + target_link_libraries(inputcommon PRIVATE SDL2::SDL2) endif() if(MSVC) diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index 7a5ee0ad26..2f43cacc42 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -30,6 +30,9 @@ #define CIFACE_USE_PIPES #endif #define CIFACE_USE_DUALSHOCKUDPCLIENT +#if defined(HAVE_SDL2) +#define CIFACE_USE_SDL +#endif namespace ciface { diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index 49f546d39f..ae821339cc 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -52,6 +52,7 @@ $(ExternalsDir)picojson;%(AdditionalIncludeDirectories) $(ExternalsDir)pugixml;%(AdditionalIncludeDirectories) $(ExternalsDir)rangeset\include;%(AdditionalIncludeDirectories) + $(ExternalsDir)SDL\SDL\include;%(AdditionalIncludeDirectories) $(ExternalsDir)SFML\include;%(AdditionalIncludeDirectories) $(ExternalsDir)soundtouch;%(AdditionalIncludeDirectories) $(ExternalsDir)Vulkan\include;%(AdditionalIncludeDirectories) @@ -91,6 +92,7 @@ HAS_LIBMGBA;%(PreprocessorDefinitions) AUTOUPDATE=1;%(PreprocessorDefinitions) SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS;%(PreprocessorDefinitions) + HAVE_SDL2=1;%(PreprocessorDefinitions) diff --git a/Source/dolphin-emu.sln b/Source/dolphin-emu.sln index 89df520d9b..b289f27548 100644 --- a/Source/dolphin-emu.sln +++ b/Source/dolphin-emu.sln @@ -81,6 +81,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmt", "..\Externals\fmt\fmt EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spirv_cross", "..\Externals\spirv_cross\spirv_cross.vcxproj", "{3d780617-ec8c-4721-b9fd-dfc9bb658c7c}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "..\Externals\SDL\SDL2.vcxproj", "{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -389,6 +391,14 @@ Global {3D780617-EC8C-4721-B9FD-DFC9BB658C7C}.Release|ARM64.Build.0 = Release|ARM64 {3D780617-EC8C-4721-B9FD-DFC9BB658C7C}.Release|x64.ActiveCfg = Release|x64 {3D780617-EC8C-4721-B9FD-DFC9BB658C7C}.Release|x64.Build.0 = Release|x64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Debug|ARM64.Build.0 = Debug|ARM64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Debug|x64.ActiveCfg = Debug|x64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Debug|x64.Build.0 = Debug|x64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|ARM64.ActiveCfg = Release|ARM64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|ARM64.Build.0 = Release|ARM64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|x64.ActiveCfg = Release|x64 + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -422,6 +432,7 @@ Global {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} {4BC5A148-0AB3-440F-A980-A29B4B999190} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} {3D780617-EC8C-4721-B9FD-DFC9BB658C7C} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} + {8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {64B0A343-3B94-4522-9C24-6937FE5EFB22}