Skip to content

Commit

Permalink
Always replug controllers when there's a mismatching controller in a …
Browse files Browse the repository at this point in the history
…save state
  • Loading branch information
DarthMew committed Jan 18, 2023
1 parent bfc5846 commit 1455f13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
30 changes: 2 additions & 28 deletions src/core/pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,6 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)

if (controller_type != state_controller_type)
{
// UI notification portion is separated from emulation portion (intentional condition check redundancy)
if (g_settings.load_devices_from_save_states)
{
g_host_interface->AddFormattedOSDMessage(
10.0f,
g_host_interface->TranslateString(
"OSDMessage", "Save state contains controller type %s in port %u, but %s is used. Switching."),
Settings::GetControllerTypeName(state_controller_type), i + 1u,
Settings::GetControllerTypeName(controller_type));
}
else
{
g_host_interface->AddFormattedOSDMessage(
10.0f, g_host_interface->TranslateString("OSDMessage", "Ignoring mismatched controller type %s in port %u."),
Settings::GetControllerTypeName(state_controller_type), i + 1u);
}

if (g_settings.load_devices_from_save_states)
{
m_controllers[i].reset();
if (state_controller_type != ControllerType::None)
m_controllers[i] = Controller::Create(state_controller_type, i);
}
else
{
// mismatched controller states prevents us from loading the state into the user's preferred controller.
// just doing a reset here is a little dodgy. If there's an active xfer on the state-saved controller
// then who knows what might happen as the rest of the packet streams in. (possibly the SIO xfer will
Expand All @@ -92,7 +67,6 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)

if (m_controllers[i])
m_controllers[i]->Reset();
}
}

// we still need to read/write the save state controller state even if the controller does not exist.
Expand All @@ -104,9 +78,9 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
return false;

if (auto& controller = m_controllers[i]; controller && controller->GetType() == state_controller_type)
return controller->DoState(sw, g_settings.load_devices_from_save_states);
return controller->DoState(sw, false);
else if (auto dummy = Controller::Create(state_controller_type, i); dummy)
return dummy->DoState(sw, g_settings.load_devices_from_save_states);
return dummy->DoState(sw, false);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/libretro/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -3934,10 +3934,10 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
{
"duckstation_Main.LoadDevicesFromSaveStates",
"Load Devices From Save States",
"Load Memory Cards From Save States",
NULL,
"Sets whether the contents of devices and memory cards will be loaded when a save state is loaded. "
"Disabling this will simulate a replug of devices and memory cards.",
"Sets whether the contents memory cards will be loaded when a save state is loaded. "
"Disabling this will simulate a replug of memory cards.",
NULL,
"advanced",
{
Expand Down

0 comments on commit 1455f13

Please sign in to comment.