Merge pull request #6166 from ligfx/invokedeviceschangedcallbacks

ControllerInterface: cleanup callbacks API and logic
This commit is contained in:
Leo Lam
2017-12-15 21:05:17 +01:00
committed by GitHub
10 changed files with 78 additions and 50 deletions

View File

@ -92,9 +92,7 @@ static void HotplugThreadFunc()
g_controller_interface.RemoveDevice([&name](const auto& device) {
return device->GetSource() == "evdev" && device->GetName() == name && !device->IsValid();
});
NOTICE_LOG(SERIALINTERFACE, "Removed device: %s", name.c_str());
s_devnode_name_map.erase(devnode);
g_controller_interface.InvokeHotplugCallbacks();
}
// Only react to "device added" events for evdev devices that we can access.
else if (strcmp(action, "add") == 0 && access(devnode, W_OK) == 0)
@ -107,8 +105,6 @@ static void HotplugThreadFunc()
{
g_controller_interface.AddDevice(std::move(device));
s_devnode_name_map.insert(std::pair<std::string, std::string>(devnode, name));
NOTICE_LOG(SERIALINTERFACE, "Added new device: %s", name.c_str());
g_controller_interface.InvokeHotplugCallbacks();
}
}
udev_device_unref(dev);