From b67ffb9ab561c106780f3b5ab0671f2cb88de3de Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 22 Sep 2022 19:52:33 +0200 Subject: [PATCH] WiimoteEmu: Make Reset() deterministic under WantsDeterminism(). --- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index bdc4fbe3f9..cba022f8dc 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -70,6 +70,8 @@ constexpr std::array named_buttons{ void Wiimote::Reset() { + const bool want_determinism = Core::WantsDeterminism(); + SetRumble(false); // Wiimote starts in non-continuous CORE mode: @@ -79,8 +81,12 @@ void Wiimote::Reset() m_speaker_mute = false; // 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"); - if (m_eeprom_dirty) + if (!want_determinism && m_eeprom_dirty) { // Write out existing EEPROM INFO_LOG_FMT(WIIMOTE, "Wrote EEPROM for {}", GetName()); @@ -93,7 +99,7 @@ void Wiimote::Reset() } m_eeprom = {}; - if (File::Exists(eeprom_file)) + if (!want_determinism && File::Exists(eeprom_file)) { // Read existing EEPROM std::ifstream file; @@ -173,19 +179,26 @@ void Wiimote::Reset() m_extension_port.AttachExtension(GetNoneExtension()); m_motion_plus.GetExtPort().AttachExtension(GetNoneExtension()); - // Switch to desired M+ status and extension (if any). - // M+ and EXT are reset on attachment. - HandleExtensionSwap(static_cast(m_attachments->GetSelectedAttachment()), - m_motion_plus_setting.GetValue()); + if (!want_determinism) + { + // Switch to desired M+ status and extension (if any). + // M+ and EXT are reset on attachment. + HandleExtensionSwap(static_cast(m_attachments->GetSelectedAttachment()), + m_motion_plus_setting.GetValue()); + } // Reset sub-devices. m_speaker_logic.Reset(); m_camera_logic.Reset(); 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. - m_status.extension = m_extension_port.IsDeviceConnected(); + + if (!want_determinism) + { + // 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: m_swing_state = {};