From 526887899ee839480f72703304331c276ccdae85 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Wed, 29 Dec 2021 17:20:32 +0100 Subject: [PATCH] Config: Port BluetoothPassthrough settings to new config system. --- Source/Core/Core/BootManager.cpp | 4 ---- Source/Core/Core/Config/MainSettings.cpp | 9 ++++++++ Source/Core/Core/Config/MainSettings.h | 7 ++++++ .../Core/ConfigLoaders/IsSettingSaveable.cpp | 3 ++- .../ConfigLoaders/NetPlayConfigLoader.cpp | 2 ++ Source/Core/Core/ConfigManager.cpp | 22 ------------------- Source/Core/Core/ConfigManager.h | 8 ------- Source/Core/Core/Core.cpp | 2 +- .../Core/Core/HW/WiimoteReal/WiimoteReal.cpp | 2 +- Source/Core/Core/IOS/IOS.cpp | 2 +- Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp | 16 ++++++++------ Source/Core/Core/WiiUtils.cpp | 6 ++--- .../Config/WiimoteControllersWidget.cpp | 6 +++-- 13 files changed, 39 insertions(+), 50 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 40930117aa..ee60c6a946 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -91,7 +91,6 @@ private: int iSelectedLanguage = 0; PowerPC::CPUCore cpu_core = PowerPC::CPUCore::Interpreter; float m_EmulationSpeed = 0; - bool m_bt_passthrough_enabled = false; std::string m_strGPUDeterminismMode; std::array iWiimoteSource{}; std::array Pads{}; @@ -121,7 +120,6 @@ void ConfigCache::SaveConfig(const SConfig& config) cpu_core = config.cpu_core; m_EmulationSpeed = config.m_EmulationSpeed; m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; - m_bt_passthrough_enabled = config.m_bt_passthrough_enabled; for (int i = 0; i != MAX_BBMOTES; ++i) iWiimoteSource[i] = WiimoteCommon::GetSource(i); @@ -189,7 +187,6 @@ void ConfigCache::RestoreConfig(SConfig* config) } config->m_strGPUDeterminismMode = m_strGPUDeterminismMode; - config->m_bt_passthrough_enabled = m_bt_passthrough_enabled; } static ConfigCache config_cache; @@ -357,7 +354,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) StartUp.bMMU = netplay_settings.m_MMU; StartUp.bFastmem = netplay_settings.m_Fastmem; StartUp.bHLE_BS2 = netplay_settings.m_SkipIPL; - StartUp.m_bt_passthrough_enabled = false; if (netplay_settings.m_HostInputAuthority && !netplay_settings.m_IsHosting) config_cache.bSetEmulationSpeed = true; } diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index bf85875532..fdbe76d924 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -298,4 +298,13 @@ const Info MAIN_DEBUG_JIT_BRANCH_OFF{{System::Main, "Debug", "JitBranchOff const Info MAIN_DEBUG_JIT_REGISTER_CACHE_OFF{{System::Main, "Debug", "JitRegisterCacheOff"}, false}; +// Main.BluetoothPassthrough + +const Info MAIN_BLUETOOTH_PASSTHROUGH_ENABLED{ + {System::Main, "BluetoothPassthrough", "Enabled"}, false}; +const Info MAIN_BLUETOOTH_PASSTHROUGH_VID{{System::Main, "BluetoothPassthrough", "VID"}, -1}; +const Info MAIN_BLUETOOTH_PASSTHROUGH_PID{{System::Main, "BluetoothPassthrough", "PID"}, -1}; +const Info MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS{ + {System::Main, "BluetoothPassthrough", "LinkKeys"}, ""}; + } // namespace Config diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index f3cd127231..87025dfc77 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -250,4 +250,11 @@ extern const Info MAIN_DEBUG_JIT_SYSTEM_REGISTERS_OFF; extern const Info MAIN_DEBUG_JIT_BRANCH_OFF; extern const Info MAIN_DEBUG_JIT_REGISTER_CACHE_OFF; +// Main.BluetoothPassthrough + +extern const Info MAIN_BLUETOOTH_PASSTHROUGH_ENABLED; +extern const Info MAIN_BLUETOOTH_PASSTHROUGH_VID; +extern const Info MAIN_BLUETOOTH_PASSTHROUGH_PID; +extern const Info MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS; + } // namespace Config diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 7acb9d625d..1ea385fddc 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -27,7 +27,8 @@ bool IsSettingSaveable(const Config::Location& config_location) { for (const std::string_view section : {"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons", - "DSP", "GameList", "FifoPlayer", "AutoUpdate", "Movie", "Input", "Debug"}) + "DSP", "GameList", "FifoPlayer", "AutoUpdate", "Movie", "Input", "Debug", + "BluetoothPassthrough"}) { if (config_location.section == section) return true; diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index c2eb753e28..128eba8ad7 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -93,6 +93,8 @@ public: layer->Set(Config::SESSION_USE_FMA, m_settings.m_UseFMA); + layer->Set(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED, false); + if (m_settings.m_StrictSettingsSync) { layer->Set(Config::GFX_HACK_VERTEX_ROUDING, m_settings.m_VertexRounding); diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 7ad9458b81..2d44656ae6 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -91,7 +91,6 @@ void SConfig::SaveSettings() SaveGeneralSettings(ini); SaveInterfaceSettings(ini); SaveCoreSettings(ini); - SaveBluetoothPassthroughSettings(ini); SaveUSBPassthroughSettings(ini); ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); @@ -196,16 +195,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("CustomRTCValue", m_customRTCValue); } -void SConfig::SaveBluetoothPassthroughSettings(IniFile& ini) -{ - IniFile::Section* section = ini.GetOrCreateSection("BluetoothPassthrough"); - - section->Set("Enabled", m_bt_passthrough_enabled); - section->Set("VID", m_bt_passthrough_vid); - section->Set("PID", m_bt_passthrough_pid); - section->Set("LinkKeys", m_bt_passthrough_link_keys); -} - void SConfig::SaveUSBPassthroughSettings(IniFile& ini) { IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough"); @@ -231,7 +220,6 @@ void SConfig::LoadSettings() LoadGeneralSettings(ini); LoadInterfaceSettings(ini); LoadCoreSettings(ini); - LoadBluetoothPassthroughSettings(ini); LoadUSBPassthroughSettings(ini); } @@ -341,16 +329,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("CustomRTCValue", &m_customRTCValue, 946684800); } -void SConfig::LoadBluetoothPassthroughSettings(IniFile& ini) -{ - IniFile::Section* section = ini.GetOrCreateSection("BluetoothPassthrough"); - - section->Get("Enabled", &m_bt_passthrough_enabled, false); - section->Get("VID", &m_bt_passthrough_vid, -1); - section->Get("PID", &m_bt_passthrough_pid, -1); - section->Get("LinkKeys", &m_bt_passthrough_link_keys, ""); -} - void SConfig::LoadUSBPassthroughSettings(IniFile& ini) { IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough"); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 3219b01d7c..e206dba83e 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -128,12 +128,6 @@ struct SConfig bool bLockCursor = false; std::string theme_name; - // Bluetooth passthrough mode settings - bool m_bt_passthrough_enabled = false; - int m_bt_passthrough_pid = -1; - int m_bt_passthrough_vid = -1; - std::string m_bt_passthrough_link_keys; - // USB passthrough settings std::set> m_usb_passthrough_devices; bool IsUSBDeviceWhitelisted(std::pair vid_pid) const; @@ -243,13 +237,11 @@ private: void SaveGeneralSettings(IniFile& ini); void SaveInterfaceSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini); - void SaveBluetoothPassthroughSettings(IniFile& ini); void SaveUSBPassthroughSettings(IniFile& ini); void LoadGeneralSettings(IniFile& ini); void LoadInterfaceSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini); - void LoadBluetoothPassthroughSettings(IniFile& ini); void LoadUSBPassthroughSettings(IniFile& ini); void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id, diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 6419d13e61..99cd305082 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -486,7 +486,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi // Load and Init Wiimotes - only if we are booting in Wii mode bool init_wiimotes = false; - if (core_parameter.bWii && !SConfig::GetInstance().m_bt_passthrough_enabled) + if (core_parameter.bWii && !Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) { if (init_controllers) { diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index b3c5b1f203..06ae8e790a 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -681,7 +681,7 @@ void WiimoteScanner::ThreadFunc() { // We don't want any remotes in passthrough mode or running in GC mode. const bool core_running = Core::GetState() != Core::State::Uninitialized; - if (SConfig::GetInstance().m_bt_passthrough_enabled || + if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED) || (core_running && !SConfig::GetInstance().bWii)) continue; diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 53c99ddaf9..6fedd7ebc4 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -515,7 +515,7 @@ void Kernel::AddStaticDevices() // OH1 (Bluetooth) AddDevice(std::make_unique(*this, "/dev/usb/oh1")); - if (!SConfig::GetInstance().m_bt_passthrough_enabled) + if (!Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) AddDevice(std::make_unique(*this, "/dev/usb/oh1/57e/305")); else AddDevice(std::make_unique(*this, "/dev/usb/oh1/57e/305")); diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index 10aa72c3b5..3144580212 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -24,7 +24,7 @@ #include "Common/Network.h" #include "Common/StringUtil.h" #include "Common/Swap.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/HW/Memmap.h" #include "Core/IOS/Device.h" @@ -38,8 +38,8 @@ constexpr u8 REQUEST_TYPE = static_cast(LIBUSB_ENDPOINT_OUT) | static bool IsWantedDevice(const libusb_device_descriptor& descriptor) { - const int vid = SConfig::GetInstance().m_bt_passthrough_vid; - const int pid = SConfig::GetInstance().m_bt_passthrough_pid; + const int vid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID); + const int pid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID); if (vid == -1 || pid == -1) return true; return descriptor.idVendor == vid && descriptor.idProduct == pid; @@ -49,9 +49,11 @@ static bool IsBluetoothDevice(const libusb_interface_descriptor& descriptor) { constexpr u8 SUBCLASS = 0x01; constexpr u8 PROTOCOL_BLUETOOTH = 0x01; - if (SConfig::GetInstance().m_bt_passthrough_vid != -1 && - SConfig::GetInstance().m_bt_passthrough_pid != -1) + if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID) != -1 && + Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID) != -1) + { return true; + } return descriptor.bInterfaceClass == LIBUSB_CLASS_WIRELESS && descriptor.bInterfaceSubClass == SUBCLASS && descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH; @@ -499,7 +501,7 @@ void BluetoothRealDevice::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl) void BluetoothRealDevice::LoadLinkKeys() { - const std::string& entries = SConfig::GetInstance().m_bt_passthrough_link_keys; + std::string entries = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS); if (entries.empty()) return; for (const auto& pair : SplitString(entries, ',')) @@ -556,7 +558,7 @@ void BluetoothRealDevice::SaveLinkKeys() std::string config_string = oss.str(); if (!config_string.empty()) config_string.pop_back(); - SConfig::GetInstance().m_bt_passthrough_link_keys = config_string; + Config::SetBase(Config::MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS, config_string); } bool BluetoothRealDevice::OpenDevice(libusb_device* device) diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp index 14dbaf5bed..8bb48ad6b1 100644 --- a/Source/Core/Core/WiiUtils.cpp +++ b/Source/Core/Core/WiiUtils.cpp @@ -29,7 +29,7 @@ #include "Common/StringUtil.h" #include "Common/Swap.h" #include "Core/CommonTitles.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/IOS/Device.h" #include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/Formats.h" @@ -967,14 +967,14 @@ static std::shared_ptr GetBluetoothDevice() std::shared_ptr GetBluetoothEmuDevice() { - if (SConfig::GetInstance().m_bt_passthrough_enabled) + if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) return nullptr; return std::static_pointer_cast(GetBluetoothDevice()); } std::shared_ptr GetBluetoothRealDevice() { - if (!SConfig::GetInstance().m_bt_passthrough_enabled) + if (!Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) return nullptr; return std::static_pointer_cast(GetBluetoothDevice()); } diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp index fbfb853d7f..70a65f5752 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp @@ -17,6 +17,7 @@ #include #include +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/Wiimote.h" @@ -308,7 +309,7 @@ void WiimoteControllersWidget::LoadSettings() m_wiimote_ciface->setChecked(SConfig::GetInstance().connect_wiimotes_for_ciface); m_wiimote_continuous_scanning->setChecked(SConfig::GetInstance().m_WiimoteContinuousScanning); - if (SConfig::GetInstance().m_bt_passthrough_enabled) + if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) m_wiimote_passthrough->setChecked(true); else m_wiimote_emu->setChecked(true); @@ -321,7 +322,8 @@ void WiimoteControllersWidget::SaveSettings() SConfig::GetInstance().m_WiimoteEnableSpeaker = m_wiimote_speaker_data->isChecked(); SConfig::GetInstance().connect_wiimotes_for_ciface = m_wiimote_ciface->isChecked(); SConfig::GetInstance().m_WiimoteContinuousScanning = m_wiimote_continuous_scanning->isChecked(); - SConfig::GetInstance().m_bt_passthrough_enabled = m_wiimote_passthrough->isChecked(); + Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED, + m_wiimote_passthrough->isChecked()); WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, m_wiimote_real_balance_board->isChecked() ? WiimoteSource::Real :