WiimoteEmu: Make Reset() deterministic under WantsDeterminism().
This commit is contained in:
parent
466f0b377b
commit
b67ffb9ab5
|
@ -70,6 +70,8 @@ constexpr std::array<std::string_view, 7> named_buttons{
|
||||||
|
|
||||||
void Wiimote::Reset()
|
void Wiimote::Reset()
|
||||||
{
|
{
|
||||||
|
const bool want_determinism = Core::WantsDeterminism();
|
||||||
|
|
||||||
SetRumble(false);
|
SetRumble(false);
|
||||||
|
|
||||||
// Wiimote starts in non-continuous CORE mode:
|
// Wiimote starts in non-continuous CORE mode:
|
||||||
|
@ -79,8 +81,12 @@ void Wiimote::Reset()
|
||||||
m_speaker_mute = false;
|
m_speaker_mute = false;
|
||||||
|
|
||||||
// EEPROM
|
// EEPROM
|
||||||
|
|
||||||
|
// TODO: This feels sketchy, this needs to properly handle the case where the load and the write
|
||||||
|
// happen under different Wii Roots and/or determinism modes.
|
||||||
|
|
||||||
std::string eeprom_file = (File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" + GetName() + ".bin");
|
std::string eeprom_file = (File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" + GetName() + ".bin");
|
||||||
if (m_eeprom_dirty)
|
if (!want_determinism && m_eeprom_dirty)
|
||||||
{
|
{
|
||||||
// Write out existing EEPROM
|
// Write out existing EEPROM
|
||||||
INFO_LOG_FMT(WIIMOTE, "Wrote EEPROM for {}", GetName());
|
INFO_LOG_FMT(WIIMOTE, "Wrote EEPROM for {}", GetName());
|
||||||
|
@ -93,7 +99,7 @@ void Wiimote::Reset()
|
||||||
}
|
}
|
||||||
m_eeprom = {};
|
m_eeprom = {};
|
||||||
|
|
||||||
if (File::Exists(eeprom_file))
|
if (!want_determinism && File::Exists(eeprom_file))
|
||||||
{
|
{
|
||||||
// Read existing EEPROM
|
// Read existing EEPROM
|
||||||
std::ifstream file;
|
std::ifstream file;
|
||||||
|
@ -173,19 +179,26 @@ void Wiimote::Reset()
|
||||||
m_extension_port.AttachExtension(GetNoneExtension());
|
m_extension_port.AttachExtension(GetNoneExtension());
|
||||||
m_motion_plus.GetExtPort().AttachExtension(GetNoneExtension());
|
m_motion_plus.GetExtPort().AttachExtension(GetNoneExtension());
|
||||||
|
|
||||||
// Switch to desired M+ status and extension (if any).
|
if (!want_determinism)
|
||||||
// M+ and EXT are reset on attachment.
|
{
|
||||||
HandleExtensionSwap(static_cast<ExtensionNumber>(m_attachments->GetSelectedAttachment()),
|
// Switch to desired M+ status and extension (if any).
|
||||||
m_motion_plus_setting.GetValue());
|
// M+ and EXT are reset on attachment.
|
||||||
|
HandleExtensionSwap(static_cast<ExtensionNumber>(m_attachments->GetSelectedAttachment()),
|
||||||
|
m_motion_plus_setting.GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
// Reset sub-devices.
|
// Reset sub-devices.
|
||||||
m_speaker_logic.Reset();
|
m_speaker_logic.Reset();
|
||||||
m_camera_logic.Reset();
|
m_camera_logic.Reset();
|
||||||
|
|
||||||
m_status = {};
|
m_status = {};
|
||||||
// This will suppress a status report on connect when an extension is already attached.
|
|
||||||
// TODO: I am not 100% sure if this is proper.
|
if (!want_determinism)
|
||||||
m_status.extension = m_extension_port.IsDeviceConnected();
|
{
|
||||||
|
// This will suppress a status report on connect when an extension is already attached.
|
||||||
|
// TODO: I am not 100% sure if this is proper.
|
||||||
|
m_status.extension = m_extension_port.IsDeviceConnected();
|
||||||
|
}
|
||||||
|
|
||||||
// Dynamics:
|
// Dynamics:
|
||||||
m_swing_state = {};
|
m_swing_state = {};
|
||||||
|
|
Loading…
Reference in New Issue