From 94ae134bf495cd943c8750808260e234da239544 Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 17 Dec 2015 23:48:26 +0100 Subject: [PATCH] Real Wiimote: Don't delay speaker data. --- .../Core/Core/HW/WiimoteReal/WiimoteReal.cpp | 46 +++++++------------ Source/Core/Core/HW/WiimoteReal/WiimoteReal.h | 7 +-- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 4360112834..e50fadf690 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -11,7 +11,6 @@ #include "Common/IniFile.h" #include "Common/StringUtil.h" #include "Common/Thread.h" -#include "Common/Timer.h" #include "Core/ConfigManager.h" #include "Core/Host.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" @@ -190,7 +189,7 @@ void Wiimote::InterruptChannel(const u16 channel, const void* const _data, const WriteReport(std::move(rpt)); } -bool Wiimote::Read() +void Wiimote::Read() { Report rpt(MAX_PAYLOAD); auto const result = IORead(rpt.data()); @@ -204,51 +203,38 @@ bool Wiimote::Read() Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost, - SConfig::GetInstance().iBBDumpPort); + SConfig::GetInstance().iBBDumpPort); } // Add it to queue rpt.resize(result); m_read_reports.Push(std::move(rpt)); - return true; } else if (0 == result) { ERROR_LOG(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wiimote %d.", m_index + 1); DisconnectInternal(); } - - return false; } -bool Wiimote::Write() +void Wiimote::Write() { - if (!m_write_reports.Empty()) + if (m_write_reports.Empty()) + return; + + Report const& rpt = m_write_reports.Front(); + + if (SConfig::GetInstance().iBBDumpPort > 0 && m_index == WIIMOTE_BALANCE_BOARD) { - Report const& rpt = m_write_reports.Front(); - - bool const is_speaker_data = rpt[1] == WM_WRITE_SPEAKER_DATA; - - if (!is_speaker_data || m_last_audio_report.GetTimeDifference() > 5) - { - if (SConfig::GetInstance().iBBDumpPort > 0 && m_index == WIIMOTE_BALANCE_BOARD) - { - static sf::UdpSocket Socket; - Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost, SConfig::GetInstance().iBBDumpPort); - } - IOWrite(rpt.data(), rpt.size()); - - if (is_speaker_data) - { - m_last_audio_report.Update(); - } - - m_write_reports.Pop(); - return true; - } + static sf::UdpSocket Socket; + Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost, SConfig::GetInstance().iBBDumpPort); } + IOWrite(rpt.data(), rpt.size()); - return false; + m_write_reports.Pop(); + + if (!m_write_reports.Empty()) + IOWakeup(); } static bool IsDataReport(const Report& rpt) diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h index 8ffc814cae..1ca31a8d69 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h @@ -14,7 +14,6 @@ #include "Common/Common.h" #include "Common/FifoQueue.h" #include "Common/NonCopyable.h" -#include "Common/Timer.h" #include "Core/HW/Wiimote.h" #include "Core/HW/WiimoteReal/WiimoteRealBase.h" @@ -39,8 +38,8 @@ public: const Report& ProcessReadQueue(); - bool Read(); - bool Write(); + void Read(); + void Write(); void StartThread(); void StopThread(); @@ -109,8 +108,6 @@ private: Common::FifoQueue m_read_reports; Common::FifoQueue m_write_reports; - - Common::Timer m_last_audio_report; }; class WiimoteScanner