Real Wiimote: Don't delay speaker data.

This commit is contained in:
degasus 2015-12-17 23:48:26 +01:00
parent c1b2eba82b
commit 94ae134bf4
2 changed files with 18 additions and 35 deletions

View File

@ -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)

View File

@ -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<Report> m_read_reports;
Common::FifoQueue<Report> m_write_reports;
Common::Timer m_last_audio_report;
};
class WiimoteScanner