Build: Clean up optional components

This commit is contained in:
Stenzek 2023-08-26 14:37:56 +10:00 committed by Connor McLaughlin
parent dfa6165662
commit a9b6f8976e
18 changed files with 62 additions and 232 deletions

View File

@ -50,14 +50,11 @@ add_subdirectory(common)
# make pcsx2 # make pcsx2
add_subdirectory(pcsx2) add_subdirectory(pcsx2)
add_subdirectory(pcsx2-qt)
if (QT_BUILD) # Updater is Windows only for now.
add_subdirectory(pcsx2-qt) if (WIN32)
add_subdirectory(updater)
# Updater is Windows only for now.
if (WIN32)
add_subdirectory(updater)
endif()
endif() endif()
# tests # tests

View File

@ -6,10 +6,6 @@ set(PCSX2_DEFS "")
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
option(DISABLE_BUILD_DATE "Disable including the binary compile date") option(DISABLE_BUILD_DATE "Disable including the binary compile date")
option(ENABLE_TESTS "Enables building the unit tests" ON) option(ENABLE_TESTS "Enables building the unit tests" ON)
set(USE_SYSTEM_LIBS "AUTO" CACHE STRING "Use system libraries instead of bundled libraries. ON - Always use system and fail if unavailable, OFF - Always use bundled, AUTO - Use system if available, otherwise use bundled. Default is AUTO")
set(DEFAULT_USE_SYSTEM_RYML OFF) # System rapidyaml causes a lot of problems
optional_system_library(fmt)
optional_system_library(ryml)
option(LTO_PCSX2_CORE "Enable LTO/IPO/LTCG on the subset of pcsx2 that benefits most from it but not anything else") option(LTO_PCSX2_CORE "Enable LTO/IPO/LTCG on the subset of pcsx2 that benefits most from it but not anything else")
option(USE_VTUNE "Plug VTUNE to profile GS JIT.") option(USE_VTUNE "Plug VTUNE to profile GS JIT.")
option(USE_ACHIEVEMENTS "Build with RetroAchievements support" ON) option(USE_ACHIEVEMENTS "Build with RetroAchievements support" ON)
@ -24,9 +20,6 @@ option(USE_VULKAN "Enable Vulkan GS renderer" ON)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Path and lib option # Path and lib option
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
option(CUBEB_API "Build Cubeb support on SPU2" ON)
option(QT_BUILD "Build Qt frontend" ON)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
option(ENABLE_SETCAP "Enable networking capability for DEV9" OFF) option(ENABLE_SETCAP "Enable networking capability for DEV9" OFF)
option(USE_LEGACY_USER_DIRECTORY "Use legacy home/PCSX2 user directory instead of XDG standard" OFF) option(USE_LEGACY_USER_DIRECTORY "Use legacy home/PCSX2 user directory instead of XDG standard" OFF)

View File

@ -197,49 +197,6 @@ function(source_groups_from_vcxproj_filters file)
endforeach() endforeach()
endfunction() endfunction()
function(optional_system_library library)
string(TOUPPER ${library} upperlib)
if (DEFINED DEFAULT_USE_SYSTEM_${upperlib})
set(extra " with extra override to ${DEFAULT_USE_SYSTEM_${upperlib}} on fully default builds")
else()
set(extra)
endif()
set(USE_SYSTEM_${upperlib} "" CACHE STRING "Use system ${library} instead of bundled. ON - Always use system and fail if unavailable, OFF - Always use bundled, AUTO - Use system if available, otherwise use bundled, blank - Delegate to USE_SYSTEM_LIBS${extra}. Default is blank.")
if ("${USE_SYSTEM_${upperlib}}" STREQUAL "")
if(${USE_SYSTEM_LIBS} STREQUAL "AUTO" AND DEFINED DEFAULT_USE_SYSTEM_${upperlib})
set(RESOLVED_USE_SYSTEM_${upperlib} ${DEFAULT_USE_SYSTEM_${upperlib}} PARENT_SCOPE)
else()
set(RESOLVED_USE_SYSTEM_${upperlib} ${USE_SYSTEM_LIBS} PARENT_SCOPE)
endif()
else()
set(RESOLVED_USE_SYSTEM_${upperlib} ${USE_SYSTEM_${upperlib}} PARENT_SCOPE)
endif()
endfunction()
function(find_optional_system_library library bundled_path)
string(TOUPPER ${library} upperlib)
if (RESOLVED_USE_SYSTEM_${upperlib})
find_package(${library} ${ARGN} QUIET)
if ((NOT ${library}_FOUND) AND (NOT ${RESOLVED_USE_SYSTEM_${upperlib}} STREQUAL "AUTO"))
find_package(${library} ${ARGN}) # For the message
message(FATAL_ERROR "No system ${library} was found. Please install it or set USE_SYSTEM_${upperlib} to AUTO.")
endif()
endif()
if (${library}_FOUND)
message("Found ${library}: ${${library}_VERSION}")
set(${library}_TYPE "System" PARENT_SCOPE)
else()
if (${RESOLVED_USE_SYSTEM_${upperlib}} STREQUAL "AUTO")
message("No system ${library} was found. Using bundled.")
endif()
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${bundled_path}/CMakeLists.txt")
message(FATAL_ERROR "No bundled ${library} was found. Did you forget to checkout submodules?")
endif()
add_subdirectory(${bundled_path} EXCLUDE_FROM_ALL)
set(${library}_TYPE "Bundled" PARENT_SCOPE)
endif()
endfunction()
function(fixup_file_properties target) function(fixup_file_properties target)
get_target_property(SOURCES ${target} SOURCES) get_target_property(SOURCES ${target} SOURCES)
if(APPLE) if(APPLE)

View File

@ -35,6 +35,7 @@ else()
set(FIND_FRAMEWORK_BACKUP ${CMAKE_FIND_FRAMEWORK}) set(FIND_FRAMEWORK_BACKUP ${CMAKE_FIND_FRAMEWORK})
set(CMAKE_FIND_FRAMEWORK NEVER) set(CMAKE_FIND_FRAMEWORK NEVER)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
find_package(CURL REQUIRED)
set(CMAKE_FIND_FRAMEWORK ${FIND_FRAMEWORK_BACKUP}) set(CMAKE_FIND_FRAMEWORK ${FIND_FRAMEWORK_BACKUP})
find_package(Vtune) find_package(Vtune)
@ -115,48 +116,8 @@ if(GCC_VERSION VERSION_GREATER_EQUAL "9.0" AND GCC_VERSION VERSION_LESS "9.2")
This text being in a compile log in an open issue may cause it to be closed.") This text being in a compile log in an open issue may cause it to be closed.")
endif() endif()
find_optional_system_library(fmt 3rdparty/fmt/fmt 7.1.3) add_subdirectory(3rdparty/fmt/fmt EXCLUDE_FROM_ALL)
find_optional_system_library(ryml 3rdparty/rapidyaml/rapidyaml 0.4.0) add_subdirectory(3rdparty/rapidyaml/rapidyaml EXCLUDE_FROM_ALL)
if(QT_BUILD)
# Default to bundled Qt6 for Windows.
if(WIN32 AND NOT DEFINED Qt6_DIR)
set(Qt6_DIR ${CMAKE_SOURCE_DIR}/3rdparty/qt/6.5.0/msvc2022_64/lib/cmake/Qt6)
endif()
# Find the Qt components that we need.
find_package(Qt6 COMPONENTS CoreTools Core GuiTools Gui WidgetsTools Widgets Network LinguistTools REQUIRED)
if (APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET AND "${CMAKE_OSX_DEPLOYMENT_TARGET}" VERSION_LESS 10.15)
get_target_property(QT_FEATURES Qt6::Core QT_ENABLED_PUBLIC_FEATURES)
if (cxx17_filesystem IN_LIST QT_FEATURES)
message("Qt compiled with std::filesystem support, requires macOS 10.15")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
endif()
endif()
# rcheevos backend for RetroAchievements.
if(USE_ACHIEVEMENTS)
add_subdirectory(3rdparty/rcheevos EXCLUDE_FROM_ALL)
if(WIN32)
add_subdirectory(3rdparty/rainterface EXCLUDE_FROM_ALL)
endif()
endif()
# Discord-RPC library for rich presence.
if(USE_DISCORD_PRESENCE)
add_subdirectory(3rdparty/rapidjson EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/discord-rpc EXCLUDE_FROM_ALL)
endif()
# Demangler for the debugger
add_subdirectory(3rdparty/demangler EXCLUDE_FROM_ALL)
endif()
if(NOT WIN32 AND QT_BUILD)
find_package(CURL REQUIRED)
endif()
add_subdirectory(3rdparty/lzma EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/lzma EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/libchdr EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/libchdr EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/soundtouch EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/soundtouch EXCLUDE_FROM_ALL)
@ -187,12 +148,38 @@ if(USE_VULKAN)
add_subdirectory(3rdparty/vulkan-headers EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/vulkan-headers EXCLUDE_FROM_ALL)
endif() endif()
if(CUBEB_API) add_subdirectory(3rdparty/cubeb EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/cubeb EXCLUDE_FROM_ALL) disable_compiler_warnings_for_target(cubeb)
disable_compiler_warnings_for_target(cubeb) disable_compiler_warnings_for_target(speex)
disable_compiler_warnings_for_target(speex)
# Find the Qt components that we need.
find_package(Qt6 COMPONENTS CoreTools Core GuiTools Gui WidgetsTools Widgets Network LinguistTools REQUIRED)
if (APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET AND "${CMAKE_OSX_DEPLOYMENT_TARGET}" VERSION_LESS 10.15)
get_target_property(QT_FEATURES Qt6::Core QT_ENABLED_PUBLIC_FEATURES)
if (cxx17_filesystem IN_LIST QT_FEATURES)
message("Qt compiled with std::filesystem support, requires macOS 10.15")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
endif()
endif() endif()
# rcheevos backend for RetroAchievements.
if(USE_ACHIEVEMENTS)
add_subdirectory(3rdparty/rcheevos EXCLUDE_FROM_ALL)
if(WIN32)
add_subdirectory(3rdparty/rainterface EXCLUDE_FROM_ALL)
endif()
endif()
# Discord-RPC library for rich presence.
if(USE_DISCORD_PRESENCE)
add_subdirectory(3rdparty/rapidjson EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/discord-rpc EXCLUDE_FROM_ALL)
endif()
# Demangler for the debugger
add_subdirectory(3rdparty/demangler EXCLUDE_FROM_ALL)
# Deliberately at the end. We don't want to set the flag on third-party projects. # Deliberately at the end. We don't want to set the flag on third-party projects.
if(MSVC) if(MSVC)
# Don't warn about "deprecated" POSIX functions. # Don't warn about "deprecated" POSIX functions.

View File

@ -179,7 +179,7 @@ if (USE_GCC AND CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set_source_files_properties(FastJmp.cpp PROPERTIES COMPILE_FLAGS -fno-lto) set_source_files_properties(FastJmp.cpp PROPERTIES COMPILE_FLAGS -fno-lto)
endif() endif()
if(NOT WIN32 AND (QT_BUILD OR NOGUI_BUILD)) if(NOT WIN32)
# libcurl-based HTTPDownloader # libcurl-based HTTPDownloader
target_sources(common PRIVATE target_sources(common PRIVATE
HTTPDownloaderCurl.cpp HTTPDownloaderCurl.cpp

View File

@ -22,10 +22,7 @@
#include "SettingWidgetBinder.h" #include "SettingWidgetBinder.h"
#include "pcsx2/Input/InputManager.h" #include "pcsx2/Input/InputManager.h"
#ifdef SDL_BUILD
#include "pcsx2/Input/SDLInputSource.h" #include "pcsx2/Input/SDLInputSource.h"
#endif
ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent, ControllerSettingsDialog* dialog) ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent, ControllerSettingsDialog* dialog)
: QWidget(parent) : QWidget(parent)
@ -35,17 +32,12 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
SettingsInterface* sif = dialog->getProfileSettingsInterface(); SettingsInterface* sif = dialog->getProfileSettingsInterface();
#ifdef SDL_BUILD
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false);
connect(m_ui.enableSDLSource, &QCheckBox::stateChanged, this, &ControllerGlobalSettingsWidget::updateSDLOptionsEnabled); connect(m_ui.enableSDLSource, &QCheckBox::stateChanged, this, &ControllerGlobalSettingsWidget::updateSDLOptionsEnabled);
connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked); connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked);
#else
m_ui.enableSDLSource->setEnabled(false);
m_ui.ledSettings->setEnabled(false);
#endif
#if defined(SDL_BUILD) && defined(_WIN32) #ifdef _WIN32
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLRawInput, "InputSources", "SDLRawInput", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLRawInput, "InputSources", "SDLRawInput", false);
#else #else
m_ui.gridLayout_2->removeWidget(m_ui.enableSDLRawInput); m_ui.gridLayout_2->removeWidget(m_ui.enableSDLRawInput);
@ -157,7 +149,6 @@ ControllerLEDSettingsDialog::~ControllerLEDSettingsDialog() = default;
void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 player_id) void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 player_id)
{ {
#ifdef SDL_BUILD
std::string key(fmt::format("Player{}LED", player_id)); std::string key(fmt::format("Player{}LED", player_id));
const u32 current_value = SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id); const u32 current_value = SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id);
button->setColor(current_value); button->setColor(current_value);
@ -165,7 +156,6 @@ void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 play
connect(button, &ColorPickerButton::colorChanged, this, [this, key = std::move(key)](u32 new_rgb) { connect(button, &ColorPickerButton::colorChanged, this, [this, key = std::move(key)](u32 new_rgb) {
m_dialog->setStringValue("SDLExtra", key.c_str(), fmt::format("{:06X}", new_rgb).c_str()); m_dialog->setStringValue("SDLExtra", key.c_str(), fmt::format("{:06X}", new_rgb).c_str());
}); });
#endif
} }
ControllerMouseSettingsDialog::ControllerMouseSettingsDialog(QWidget* parent, ControllerSettingsDialog* dialog) ControllerMouseSettingsDialog::ControllerMouseSettingsDialog(QWidget* parent, ControllerSettingsDialog* dialog)

View File

@ -49,7 +49,7 @@
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(ProjectDir)\Settings;$(ProjectDir)\GameList;$(ProjectDir)\Tools\InputRecording;$(ProjectDir)\Debugger;$(ProjectDir)\Debugger\Models</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(ProjectDir)\Settings;$(ProjectDir)\GameList;$(ProjectDir)\Tools\InputRecording;$(ProjectDir)\Debugger;$(ProjectDir)\Debugger\Models</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>PrecompiledHeader.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>PrecompiledHeader.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>LZMA_API_STATIC;BUILD_DX=1;ENABLE_RAINTEGRATION;ENABLE_ACHIEVEMENTS;ENABLE_DISCORD_PRESENCE;ENABLE_OPENGL;ENABLE_VULKAN;SDL_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LZMA_API_STATIC;BUILD_DX=1;ENABLE_RAINTEGRATION;ENABLE_ACHIEVEMENTS;ENABLE_DISCORD_PRESENCE;ENABLE_OPENGL;ENABLE_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>QT_NO_EXCEPTIONS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>QT_NO_EXCEPTIONS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!-- Current Qt debug builds assert on RTTI. Remove this once we next build Qt. --> <!-- Current Qt debug builds assert on RTTI. Remove this once we next build Qt. -->
<RuntimeTypeInfo Condition="$(Configuration.Contains(Clang)) And $(Configuration.Contains(Debug))">true</RuntimeTypeInfo> <RuntimeTypeInfo Condition="$(Configuration.Contains(Clang)) And $(Configuration.Contains(Debug))">true</RuntimeTypeInfo>

View File

@ -56,15 +56,6 @@ if(USE_LINKED_FFMPEG)
target_link_libraries(PCSX2_FLAGS INTERFACE FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil FFMPEG::swscale FFMPEG::swresample) target_link_libraries(PCSX2_FLAGS INTERFACE FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil FFMPEG::swscale FFMPEG::swresample)
endif() endif()
if(TARGET SDL2::SDL2)
target_compile_definitions(PCSX2_FLAGS INTERFACE SDL_BUILD)
target_link_libraries(PCSX2_FLAGS INTERFACE SDL2::SDL2)
target_sources(PCSX2 PRIVATE
Input/SDLInputSource.cpp
Input/SDLInputSource.h
)
endif()
if(WIN32) if(WIN32)
set(MIN_WIN32 0x0A00) set(MIN_WIN32 0x0A00)
target_compile_definitions(PCSX2_FLAGS INTERFACE target_compile_definitions(PCSX2_FLAGS INTERFACE
@ -289,6 +280,7 @@ set(pcsx2SPU2Sources
SPU2/RegTable.cpp SPU2/RegTable.cpp
SPU2/Reverb.cpp SPU2/Reverb.cpp
SPU2/SndOut.cpp SPU2/SndOut.cpp
SPU2/SndOut_Cubeb.cpp
SPU2/spu2freeze.cpp SPU2/spu2freeze.cpp
SPU2/spu2sys.cpp SPU2/spu2sys.cpp
SPU2/Wavedump_wav.cpp SPU2/Wavedump_wav.cpp
@ -308,12 +300,6 @@ set(pcsx2SPU2Headers
SPU2/spdif.h SPU2/spdif.h
) )
if(CUBEB_API)
list(APPEND pcsx2SPU2Sources SPU2/SndOut_Cubeb.cpp)
target_compile_definitions(PCSX2_FLAGS INTERFACE "SPU2X_CUBEB")
target_link_libraries(PCSX2_FLAGS INTERFACE cubeb)
endif()
if(WIN32) if(WIN32)
list(APPEND pcsx2SPU2Sources list(APPEND pcsx2SPU2Sources
SPU2/SndOut_XAudio2.cpp SPU2/SndOut_XAudio2.cpp
@ -424,12 +410,14 @@ set(pcsx2USBSources
USB/usb-eyetoy/usb-eyetoy-webcam.cpp USB/usb-eyetoy/usb-eyetoy-webcam.cpp
USB/usb-hid/usb-hid.cpp USB/usb-hid/usb-hid.cpp
USB/usb-lightgun/guncon2.cpp USB/usb-lightgun/guncon2.cpp
USB/usb-mic/audiodev-cubeb.cpp
USB/usb-mic/usb-headset.cpp USB/usb-mic/usb-headset.cpp
USB/usb-mic/usb-mic-logitech.cpp USB/usb-mic/usb-mic-logitech.cpp
USB/usb-mic/usb-mic-singstar.cpp USB/usb-mic/usb-mic-singstar.cpp
USB/usb-msd/usb-msd.cpp USB/usb-msd/usb-msd.cpp
USB/usb-pad/lg/lg_ff.cpp USB/usb-pad/lg/lg_ff.cpp
USB/usb-pad/usb-pad-ff.cpp USB/usb-pad/usb-pad-ff.cpp
USB/usb-pad/usb-pad-sdl-ff.cpp
USB/usb-pad/usb-pad.cpp USB/usb-pad/usb-pad.cpp
USB/usb-pad/usb-seamic.cpp USB/usb-pad/usb-seamic.cpp
USB/usb-pad/usb-turntable.cpp USB/usb-pad/usb-turntable.cpp
@ -454,27 +442,18 @@ set(pcsx2USBHeaders
USB/usb-hid/usb-hid.h USB/usb-hid/usb-hid.h
USB/usb-lightgun/guncon2.h USB/usb-lightgun/guncon2.h
USB/usb-mic/audio.h USB/usb-mic/audio.h
USB/usb-mic/audiodev-cubeb.h
USB/usb-mic/audiodev-noop.h USB/usb-mic/audiodev-noop.h
USB/usb-mic/audiodev.h USB/usb-mic/audiodev.h
USB/usb-mic/usb-headset.h USB/usb-mic/usb-headset.h
USB/usb-mic/usb-mic-singstar.h USB/usb-mic/usb-mic-singstar.h
USB/usb-msd/usb-msd.h USB/usb-msd/usb-msd.h
USB/usb-pad/lg/lg_ff.h USB/usb-pad/lg/lg_ff.h
USB/usb-pad/usb-pad-sdl-ff.h
USB/usb-pad/usb-pad.h USB/usb-pad/usb-pad.h
USB/usb-printer/usb-printer.h USB/usb-printer/usb-printer.h
) )
if(CUBEB_API)
list(APPEND pcsx2USBSources USB/usb-mic/audiodev-cubeb.cpp)
list(APPEND pcsx2USBHeaders USB/usb-mic/audiodev-cubeb.h)
endif()
if(TARGET SDL2::SDL2)
list(APPEND pcsx2USBSources USB/usb-pad/usb-pad-sdl-ff.cpp)
list(APPEND pcsx2USBHeaders USB/usb-pad/usb-pad-sdl-ff.h)
endif()
# Host PAD # Host PAD
set(pcsx2PADSources set(pcsx2PADSources
SIO/Pad/Pad.cpp SIO/Pad/Pad.cpp
@ -859,10 +838,12 @@ set(pcsx2ImGuiHeaders
set(pcsx2InputSources set(pcsx2InputSources
Input/InputManager.cpp Input/InputManager.cpp
Input/InputSource.cpp Input/InputSource.cpp
Input/SDLInputSource.cpp
) )
set(pcsx2InputHeaders set(pcsx2InputHeaders
Input/InputManager.h Input/InputManager.h
Input/InputSource.h Input/InputSource.h
Input/SDLInputSource.h
) )
if(APPLE) if(APPLE)
@ -1171,6 +1152,8 @@ target_link_libraries(PCSX2_FLAGS INTERFACE
libzip::zip libzip::zip
cpuinfo cpuinfo
zydis zydis
cubeb
SDL2::SDL2
ZLIB::ZLIB ZLIB::ZLIB
SoundTouch::SoundTouch SoundTouch::SoundTouch
PNG::PNG PNG::PNG

View File

@ -3401,29 +3401,19 @@ void FullscreenUI::DrawAudioSettingsPage()
}; };
static constexpr const char* output_entries[] = { static constexpr const char* output_entries[] = {
"No Sound (Emulate SPU2 only)", "No Sound (Emulate SPU2 only)",
#ifdef SPU2X_CUBEB
"Cubeb (Cross-platform)", "Cubeb (Cross-platform)",
#endif
#ifdef _WIN32 #ifdef _WIN32
"XAudio2", "XAudio2",
#endif #endif
}; };
static constexpr const char* output_values[] = { static constexpr const char* output_values[] = {
"nullout", "nullout",
#ifdef SPU2X_CUBEB
"cubeb", "cubeb",
#endif
#ifdef _WIN32 #ifdef _WIN32
"xaudio2", "xaudio2",
#endif #endif
}; };
#if defined(SPU2X_CUBEB)
static constexpr const char* default_output_module = "cubeb"; static constexpr const char* default_output_module = "cubeb";
#elif defined(_WIN32)
static constexpr const char* default_output_module = "xaudio2";
#else
static constexpr const char* default_output_module = "nullout";
#endif
SettingsInterface* bsi = GetEditingSettingsInterface(); SettingsInterface* bsi = GetEditingSettingsInterface();
@ -3802,18 +3792,14 @@ void FullscreenUI::DrawControllerSettingsPage()
MenuHeading("Input Sources"); MenuHeading("Input Sources");
#ifdef SDL_BUILD
DrawToggleSetting(bsi, ICON_FA_COG " Enable SDL Input Source", "The SDL input source supports most controllers.", "InputSources", "SDL", DrawToggleSetting(bsi, ICON_FA_COG " Enable SDL Input Source", "The SDL input source supports most controllers.", "InputSources", "SDL",
true, true, false); true, true, false);
DrawToggleSetting(bsi, ICON_FA_WIFI " SDL DualShock 4 / DualSense Enhanced Mode", DrawToggleSetting(bsi, ICON_FA_WIFI " SDL DualShock 4 / DualSense Enhanced Mode",
"Provides vibration and LED control support over Bluetooth.", "InputSources", "SDLControllerEnhancedMode", false, "Provides vibration and LED control support over Bluetooth.", "InputSources", "SDLControllerEnhancedMode", false,
bsi->GetBoolValue("InputSources", "SDL", true), false); bsi->GetBoolValue("InputSources", "SDL", true), false);
#endif #ifdef _WIN32
#if defined(SDL_BUILD) && defined(_WIN32)
DrawToggleSetting(bsi, ICON_FA_COG " SDL Raw Input", "Allow SDL to use raw access to input devices.", "InputSources", "SDLRawInput", DrawToggleSetting(bsi, ICON_FA_COG " SDL Raw Input", "Allow SDL to use raw access to input devices.", "InputSources", "SDLRawInput",
false, bsi->GetBoolValue("InputSources", "SDL", true), false); false, bsi->GetBoolValue("InputSources", "SDL", true), false);
#endif
#ifdef _WIN32
DrawToggleSetting(bsi, ICON_FA_COG " Enable XInput Input Source", DrawToggleSetting(bsi, ICON_FA_COG " Enable XInput Input Source",
"The XInput source provides support for XBox 360/XBox One/XBox Series controllers.", "InputSources", "XInput", false, true, false); "The XInput source provides support for XBox 360/XBox One/XBox Series controllers.", "InputSources", "XInput", false, true, false);
#endif #endif

View File

@ -444,13 +444,11 @@ InputBindingKey InputManager::MakePointerAxisKey(u32 index, InputPointerAxis axi
static std::array<const char*, static_cast<u32>(InputSourceType::Count)> s_input_class_names = {{ static std::array<const char*, static_cast<u32>(InputSourceType::Count)> s_input_class_names = {{
"Keyboard", "Keyboard",
"Mouse", "Mouse",
"SDL",
#ifdef _WIN32 #ifdef _WIN32
"DInput", "DInput",
"XInput", "XInput",
#endif #endif
#ifdef SDL_BUILD
"SDL",
#endif
}}; }};
InputSource* InputManager::GetInputSourceInterface(InputSourceType type) InputSource* InputManager::GetInputSourceInterface(InputSourceType type)
@ -469,6 +467,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
{ {
case InputSourceType::Keyboard: case InputSourceType::Keyboard:
case InputSourceType::Pointer: case InputSourceType::Pointer:
case InputSourceType::SDL:
return true; return true;
#ifdef _WIN32 #ifdef _WIN32
@ -476,17 +475,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
return false; return false;
case InputSourceType::XInput: case InputSourceType::XInput:
// Disable xinput by default if we have SDL.
#ifdef SDL_BUILD
return false; return false;
#else
return true;
#endif
#endif
#ifdef SDL_BUILD
case InputSourceType::SDL:
return true;
#endif #endif
default: default:
@ -1521,22 +1510,18 @@ void InputManager::UpdateInputSourceState(SettingsInterface& si, std::unique_loc
} }
} }
#include "Input/SDLInputSource.h"
#ifdef _WIN32 #ifdef _WIN32
#include "Input/DInputSource.h" #include "Input/DInputSource.h"
#include "Input/XInputSource.h" #include "Input/XInputSource.h"
#endif #endif
#ifdef SDL_BUILD
#include "Input/SDLInputSource.h"
#endif
void InputManager::ReloadSources(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock) void InputManager::ReloadSources(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock)
{ {
UpdateInputSourceState<SDLInputSource>(si, settings_lock, InputSourceType::SDL);
#ifdef _WIN32 #ifdef _WIN32
UpdateInputSourceState<DInputSource>(si, settings_lock, InputSourceType::DInput); UpdateInputSourceState<DInputSource>(si, settings_lock, InputSourceType::DInput);
UpdateInputSourceState<XInputSource>(si, settings_lock, InputSourceType::XInput); UpdateInputSourceState<XInputSource>(si, settings_lock, InputSourceType::XInput);
#endif #endif
#ifdef SDL_BUILD
UpdateInputSourceState<SDLInputSource>(si, settings_lock, InputSourceType::SDL);
#endif
} }

View File

@ -33,12 +33,10 @@ enum class InputSourceType : u32
{ {
Keyboard, Keyboard,
Pointer, Pointer,
SDL,
#ifdef _WIN32 #ifdef _WIN32
DInput, DInput,
XInput, XInput,
#endif
#ifdef SDL_BUILD
SDL,
#endif #endif
Count, Count,
}; };

View File

@ -150,9 +150,7 @@ void Pad::SetDefaultControllerConfig(SettingsInterface& si)
InputManager::InputSourceToString(static_cast<InputSourceType>(i)), InputManager::InputSourceToString(static_cast<InputSourceType>(i)),
InputManager::GetInputSourceDefaultEnabled(static_cast<InputSourceType>(i))); InputManager::GetInputSourceDefaultEnabled(static_cast<InputSourceType>(i)));
} }
#ifdef SDL_BUILD
si.SetBoolValue("InputSources", "SDLControllerEnhancedMode", false); si.SetBoolValue("InputSources", "SDLControllerEnhancedMode", false);
#endif
si.SetBoolValue("Pad", "MultitapPort1", false); si.SetBoolValue("Pad", "MultitapPort1", false);
si.SetBoolValue("Pad", "MultitapPort2", false); si.SetBoolValue("Pad", "MultitapPort2", false);
si.SetFloatValue("Pad", "PointerXScale", 8.0f); si.SetFloatValue("Pad", "PointerXScale", 8.0f);
@ -321,9 +319,7 @@ void Pad::CopyConfiguration(SettingsInterface* dest_si, const SettingsInterface&
dest_si->CopyBoolValue(src_si, "InputSources", dest_si->CopyBoolValue(src_si, "InputSources",
InputManager::InputSourceToString(static_cast<InputSourceType>(i))); InputManager::InputSourceToString(static_cast<InputSourceType>(i)));
} }
#ifdef SDL_BUILD
dest_si->CopyBoolValue(src_si, "InputSources", "SDLControllerEnhancedMode"); dest_si->CopyBoolValue(src_si, "InputSources", "SDLControllerEnhancedMode");
#endif
} }
for (u32 port = 0; port < Pad::NUM_CONTROLLER_PORTS; port++) for (u32 port = 0; port < Pad::NUM_CONTROLLER_PORTS; port++)

View File

@ -68,23 +68,19 @@ namespace
static NullOutModule s_NullOut; static NullOutModule s_NullOut;
static SndOutModule* NullOut = &s_NullOut; static SndOutModule* NullOut = &s_NullOut;
extern SndOutModule* CubebOut;
#ifdef _WIN32 #ifdef _WIN32
extern SndOutModule* XAudio2Out; extern SndOutModule* XAudio2Out;
#endif #endif
#if defined(SPU2X_CUBEB)
extern SndOutModule* CubebOut;
#endif
static SndOutModule* mods[] = static SndOutModule* mods[] =
{ {
NullOut, NullOut,
CubebOut,
#ifdef _WIN32 #ifdef _WIN32
XAudio2Out, XAudio2Out,
#endif #endif
#if defined(SPU2X_CUBEB)
CubebOut,
#endif
}; };
static SndOutModule* s_output_module; static SndOutModule* s_output_module;

View File

@ -30,6 +30,8 @@
#include "USB/qemu-usb/USBinternal.h" #include "USB/qemu-usb/USBinternal.h"
#include "USB/usb-mic/usb-mic-singstar.h" #include "USB/usb-mic/usb-mic-singstar.h"
#include "USB/usb-mic/audiodev.h" #include "USB/usb-mic/audiodev.h"
#include "USB/usb-mic/audiodev-noop.h"
#include "USB/usb-mic/audiodev-cubeb.h"
#include "USB/usb-mic/audio.h" #include "USB/usb-mic/audio.h"
#include "USB/USB.h" #include "USB/USB.h"
#include "Host.h" #include "Host.h"
@ -886,16 +888,11 @@ namespace usb_mic
} }
} // namespace usb_mic } // namespace usb_mic
#include "USB/usb-mic/audiodev-noop.h"
std::unique_ptr<AudioDevice> AudioDevice::CreateNoopDevice(u32 port, AudioDir dir, u32 channels) std::unique_ptr<AudioDevice> AudioDevice::CreateNoopDevice(u32 port, AudioDir dir, u32 channels)
{ {
return std::make_unique<usb_mic::audiodev_noop::NoopAudioDevice>(port, dir, channels); return std::make_unique<usb_mic::audiodev_noop::NoopAudioDevice>(port, dir, channels);
} }
#ifdef SPU2X_CUBEB
#include "USB/usb-mic/audiodev-cubeb.h"
std::unique_ptr<AudioDevice> AudioDevice::CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency) std::unique_ptr<AudioDevice> AudioDevice::CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency)
{ {
return std::make_unique<usb_mic::audiodev_cubeb::CubebAudioDevice>(port, dir, channels, std::move(devname), latency); return std::make_unique<usb_mic::audiodev_cubeb::CubebAudioDevice>(port, dir, channels, std::move(devname), latency);
@ -910,23 +907,3 @@ std::vector<std::pair<std::string, std::string>> AudioDevice::GetOutputDeviceLis
{ {
return usb_mic::audiodev_cubeb::CubebAudioDevice::GetDeviceList(false); return usb_mic::audiodev_cubeb::CubebAudioDevice::GetDeviceList(false);
} }
#else
std::unique_ptr<AudioDevice> AudioDevice::CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency)
{
Console.Warning("Cubeb is unavailable, creating a noop audio device.");
return CreateNoopDevice(port, dir, channels);
}
std::vector<std::pair<std::string, std::string>> AudioDevice::GetInputDeviceList()
{
return {};
}
std::vector<std::pair<std::string, std::string>> AudioDevice::GetOutputDeviceList()
{
return {};
}
#endif

View File

@ -24,8 +24,6 @@
#include <algorithm> #include <algorithm>
#ifdef SDL_BUILD
namespace usb_pad namespace usb_pad
{ {
SDLFFDevice::SDLFFDevice(SDL_Haptic* haptic) SDLFFDevice::SDLFFDevice(SDL_Haptic* haptic)
@ -356,5 +354,3 @@ namespace usb_pad
} }
} // namespace usb_pad } // namespace usb_pad
#endif

View File

@ -16,9 +16,6 @@
#pragma once #pragma once
#include "USB/usb-pad/usb-pad.h" #include "USB/usb-pad/usb-pad.h"
#ifdef SDL_BUILD
#include "Input/SDLInputSource.h" #include "Input/SDLInputSource.h"
namespace usb_pad namespace usb_pad
@ -64,5 +61,3 @@ namespace usb_pad
bool m_autocenter_supported = false; bool m_autocenter_supported = false;
}; };
} // namespace usb_pad } // namespace usb_pad
#endif

View File

@ -16,14 +16,11 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "usb-pad.h" #include "usb-pad.h"
#include "USB/qemu-usb/USBinternal.h" #include "USB/qemu-usb/USBinternal.h"
#include "USB/usb-pad/usb-pad-sdl-ff.h"
#include "USB/USB.h" #include "USB/USB.h"
#include "Host.h" #include "Host.h"
#include "StateWrapper.h" #include "StateWrapper.h"
#ifdef SDL_BUILD
#include "USB/usb-pad/usb-pad-sdl-ff.h"
#endif
namespace usb_pad namespace usb_pad
{ {
static const USBDescStrings df_desc_strings = { static const USBDescStrings df_desc_strings = {
@ -627,10 +624,7 @@ namespace usb_pad
return; return;
mFFdev.reset(); mFFdev.reset();
#ifdef SDL_BUILD
mFFdev = SDLFFDevice::Create(mFFdevName); mFFdev = SDLFFDevice::Create(mFFdevName);
#endif
} }
static void pad_handle_data(USBDevice* dev, USBPacket* p) static void pad_handle_data(USBDevice* dev, USBPacket* p)

View File

@ -64,7 +64,7 @@
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>PrecompiledHeader.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>PrecompiledHeader.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>PrecompiledHeader.h;%(ForcedIncludeFiles)</ForcedIncludeFiles> <ForcedIncludeFiles>PrecompiledHeader.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<PreprocessorDefinitions>LZMA_API_STATIC;ST_NO_EXCEPTION_HANDLING;ENABLE_DISCORD_PRESENCE;ENABLE_RAINTEGRATION;ENABLE_ACHIEVEMENTS;ENABLE_OPENGL;ENABLE_VULKAN;SPU2X_CUBEB;SDL_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LZMA_API_STATIC;ST_NO_EXCEPTION_HANDLING;ENABLE_DISCORD_PRESENCE;ENABLE_RAINTEGRATION;ENABLE_ACHIEVEMENTS;ENABLE_OPENGL;ENABLE_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">XBYAK_NO_EXCEPTION;ZYCORE_STATIC_DEFINE;ZYDIS_STATIC_DEFINE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(Platform)'=='x64'">XBYAK_NO_EXCEPTION;ZYCORE_STATIC_DEFINE;ZYDIS_STATIC_DEFINE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName> <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile> </ClCompile>