USB: Don't reset configuration when saving state

This commit is contained in:
Stenzek 2024-01-27 15:52:43 +10:00 committed by Connor McLaughlin
parent 8c9a65d094
commit e5bb405b47
1 changed files with 8 additions and 4 deletions

View File

@ -250,15 +250,19 @@ void USB::DoDeviceState(USBDevice* dev, StateWrapper& sw)
sw.Do(&dev->setup_index);
sw.Do(&dev->configuration);
usb_desc_set_config(dev, dev->configuration);
if (sw.IsReading())
usb_desc_set_config(dev, dev->configuration);
int altsetting[USB_MAX_INTERFACES];
std::memcpy(altsetting, dev->altsetting, sizeof(altsetting));
sw.DoPODArray(altsetting, std::size(altsetting));
for (u32 i = 0; i < USB_MAX_INTERFACES; i++)
if (sw.IsReading())
{
dev->altsetting[i] = altsetting[i];
usb_desc_set_interface(dev, i, altsetting[i]);
for (u32 i = 0; i < USB_MAX_INTERFACES; i++)
{
dev->altsetting[i] = altsetting[i];
usb_desc_set_interface(dev, i, altsetting[i]);
}
}
DoEndpointState(&dev->ep_ctl, sw);