mirror of
https://github.com/PixlOne/logiops.git
synced 2025-07-14 13:22:33 +08:00
Wait for devices to be ready before adding them.
This commit is contained in:
parent
adcb173e4c
commit
0115aaa804
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
namespace logid {
|
namespace logid {
|
||||||
namespace defaults {
|
namespace defaults {
|
||||||
static constexpr double io_timeout = 1000;
|
static constexpr double io_timeout = 500;
|
||||||
static constexpr int gesture_threshold = 50;
|
static constexpr int gesture_threshold = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,15 @@ void DeviceMonitor::ready() {
|
|||||||
std::string dev_node = udev_device_get_devnode(device);
|
std::string dev_node = udev_device_get_devnode(device);
|
||||||
|
|
||||||
if (action == "add")
|
if (action == "add")
|
||||||
spawn_task([this, dev_node]() { _addHandler(dev_node); });
|
spawn_task([this, dev_node]() {
|
||||||
|
/* Device was just connected, may not be ready yet.
|
||||||
|
* Sleep for 2 seconds to ensure device is ready before attempting to add.
|
||||||
|
* This is a bit of a hack and this time was determined through a bit of
|
||||||
|
* experimentation.
|
||||||
|
*/
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(ready_wait));
|
||||||
|
_addHandler(dev_node);
|
||||||
|
});
|
||||||
else if (action == "remove")
|
else if (action == "remove")
|
||||||
spawn_task([this, dev_node]() { _removeHandler(dev_node); });
|
spawn_task([this, dev_node]() { _removeHandler(dev_node); });
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ struct udev_monitor;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace logid::backend::raw {
|
namespace logid::backend::raw {
|
||||||
|
static constexpr int ready_wait = 2000;
|
||||||
|
|
||||||
class DeviceMonitor {
|
class DeviceMonitor {
|
||||||
public:
|
public:
|
||||||
virtual ~DeviceMonitor();
|
virtual ~DeviceMonitor();
|
||||||
|
Loading…
Reference in New Issue
Block a user