From 9e54cf80c29e54e4fbda67b58045ffc923bf50a1 Mon Sep 17 00:00:00 2001 From: rabbott99 Date: Tue, 22 Dec 2015 23:26:18 -0500 Subject: [PATCH] Movie: Reset wiimotes at at start of recording/playback, to prevent desync issues which occur when the a game has been opened beforehand --- Source/Core/Core/HW/Wiimote.cpp | 6 ++++++ Source/Core/Core/HW/Wiimote.h | 1 + Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h | 3 +-- Source/Core/Core/Movie.cpp | 11 +++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp index 8a95873047..94e88439cb 100644 --- a/Source/Core/Core/HW/Wiimote.cpp +++ b/Source/Core/Core/HW/Wiimote.cpp @@ -51,6 +51,12 @@ void Initialize(void* const hwnd, bool wait) Movie::ChangeWiiPads(); } +void ResetAllWiimotes() +{ + for (int i = WIIMOTE_CHAN_0; i < MAX_BBMOTES; ++i) + static_cast(s_config.GetController(i))->Reset(); +} + void LoadConfig() { s_config.LoadConfig(false); diff --git a/Source/Core/Core/HW/Wiimote.h b/Source/Core/Core/HW/Wiimote.h index 3bf03457ad..c8f117358c 100644 --- a/Source/Core/Core/HW/Wiimote.h +++ b/Source/Core/Core/HW/Wiimote.h @@ -37,6 +37,7 @@ namespace Wiimote void Shutdown(); void Initialize(void* const hwnd, bool wait = false); +void ResetAllWiimotes(); void LoadConfig(); void Resume(); void Pause(); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h index 82185adfc6..7aacdb3c9d 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h @@ -115,6 +115,7 @@ public: void InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size); void ControlChannel(const u16 _channelID, const void* _pData, u32 _Size); void ConnectOnInput(); + void Reset(); void DoState(PointerWrap& p); void RealState(); @@ -145,8 +146,6 @@ private: u8* data; }; - void Reset(); - void ReportMode(const wm_report_mode* const dr); void SendAck(const u8 _reportID); void RequestStatus(const wm_request_status* const rs = nullptr); diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 7df14aea06..4d0c806aa5 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -500,6 +500,14 @@ bool BeginRecordingInput(int controllers) md5thread.detach(); GetSettings(); } + + // Wiimotes cause desync issues if they're not reset before launching the game + if (!Core::IsRunningAndStarted()) + { + // This will also reset the wiimotes for gamecube games, but that shouldn't do anything + Wiimote::ResetAllWiimotes(); + } + s_playMode = MODE_RECORDING; s_author = SConfig::GetInstance().m_strMovieAuthor; EnsureTmpInputSize(1); @@ -854,6 +862,9 @@ bool PlayInput(const std::string& filename) s_playMode = MODE_PLAYING; + // Wiimotes cause desync issues if they're not reset before launching the game + Wiimote::ResetAllWiimotes(); + Core::UpdateWantDeterminism(); s_totalBytes = g_recordfd.GetSize() - 256;