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
This commit is contained in:
Techjar 2018-06-17 03:18:22 -04:00
parent 58606702f7
commit 7778859b55
1 changed files with 32 additions and 3 deletions

View File

@ -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;