improve input device detection

This commit is contained in:
chrys 2017-10-01 13:28:13 +02:00
parent afc4b398dc
commit ce817466c3
2 changed files with 14 additions and 13 deletions

View File

@ -327,12 +327,12 @@ class settingsManager():
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']['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()

View File

@ -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()