From 7c71ebd451256886b12b953adba47c717dbda4ba Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 31 Jan 2017 10:37:39 +0100 Subject: [PATCH] add compat for older evdev versions. --- src/fenrir/inputDriver/evdevDriver.py | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/fenrir/inputDriver/evdevDriver.py b/src/fenrir/inputDriver/evdevDriver.py index 3724faf2..1fff537e 100644 --- a/src/fenrir/inputDriver/evdevDriver.py +++ b/src/fenrir/inputDriver/evdevDriver.py @@ -161,7 +161,28 @@ class driver(): self.ledDevices[i].set_led(led , 1) def grabDevices(self): if not self._initialized: - return None + return None + try: + for fd in self.iDevices: + try: + self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn) + except: + try: + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: compat fallback: ' + str(e),debug.debugLevel.ERROR) + dev = self.iDevices[fd] + cap = dev.capabilities() + del cap[0] + self.uDevices[fd] = UInput( + cap, + dev.name, + ) + except Exception as e: + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR) + return + try: + self.iDevices[fd].grab() + except Exception as e: + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR) # leve the old code until the new one is better tested # for fd in self.iDevices: # dev = self.iDevices[fd] @@ -175,14 +196,10 @@ class driver(): # #dev.version, # #dev.info.bustype, # #'/dev/uinput' -# ) +# ) # dev.grab() - for fd in self.iDevices: - try: - self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn) - self.iDevices[fd].grab() - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR) + + def releaseDevices(self): if not self._initialized: return None