[PATCH xorg-gtest 5/6] device: if the device node is still empty when we need it, re-guess

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 28 23:14:33 PDT 2012


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 at who-t.net>
---
 src/device.cpp | 7 +++++--
 1 file 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;
 }
 
-- 
1.7.11.2



More information about the xorg-devel mailing list