diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 266e67f3e1..d2ddd283c8 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -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(); } diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h index 54039ab2b2..bd322543af 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h @@ -39,7 +39,7 @@ public: const Report& ProcessReadQueue(); void Read(); - void Write(); + bool Write(); void StartThread(); void StopThread();