Config: Port EXI device settings to new config system.

This commit is contained in:
Admiral H. Curtiss 2022-01-06 07:17:29 +01:00
parent 193ca92cb8
commit a0a0bfc5ca
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
12 changed files with 60 additions and 71 deletions

View File

@ -67,7 +67,6 @@ public:
bool bSetVolume = false;
std::array<bool, MAX_BBMOTES> bSetWiimoteSource{};
std::array<bool, SerialInterface::MAX_SI_CHANNELS> bSetPads{};
std::array<bool, ExpansionInterface::MAX_EXI_CHANNELS> bSetEXIDevice{};
private:
bool valid = false;
@ -79,7 +78,6 @@ private:
float fSyncGpuOverclock = 0;
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource{};
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads{};
std::array<ExpansionInterface::TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice{};
};
void ConfigCache::SaveConfig(const SConfig& config)
@ -97,12 +95,10 @@ void ConfigCache::SaveConfig(const SConfig& config)
iWiimoteSource[i] = WiimoteCommon::GetSource(i);
std::copy(std::begin(config.m_SIDevice), std::end(config.m_SIDevice), std::begin(Pads));
std::copy(std::begin(config.m_EXIDevice), std::end(config.m_EXIDevice), std::begin(m_EXIDevice));
bSetVolume = false;
bSetWiimoteSource.fill(false);
bSetPads.fill(false);
bSetEXIDevice.fill(false);
}
void ConfigCache::RestoreConfig(SConfig* config)
@ -135,12 +131,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
if (bSetPads[i])
config->m_SIDevice[i] = Pads[i];
}
for (unsigned int i = 0; i < ExpansionInterface::MAX_EXI_CHANNELS; ++i)
{
if (bSetEXIDevice[i])
config->m_EXIDevice[i] = m_EXIDevice[i];
}
}
static ConfigCache config_cache;
@ -237,12 +227,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
StartUp.bCPUThread = netplay_settings.m_CPUthread;
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
StartUp.m_EXIDevice[0] = netplay_settings.m_EXIDevice[0];
StartUp.m_EXIDevice[1] = netplay_settings.m_EXIDevice[1];
StartUp.m_EXIDevice[2] = netplay_settings.m_EXIDevice[2];
config_cache.bSetEXIDevice[0] = true;
config_cache.bSetEXIDevice[1] = true;
config_cache.bSetEXIDevice[2] = true;
StartUp.bSyncGPU = netplay_settings.m_SyncGPU;
StartUp.iSyncGpuMaxDistance = netplay_settings.m_SyncGpuMaxDistance;
StartUp.iSyncGpuMinDistance = netplay_settings.m_SyncGpuMinDistance;

View File

@ -54,11 +54,24 @@ const Info<std::string> MAIN_GCI_FOLDER_A_PATH_OVERRIDE{
{System::Main, "Core", "GCIFolderAPathOverride"}, ""};
const Info<std::string> MAIN_GCI_FOLDER_B_PATH_OVERRIDE{
{System::Main, "Core", "GCIFolderBPathOverride"}, ""};
const Info<int> MAIN_SLOT_A{{System::Main, "Core", "SlotA"},
ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER};
const Info<int> MAIN_SLOT_B{{System::Main, "Core", "SlotB"}, ExpansionInterface::EXIDEVICE_NONE};
const Info<int> MAIN_SERIAL_PORT_1{{System::Main, "Core", "SerialPort1"},
const Info<ExpansionInterface::TEXIDevices> MAIN_SLOT_A{
{System::Main, "Core", "SlotA"}, ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER};
const Info<ExpansionInterface::TEXIDevices> MAIN_SLOT_B{{System::Main, "Core", "SlotB"},
ExpansionInterface::EXIDEVICE_NONE};
const Info<ExpansionInterface::TEXIDevices> MAIN_SERIAL_PORT_1{
{System::Main, "Core", "SerialPort1"}, ExpansionInterface::EXIDEVICE_NONE};
const Info<ExpansionInterface::TEXIDevices>& GetInfoForEXIDevice(int channel)
{
static constexpr std::array<const Info<ExpansionInterface::TEXIDevices>*, 3> infos{
&MAIN_SLOT_A,
&MAIN_SLOT_B,
&MAIN_SERIAL_PORT_1,
};
return *infos[channel];
}
const Info<std::string> MAIN_BBA_MAC{{System::Main, "Core", "BBA_MAC"}, ""};
const Info<std::string> MAIN_BBA_XLINK_IP{{System::Main, "Core", "BBA_XLINK_IP"}, "127.0.0.1"};
const Info<bool> MAIN_BBA_XLINK_CHAT_OSD{{System::Main, "Core", "BBA_XLINK_CHAT_OSD"}, true};

View File

@ -31,6 +31,11 @@ namespace AudioCommon
enum class DPL2Quality;
}
namespace ExpansionInterface
{
enum TEXIDevices : int;
}
namespace Config
{
// Main.Core
@ -59,9 +64,10 @@ extern const Info<std::string> MAIN_AGP_CART_A_PATH;
extern const Info<std::string> MAIN_AGP_CART_B_PATH;
extern const Info<std::string> MAIN_GCI_FOLDER_A_PATH_OVERRIDE;
extern const Info<std::string> MAIN_GCI_FOLDER_B_PATH_OVERRIDE;
extern const Info<int> MAIN_SLOT_A;
extern const Info<int> MAIN_SLOT_B;
extern const Info<int> MAIN_SERIAL_PORT_1;
extern const Info<ExpansionInterface::TEXIDevices> MAIN_SLOT_A;
extern const Info<ExpansionInterface::TEXIDevices> MAIN_SLOT_B;
extern const Info<ExpansionInterface::TEXIDevices> MAIN_SERIAL_PORT_1;
const Info<ExpansionInterface::TEXIDevices>& GetInfoForEXIDevice(int channel);
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;

View File

@ -110,6 +110,9 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::MAIN_WIIMOTE_CONTINUOUS_SCANNING.GetLocation(),
&Config::MAIN_WIIMOTE_ENABLE_SPEAKER.GetLocation(),
&Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE.GetLocation(),
&Config::MAIN_SLOT_A.GetLocation(),
&Config::MAIN_SLOT_B.GetLocation(),
&Config::MAIN_SERIAL_PORT_1.GetLocation(),
// UI.General

View File

@ -37,9 +37,9 @@ public:
layer->Set(Config::MAIN_DSP_HLE, m_settings.m_DSPHLE);
layer->Set(Config::MAIN_OVERCLOCK_ENABLE, m_settings.m_OCEnable);
layer->Set(Config::MAIN_OVERCLOCK, m_settings.m_OCFactor);
layer->Set(Config::MAIN_SLOT_A, static_cast<int>(m_settings.m_EXIDevice[0]));
layer->Set(Config::MAIN_SLOT_B, static_cast<int>(m_settings.m_EXIDevice[1]));
layer->Set(Config::MAIN_SERIAL_PORT_1, static_cast<int>(m_settings.m_EXIDevice[2]));
layer->Set(Config::MAIN_SLOT_A, m_settings.m_EXIDevice[0]);
layer->Set(Config::MAIN_SLOT_B, m_settings.m_EXIDevice[1]);
layer->Set(Config::MAIN_SERIAL_PORT_1, m_settings.m_EXIDevice[2]);
layer->Set(Config::SESSION_SAVE_DATA_WRITABLE, m_settings.m_WriteToMemcard);
layer->Set(Config::MAIN_RAM_OVERRIDE_ENABLE, m_settings.m_RAMOverrideEnable);
layer->Set(Config::MAIN_MEM1_SIZE, m_settings.m_Mem1Size);

View File

@ -104,9 +104,6 @@ void SConfig::SaveCoreSettings(IniFile& ini)
core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance);
core->Set("SyncGpuMinDistance", iSyncGpuMinDistance);
core->Set("SyncGpuOverclock", fSyncGpuOverclock);
core->Set("SlotA", m_EXIDevice[0]);
core->Set("SlotB", m_EXIDevice[1]);
core->Set("SerialPort1", m_EXIDevice[2]);
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
{
core->Set(fmt::format("SIDevice{}", i), m_SIDevice[i]);
@ -130,9 +127,6 @@ void SConfig::LoadCoreSettings(IniFile& ini)
IniFile::Section* core = ini.GetOrCreateSection("Core");
core->Get("CPUThread", &bCPUThread, true);
core->Get("SlotA", (int*)&m_EXIDevice[0], ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER);
core->Get("SlotB", (int*)&m_EXIDevice[1], ExpansionInterface::EXIDEVICE_NONE);
core->Get("SerialPort1", (int*)&m_EXIDevice[2], ExpansionInterface::EXIDEVICE_NONE);
for (size_t i = 0; i < std::size(m_SIDevice); ++i)
{
core->Get(fmt::format("SIDevice{}", i), &m_SIDevice[i],

View File

@ -114,7 +114,6 @@ struct SConfig
static IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision);
static IniFile LoadGameIni(const std::string& id, std::optional<u16> revision);
ExpansionInterface::TEXIDevices m_EXIDevice[3];
SerialInterface::SIDevices m_SIDevice[4];
SConfig(const SConfig&) = delete;

View File

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
#include "Common/IniFile.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/CoreTiming.h"
#include "Core/HW/EXI/EXI_Channel.h"
@ -45,7 +46,7 @@ void AddMemoryCards(int i)
{
if (Movie::IsUsingMemcard(i))
{
if (SConfig::GetInstance().m_EXIDevice[i] == EXIDEVICE_MEMORYCARDFOLDER)
if (Config::Get(Config::GetInfoForEXIDevice(i)) == EXIDEVICE_MEMORYCARDFOLDER)
memorycard_device = EXIDEVICE_MEMORYCARDFOLDER;
else
memorycard_device = EXIDEVICE_MEMORYCARD;
@ -57,7 +58,7 @@ void AddMemoryCards(int i)
}
else
{
memorycard_device = SConfig::GetInstance().m_EXIDevice[i];
memorycard_device = Config::Get(Config::GetInfoForEXIDevice(i));
}
g_Channels[i]->AddDevice(memorycard_device, 0);
@ -101,7 +102,7 @@ void Init()
AddMemoryCards(i);
g_Channels[0]->AddDevice(EXIDEVICE_MASKROM, 1);
g_Channels[0]->AddDevice(SConfig::GetInstance().m_EXIDevice[2], 2); // Serial Port 1
g_Channels[0]->AddDevice(Config::Get(Config::MAIN_SERIAL_PORT_1), 2);
g_Channels[2]->AddDevice(EXIDEVICE_AD16, 0);
changeDevice = CoreTiming::RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback);

View File

@ -1435,14 +1435,12 @@ void SetGraphicsConfig()
// NOTE: EmuThread / Host Thread
void GetSettings()
{
const bool slot_a_has_raw_memcard =
SConfig::GetInstance().m_EXIDevice[0] == ExpansionInterface::EXIDEVICE_MEMORYCARD;
const bool slot_a_has_gci_folder =
SConfig::GetInstance().m_EXIDevice[0] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER;
const bool slot_b_has_raw_memcard =
SConfig::GetInstance().m_EXIDevice[1] == ExpansionInterface::EXIDEVICE_MEMORYCARD;
const bool slot_b_has_gci_folder =
SConfig::GetInstance().m_EXIDevice[1] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER;
const ExpansionInterface::TEXIDevices slot_a_type = Config::Get(Config::MAIN_SLOT_A);
const ExpansionInterface::TEXIDevices slot_b_type = Config::Get(Config::MAIN_SLOT_B);
const bool slot_a_has_raw_memcard = slot_a_type == ExpansionInterface::EXIDEVICE_MEMORYCARD;
const bool slot_a_has_gci_folder = slot_a_type == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER;
const bool slot_b_has_raw_memcard = slot_b_type == ExpansionInterface::EXIDEVICE_MEMORYCARD;
const bool slot_b_has_gci_folder = slot_b_type == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER;
s_bSaveConfig = true;
s_bNetPlay = NetPlay::IsNetPlayRunning();

View File

@ -1307,10 +1307,8 @@ bool NetPlayServer::SetupNetSettings()
settings.m_CopyWiiSave = Config::Get(Config::NETPLAY_LOAD_WII_SAVE);
settings.m_OCEnable = Config::Get(Config::MAIN_OVERCLOCK_ENABLE);
settings.m_OCFactor = Config::Get(Config::MAIN_OVERCLOCK);
settings.m_EXIDevice[0] =
static_cast<ExpansionInterface::TEXIDevices>(Config::Get(Config::MAIN_SLOT_A));
settings.m_EXIDevice[1] =
static_cast<ExpansionInterface::TEXIDevices>(Config::Get(Config::MAIN_SLOT_B));
settings.m_EXIDevice[0] = Config::Get(Config::MAIN_SLOT_A);
settings.m_EXIDevice[1] = Config::Get(Config::MAIN_SLOT_B);
// There's no way the BBA is going to sync, disable it
settings.m_EXIDevice[2] = ExpansionInterface::EXIDEVICE_NONE;
@ -1595,11 +1593,12 @@ bool NetPlayServer::SyncSaveData()
u8 save_count = 0;
constexpr size_t exi_device_count = 2;
for (size_t i = 0; i < exi_device_count; i++)
constexpr int exi_device_count = 2;
for (int i = 0; i < exi_device_count; ++i)
{
if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARD ||
SConfig::GetInstance().m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER)
Config::Get(Config::GetInfoForEXIDevice(i)) ==
ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER)
{
save_count++;
}
@ -1654,7 +1653,7 @@ bool NetPlayServer::SyncSaveData()
const std::string region =
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(game->GetRegion()));
for (size_t i = 0; i < exi_device_count; i++)
for (int i = 0; i < exi_device_count; ++i)
{
const bool is_slot_a = i == 0;
@ -1695,7 +1694,7 @@ bool NetPlayServer::SyncSaveData()
SendChunkedToClients(std::move(pac), 1,
fmt::format("Memory Card {} Synchronization", is_slot_a ? 'A' : 'B'));
}
else if (SConfig::GetInstance().m_EXIDevice[i] ==
else if (Config::Get(Config::GetInfoForEXIDevice(i)) ==
ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER)
{
const std::string path = File::GetUserPath(D_GCUSER_IDX) + region + DIR_SEP +

View File

@ -664,7 +664,9 @@ void GameList::OpenGCSaveFolder()
for (int i = 0; i < 2; i++)
{
QUrl url;
switch (SConfig::GetInstance().m_EXIDevice[i])
const ExpansionInterface::TEXIDevices current_exi_device =
Config::Get(Config::GetInfoForEXIDevice(i));
switch (current_exi_device)
{
case ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER:
{

View File

@ -458,8 +458,8 @@ void GameCubePane::LoadSettings()
for (int i = 0; i < SLOT_COUNT; i++)
{
QSignalBlocker blocker(m_slot_combos[i]);
m_slot_combos[i]->setCurrentIndex(
m_slot_combos[i]->findData(SConfig::GetInstance().m_EXIDevice[i]));
const ExpansionInterface::TEXIDevices exi_device = Config::Get(Config::GetInfoForEXIDevice(i));
m_slot_combos[i]->setCurrentIndex(m_slot_combos[i]->findData(exi_device));
UpdateButton(i);
}
@ -486,8 +486,10 @@ void GameCubePane::SaveSettings()
for (int i = 0; i < SLOT_COUNT; i++)
{
const auto dev = ExpansionInterface::TEXIDevices(m_slot_combos[i]->currentData().toInt());
const ExpansionInterface::TEXIDevices current_exi_device =
Config::Get(Config::GetInfoForEXIDevice(i));
if (Core::IsRunning() && SConfig::GetInstance().m_EXIDevice[i] != dev)
if (Core::IsRunning() && current_exi_device != dev)
{
ExpansionInterface::ChangeDevice(
// SlotB is on channel 1, slotA and SP1 are on 0
@ -498,19 +500,7 @@ void GameCubePane::SaveSettings()
(i == 2) ? 2 : 0);
}
SConfig::GetInstance().m_EXIDevice[i] = dev;
switch (i)
{
case SLOT_A_INDEX:
Config::SetBaseOrCurrent(Config::MAIN_SLOT_A, dev);
break;
case SLOT_B_INDEX:
Config::SetBaseOrCurrent(Config::MAIN_SLOT_B, dev);
break;
case SLOT_SP1_INDEX:
Config::SetBaseOrCurrent(Config::MAIN_SERIAL_PORT_1, dev);
break;
}
Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(i), dev);
}
#ifdef HAS_LIBMGBA