mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Track the real wiimote rumble state to drop outgoing rumble reports with no effect.
This eliminates constant streams of reports in various games that constantly send audio reports. (Just Dance 2, DKCR, etc.) (Speaker data reports are converted to rumble reports when speaker data is disabled.)
This commit is contained in:
parent
4c40e70b8a
commit
018282c2b9
@ -58,7 +58,9 @@ Wiimote::Wiimote()
|
||||
, dev_handle(0), stack(MSBT_STACK_UNKNOWN)
|
||||
#endif
|
||||
, m_last_input_report()
|
||||
, m_channel(0), m_run_thread(false)
|
||||
, m_channel(0)
|
||||
, m_rumble_state()
|
||||
, m_run_thread(false)
|
||||
{
|
||||
#if defined(__linux__) && HAVE_BLUEZ
|
||||
bdaddr = (bdaddr_t){{0, 0, 0, 0, 0, 0}};
|
||||
@ -76,6 +78,26 @@ Wiimote::~Wiimote()
|
||||
m_write_reports.Clear();
|
||||
}
|
||||
|
||||
// to be called from CPU thread
|
||||
void Wiimote::WriteReport(Report rpt)
|
||||
{
|
||||
if (rpt.size() >= 3)
|
||||
{
|
||||
bool const new_rumble_state = (rpt[2] & 0x1) != 0;
|
||||
|
||||
if (WM_RUMBLE == rpt[1] && new_rumble_state == m_rumble_state)
|
||||
{
|
||||
// If this is a rumble report and the rumble state didn't change, ignore
|
||||
//ERROR_LOG(WIIMOTE, "Ignoring rumble report.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_rumble_state = new_rumble_state;
|
||||
}
|
||||
|
||||
m_write_reports.Push(std::move(rpt));
|
||||
}
|
||||
|
||||
// to be called from CPU thread
|
||||
void Wiimote::QueueReport(u8 rpt_id, const void* _data, unsigned int size)
|
||||
{
|
||||
@ -85,7 +107,7 @@ void Wiimote::QueueReport(u8 rpt_id, const void* _data, unsigned int size)
|
||||
rpt[0] = WM_SET_REPORT | WM_BT_OUTPUT;
|
||||
rpt[1] = rpt_id;
|
||||
std::copy_n(data, size, rpt.begin() + 2);
|
||||
m_write_reports.Push(std::move(rpt));
|
||||
WriteReport(std::move(rpt));
|
||||
}
|
||||
|
||||
void Wiimote::DisableDataReporting()
|
||||
@ -171,7 +193,7 @@ void Wiimote::InterruptChannel(const u16 channel, const void* const _data, const
|
||||
rpt.resize(3);
|
||||
}
|
||||
|
||||
m_write_reports.Push(std::move(rpt));
|
||||
WriteReport(std::move(rpt));
|
||||
}
|
||||
|
||||
bool Wiimote::Read()
|
||||
|
@ -103,12 +103,15 @@ protected:
|
||||
|
||||
private:
|
||||
void ClearReadQueue();
|
||||
void WriteReport(Report rpt);
|
||||
|
||||
int IORead(u8* buf);
|
||||
int IOWrite(u8 const* buf, int len);
|
||||
|
||||
void ThreadFunc();
|
||||
|
||||
bool m_rumble_state;
|
||||
|
||||
bool m_run_thread;
|
||||
std::thread m_wiimote_thread;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user