WiimoteReal: Only duplicate data reports when speaker data is enabled.

This commit is contained in:
Jordan Woyak 2020-09-19 20:04:27 -05:00
parent 39df01434c
commit 8587ebba86
2 changed files with 21 additions and 31 deletions

View File

@ -173,12 +173,6 @@ void Wiimote::WriteReport(Report rpt)
m_speaker_mute = (rpt[2] & 0x4) != 0; m_speaker_mute = (rpt[2] & 0x4) != 0;
break; break;
case OutputReportID::ReportMode:
// Force non-continuous reporting for less BT traffic.
// We duplicate reports to maintain 200hz anyways.
rpt[2] &= ~0x4;
break;
default: default:
break; break;
} }
@ -414,40 +408,36 @@ bool Wiimote::GetNextReport(Report* report)
} }
// Returns the next report that should be sent // Returns the next report that should be sent
Report& Wiimote::ProcessReadQueue() Report& Wiimote::ProcessReadQueue(bool repeat_last_data_report)
{ {
// Pop through the queued reports if (!GetNextReport(&m_last_input_report) &&
while (GetNextReport(&m_last_input_report)) !(IsDataReport(m_last_input_report) && repeat_last_data_report))
{ {
if (!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();
// A non-data report, use it.
return m_last_input_report;
// Forget the last data report as it may be of the wrong type
// or contain outdated button data
// or it's not supposed to be sent at this time
// It's just easier to be correct this way and it's probably not horrible.
}
} }
// If the last report wasn't a data report it's irrelevant.
if (!IsDataReport(m_last_input_report))
m_last_input_report.clear();
// If it was a data report, we repeat that until something else comes in.
return m_last_input_report; return m_last_input_report;
} }
void Wiimote::Update() void Wiimote::Update()
{ {
// Pop through the queued reports // Wii remotes send input at 200hz once a Wii enables "sniff mode" on the connection.
const Report& rpt = ProcessReadQueue(); // PC bluetooth stacks do not enable sniff mode causing remotes to send input at only 100hz.
// Commercial games do not send speaker data unless input rates approach 200hz.
// If we want speaker data we must pretend input is at 200hz.
// We duplicate data reports to accomplish this.
// Unfortunately this breaks detection of motion gestures in some games.
// e.g. Sonic and the Secret Rings, Jett Rocket
const bool repeat_reports_to_maintain_200hz = SConfig::GetInstance().m_WiimoteEnableSpeaker;
// Send the report const Report& rpt = ProcessReadQueue(repeat_reports_to_maintain_200hz);
if (!rpt.empty())
InterruptCallback(rpt.front(), rpt.data() + REPORT_HID_HEADER_SIZE, if (rpt.empty())
u32(rpt.size() - REPORT_HID_HEADER_SIZE)); return;
InterruptCallback(rpt.front(), rpt.data() + REPORT_HID_HEADER_SIZE,
u32(rpt.size() - REPORT_HID_HEADER_SIZE));
} }
bool Wiimote::IsButtonPressed() bool Wiimote::IsButtonPressed()

View File

@ -116,7 +116,7 @@ private:
virtual bool ConnectInternal() = 0; virtual bool ConnectInternal() = 0;
virtual void DisconnectInternal() = 0; virtual void DisconnectInternal() = 0;
Report& ProcessReadQueue(); Report& ProcessReadQueue(bool repeat_last_data_report);
void ClearReadQueue(); void ClearReadQueue();
void WriteReport(Report rpt); void WriteReport(Report rpt);