USB: Fix loading old states without USB.bin

This commit is contained in:
Stenzek 2022-12-26 18:44:28 +10:00 committed by refractionpcsx2
parent 72d6ff625c
commit 51f29f40ee
1 changed files with 10 additions and 7 deletions

View File

@ -383,15 +383,15 @@ bool USB::DoState(StateWrapper& sw)
{ {
std::array<bool, 2> valid_devices = {}; std::array<bool, 2> valid_devices = {};
if (sw.IsReading())
{
if (!sw.DoMarker("USB") || !USB::DoOHCIState(sw)) if (!sw.DoMarker("USB") || !USB::DoOHCIState(sw))
{ {
Console.Error("USB state is invalid, resetting."); Console.Error("USB state is invalid, resetting.");
USBreset(); USBreset();
return false; return true;
} }
if (sw.IsReading())
{
for (u32 port = 0; port < USB::NUM_PORTS; port++) for (u32 port = 0; port < USB::NUM_PORTS; port++)
{ {
s32 state_devtype; s32 state_devtype;
@ -444,6 +444,9 @@ bool USB::DoState(StateWrapper& sw)
} }
else else
{ {
if (!sw.DoMarker("USB") || !USB::DoOHCIState(sw))
return false;
for (u32 port = 0; port < USB::NUM_PORTS; port++) for (u32 port = 0; port < USB::NUM_PORTS; port++)
{ {
s32 state_devtype = EmuConfig.USB.Ports[port].DeviceType; s32 state_devtype = EmuConfig.USB.Ports[port].DeviceType;