More settings

This commit is contained in:
georgemoralis
2025-11-27 19:26:10 +02:00
parent 6bb8ad8968
commit d39ff10747
7 changed files with 24 additions and 72 deletions

View File

@@ -130,11 +130,7 @@ public:
// General
static ConfigEntry<int> volumeSlider(100);
static ConfigEntry<string> logFilter("");
static ConfigEntry<string> logType("sync");
static ConfigEntry<string> userName("shadPS4");
static ConfigEntry<bool> isConnectedToNetwork(false);
static bool enableDiscordRPC = false;
// Input
static ConfigEntry<int> 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<bool>(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;

View File

@@ -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);

View File

@@ -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<Impl, decltype(&Deleter)>(
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); });

View File

@@ -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)

View File

@@ -4,6 +4,7 @@
#include <algorithm>
#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);

View File

@@ -15,6 +15,7 @@
#include <common/singleton.h>
#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;

View File

@@ -203,10 +203,11 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> 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<std::string> args,
#ifdef ENABLE_DISCORD_RPC
// Discord RPC
if (Config::getEnableDiscordRPC()) {
if (EmulatorSettings::GetInstance()->IsDiscorRPCEnabled()) {
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
if (rpc->getRPCEnabled() == false) {
rpc->init();