make new device detection work

This commit is contained in:
chrys 2018-05-20 07:43:26 +02:00
parent 27c5075b23
commit 6981145a8c

View File

@ -70,8 +70,9 @@ class driver(inputDriver):
while device:
try:
if not '/sys/devices/virtual/input/' in device.sys_path:
validDevices.append(str(device.device_path))
device = monitor.poll(0.2)
if device.device_node:
validDevices.append(str(device.device_node))
device = monitor.poll(0.1)
except:
pass
if validDevices:
@ -146,7 +147,6 @@ class driver(inputDriver):
if init:
self.removeAllDevices()
print(newDevices)
deviceFileList = None
if newDevices and not init:
@ -173,6 +173,7 @@ class driver(inputDriver):
continue
if deviceFile in iDevicesFiles:
continue
try:
open(deviceFile)
except Exception as e:
@ -181,13 +182,22 @@ class driver(inputDriver):
# 3 pos absolute
# 2 pos relative
# 1 Keys
currDevice = evdev.InputDevice(deviceFile)
if currDevice.name.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
continue
if currDevice.phys.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
continue
if 'BRLTTY' in currDevice.name.upper():
try:
currDevice = evdev.InputDevice(deviceFile)
except:
continue
try:
if currDevice.name.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
continue
if currDevice.phys.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
continue
if 'BRLTTY' in currDevice.name.upper():
continue
except:
pass
cap = currDevice.capabilities()
if mode in ['ALL','NOMICE']:
if eventType.EV_KEY in cap:
@ -213,6 +223,7 @@ class driver(inputDriver):
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
self.iDeviceNo = len(evdev.list_devices())
self.updateMPiDevicesFD()
def updateMPiDevicesFD(self):
try:
for fd in self.iDevices: