From 7778859b55a04acf7b9f081cb3429cded0fe31ea Mon Sep 17 00:00:00 2001 From: Techjar Date: Sun, 17 Jun 2018 03:18:22 -0400 Subject: [PATCH] Qt/GameCubePane: Fix issues with changing memcard slots while game is running Selecting Dummy or Memory Card would pass wrong values to EXI::ChangeDevice and not work as expected Changing path had no effect until device was changed as it didn't call EXI::ChangeDevice at all --- .../Core/DolphinQt2/Settings/GameCubePane.cpp | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt2/Settings/GameCubePane.cpp b/Source/Core/DolphinQt2/Settings/GameCubePane.cpp index 8cec3352eb..afd3204b33 100644 --- a/Source/Core/DolphinQt2/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt2/Settings/GameCubePane.cpp @@ -209,6 +209,21 @@ void GameCubePane::OnConfigPressed(int slot) } } + QString path_old; + if (memcard) + { + path_old = + QFileInfo(QString::fromStdString(slot == 0 ? SConfig::GetInstance().m_strMemoryCardA : + SConfig::GetInstance().m_strMemoryCardB)) + .absoluteFilePath(); + } + else + { + path_old = QFileInfo(QString::fromStdString(slot == 0 ? SConfig::GetInstance().m_strGbaCartA : + SConfig::GetInstance().m_strGbaCartB)) + .absoluteFilePath(); + } + if (memcard) { if (slot == SLOT_A_INDEX) @@ -231,6 +246,17 @@ void GameCubePane::OnConfigPressed(int slot) SConfig::GetInstance().m_strGbaCartB = path_abs.toStdString(); } } + + if (Core::IsRunning() && path_abs != path_old) + { + ExpansionInterface::ChangeDevice( + // SlotB is on channel 1, slotA and SP1 are on 0 + slot, + // The device enum to change to + memcard ? ExpansionInterface::EXIDEVICE_MEMORYCARD : ExpansionInterface::EXIDEVICE_AGP, + // SP1 is device 2, slots are device 0 + 0); + } } void GameCubePane::LoadSettings() @@ -350,9 +376,12 @@ void GameCubePane::SaveSettings() if (Core::IsRunning() && SConfig::GetInstance().m_EXIDevice[i] != dev) { ExpansionInterface::ChangeDevice( - (index == 1) ? 1 : 0, // SlotB is on channel 1, slotA and SP1 are on 0 - dev, // The device enum to change to - (index == 2) ? 2 : 0); // SP1 is device 2, slots are device 0 + // SlotB is on channel 1, slotA and SP1 are on 0 + (i == 1) ? 1 : 0, + // The device enum to change to + dev, + // SP1 is device 2, slots are device 0 + (i == 2) ? 2 : 0); } SConfig::GetInstance().m_EXIDevice[i] = dev;