From a37e89b52f86fefd56e533bacec0e98cbfadcafc Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 16 Sep 2023 14:39:13 +1000 Subject: [PATCH] CMake: Remove unsupported options --- CMakeLists.txt | 66 ++--- CMakeModules/DolphinPostprocessBundle.cmake | 46 ---- src/core/CMakeLists.txt | 232 +++++++++--------- src/core/fullscreen_ui.cpp | 2 +- src/core/host.cpp | 2 +- src/core/settings.cpp | 4 +- src/core/settings.h | 2 +- src/core/types.h | 2 +- src/duckstation-qt/CMakeLists.txt | 17 +- src/duckstation-qt/audiosettingswidget.cpp | 2 +- .../controllerglobalsettingswidget.cpp | 7 - src/util/CMakeLists.txt | 23 +- src/util/audio_stream.h | 2 +- src/util/input_manager.cpp | 11 +- src/util/input_manager.h | 2 +- src/util/input_source.h | 2 +- src/util/platform_misc_unix.cpp | 67 +---- src/util/util.props | 2 +- 18 files changed, 173 insertions(+), 318 deletions(-) delete mode 100644 CMakeModules/DolphinPostprocessBundle.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f3d78fbf4..3327c26e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,55 +15,32 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/") # Platform detection. if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(LINUX TRUE) - set(SUPPORTS_X11 TRUE) - set(SUPPORTS_WAYLAND TRUE) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set(FREEBSD TRUE) - set(SUPPORTS_X11 TRUE) endif() -# Global options. -option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF) -option(BUILD_QT_FRONTEND "Build the Qt frontend" ON) -option(BUILD_REGTEST "Build regression test runner" OFF) -option(BUILD_TESTS "Build unit tests" OFF) -option(ENABLE_CUBEB "Build with Cubeb audio output" ON) +# Renderer options. option(ENABLE_OPENGL "Build with OpenGL renderer" ON) option(ENABLE_VULKAN "Build with Vulkan renderer" ON) -option(ENABLE_DISCORD_PRESENCE "Build with Discord Rich Presence support" ON) -#option(USE_SDL2 "Link with SDL2 for controller support" ON) -set(USE_SDL2 ON) +# Global options. +if(NOT ANDROID) + option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF) + option(BUILD_QT_FRONTEND "Build the Qt frontend" ON) + option(BUILD_REGTEST "Build regression test runner" OFF) + option(BUILD_TESTS "Build unit tests" OFF) -# OpenGL context creation methods. -if(SUPPORTS_X11) - option(USE_X11 "Support X11 window system" ON) -endif() -if(SUPPORTS_WAYLAND) - option(USE_WAYLAND "Support Wayland window system" ON) -endif() -if((LINUX OR FREEBSD) AND NOT ANDROID) - option(USE_DBUS "Enable DBus support for screensaver inhibiting" ON) -endif() -if(APPLE) - option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF) -endif() + set(ENABLE_CUBEB ON) + set(ENABLE_DISCORD_PRESENCE ON) + set(USE_SDL2 ON) -if(ANDROID) - if(CMAKE_BUILD_TYPE STREQUAL "Release") - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + if(LINUX OR FREEBSD) + option(USE_X11 "Support X11 window system" ON) + option(USE_WAYLAND "Support Wayland window system" ON) + endif() + if(APPLE) + option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF) endif() - set(BUILD_NOGUI_FRONTEND OFF CACHE BOOL "") - set(BUILD_QT_FRONTEND OFF CACHE BOOL "") - set(BUILD_REGTEST OFF CACHE BOOL "") - set(ENABLE_CUBEB OFF CACHE BOOL "") - set(ENABLE_OPENGL ON CACHE BOOL "") - set(ENABLE_VULKAN ON CACHE BOOL "") - set(ENABLE_DISCORD_PRESENCE OFF CACHE BOOL "") - set(ENABLE_CHEEVOS ON CACHE BOOL "") - set(USE_SDL2 OFF CACHE BOOL "") - set(USE_X11 OFF CACHE BOOL "") - set(USE_WAYLAND OFF CACHE BOOL "") endif() @@ -73,9 +50,11 @@ if(USE_SDL2) endif() if(NOT WIN32 AND NOT ANDROID) find_package(CURL REQUIRED) - find_package(Libbacktrace) - if(NOT LIBBACKTRACE_FOUND) - message(WARNING "libbacktrace not found, crashes will not produce backtraces.") + if(NOT APPLE) + find_package(Libbacktrace) + if(NOT LIBBACKTRACE_FOUND) + message(WARNING "libbacktrace not found, crashes will not produce backtraces.") + endif() endif() endif() if(BUILD_QT_FRONTEND) @@ -99,9 +78,6 @@ endif() if(USE_WAYLAND) message(STATUS "Wayland support enabled") endif() -if(ENABLE_CHEEVOS) - message(STATUS "RetroAchievements support enabled") -endif() # Set _DEBUG macro for Debug builds. diff --git a/CMakeModules/DolphinPostprocessBundle.cmake b/CMakeModules/DolphinPostprocessBundle.cmake deleted file mode 100644 index ba412ba48..000000000 --- a/CMakeModules/DolphinPostprocessBundle.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# This module can be used in two different ways. -# -# When invoked as `cmake -P DolphinPostprocessBundle.cmake`, it fixes up an -# application folder to be standalone. It bundles all required libraries from -# the system and fixes up library IDs. Any additional shared libraries, like -# plugins, that are found under Contents/MacOS/ will be made standalone as well. -# -# When called with `include(DolphinPostprocessBundle)`, it defines a helper -# function `dolphin_postprocess_bundle` that sets up the command form of the -# module as a post-build step. - -if(CMAKE_GENERATOR) - # Being called as include(DolphinPostprocessBundle), so define a helper function. - set(_DOLPHIN_POSTPROCESS_BUNDLE_MODULE_LOCATION "${CMAKE_CURRENT_LIST_FILE}") - function(dolphin_postprocess_bundle target) - add_custom_command(TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -DDOLPHIN_BUNDLE_PATH="$/../.." - -P "${_DOLPHIN_POSTPROCESS_BUNDLE_MODULE_LOCATION}" - ) - endfunction() - return() -endif() - -get_filename_component(DOLPHIN_BUNDLE_PATH "${DOLPHIN_BUNDLE_PATH}" ABSOLUTE) -message(STATUS "Fixing up application bundle: ${DOLPHIN_BUNDLE_PATH}") - -# Make sure to fix up any additional shared libraries (like plugins) that are -# needed. -file(GLOB_RECURSE extra_libs "${DOLPHIN_BUNDLE_PATH}/Contents/MacOS/*.dylib") - -# BundleUtilities doesn't support DYLD_FALLBACK_LIBRARY_PATH behavior, which -# makes it sometimes break on libraries that do weird things with @rpath. Specify -# equivalent search directories until https://gitlab.kitware.com/cmake/cmake/issues/16625 -# is fixed and in our minimum CMake version. -set(extra_dirs "/usr/local/lib" "/lib" "/usr/lib") - -# BundleUtilities is overly verbose, so disable most of its messages -function(message) - if(NOT ARGV MATCHES "^STATUS;") - _message(${ARGV}) - endif() -endfunction() - -include(BundleUtilities) -set(BU_CHMOD_BUNDLE_ITEMS ON) -fixup_bundle("${DOLPHIN_BUNDLE_PATH}" "${extra_libs}" "${extra_dirs}") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e2ea01b38..c708f0a1d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,123 +1,123 @@ add_library(core - achievements.cpp - achievements.h - analog_controller.cpp - analog_controller.h - analog_joystick.cpp - analog_joystick.h - bios.cpp - bios.h - bus.cpp - bus.h - cdrom.cpp - cdrom.h - cdrom_async_reader.cpp - cdrom_async_reader.h - cheats.cpp - cheats.h - controller.cpp - controller.h - cpu_code_cache.cpp - cpu_code_cache.h - cpu_core.cpp - cpu_core.h - cpu_core_private.h - cpu_disasm.cpp - cpu_disasm.h - cpu_types.cpp - cpu_types.h - digital_controller.cpp - digital_controller.h - dma.cpp - dma.h - fullscreen_ui.cpp - fullscreen_ui.h - game_database.cpp - game_database.h - game_list.cpp - game_list.h - gdb_protocol.cpp - gdb_protocol.h - gpu.cpp - gpu.h - gpu_backend.cpp - gpu_backend.h - gpu_commands.cpp - gpu_hw.cpp - gpu_hw.h - gpu_hw_shadergen.cpp - gpu_hw_shadergen.h - gpu_shadergen.cpp - gpu_shadergen.h - gpu_sw.cpp - gpu_sw.h - gpu_sw_backend.cpp - gpu_sw_backend.h - gpu_types.h - guncon.cpp - guncon.h - gte.cpp - gte.h - gte_types.h - host.cpp - host.h - host_interface_progress_callback.cpp - host_interface_progress_callback.h - hotkeys.cpp - input_types.h - imgui_overlays.cpp - imgui_overlays.h - interrupt_controller.cpp - interrupt_controller.h - mdec.cpp - mdec.h - memory_card.cpp - memory_card.h - memory_card_image.cpp - memory_card_image.h - multitap.cpp - multitap.h - negcon.cpp - negcon.h - pad.cpp - pad.h - pcdrv.cpp - pcdrv.h - pgxp.cpp - pgxp.h - playstation_mouse.cpp - playstation_mouse.h - psf_loader.cpp - psf_loader.h - resources.cpp - resources.h - save_state_version.h - settings.cpp - settings.h - shader_cache_version.h - sio.cpp - sio.h - spu.cpp - spu.h - system.cpp - system.h - texture_replacements.cpp - texture_replacements.h - timers.cpp - timers.h - timing_event.cpp - timing_event.h - types.h + achievements.cpp + achievements.h + analog_controller.cpp + analog_controller.h + analog_joystick.cpp + analog_joystick.h + bios.cpp + bios.h + bus.cpp + bus.h + cdrom.cpp + cdrom.h + cdrom_async_reader.cpp + cdrom_async_reader.h + cheats.cpp + cheats.h + controller.cpp + controller.h + cpu_code_cache.cpp + cpu_code_cache.h + cpu_core.cpp + cpu_core.h + cpu_core_private.h + cpu_disasm.cpp + cpu_disasm.h + cpu_types.cpp + cpu_types.h + digital_controller.cpp + digital_controller.h + dma.cpp + dma.h + fullscreen_ui.cpp + fullscreen_ui.h + game_database.cpp + game_database.h + game_list.cpp + game_list.h + gdb_protocol.cpp + gdb_protocol.h + gpu.cpp + gpu.h + gpu_backend.cpp + gpu_backend.h + gpu_commands.cpp + gpu_hw.cpp + gpu_hw.h + gpu_hw_shadergen.cpp + gpu_hw_shadergen.h + gpu_shadergen.cpp + gpu_shadergen.h + gpu_sw.cpp + gpu_sw.h + gpu_sw_backend.cpp + gpu_sw_backend.h + gpu_types.h + guncon.cpp + guncon.h + gte.cpp + gte.h + gte_types.h + host.cpp + host.h + host_interface_progress_callback.cpp + host_interface_progress_callback.h + hotkeys.cpp + input_types.h + imgui_overlays.cpp + imgui_overlays.h + interrupt_controller.cpp + interrupt_controller.h + mdec.cpp + mdec.h + memory_card.cpp + memory_card.h + memory_card_image.cpp + memory_card_image.h + multitap.cpp + multitap.h + negcon.cpp + negcon.h + pad.cpp + pad.h + pcdrv.cpp + pcdrv.h + pgxp.cpp + pgxp.h + playstation_mouse.cpp + playstation_mouse.h + psf_loader.cpp + psf_loader.h + resources.cpp + resources.h + save_state_version.h + settings.cpp + settings.h + shader_cache_version.h + sio.cpp + sio.h + spu.cpp + spu.h + system.cpp + system.h + texture_replacements.cpp + texture_replacements.h + timers.cpp + timers.h + timing_event.cpp + timing_event.h + types.h ) set(RECOMPILER_SRCS - cpu_recompiler_code_generator.cpp - cpu_recompiler_code_generator.h - cpu_recompiler_code_generator_generic.cpp - cpu_recompiler_register_cache.cpp - cpu_recompiler_register_cache.h - cpu_recompiler_thunks.h - cpu_recompiler_types.h + cpu_recompiler_code_generator.cpp + cpu_recompiler_code_generator.h + cpu_recompiler_code_generator_generic.cpp + cpu_recompiler_register_cache.cpp + cpu_recompiler_register_cache.h + cpu_recompiler_thunks.h + cpu_recompiler_types.h ) target_precompile_headers(core PRIVATE "pch.h") diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 28420f114..67a9e48a3 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -3219,7 +3219,7 @@ void FullscreenUI::DrawControllerSettingsPage() MenuHeading("Input Sources"); -#ifdef WITH_SDL2 +#ifdef USE_SDL2 DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_COG, "Enable SDL Input Source"), FSUI_CSTR("The SDL input source supports most controllers."), "InputSources", "SDL", true, true, false); diff --git a/src/core/host.cpp b/src/core/host.cpp index 2cb42922a..671822bc5 100644 --- a/src/core/host.cpp +++ b/src/core/host.cpp @@ -319,7 +319,7 @@ std::unique_ptr Host::CreateAudioStream(AudioBackend backend, u32 s { switch (backend) { -#ifdef WITH_CUBEB +#ifdef USE_CUBEB case AudioBackend::Cubeb: return AudioStream::CreateCubebAudioStream(sample_rate, channels, buffer_ms, latency_ms, stretch); #endif diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 20b16c99c..a6c1ab09b 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -1247,7 +1247,7 @@ const char* Settings::GetDisplayScalingDisplayName(DisplayScalingMode mode) static constexpr const char* s_audio_backend_names[] = { "Null", -#ifdef WITH_CUBEB +#ifdef USE_CUBEB "Cubeb", #endif #ifdef _WIN32 @@ -1259,7 +1259,7 @@ static constexpr const char* s_audio_backend_names[] = { }; static constexpr const char* s_audio_backend_display_names[] = { TRANSLATE_NOOP("AudioBackend", "Null (No Output)"), -#ifdef WITH_CUBEB +#ifdef USE_CUBEB TRANSLATE_NOOP("AudioBackend", "Cubeb"), #endif #ifdef _WIN32 diff --git a/src/core/settings.h b/src/core/settings.h index 843e55eb0..753770f81 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -446,7 +446,7 @@ struct Settings static constexpr CPUFastmemMode DEFAULT_CPU_FASTMEM_MODE = CPUFastmemMode::Disabled; #endif -#if defined(WITH_CUBEB) +#if defined(USE_CUBEB) static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::Cubeb; #elif defined(_WIN32) static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::XAudio2; diff --git a/src/core/types.h b/src/core/types.h index a67ff2c12..4923432df 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -144,7 +144,7 @@ enum class DisplayScalingMode : u8 enum class AudioBackend : u8 { Null, -#ifdef WITH_CUBEB +#ifdef USE_CUBEB Cubeb, #endif #ifdef _WIN32 diff --git a/src/duckstation-qt/CMakeLists.txt b/src/duckstation-qt/CMakeLists.txt index 2fd437c79..fcb6331cb 100644 --- a/src/duckstation-qt/CMakeLists.txt +++ b/src/duckstation-qt/CMakeLists.txt @@ -9,6 +9,12 @@ set(SRCS aboutdialog.cpp aboutdialog.h aboutdialog.ui + achievementlogindialog.cpp + achievementlogindialog.h + achievementlogindialog.ui + achievementsettingswidget.cpp + achievementsettingswidget.h + achievementsettingswidget.ui advancedsettingswidget.cpp advancedsettingswidget.h advancedsettingswidget.ui @@ -136,17 +142,6 @@ set(SRCS setupwizarddialog.ui ) -if(ENABLE_CHEEVOS) - set(SRCS ${SRCS} - achievementlogindialog.cpp - achievementlogindialog.h - achievementlogindialog.ui - achievementsettingswidget.cpp - achievementsettingswidget.h - achievementsettingswidget.ui - ) -endif() - set(TS_FILES translations/duckstation-qt_de.ts translations/duckstation-qt_en.ts diff --git a/src/duckstation-qt/audiosettingswidget.cpp b/src/duckstation-qt/audiosettingswidget.cpp index bb6fb49f2..57c46ff15 100644 --- a/src/duckstation-qt/audiosettingswidget.cpp +++ b/src/duckstation-qt/audiosettingswidget.cpp @@ -103,7 +103,7 @@ void AudioSettingsWidget::updateDriverNames() std::vector names; std::vector> devices; -#ifdef WITH_CUBEB +#ifdef USE_CUBEB if (backend == AudioBackend::Cubeb) { names = AudioStream::GetCubebDriverNames(); diff --git a/src/duckstation-qt/controllerglobalsettingswidget.cpp b/src/duckstation-qt/controllerglobalsettingswidget.cpp index 13dde955c..d2bc7c5a5 100644 --- a/src/duckstation-qt/controllerglobalsettingswidget.cpp +++ b/src/duckstation-qt/controllerglobalsettingswidget.cpp @@ -16,17 +16,12 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent, SettingsInterface* sif = dialog->getProfileSettingsInterface(); -#ifdef WITH_SDL2 SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false); connect(m_ui.enableSDLSource, &QCheckBox::stateChanged, this, &ControllerGlobalSettingsWidget::updateSDLOptionsEnabled); connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked); -#else - m_ui.enableSDLSource->setEnabled(false); - m_ui.ledSettings->setEnabled(false); -#endif #ifdef _WIN32 SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableDInputSource, "InputSources", "DInput", false); @@ -129,7 +124,6 @@ ControllerLEDSettingsDialog::~ControllerLEDSettingsDialog() = default; void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 player_id) { -#ifdef WITH_SDL2 std::string key(fmt::format("Player{}LED", player_id)); const u32 current_value = SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id); @@ -138,5 +132,4 @@ void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 play 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()); }); -#endif } diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index e81632829..12e998179 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -74,25 +74,22 @@ target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") target_link_libraries(util PUBLIC common simpleini imgui) target_link_libraries(util PRIVATE stb libchdr zlib soundtouch Zstd::Zstd reshadefx) -if(ENABLE_CUBEB) +if(USE_CUBEB) target_sources(util PRIVATE cubeb_audio_stream.cpp cubeb_audio_stream.h ) - target_compile_definitions(util PUBLIC "WITH_CUBEB=1") + target_compile_definitions(util PUBLIC "USE_CUBEB=1") target_link_libraries(util PRIVATE cubeb) endif() if(USE_X11) target_compile_definitions(util PRIVATE "-DUSE_X11=1") - target_include_directories(util PRIVATE "${X11_INCLUDE_DIR}" "${X11_Xrandr_INCLUDE_PATH}") - target_link_libraries(util PRIVATE "${X11_LIBRARIES}" "${X11_Xrandr_LIB}") + target_link_libraries(util PRIVATE X11::X11 X11::Xrandr) endif() if(USE_WAYLAND) target_compile_definitions(util PRIVATE "-DUSE_WAYLAND=1") -elseif(SUPPORTS_WAYLAND) - message(WARNING "Wayland support for renderers is disabled.\nDuckStation will FAIL to start on Wayland.") endif() if(ENABLE_OPENGL) @@ -199,7 +196,7 @@ if(USE_SDL2) sdl_input_source.cpp sdl_input_source.h ) - target_compile_definitions(util PUBLIC "WITH_SDL2=1") + target_compile_definitions(util PUBLIC "USE_SDL2=1") target_link_libraries(util PUBLIC SDL2::SDL2) # Copy bundled SDL2 to output on Windows. @@ -215,14 +212,6 @@ if(USE_SDL2) endif() endif() -if(USE_DBUS) - target_compile_definitions(util PRIVATE USE_DBUS) - find_package(PkgConfig REQUIRED) - pkg_check_modules(DBUS REQUIRED dbus-1) - target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS}) - target_link_libraries(util PRIVATE ${DBUS_LINK_LIBRARIES}) -endif() - if(WIN32) target_sources(util PRIVATE d3d_common.cpp @@ -288,6 +277,10 @@ elseif(NOT ANDROID) target_sources(util PRIVATE platform_misc_unix.cpp ) + find_package(PkgConfig REQUIRED) + pkg_check_modules(DBUS REQUIRED dbus-1) + target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS}) + target_link_libraries(util PRIVATE ${DBUS_LINK_LIBRARIES}) endif() function(add_util_resources target) diff --git a/src/util/audio_stream.h b/src/util/audio_stream.h index eeafbff3b..4113dcbeb 100644 --- a/src/util/audio_stream.h +++ b/src/util/audio_stream.h @@ -79,7 +79,7 @@ public: static std::unique_ptr CreateNullStream(u32 sample_rate, u32 channels, u32 buffer_ms); -#ifdef WITH_CUBEB +#ifdef USE_CUBEB static std::unique_ptr CreateCubebAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, u32 latency_ms, AudioStretchMode stretch); static std::vector GetCubebDriverNames(); diff --git a/src/util/input_manager.cpp b/src/util/input_manager.cpp index 1a07dbf7b..dd77263bc 100644 --- a/src/util/input_manager.cpp +++ b/src/util/input_manager.cpp @@ -481,7 +481,7 @@ static std::array(InputSourceType::Count)> s_input "XInput", "RawInput", #endif -#ifdef WITH_SDL2 +#ifdef USE_SDL2 "SDL", #endif #ifdef __ANDROID__ @@ -512,17 +512,12 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type) return false; case InputSourceType::XInput: - // Disable xinput by default if we have SDL. -#ifdef WITH_SDL2 return false; -#else - return true; -#endif case InputSourceType::RawInput: return false; #endif -#ifdef WITH_SDL2 +#ifdef USE_SDL2 case InputSourceType::SDL: return true; #endif @@ -1931,7 +1926,7 @@ void InputManager::ReloadSources(SettingsInterface& si, std::unique_lock CreateXInputSource(); static std::unique_ptr CreateWin32RawInputSource(); #endif -#ifdef WITH_SDL2 +#ifdef USE_SDL2 static std::unique_ptr CreateSDLSource(); #endif #ifdef __ANDROID__ diff --git a/src/util/platform_misc_unix.cpp b/src/util/platform_misc_unix.cpp index ffce1e54c..d43ed6019 100644 --- a/src/util/platform_misc_unix.cpp +++ b/src/util/platform_misc_unix.cpp @@ -1,47 +1,20 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin and contributors. // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) +#include "input_manager.h" +#include "platform_misc.h" + #include "common/log.h" #include "common/scoped_guard.h" #include "common/string.h" -#include "input_manager.h" -#include "platform_misc.h" -#include -Log_SetChannel(PlatformMisc); +#include #include #include - -#if !defined(USE_DBUS) && defined(USE_X11) -#include -#include - -static bool SetScreensaverInhibitX11(bool inhibit, const WindowInfo& wi) -{ - TinyString command; - command.AppendString("xdg-screensaver"); - - TinyString operation; - operation.AppendString(inhibit ? "suspend" : "resume"); - - TinyString id; - id.Format("0x%" PRIx64, static_cast(reinterpret_cast(wi.window_handle))); - - char* argv[4] = {command.GetWriteableCharArray(), operation.GetWriteableCharArray(), id.GetWriteableCharArray(), - nullptr}; - pid_t pid; - int res = posix_spawnp(&pid, "xdg-screensaver", nullptr, nullptr, argv, environ); - if (res != 0) - { - Log_ErrorPrintf("posix_spawnp() failed: %d", res); - return false; - } - - return true; -} - -#elif defined(USE_DBUS) #include + +Log_SetChannel(PlatformMisc); + static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char* program_name, const char* reason) { static dbus_uint32_t s_cookie; @@ -115,33 +88,9 @@ static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char* return true; } -#endif - static bool SetScreensaverInhibit(bool inhibit) { -#ifdef USE_DBUS return SetScreensaverInhibitDBus(inhibit, "DuckStation", "DuckStation VM is running."); -#else - - std::optional wi(Host::GetTopLevelWindowInfo()); - if (!wi.has_value()) - { - Log_ErrorPrintf("No top-level window."); - return false; - } - - switch (wi->type) - { -#ifdef USE_X11 - case WindowInfo::Type::X11: - return SetScreensaverInhibitX11(inhibit, wi.value()); -#endif - - default: - Log_ErrorPrintf("Unknown type: %u", static_cast(wi->type)); - return false; - } -#endif } static bool s_screensaver_suspended; diff --git a/src/util/util.props b/src/util/util.props index 35d993262..00f7212dd 100644 --- a/src/util/util.props +++ b/src/util/util.props @@ -5,7 +5,7 @@ %(PreprocessorDefinitions);SOUNDTOUCH_FLOAT_SAMPLES;SOUNDTOUCH_ALLOW_SSE;ST_NO_EXCEPTION_HANDLING=1 - WITH_CUBEB=1;WITH_SDL2=1;WITH_DINPUT=1;%(PreprocessorDefinitions) + USE_CUBEB=1;USE_SDL2=1;%(PreprocessorDefinitions) %(PreprocessorDefinitions);WITH_OPENGL=1;WITH_VULKAN=1 %(PreprocessorDefinitions);SOUNDTOUCH_USE_NEON %(AdditionalIncludeDirectories);$(SolutionDir)dep\soundtouch\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\libchdr\include;$(SolutionDir)dep\cubeb\include;$(SolutionDir)dep\d3d12ma\include;$(SolutionDir)dep\zstd\lib