From 1aabb253bce121d40095a7b5aa74c573b837ec79 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 19 Oct 2016 20:33:23 +0200 Subject: [PATCH] filter out bogous evdev devices --- src/fenrir/inputDriver/evdev.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index 4c9217c6..2bd61dff 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -58,13 +58,21 @@ class driver(): uDevice.write_event(event) uDevice.syn() def getInputDevices(self): + deviceList = evdev.list_devices() + readableDevices = [] + for dev in deviceList: + try: + open(dev) + readableDevices.append(dev) + except Exception as e: + self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + dev +' ' + str(e),debug.debugLevel.ERROR) + self.iDevices = map(evdev.InputDevice, (readableDevices)) + self.ledDevices = map(evdev.InputDevice, (readableDevices)) # 3 pos absolute # 2 pos relative # 17 LEDs # 1 Keys - # we try to filter out mices and other stuff here - self.iDevices = map(evdev.InputDevice, (evdev.list_devices())) - self.ledDevices = map(evdev.InputDevice, (evdev.list_devices())) + # we try to filter out mices and other stuff here if self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'ALL': self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()} self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities()}