mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-29 19:15:38 +00:00
Pad: Change controller types when loading states if needed
This commit is contained in:
parent
0df741a799
commit
52c82b6aa3
|
@ -10,6 +10,7 @@
|
||||||
- Windows and Linux support - macOS may work, but not actively maintained
|
- Windows and Linux support - macOS may work, but not actively maintained
|
||||||
- Currently only .bin/.cue disc image formats are supported. Additional formats are planned
|
- Currently only .bin/.cue disc image formats are supported. Additional formats are planned
|
||||||
- Direct booting of homebrew executables
|
- Direct booting of homebrew executables
|
||||||
|
- Digital and analog controllers for input (rumble is forwarded to host)
|
||||||
|
|
||||||
## System Requirements
|
## System Requirements
|
||||||
- A CPU faster than a potato.
|
- A CPU faster than a potato.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
#include "YBaseLib/Log.h"
|
#include "YBaseLib/Log.h"
|
||||||
#include "common/state_wrapper.h"
|
#include "common/state_wrapper.h"
|
||||||
|
#include "controller.h"
|
||||||
#include "host_interface.h"
|
#include "host_interface.h"
|
||||||
#include "interrupt_controller.h"
|
#include "interrupt_controller.h"
|
||||||
#include "memory_card.h"
|
#include "memory_card.h"
|
||||||
#include "controller.h"
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
Log_SetChannel(Pad);
|
Log_SetChannel(Pad);
|
||||||
|
|
||||||
|
@ -36,16 +36,26 @@ bool Pad::DoState(StateWrapper& sw)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < NUM_SLOTS; i++)
|
for (u32 i = 0; i < NUM_SLOTS; i++)
|
||||||
{
|
{
|
||||||
|
ControllerType controller_type = m_controllers[i] ? m_controllers[i]->GetType() : ControllerType::None;
|
||||||
|
ControllerType state_controller_type = controller_type;
|
||||||
|
sw.Do(&state_controller_type);
|
||||||
|
|
||||||
|
if (controller_type != state_controller_type)
|
||||||
|
{
|
||||||
|
m_system->GetHostInterface()->AddOSDMessage(SmallString::FromFormat(
|
||||||
|
"Save state contains controller type %s in port %u, but %s is used. Switching.",
|
||||||
|
Settings::GetControllerTypeName(state_controller_type), i, Settings::GetControllerTypeName(controller_type)));
|
||||||
|
|
||||||
|
m_controllers[i].reset();
|
||||||
|
if (state_controller_type != ControllerType::None)
|
||||||
|
m_controllers[i] = Controller::Create(state_controller_type);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_controllers[i])
|
if (m_controllers[i])
|
||||||
{
|
{
|
||||||
if (!sw.DoMarker("Controller") || !m_controllers[i]->DoState(sw))
|
if (!sw.DoMarker("Controller") || !m_controllers[i]->DoState(sw))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!sw.DoMarker("NoController"))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool card_present = static_cast<bool>(m_memory_cards[i]);
|
bool card_present = static_cast<bool>(m_memory_cards[i]);
|
||||||
sw.Do(&card_present);
|
sw.Do(&card_present);
|
||||||
|
@ -74,11 +84,6 @@ bool Pad::DoState(StateWrapper& sw)
|
||||||
if (!sw.DoMarker("MemoryCard") || !m_memory_cards[i]->DoState(sw))
|
if (!sw.DoMarker("MemoryCard") || !m_memory_cards[i]->DoState(sw))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!sw.DoMarker("NoController"))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Do(&m_state);
|
sw.Do(&m_state);
|
||||||
|
|
Loading…
Reference in a new issue