mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
WiimoteReal: Disconnect the Wiimote if IOWrite fails
This is intended to make reconnecting Wiimotes easier with a DolphinBar. Unfortunately, this change isn't enough as it doesn't always catch disconnections for Wiimotes connected with a DolphinBar. But it's better than nothing and eventually a disconnection will be detected when something tries to write to the Wiimote, instead of never. There is no other solution as the DolphinBar always exposes 4 HIDs even when the associated Wiimotes are not connected. We could try to detect this using the fake input reports sent by the DolphinBar, but this only works for the first HID (probably because of a bug in the firmware?), so this method is not an option.
This commit is contained in:
parent
53d553d2b0
commit
d9a9e34994
@ -218,10 +218,11 @@ void Wiimote::Read()
|
||||
}
|
||||
}
|
||||
|
||||
void Wiimote::Write()
|
||||
bool Wiimote::Write()
|
||||
{
|
||||
// nothing written, but this is not an error
|
||||
if (m_write_reports.Empty())
|
||||
return;
|
||||
return true;
|
||||
|
||||
Report const& rpt = m_write_reports.Front();
|
||||
|
||||
@ -231,12 +232,14 @@ void Wiimote::Write()
|
||||
Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost,
|
||||
SConfig::GetInstance().iBBDumpPort);
|
||||
}
|
||||
IOWrite(rpt.data(), rpt.size());
|
||||
int ret = IOWrite(rpt.data(), rpt.size());
|
||||
|
||||
m_write_reports.Pop();
|
||||
|
||||
if (!m_write_reports.Empty())
|
||||
IOWakeup();
|
||||
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
static bool IsDataReport(const Report& rpt)
|
||||
@ -577,7 +580,11 @@ void Wiimote::ThreadFunc()
|
||||
m_index + 1);
|
||||
break;
|
||||
}
|
||||
Write();
|
||||
if (!Write())
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Wiimote::Write failed. Disconnecting Wiimote %d.", m_index + 1);
|
||||
break;
|
||||
}
|
||||
Read();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
const Report& ProcessReadQueue();
|
||||
|
||||
void Read();
|
||||
void Write();
|
||||
bool Write();
|
||||
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
|
Loading…
Reference in New Issue
Block a user