diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index b4b9747a4..bc0c0f0da 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -54,10 +54,10 @@ HostInterface::HostInterface() { SetUserDirectory(); CreateUserDirectorySubdirectories(); + SetDefaultSettings(); m_game_list = std::make_unique(); m_game_list->SetCacheFilename(GetGameListCacheFileName()); m_game_list->SetDatabaseFilename(GetGameListDatabaseFileName()); - m_settings.SetDefaults(); m_last_throttle_time = Common::Timer::GetValue(); } @@ -542,6 +542,38 @@ std::string HostInterface::GetGameMemoryCardPath(const char* game_code, u32 slot return GetUserDirectoryRelativePath("memcards/game_card_%s_%d.mcd", game_code, slot + 1); } +void HostInterface::SetDefaultSettings() +{ + m_settings.region = ConsoleRegion::Auto; + m_settings.cpu_execution_mode = CPUExecutionMode::Interpreter; + + m_settings.speed_limiter_enabled = true; + m_settings.start_paused = false; + + m_settings.gpu_renderer = GPURenderer::HardwareOpenGL; + m_settings.gpu_resolution_scale = 1; + m_settings.gpu_true_color = true; + m_settings.gpu_texture_filtering = false; + m_settings.gpu_force_progressive_scan = true; + m_settings.gpu_use_debug_device = false; + m_settings.display_linear_filtering = true; + m_settings.display_fullscreen = false; + m_settings.video_sync_enabled = true; + + m_settings.audio_backend = AudioBackend::Default; + m_settings.audio_sync_enabled = true; + + m_settings.bios_path = "scph1001.bin"; + m_settings.bios_patch_tty_enable = false; + m_settings.bios_patch_fast_boot = false; + + m_settings.controller_types[0] = ControllerType::DigitalController; + m_settings.controller_types[1] = ControllerType::None; + + m_settings.memory_card_paths[0] = GetSharedMemoryCardPath(0); + m_settings.memory_card_paths[1] = GetSharedMemoryCardPath(1); +} + void HostInterface::UpdateSettings(const std::function& apply_callback) { const GPURenderer old_gpu_renderer = m_settings.gpu_renderer; diff --git a/src/core/host_interface.h b/src/core/host_interface.h index b66ea6307..a155e8e5c 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -116,6 +116,9 @@ protected: /// Returns the default path to a memory card for a specific game. std::string GetGameMemoryCardPath(const char* game_code, u32 slot); + /// Restores all settings to defaults. + void SetDefaultSettings(); + /// Applies new settings, updating internal state as needed. apply_callback should call m_settings.Load() after /// locking any required mutexes. void UpdateSettings(const std::function& apply_callback); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index db5603e50..42aa06468 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -4,38 +4,6 @@ Settings::Settings() = default; -void Settings::SetDefaults() -{ - region = ConsoleRegion::Auto; - cpu_execution_mode = CPUExecutionMode::Interpreter; - - speed_limiter_enabled = true; - start_paused = false; - - gpu_renderer = GPURenderer::HardwareOpenGL; - gpu_resolution_scale = 1; - gpu_true_color = true; - gpu_texture_filtering = false; - gpu_force_progressive_scan = true; - gpu_use_debug_device = false; - display_linear_filtering = true; - display_fullscreen = false; - video_sync_enabled = true; - - audio_backend = AudioBackend::Default; - audio_sync_enabled = true; - - bios_path = "scph1001.bin"; - bios_patch_tty_enable = false; - bios_patch_fast_boot = false; - - controller_types[0] = ControllerType::DigitalController; - controller_types[1] = ControllerType::None; - - memory_card_paths[0] = "memory_card_1.mcd"; - memory_card_paths[1].clear(); -} - void Settings::Load(SettingsInterface& si) { region = diff --git a/src/core/settings.h b/src/core/settings.h index 6b2cd1e01..2b9bec3b3 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -75,7 +75,6 @@ struct Settings std::array controller_types{}; std::array memory_card_paths{}; - void SetDefaults(); void Load(SettingsInterface& si); void Save(SettingsInterface& si) const; diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index c771a64ba..9ac28ecfc 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -52,12 +52,12 @@ void QtHostInterface::ReportMessage(const char* message) void QtHostInterface::setDefaultSettings() { - std::lock_guard guard(m_qsettings_mutex); - - m_settings.SetDefaults(); + HostInterface::UpdateSettings([this]() { + HostInterface::SetDefaultSettings(); + }); // default input settings for Qt - m_settings.controller_types[0] = ControllerType::DigitalController; + std::lock_guard guard(m_qsettings_mutex); m_qsettings.setValue(QStringLiteral("Controller1/ButtonUp"), QStringLiteral("Keyboard/W")); m_qsettings.setValue(QStringLiteral("Controller1/ButtonDown"), QStringLiteral("Keyboard/S")); m_qsettings.setValue(QStringLiteral("Controller1/ButtonLeft"), QStringLiteral("Keyboard/A"));