ControllerInterface: invoke callbacks in AddDevice/RemoveDevice

Some backends already cause this to happen, so make it consistent across
systems.
This commit is contained in:
Michael M
2017-11-09 12:14:21 -08:00
parent 126b7ea01c
commit 7355b5f70d
6 changed files with 47 additions and 30 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);