Config: Port BluetoothPassthrough settings to new config system.

This commit is contained in:
Admiral H. Curtiss 2021-12-29 17:20:32 +01:00
parent 5c6dc5002f
commit 526887899e
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
13 changed files with 39 additions and 50 deletions

View File

@ -91,7 +91,6 @@ private:
int iSelectedLanguage = 0; int iSelectedLanguage = 0;
PowerPC::CPUCore cpu_core = PowerPC::CPUCore::Interpreter; PowerPC::CPUCore cpu_core = PowerPC::CPUCore::Interpreter;
float m_EmulationSpeed = 0; float m_EmulationSpeed = 0;
bool m_bt_passthrough_enabled = false;
std::string m_strGPUDeterminismMode; std::string m_strGPUDeterminismMode;
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource{}; std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource{};
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads{}; std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads{};
@ -121,7 +120,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
cpu_core = config.cpu_core; cpu_core = config.cpu_core;
m_EmulationSpeed = config.m_EmulationSpeed; m_EmulationSpeed = config.m_EmulationSpeed;
m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; m_strGPUDeterminismMode = config.m_strGPUDeterminismMode;
m_bt_passthrough_enabled = config.m_bt_passthrough_enabled;
for (int i = 0; i != MAX_BBMOTES; ++i) for (int i = 0; i != MAX_BBMOTES; ++i)
iWiimoteSource[i] = WiimoteCommon::GetSource(i); iWiimoteSource[i] = WiimoteCommon::GetSource(i);
@ -189,7 +187,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
} }
config->m_strGPUDeterminismMode = m_strGPUDeterminismMode; config->m_strGPUDeterminismMode = m_strGPUDeterminismMode;
config->m_bt_passthrough_enabled = m_bt_passthrough_enabled;
} }
static ConfigCache config_cache; static ConfigCache config_cache;
@ -357,7 +354,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
StartUp.bMMU = netplay_settings.m_MMU; StartUp.bMMU = netplay_settings.m_MMU;
StartUp.bFastmem = netplay_settings.m_Fastmem; StartUp.bFastmem = netplay_settings.m_Fastmem;
StartUp.bHLE_BS2 = netplay_settings.m_SkipIPL; StartUp.bHLE_BS2 = netplay_settings.m_SkipIPL;
StartUp.m_bt_passthrough_enabled = false;
if (netplay_settings.m_HostInputAuthority && !netplay_settings.m_IsHosting) if (netplay_settings.m_HostInputAuthority && !netplay_settings.m_IsHosting)
config_cache.bSetEmulationSpeed = true; config_cache.bSetEmulationSpeed = true;
} }

View File

@ -298,4 +298,13 @@ const Info<bool> MAIN_DEBUG_JIT_BRANCH_OFF{{System::Main, "Debug", "JitBranchOff
const Info<bool> MAIN_DEBUG_JIT_REGISTER_CACHE_OFF{{System::Main, "Debug", "JitRegisterCacheOff"}, const Info<bool> MAIN_DEBUG_JIT_REGISTER_CACHE_OFF{{System::Main, "Debug", "JitRegisterCacheOff"},
false}; false};
// Main.BluetoothPassthrough
const Info<bool> MAIN_BLUETOOTH_PASSTHROUGH_ENABLED{
{System::Main, "BluetoothPassthrough", "Enabled"}, false};
const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_VID{{System::Main, "BluetoothPassthrough", "VID"}, -1};
const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_PID{{System::Main, "BluetoothPassthrough", "PID"}, -1};
const Info<std::string> MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS{
{System::Main, "BluetoothPassthrough", "LinkKeys"}, ""};
} // namespace Config } // namespace Config

View File

@ -250,4 +250,11 @@ extern const Info<bool> MAIN_DEBUG_JIT_SYSTEM_REGISTERS_OFF;
extern const Info<bool> MAIN_DEBUG_JIT_BRANCH_OFF; extern const Info<bool> MAIN_DEBUG_JIT_BRANCH_OFF;
extern const Info<bool> MAIN_DEBUG_JIT_REGISTER_CACHE_OFF; extern const Info<bool> MAIN_DEBUG_JIT_REGISTER_CACHE_OFF;
// Main.BluetoothPassthrough
extern const Info<bool> MAIN_BLUETOOTH_PASSTHROUGH_ENABLED;
extern const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_VID;
extern const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_PID;
extern const Info<std::string> MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS;
} // namespace Config } // namespace Config

View File

@ -27,7 +27,8 @@ bool IsSettingSaveable(const Config::Location& config_location)
{ {
for (const std::string_view section : for (const std::string_view section :
{"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons", {"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) if (config_location.section == section)
return true; return true;

View File

@ -93,6 +93,8 @@ public:
layer->Set(Config::SESSION_USE_FMA, m_settings.m_UseFMA); layer->Set(Config::SESSION_USE_FMA, m_settings.m_UseFMA);
layer->Set(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED, false);
if (m_settings.m_StrictSettingsSync) if (m_settings.m_StrictSettingsSync)
{ {
layer->Set(Config::GFX_HACK_VERTEX_ROUDING, m_settings.m_VertexRounding); layer->Set(Config::GFX_HACK_VERTEX_ROUDING, m_settings.m_VertexRounding);

View File

@ -91,7 +91,6 @@ void SConfig::SaveSettings()
SaveGeneralSettings(ini); SaveGeneralSettings(ini);
SaveInterfaceSettings(ini); SaveInterfaceSettings(ini);
SaveCoreSettings(ini); SaveCoreSettings(ini);
SaveBluetoothPassthroughSettings(ini);
SaveUSBPassthroughSettings(ini); SaveUSBPassthroughSettings(ini);
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
@ -196,16 +195,6 @@ void SConfig::SaveCoreSettings(IniFile& ini)
core->Set("CustomRTCValue", m_customRTCValue); 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) void SConfig::SaveUSBPassthroughSettings(IniFile& ini)
{ {
IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough"); IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough");
@ -231,7 +220,6 @@ void SConfig::LoadSettings()
LoadGeneralSettings(ini); LoadGeneralSettings(ini);
LoadInterfaceSettings(ini); LoadInterfaceSettings(ini);
LoadCoreSettings(ini); LoadCoreSettings(ini);
LoadBluetoothPassthroughSettings(ini);
LoadUSBPassthroughSettings(ini); LoadUSBPassthroughSettings(ini);
} }
@ -341,16 +329,6 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("CustomRTCValue", &m_customRTCValue, 946684800); 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) void SConfig::LoadUSBPassthroughSettings(IniFile& ini)
{ {
IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough"); IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough");

View File

@ -128,12 +128,6 @@ struct SConfig
bool bLockCursor = false; bool bLockCursor = false;
std::string theme_name; 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 // USB passthrough settings
std::set<std::pair<u16, u16>> m_usb_passthrough_devices; std::set<std::pair<u16, u16>> m_usb_passthrough_devices;
bool IsUSBDeviceWhitelisted(std::pair<u16, u16> vid_pid) const; bool IsUSBDeviceWhitelisted(std::pair<u16, u16> vid_pid) const;
@ -243,13 +237,11 @@ private:
void SaveGeneralSettings(IniFile& ini); void SaveGeneralSettings(IniFile& ini);
void SaveInterfaceSettings(IniFile& ini); void SaveInterfaceSettings(IniFile& ini);
void SaveCoreSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini);
void SaveBluetoothPassthroughSettings(IniFile& ini);
void SaveUSBPassthroughSettings(IniFile& ini); void SaveUSBPassthroughSettings(IniFile& ini);
void LoadGeneralSettings(IniFile& ini); void LoadGeneralSettings(IniFile& ini);
void LoadInterfaceSettings(IniFile& ini); void LoadInterfaceSettings(IniFile& ini);
void LoadCoreSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini);
void LoadBluetoothPassthroughSettings(IniFile& ini);
void LoadUSBPassthroughSettings(IniFile& ini); void LoadUSBPassthroughSettings(IniFile& ini);
void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id, void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,

View File

@ -486,7 +486,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
// Load and Init Wiimotes - only if we are booting in Wii mode // Load and Init Wiimotes - only if we are booting in Wii mode
bool init_wiimotes = false; 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) if (init_controllers)
{ {

View File

@ -681,7 +681,7 @@ void WiimoteScanner::ThreadFunc()
{ {
// We don't want any remotes in passthrough mode or running in GC mode. // We don't want any remotes in passthrough mode or running in GC mode.
const bool core_running = Core::GetState() != Core::State::Uninitialized; 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)) (core_running && !SConfig::GetInstance().bWii))
continue; continue;

View File

@ -515,7 +515,7 @@ void Kernel::AddStaticDevices()
// OH1 (Bluetooth) // OH1 (Bluetooth)
AddDevice(std::make_unique<DeviceStub>(*this, "/dev/usb/oh1")); AddDevice(std::make_unique<DeviceStub>(*this, "/dev/usb/oh1"));
if (!SConfig::GetInstance().m_bt_passthrough_enabled) if (!Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED))
AddDevice(std::make_unique<BluetoothEmuDevice>(*this, "/dev/usb/oh1/57e/305")); AddDevice(std::make_unique<BluetoothEmuDevice>(*this, "/dev/usb/oh1/57e/305"));
else else
AddDevice(std::make_unique<BluetoothRealDevice>(*this, "/dev/usb/oh1/57e/305")); AddDevice(std::make_unique<BluetoothRealDevice>(*this, "/dev/usb/oh1/57e/305"));

View File

@ -24,7 +24,7 @@
#include "Common/Network.h" #include "Common/Network.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/Swap.h" #include "Common/Swap.h"
#include "Core/ConfigManager.h" #include "Core/Config/MainSettings.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
#include "Core/IOS/Device.h" #include "Core/IOS/Device.h"
@ -38,8 +38,8 @@ constexpr u8 REQUEST_TYPE = static_cast<u8>(LIBUSB_ENDPOINT_OUT) |
static bool IsWantedDevice(const libusb_device_descriptor& descriptor) static bool IsWantedDevice(const libusb_device_descriptor& descriptor)
{ {
const int vid = SConfig::GetInstance().m_bt_passthrough_vid; const int vid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID);
const int pid = SConfig::GetInstance().m_bt_passthrough_pid; const int pid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID);
if (vid == -1 || pid == -1) if (vid == -1 || pid == -1)
return true; return true;
return descriptor.idVendor == vid && descriptor.idProduct == pid; 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 SUBCLASS = 0x01;
constexpr u8 PROTOCOL_BLUETOOTH = 0x01; constexpr u8 PROTOCOL_BLUETOOTH = 0x01;
if (SConfig::GetInstance().m_bt_passthrough_vid != -1 && if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID) != -1 &&
SConfig::GetInstance().m_bt_passthrough_pid != -1) Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID) != -1)
{
return true; return true;
}
return descriptor.bInterfaceClass == LIBUSB_CLASS_WIRELESS && return descriptor.bInterfaceClass == LIBUSB_CLASS_WIRELESS &&
descriptor.bInterfaceSubClass == SUBCLASS && descriptor.bInterfaceSubClass == SUBCLASS &&
descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH; descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH;
@ -499,7 +501,7 @@ void BluetoothRealDevice::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
void BluetoothRealDevice::LoadLinkKeys() 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()) if (entries.empty())
return; return;
for (const auto& pair : SplitString(entries, ',')) for (const auto& pair : SplitString(entries, ','))
@ -556,7 +558,7 @@ void BluetoothRealDevice::SaveLinkKeys()
std::string config_string = oss.str(); std::string config_string = oss.str();
if (!config_string.empty()) if (!config_string.empty())
config_string.pop_back(); 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) bool BluetoothRealDevice::OpenDevice(libusb_device* device)

View File

@ -29,7 +29,7 @@
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/Swap.h" #include "Common/Swap.h"
#include "Core/CommonTitles.h" #include "Core/CommonTitles.h"
#include "Core/ConfigManager.h" #include "Core/Config/MainSettings.h"
#include "Core/IOS/Device.h" #include "Core/IOS/Device.h"
#include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/ES.h"
#include "Core/IOS/ES/Formats.h" #include "Core/IOS/ES/Formats.h"
@ -967,14 +967,14 @@ static std::shared_ptr<IOS::HLE::Device> GetBluetoothDevice()
std::shared_ptr<IOS::HLE::BluetoothEmuDevice> GetBluetoothEmuDevice() std::shared_ptr<IOS::HLE::BluetoothEmuDevice> GetBluetoothEmuDevice()
{ {
if (SConfig::GetInstance().m_bt_passthrough_enabled) if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED))
return nullptr; return nullptr;
return std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(GetBluetoothDevice()); return std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(GetBluetoothDevice());
} }
std::shared_ptr<IOS::HLE::BluetoothRealDevice> GetBluetoothRealDevice() std::shared_ptr<IOS::HLE::BluetoothRealDevice> GetBluetoothRealDevice()
{ {
if (!SConfig::GetInstance().m_bt_passthrough_enabled) if (!Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED))
return nullptr; return nullptr;
return std::static_pointer_cast<IOS::HLE::BluetoothRealDevice>(GetBluetoothDevice()); return std::static_pointer_cast<IOS::HLE::BluetoothRealDevice>(GetBluetoothDevice());
} }

View File

@ -17,6 +17,7 @@
#include <map> #include <map>
#include <optional> #include <optional>
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/HW/Wiimote.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_ciface->setChecked(SConfig::GetInstance().connect_wiimotes_for_ciface);
m_wiimote_continuous_scanning->setChecked(SConfig::GetInstance().m_WiimoteContinuousScanning); 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); m_wiimote_passthrough->setChecked(true);
else else
m_wiimote_emu->setChecked(true); m_wiimote_emu->setChecked(true);
@ -321,7 +322,8 @@ void WiimoteControllersWidget::SaveSettings()
SConfig::GetInstance().m_WiimoteEnableSpeaker = m_wiimote_speaker_data->isChecked(); SConfig::GetInstance().m_WiimoteEnableSpeaker = m_wiimote_speaker_data->isChecked();
SConfig::GetInstance().connect_wiimotes_for_ciface = m_wiimote_ciface->isChecked(); SConfig::GetInstance().connect_wiimotes_for_ciface = m_wiimote_ciface->isChecked();
SConfig::GetInstance().m_WiimoteContinuousScanning = m_wiimote_continuous_scanning->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() ? WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, m_wiimote_real_balance_board->isChecked() ?
WiimoteSource::Real : WiimoteSource::Real :