From ce817466c392a16685c5c872e978f333d1daf7ef Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 1 Oct 2017 13:28:13 +0200 Subject: [PATCH] improve input device detection --- src/fenrir/core/settingsManager.py | 12 ++++++------ src/fenrir/inputDriver/evdevDriver.py | 15 ++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/fenrir/core/settingsManager.py b/src/fenrir/core/settingsManager.py index 1d33614c..39f86095 100644 --- a/src/fenrir/core/settingsManager.py +++ b/src/fenrir/core/settingsManager.py @@ -322,17 +322,17 @@ class settingsManager(): environment['runtime']['settingsManager'].loadDicts(self.getSetting('general','punctuationProfile')) if fenrirManager: - environment['runtime']['fenrirManager'] = fenrirManager + environment['runtime']['fenrirManager'] = fenrirManager environment['runtime']['eventManager'] = eventManager.eventManager() - environment['runtime']['eventManager'].initialize(environment) - environment['runtime']['processManager'] = processManager.processManager() - environment['runtime']['processManager'].initialize(environment) - environment['runtime']['inputManager'] = inputManager.inputManager() - environment['runtime']['inputManager'].initialize(environment) + environment['runtime']['eventManager'].initialize(environment) + environment['runtime']['processManager'] = processManager.processManager() + environment['runtime']['processManager'].initialize(environment) environment['runtime']['outputManager'] = outputManager.outputManager() environment['runtime']['outputManager'].initialize(environment) environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'].initialize(environment) + environment['runtime']['inputManager'] = inputManager.inputManager() + environment['runtime']['inputManager'].initialize(environment) environment['runtime']['punctuationManager'] = punctuationManager.punctuationManager() environment['runtime']['punctuationManager'].initialize(environment) environment['runtime']['cursorManager'] = cursorManager.cursorManager() diff --git a/src/fenrir/inputDriver/evdevDriver.py b/src/fenrir/inputDriver/evdevDriver.py index 87d749a0..538929e5 100644 --- a/src/fenrir/inputDriver/evdevDriver.py +++ b/src/fenrir/inputDriver/evdevDriver.py @@ -60,11 +60,11 @@ class driver(): monitor = pyudev.Monitor.from_netlink(context) monitor.filter_by(subsystem='input') monitor.start() - while active.value == 1: + while active.value: devices = monitor.poll(2) if devices: - while monitor.poll(0.05): - time.sleep(0.01) + while monitor.poll(0.5): + time.sleep(0.2) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) return time.time() def plugInputDeviceWatchdogTimer(self, active): @@ -181,10 +181,10 @@ class driver(): if mode in ['ALL','NOMICE']: if eventType.EV_KEY in cap: if 116 in cap[eventType.EV_KEY] and len(cap[eventType.EV_KEY]) < 10: - self.env['runtime']['debug'].writeDebugOut('Device Skipped (has 116):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut('Device Skipped (has 116):' + currDevice.name,debug.debugLevel.INFO) continue if len(cap[eventType.EV_KEY]) < 30: - self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 30 keys):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 30 keys):' + currDevice.name,debug.debugLevel.INFO) continue if mode == 'ALL': self.iDevices[currDevice.fd] = currDevice @@ -196,13 +196,14 @@ class driver(): self.grabDevice(currDevice.fd) self.env['runtime']['debug'].writeDebugOut('Device added (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) else: - self.env['runtime']['debug'].writeDebugOut('Device Skipped (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut('Device Skipped (NOMICE):' + currDevice.name,debug.debugLevel.INFO) elif currDevice.name.upper() in mode.split(','): self.iDevices[currDevice.fd] = currDevice self.grabDevice(currDevice.fd) self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) except Exception as e: - self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + str(e),debug.debugLevel.ERROR) + print(e) + self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO) self.iDeviceNo = len(evdev.list_devices()) self.updateMPiDevicesFD()