HW/WiimoteReal: Drop stale data reports to prevent read queue from filling up and causing input delays.

This commit is contained in:
Jordan Woyak 2020-12-12 12:18:10 -06:00
parent fa0e5e36c7
commit 0fa6bde374

View File

@ -411,11 +411,16 @@ bool Wiimote::GetNextReport(Report* report)
// Returns the next report that should be sent // Returns the next report that should be sent
Report& Wiimote::ProcessReadQueue(bool repeat_last_data_report) Report& Wiimote::ProcessReadQueue(bool repeat_last_data_report)
{ {
if (!GetNextReport(&m_last_input_report) && // If we're not repeating data reports or had a non-data report, any old report is irrelevant.
!(IsDataReport(m_last_input_report) && repeat_last_data_report)) if (!repeat_last_data_report || !IsDataReport(m_last_input_report))
{
// If we didn't get a new report and it's not a data report to repeat, it's irrelevant.
m_last_input_report.clear(); m_last_input_report.clear();
// Step through the read queue.
while (GetNextReport(&m_last_input_report))
{
// Stop on a non-data report.
if (!IsDataReport(m_last_input_report))
break;
} }
return m_last_input_report; return m_last_input_report;