From d39ff10747f23da382d995485f345978c67bdfe2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 27 Nov 2025 19:26:10 +0200 Subject: [PATCH] More settings --- src/common/config.cpp | 51 ---------------------- src/common/config.h | 8 ---- src/common/logging/backend.cpp | 5 ++- src/core/emulator_settings.h | 4 ++ src/core/libraries/network/net_ctl_obj.cpp | 11 +++-- src/core/libraries/network/netctl.cpp | 10 +++-- src/emulator.cpp | 7 +-- 7 files changed, 24 insertions(+), 72 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index abc65e38d..b571c8ed4 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -130,11 +130,7 @@ public: // General static ConfigEntry volumeSlider(100); -static ConfigEntry logFilter(""); -static ConfigEntry logType("sync"); static ConfigEntry userName("shadPS4"); -static ConfigEntry isConnectedToNetwork(false); -static bool enableDiscordRPC = false; // Input static ConfigEntry cursorState(HideCursorState::Idle); @@ -288,10 +284,6 @@ std::string getPresentMode() { return presentMode.get(); } -bool getEnableDiscordRPC() { - return enableDiscordRPC; -} - s16 getCursorState() { return cursorState.get(); } @@ -332,14 +324,6 @@ s32 getGpuId() { return gpuId.get(); } -string getLogFilter() { - return logFilter.get(); -} - -string getLogType() { - return logType.get(); -} - string getUserName() { return userName.get(); } @@ -451,14 +435,6 @@ void setVkGuestMarkersEnabled(bool enable, bool is_game_specific) { vkGuestMarkers.set(enable, is_game_specific); } -bool getIsConnectedToNetwork() { - return isConnectedToNetwork.get(); -} - -void setConnectedToNetwork(bool enable, bool is_game_specific) { - isConnectedToNetwork.set(enable, is_game_specific); -} - void setGpuId(s32 selectedGpuId, bool is_game_specific) { gpuId.set(selectedGpuId, is_game_specific); } @@ -555,10 +531,6 @@ void setPresentMode(std::string mode, bool is_game_specific) { presentMode.set(mode, is_game_specific); } -void setEnableDiscordRPC(bool enable) { - enableDiscordRPC = enable; -} - void setCursorState(s16 newCursorState, bool is_game_specific) { cursorState.set(newCursorState, is_game_specific); } @@ -583,14 +555,6 @@ void setLanguage(u32 language, bool is_game_specific) { m_language.set(language, is_game_specific); } -void setLogType(const string& type, bool is_game_specific) { - logType.set(type, is_game_specific); -} - -void setLogFilter(const string& type, bool is_game_specific) { - logFilter.set(type, is_game_specific); -} - void setUserName(const string& name, bool is_game_specific) { userName.set(name, is_game_specific); } @@ -696,11 +660,7 @@ void load(const std::filesystem::path& path, bool is_game_specific) { const toml::value& general = data.at("General"); volumeSlider.setFromToml(general, "volumeSlider", is_game_specific); - enableDiscordRPC = toml::find_or(general, "enableDiscordRPC", enableDiscordRPC); - logFilter.setFromToml(general, "logFilter", is_game_specific); - logType.setFromToml(general, "logType", is_game_specific); userName.setFromToml(general, "userName", is_game_specific); - isConnectedToNetwork.setFromToml(general, "isConnectedToNetwork", is_game_specific); defaultControllerID.setFromToml(general, "defaultControllerID", is_game_specific); } @@ -870,10 +830,7 @@ void save(const std::filesystem::path& path, bool is_game_specific) { } // Entries saved by the game-specific settings GUI volumeSlider.setTomlValue(data, "General", "volumeSlider", is_game_specific); - logFilter.setTomlValue(data, "General", "logFilter", is_game_specific); - logType.setTomlValue(data, "General", "logType", is_game_specific); userName.setTomlValue(data, "General", "userName", is_game_specific); - isConnectedToNetwork.setTomlValue(data, "General", "isConnectedToNetwork", is_game_specific); cursorState.setTomlValue(data, "Input", "cursorState", is_game_specific); cursorHideTimeout.setTomlValue(data, "Input", "cursorHideTimeout", is_game_specific); @@ -951,7 +908,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { } // Non game-specific entries - data["General"]["enableDiscordRPC"] = enableDiscordRPC; data["GUI"]["installDirs"] = install_dirs; data["GUI"]["installDirsEnabled"] = install_dirs_enabled; data["GUI"]["saveDataPath"] = string{fmt::UTF(save_data_path.u8string()).data}; @@ -984,15 +940,12 @@ void setDefaultValues(bool is_game_specific) { if (is_game_specific) { readbacksEnabled.set(false, is_game_specific); readbackLinearImagesEnabled.set(false, is_game_specific); - isConnectedToNetwork.set(false, is_game_specific); directMemoryAccessEnabled.set(false, is_game_specific); } // Entries with game-specific settings that are in both the game-specific and global GUI // GS - General volumeSlider.set(100, is_game_specific); - logFilter.set("", is_game_specific); - logType.set("sync", is_game_specific); userName.set("shadPS4", is_game_specific); // GS - Input @@ -1041,10 +994,6 @@ void setDefaultValues(bool is_game_specific) { // All other entries if (!is_game_specific) { - - // General - enableDiscordRPC = false; - // Input useSpecialPad.base_value = false; specialPadClass.base_value = 1; diff --git a/src/common/config.h b/src/common/config.h index f25a7831f..af5acbee9 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -85,14 +85,8 @@ bool getVkHostMarkersEnabled(); void setVkHostMarkersEnabled(bool enable, bool is_game_specific = false); bool getVkGuestMarkersEnabled(); void setVkGuestMarkersEnabled(bool enable, bool is_game_specific = false); -bool getEnableDiscordRPC(); -void setEnableDiscordRPC(bool enable); bool isRdocEnabled(); void setRdocEnabled(bool enable, bool is_game_specific = false); -std::string getLogType(); -void setLogType(const std::string& type, bool is_game_specific = false); -std::string getLogFilter(); -void setLogFilter(const std::string& type, bool is_game_specific = false); int getCursorHideTimeout(); std::string getMainOutputDevice(); void setMainOutputDevice(std::string device, bool is_game_specific = false); @@ -123,8 +117,6 @@ bool getRcasEnabled(); void setRcasEnabled(bool enable, bool is_game_specific = false); int getRcasAttenuation(); void setRcasAttenuation(int value, bool is_game_specific = false); -bool getIsConnectedToNetwork(); -void setConnectedToNetwork(bool enable, bool is_game_specific = false); void setUserName(const std::string& name, bool is_game_specific = false); bool getLoadAutoPatches(); void setLoadAutoPatches(bool enable); diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 4a85c4cde..808df8599 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -22,6 +22,7 @@ #include "common/path_util.h" #include "common/string_util.h" #include "common/thread.h" +#include "core/emulator_settings.h" namespace Common::Log { @@ -139,7 +140,7 @@ public: const auto& log_dir = GetUserPath(PathType::LogDir); std::filesystem::create_directory(log_dir); Filter filter; - filter.ParseFilterString(Config::getLogFilter()); + filter.ParseFilterString(EmulatorSettings::GetInstance()->GetLogFilter()); const auto& log_file_path = log_file.empty() ? LOG_FILE : log_file; instance = std::unique_ptr( new Impl(log_dir / log_file_path, filter), Deleter); @@ -220,7 +221,7 @@ public: .function = function, .message = std::move(message), }; - if (Config::getLogType() == "async") { + if (EmulatorSettings::GetInstance()->GetLogType() == "async") { message_queue.EmplaceWait(entry); } else { ForEachBackend([&entry](auto& backend) { backend.Write(entry); }); diff --git a/src/core/emulator_settings.h b/src/core/emulator_settings.h index f950b5e82..f2885a044 100644 --- a/src/core/emulator_settings.h +++ b/src/core/emulator_settings.h @@ -333,6 +333,10 @@ public: SETTING_FORWARD(m_general, TrophyNotificationSide, trophy_notification_side) SETTING_FORWARD_BOOL(m_general, ShowSplash, show_splash) SETTING_FORWARD(m_general, AddonInstallDir, addon_install_dir) + SETTING_FORWARD(m_general, LogFilter, log_filter) + SETTING_FORWARD(m_general, LogType, log_type) + SETTING_FORWARD_BOOL(m_general, ConnectedToNetwork, connected_to_network) + SETTING_FORWARD_BOOL(m_general, DiscorRPCEnabled, discord_rpc_enabled) // Debug settings SETTING_FORWARD_BOOL(m_debug, SeparateLoggingEnabled, separate_logging_enabled) diff --git a/src/core/libraries/network/net_ctl_obj.cpp b/src/core/libraries/network/net_ctl_obj.cpp index a295477b6..f6d94845d 100644 --- a/src/core/libraries/network/net_ctl_obj.cpp +++ b/src/core/libraries/network/net_ctl_obj.cpp @@ -4,6 +4,7 @@ #include #include "common/config.h" #include "common/logging/log.h" +#include "core/emulator_settings.h" #include "core/libraries/network/net_ctl_codes.h" #include "core/libraries/network/net_ctl_obj.h" #include "core/tls.h" @@ -46,8 +47,9 @@ s32 NetCtlInternal::RegisterNpToolkitCallback(OrbisNetCtlCallbackForNpToolkit fu void NetCtlInternal::CheckCallback() { std::scoped_lock lock{m_mutex}; - const auto event = Config::getIsConnectedToNetwork() ? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED - : ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED; + const auto event = EmulatorSettings::GetInstance()->IsConnectedToNetwork() + ? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED + : ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED; for (const auto [func, arg] : callbacks) { if (func != nullptr) { Core::ExecuteGuest(func, event, arg); @@ -57,8 +59,9 @@ void NetCtlInternal::CheckCallback() { void NetCtlInternal::CheckNpToolkitCallback() { std::scoped_lock lock{m_mutex}; - const auto event = Config::getIsConnectedToNetwork() ? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED - : ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED; + const auto event = EmulatorSettings::GetInstance()->IsConnectedToNetwork() + ? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED + : ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED; for (const auto [func, arg] : nptool_callbacks) { if (func != nullptr) { Core::ExecuteGuest(func, event, arg); diff --git a/src/core/libraries/network/netctl.cpp b/src/core/libraries/network/netctl.cpp index 8d60d3627..ecf195004 100644 --- a/src/core/libraries/network/netctl.cpp +++ b/src/core/libraries/network/netctl.cpp @@ -15,6 +15,7 @@ #include #include "common/config.h" #include "common/logging/log.h" +#include "core/emulator_settings.h" #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" #include "core/libraries/network/net_ctl_codes.h" @@ -162,7 +163,7 @@ int PS4_SYSV_ABI sceNetCtlGetIfStat() { int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) { LOG_DEBUG(Lib_NetCtl, "code = {}", code); - if (!Config::getIsConnectedToNetwork()) { + if (!EmulatorSettings::GetInstance()->IsConnectedToNetwork()) { return ORBIS_NET_CTL_ERROR_NOT_CONNECTED; } @@ -180,8 +181,9 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) { info->mtu = 1500; // default value break; case ORBIS_NET_CTL_INFO_LINK: - info->link = Config::getIsConnectedToNetwork() ? ORBIS_NET_CTL_LINK_CONNECTED - : ORBIS_NET_CTL_LINK_DISCONNECTED; + info->link = EmulatorSettings::GetInstance()->IsConnectedToNetwork() + ? ORBIS_NET_CTL_LINK_CONNECTED + : ORBIS_NET_CTL_LINK_DISCONNECTED; break; case ORBIS_NET_CTL_INFO_IP_ADDRESS: { strcpy(info->ip_address, @@ -318,7 +320,7 @@ int PS4_SYSV_ABI sceNetCtlGetScanInfoForSsidScanIpcInt() { } int PS4_SYSV_ABI sceNetCtlGetState(int* state) { - const auto connected = Config::getIsConnectedToNetwork(); + const auto connected = EmulatorSettings::GetInstance()->IsConnectedToNetwork(); LOG_DEBUG(Lib_NetCtl, "connected = {}", connected); const auto current_state = connected ? ORBIS_NET_CTL_STATE_IPOBTAINED : ORBIS_NET_CTL_STATE_DISCONNECTED; diff --git a/src/emulator.cpp b/src/emulator.cpp index 81284a1db..963a2387c 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -203,10 +203,11 @@ void Emulator::Run(std::filesystem::path file, std::vector args, Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) / (id + ".toml")); LOG_INFO(Config, "Game-specific config exists: {}", has_game_config); - LOG_INFO(Config, "General LogType: {}", Config::getLogType()); + LOG_INFO(Config, "General LogType: {}", EmulatorSettings::GetInstance()->GetLogType()); LOG_INFO(Config, "General isNeo: {}", EmulatorSettings::GetInstance()->IsNeo()); LOG_INFO(Config, "General isDevKit: {}", EmulatorSettings::GetInstance()->IsDevKit()); - LOG_INFO(Config, "General isConnectedToNetwork: {}", Config::getIsConnectedToNetwork()); + LOG_INFO(Config, "General isConnectedToNetwork: {}", + EmulatorSettings::GetInstance()->IsConnectedToNetwork()); LOG_INFO(Config, "General isPsnSignedIn: {}", EmulatorSettings::GetInstance()->IsPSNSignedIn()); LOG_INFO(Config, "GPU isNullGpu: {}", Config::nullGpu()); LOG_INFO(Config, "GPU readbacks: {}", Config::readbacks()); @@ -358,7 +359,7 @@ void Emulator::Run(std::filesystem::path file, std::vector args, #ifdef ENABLE_DISCORD_RPC // Discord RPC - if (Config::getEnableDiscordRPC()) { + if (EmulatorSettings::GetInstance()->IsDiscorRPCEnabled()) { auto* rpc = Common::Singleton::Instance(); if (rpc->getRPCEnabled() == false) { rpc->init();