mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-10 00:41:19 +12:00
Fix a crash from writing to a disconnected device
This commit is contained in:
parent
55e240339c
commit
e14c54b846
1 changed files with 6 additions and 3 deletions
|
@ -955,15 +955,18 @@ void WiimoteControllerProvider::writer_thread()
|
||||||
if (index != (size_t)-1 && !data.empty())
|
if (index != (size_t)-1 && !data.empty())
|
||||||
{
|
{
|
||||||
auto& wiimote = m_wiimotes[index];
|
auto& wiimote = m_wiimotes[index];
|
||||||
|
if (!wiimote.device)
|
||||||
|
continue;
|
||||||
if (wiimote.rumble)
|
if (wiimote.rumble)
|
||||||
data[1] |= 1;
|
data[1] |= 1;
|
||||||
if (!wiimote.device->write_data(data))
|
if (!wiimote.device->write_data(data))
|
||||||
|
{
|
||||||
wiimote.device.reset();
|
wiimote.device.reset();
|
||||||
if (wiimote.device)
|
|
||||||
wiimote.data_ts = std::chrono::high_resolution_clock::now();
|
|
||||||
else
|
|
||||||
wiimote.rumble = false;
|
wiimote.rumble = false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
wiimote.data_ts = std::chrono::high_resolution_clock::now();
|
||||||
|
}
|
||||||
device_lock.unlock();
|
device_lock.unlock();
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue