diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 5f72002545..e61f873539 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -67,7 +67,6 @@ public: bool bSetVolume = false; std::array bSetWiimoteSource{}; std::array bSetPads{}; - std::array bSetEXIDevice{}; private: bool valid = false; @@ -79,7 +78,6 @@ private: float fSyncGpuOverclock = 0; std::array iWiimoteSource{}; std::array Pads{}; - std::array 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 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; diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 7f8c132c58..23a1ae99a6 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -54,11 +54,24 @@ const Info MAIN_GCI_FOLDER_A_PATH_OVERRIDE{ {System::Main, "Core", "GCIFolderAPathOverride"}, ""}; const Info MAIN_GCI_FOLDER_B_PATH_OVERRIDE{ {System::Main, "Core", "GCIFolderBPathOverride"}, ""}; -const Info MAIN_SLOT_A{{System::Main, "Core", "SlotA"}, - ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER}; -const Info MAIN_SLOT_B{{System::Main, "Core", "SlotB"}, ExpansionInterface::EXIDEVICE_NONE}; -const Info MAIN_SERIAL_PORT_1{{System::Main, "Core", "SerialPort1"}, - ExpansionInterface::EXIDEVICE_NONE}; + +const Info MAIN_SLOT_A{ + {System::Main, "Core", "SlotA"}, ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER}; +const Info MAIN_SLOT_B{{System::Main, "Core", "SlotB"}, + ExpansionInterface::EXIDEVICE_NONE}; +const Info MAIN_SERIAL_PORT_1{ + {System::Main, "Core", "SerialPort1"}, ExpansionInterface::EXIDEVICE_NONE}; + +const Info& GetInfoForEXIDevice(int channel) +{ + static constexpr std::array*, 3> infos{ + &MAIN_SLOT_A, + &MAIN_SLOT_B, + &MAIN_SERIAL_PORT_1, + }; + return *infos[channel]; +} + const Info MAIN_BBA_MAC{{System::Main, "Core", "BBA_MAC"}, ""}; const Info MAIN_BBA_XLINK_IP{{System::Main, "Core", "BBA_XLINK_IP"}, "127.0.0.1"}; const Info MAIN_BBA_XLINK_CHAT_OSD{{System::Main, "Core", "BBA_XLINK_CHAT_OSD"}, true}; diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 0e5b0fdbe9..6b7777d48b 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -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 MAIN_AGP_CART_A_PATH; extern const Info MAIN_AGP_CART_B_PATH; extern const Info MAIN_GCI_FOLDER_A_PATH_OVERRIDE; extern const Info MAIN_GCI_FOLDER_B_PATH_OVERRIDE; -extern const Info MAIN_SLOT_A; -extern const Info MAIN_SLOT_B; -extern const Info MAIN_SERIAL_PORT_1; +extern const Info MAIN_SLOT_A; +extern const Info MAIN_SLOT_B; +extern const Info MAIN_SERIAL_PORT_1; +const Info& GetInfoForEXIDevice(int channel); extern const Info MAIN_BBA_MAC; extern const Info MAIN_BBA_XLINK_IP; extern const Info MAIN_BBA_XLINK_CHAT_OSD; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 9859fb977d..0713f550ac 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -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 diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index 128eba8ad7..cd6f6d8829 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -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(m_settings.m_EXIDevice[0])); - layer->Set(Config::MAIN_SLOT_B, static_cast(m_settings.m_EXIDevice[1])); - layer->Set(Config::MAIN_SERIAL_PORT_1, static_cast(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); diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index cdd691f259..d222941b65 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -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], diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 51dfc2b85e..318f5db807 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -114,7 +114,6 @@ struct SConfig static IniFile LoadLocalGameIni(const std::string& id, std::optional revision); static IniFile LoadGameIni(const std::string& id, std::optional revision); - ExpansionInterface::TEXIDevices m_EXIDevice[3]; SerialInterface::SIDevices m_SIDevice[4]; SConfig(const SConfig&) = delete; diff --git a/Source/Core/Core/HW/EXI/EXI.cpp b/Source/Core/Core/HW/EXI/EXI.cpp index c4be51e2ed..d7fc90a25e 100644 --- a/Source/Core/Core/HW/EXI/EXI.cpp +++ b/Source/Core/Core/HW/EXI/EXI.cpp @@ -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); diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 70d32ffb14..8b4402e2bc 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -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(); diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index ed1527c0c5..34379f29aa 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -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(Config::Get(Config::MAIN_SLOT_A)); - settings.m_EXIDevice[1] = - static_cast(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 + diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 7127553e95..2fd137055f 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -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: { diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp index 054802e72b..77b3b86b0c 100644 --- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp @@ -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