diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-08-29 13:52:47 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-08-29 16:09:27 +1000 |
commit | 0789bc663cd17c82138f8358fda3ab4ec3925fe2 (patch) | |
tree | a6cf20dd51b85d926aeb811f253f6c7dea8c6373 | |
parent | f75d74ef55071f157950d339222179bb6582649a (diff) |
device: if the device node is still empty when we need it, re-guess
Sometimes the device is there, but EVIOCGNAME fails on it and we can't guess
the device node after creation time. Try again whenever we ask for the
node, in the hope that enough time has passed and we may get it this time.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | src/device.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/device.cpp b/src/device.cpp index 50d0c28..232d3ae 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -45,6 +45,7 @@ struct xorg::testing::evemu::Device::Private { int fd; struct evemu_device* device; std::string device_node; + time_t ctime; }; static int _event_device_compare(const struct dirent **a, @@ -137,14 +138,14 @@ xorg::testing::evemu::Device::Device(const std::string& path) throw std::runtime_error("Failed to open uinput node"); } - time_t ctime = time(NULL); + d_->ctime = time(NULL); if (evemu_create(d_->device, d_->fd) < 0) { close(d_->fd); evemu_delete(d_->device); throw std::runtime_error("Failed to create evemu device"); } - GuessDeviceNode(ctime); + GuessDeviceNode(d_->ctime); } void xorg::testing::evemu::Device::Play(const std::string& path) const { @@ -179,6 +180,8 @@ void xorg::testing::evemu::Device::PlayOne(int type, int code, int value, bool s } const std::string& xorg::testing::evemu::Device::GetDeviceNode(void) { + if (d_->device_node.empty()) + GuessDeviceNode(d_->ctime); return d_->device_node; } |