Config: Port GC Adapter settings to new config system.
This commit is contained in:
parent
e08171fa24
commit
0bfffe4095
|
@ -69,14 +69,26 @@ Info<u32> GetInfoForSIDevice(u32 channel)
|
|||
SerialInterface::SIDEVICE_NONE)};
|
||||
}
|
||||
|
||||
Info<bool> GetInfoForAdapterRumble(u32 channel)
|
||||
const Info<bool>& GetInfoForAdapterRumble(int channel)
|
||||
{
|
||||
return {{System::Main, "Core", fmt::format("AdapterRumble{}", channel)}, true};
|
||||
static const std::array<const Info<bool>, 4> infos{
|
||||
Info<bool>{{System::Main, "Core", "AdapterRumble0"}, true},
|
||||
Info<bool>{{System::Main, "Core", "AdapterRumble1"}, true},
|
||||
Info<bool>{{System::Main, "Core", "AdapterRumble2"}, true},
|
||||
Info<bool>{{System::Main, "Core", "AdapterRumble3"}, true},
|
||||
};
|
||||
return infos[channel];
|
||||
}
|
||||
|
||||
Info<bool> GetInfoForSimulateKonga(u32 channel)
|
||||
const Info<bool>& GetInfoForSimulateKonga(int channel)
|
||||
{
|
||||
return {{System::Main, "Core", fmt::format("SimulateKonga{}", channel)}, false};
|
||||
static const std::array<const Info<bool>, 4> infos{
|
||||
Info<bool>{{System::Main, "Core", "SimulateKonga0"}, false},
|
||||
Info<bool>{{System::Main, "Core", "SimulateKonga1"}, false},
|
||||
Info<bool>{{System::Main, "Core", "SimulateKonga2"}, false},
|
||||
Info<bool>{{System::Main, "Core", "SimulateKonga3"}, false},
|
||||
};
|
||||
return infos[channel];
|
||||
}
|
||||
|
||||
const Info<bool> MAIN_WII_SD_CARD{{System::Main, "Core", "WiiSDCard"}, true};
|
||||
|
|
|
@ -66,8 +66,8 @@ extern const Info<std::string> MAIN_BBA_MAC;
|
|||
extern const Info<std::string> MAIN_BBA_XLINK_IP;
|
||||
extern const Info<bool> MAIN_BBA_XLINK_CHAT_OSD;
|
||||
Info<u32> GetInfoForSIDevice(u32 channel);
|
||||
Info<bool> GetInfoForAdapterRumble(u32 channel);
|
||||
Info<bool> GetInfoForSimulateKonga(u32 channel);
|
||||
const Info<bool>& GetInfoForAdapterRumble(int channel);
|
||||
const Info<bool>& GetInfoForSimulateKonga(int channel);
|
||||
extern const Info<bool> MAIN_WII_SD_CARD;
|
||||
extern const Info<bool> MAIN_WII_KEYBOARD;
|
||||
extern const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING;
|
||||
|
|
|
@ -48,7 +48,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
|||
}
|
||||
}
|
||||
|
||||
static constexpr auto s_setting_saveable = {
|
||||
static const auto s_setting_saveable = {
|
||||
// Main.Core
|
||||
|
||||
&Config::MAIN_DEFAULT_ISO.GetLocation(),
|
||||
|
@ -89,6 +89,14 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
|||
&Config::MAIN_LOW_DCBZ_HACK.GetLocation(),
|
||||
&Config::MAIN_FPRF.GetLocation(),
|
||||
&Config::MAIN_ACCURATE_NANS.GetLocation(),
|
||||
&Config::GetInfoForAdapterRumble(0).GetLocation(),
|
||||
&Config::GetInfoForAdapterRumble(1).GetLocation(),
|
||||
&Config::GetInfoForAdapterRumble(2).GetLocation(),
|
||||
&Config::GetInfoForAdapterRumble(3).GetLocation(),
|
||||
&Config::GetInfoForSimulateKonga(0).GetLocation(),
|
||||
&Config::GetInfoForSimulateKonga(1).GetLocation(),
|
||||
&Config::GetInfoForSimulateKonga(2).GetLocation(),
|
||||
&Config::GetInfoForSimulateKonga(3).GetLocation(),
|
||||
|
||||
// UI.General
|
||||
|
||||
|
|
|
@ -113,8 +113,6 @@ void SConfig::SaveCoreSettings(IniFile& ini)
|
|||
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||
{
|
||||
core->Set(fmt::format("SIDevice{}", i), m_SIDevice[i]);
|
||||
core->Set(fmt::format("AdapterRumble{}", i), m_AdapterRumble[i]);
|
||||
core->Set(fmt::format("SimulateKonga{}", i), m_AdapterKonga[i]);
|
||||
}
|
||||
core->Set("WiiSDCard", m_WiiSDCard);
|
||||
core->Set("WiiKeyboard", m_WiiKeyboard);
|
||||
|
@ -155,8 +153,6 @@ void SConfig::LoadCoreSettings(IniFile& ini)
|
|||
{
|
||||
core->Get(fmt::format("SIDevice{}", i), &m_SIDevice[i],
|
||||
(i == 0) ? SerialInterface::SIDEVICE_GC_CONTROLLER : SerialInterface::SIDEVICE_NONE);
|
||||
core->Get(fmt::format("AdapterRumble{}", i), &m_AdapterRumble[i], true);
|
||||
core->Get(fmt::format("SimulateKonga{}", i), &m_AdapterKonga[i], false);
|
||||
}
|
||||
core->Get("WiiSDCard", &m_WiiSDCard, true);
|
||||
core->Get("WiiKeyboard", &m_WiiKeyboard, false);
|
||||
|
|
|
@ -151,10 +151,6 @@ struct SConfig
|
|||
|
||||
float m_EmulationSpeed;
|
||||
|
||||
// Input settings
|
||||
bool m_AdapterRumble[4];
|
||||
bool m_AdapterKonga[4];
|
||||
|
||||
SConfig(const SConfig&) = delete;
|
||||
SConfig& operator=(const SConfig&) = delete;
|
||||
SConfig(SConfig&&) = delete;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Swap.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
|
@ -24,7 +25,7 @@ CSIDevice_GCAdapter::CSIDevice_GCAdapter(SIDevices device, int device_number)
|
|||
// get the correct pad number that should rumble locally when using netplay
|
||||
const int pad_num = NetPlay_InGamePadToLocalPad(m_device_number);
|
||||
if (pad_num < 4)
|
||||
m_simulate_konga = SConfig::GetInstance().m_AdapterKonga[pad_num];
|
||||
m_simulate_konga = Config::Get(Config::GetInfoForSimulateKonga(pad_num));
|
||||
}
|
||||
|
||||
GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||
|
||||
|
@ -86,12 +87,12 @@ void GCPadWiiUConfigDialog::UpdateAdapterStatus()
|
|||
|
||||
void GCPadWiiUConfigDialog::LoadSettings()
|
||||
{
|
||||
m_rumble->setChecked(SConfig::GetInstance().m_AdapterRumble[m_port]);
|
||||
m_simulate_bongos->setChecked(SConfig::GetInstance().m_AdapterKonga[m_port]);
|
||||
m_rumble->setChecked(Config::Get(Config::GetInfoForAdapterRumble(m_port)));
|
||||
m_simulate_bongos->setChecked(Config::Get(Config::GetInfoForSimulateKonga(m_port)));
|
||||
}
|
||||
|
||||
void GCPadWiiUConfigDialog::SaveSettings()
|
||||
{
|
||||
SConfig::GetInstance().m_AdapterRumble[m_port] = m_rumble->isChecked();
|
||||
SConfig::GetInstance().m_AdapterKonga[m_port] = m_simulate_bongos->isChecked();
|
||||
Config::SetBaseOrCurrent(Config::GetInfoForAdapterRumble(m_port), m_rumble->isChecked());
|
||||
Config::SetBaseOrCurrent(Config::GetInfoForSimulateKonga(m_port), m_simulate_bongos->isChecked());
|
||||
}
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <libusb.h>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
#include "Common/Event.h"
|
||||
#include "Common/Flag.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/ScopeGuard.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
|
@ -79,6 +82,9 @@ static u8 s_endpoint_out = 0;
|
|||
|
||||
static u64 s_last_init = 0;
|
||||
|
||||
static std::optional<size_t> s_config_callback_id = std::nullopt;
|
||||
static std::array<bool, SerialInterface::MAX_SI_CHANNELS> s_config_rumble_enabled{};
|
||||
|
||||
static void Read()
|
||||
{
|
||||
int payload_size = 0;
|
||||
|
@ -196,6 +202,12 @@ void SetAdapterCallback(std::function<void()> func)
|
|||
s_detect_callback = func;
|
||||
}
|
||||
|
||||
static void RefreshConfig()
|
||||
{
|
||||
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||
s_config_rumble_enabled[i] = Config::Get(Config::GetInfoForAdapterRumble(i));
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
if (s_handle != nullptr)
|
||||
|
@ -211,6 +223,10 @@ void Init()
|
|||
|
||||
s_status = NO_ADAPTER_DETECTED;
|
||||
|
||||
if (!s_config_callback_id)
|
||||
s_config_callback_id = Config::AddConfigChangedCallback(RefreshConfig);
|
||||
RefreshConfig();
|
||||
|
||||
if (UseAdapter())
|
||||
StartScanThread();
|
||||
}
|
||||
|
@ -382,6 +398,12 @@ void Shutdown()
|
|||
Reset();
|
||||
|
||||
s_status = NO_ADAPTER_DETECTED;
|
||||
|
||||
if (s_config_callback_id)
|
||||
{
|
||||
Config::RemoveConfigChangedCallback(*s_config_callback_id);
|
||||
s_config_callback_id = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
static void Reset()
|
||||
|
@ -557,7 +579,7 @@ static void ResetRumbleLockNeeded()
|
|||
|
||||
void Output(int chan, u8 rumble_command)
|
||||
{
|
||||
if (s_handle == nullptr || !UseAdapter() || !SConfig::GetInstance().m_AdapterRumble[chan])
|
||||
if (s_handle == nullptr || !UseAdapter() || !s_config_rumble_enabled[chan])
|
||||
return;
|
||||
|
||||
// Skip over rumble commands if it has not changed or the controller is wireless
|
||||
|
|
Loading…
Reference in New Issue