Switched device removal and insertion responsibility to DeviceFinder

This commit is contained in:
rockerbacon
2019-09-20 17:20:06 -03:00
parent 13bce5cc76
commit ba0bf93b80
3 changed files with 90 additions and 43 deletions
+2 -14
View File
@@ -248,19 +248,7 @@ void ReceiverHandler::handleEvent(const HIDPP::Report &event)
{
case HIDPP10::IReceiver::DeviceUnpaired:
{
// Find device, stop it, and delete it
auto it = finder->devices.begin();
while (it != finder->devices.end())
{
if(it->first->path == dev->path && it->first->index == event.deviceIndex())
{
log_printf(INFO, "%s (Device %d on %s) unpaired.", it->first->name.c_str(), event.deviceIndex(), dev->path.c_str());
it->first->stop();
it->second.join();
finder->devices.erase(it);
}
else it++;
}
finder->stopAndDeleteDevice(dev->path, event.deviceIndex());
break;
}
case HIDPP10::IReceiver::DevicePaired:
@@ -384,4 +372,4 @@ std::map<uint16_t, uint8_t> Device::get_features()
_features.insert( {i, ifs.getFeatureID(i) } );
return _features;
}
}