make new device detection work
This commit is contained in:
parent
27c5075b23
commit
6981145a8c
@ -70,8 +70,9 @@ class driver(inputDriver):
|
|||||||
while device:
|
while device:
|
||||||
try:
|
try:
|
||||||
if not '/sys/devices/virtual/input/' in device.sys_path:
|
if not '/sys/devices/virtual/input/' in device.sys_path:
|
||||||
validDevices.append(str(device.device_path))
|
if device.device_node:
|
||||||
device = monitor.poll(0.2)
|
validDevices.append(str(device.device_node))
|
||||||
|
device = monitor.poll(0.1)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if validDevices:
|
if validDevices:
|
||||||
@ -145,10 +146,9 @@ class driver(inputDriver):
|
|||||||
def updateInputDevices(self, newDevices = None, init = False):
|
def updateInputDevices(self, newDevices = None, init = False):
|
||||||
if init:
|
if init:
|
||||||
self.removeAllDevices()
|
self.removeAllDevices()
|
||||||
|
|
||||||
print(newDevices)
|
|
||||||
deviceFileList = None
|
deviceFileList = None
|
||||||
|
|
||||||
if newDevices and not init:
|
if newDevices and not init:
|
||||||
deviceFileList = newDevices
|
deviceFileList = newDevices
|
||||||
else:
|
else:
|
||||||
@ -157,7 +157,7 @@ class driver(inputDriver):
|
|||||||
return
|
return
|
||||||
if not deviceFileList:
|
if not deviceFileList:
|
||||||
return
|
return
|
||||||
|
|
||||||
mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper()
|
mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper()
|
||||||
|
|
||||||
iDevicesFiles = []
|
iDevicesFiles = []
|
||||||
@ -172,7 +172,8 @@ class driver(inputDriver):
|
|||||||
if deviceFile == '':
|
if deviceFile == '':
|
||||||
continue
|
continue
|
||||||
if deviceFile in iDevicesFiles:
|
if deviceFile in iDevicesFiles:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
open(deviceFile)
|
open(deviceFile)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -181,13 +182,22 @@ class driver(inputDriver):
|
|||||||
# 3 pos absolute
|
# 3 pos absolute
|
||||||
# 2 pos relative
|
# 2 pos relative
|
||||||
# 1 Keys
|
# 1 Keys
|
||||||
currDevice = evdev.InputDevice(deviceFile)
|
|
||||||
if currDevice.name.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
|
try:
|
||||||
|
currDevice = evdev.InputDevice(deviceFile)
|
||||||
|
except:
|
||||||
continue
|
continue
|
||||||
if currDevice.phys.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
|
|
||||||
continue
|
try:
|
||||||
if 'BRLTTY' in currDevice.name.upper():
|
if currDevice.name.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
|
||||||
continue
|
continue
|
||||||
|
if currDevice.phys.upper() in ['','SPEAKUP','PY-EVDEV-UINPUT']:
|
||||||
|
continue
|
||||||
|
if 'BRLTTY' in currDevice.name.upper():
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
cap = currDevice.capabilities()
|
cap = currDevice.capabilities()
|
||||||
if mode in ['ALL','NOMICE']:
|
if mode in ['ALL','NOMICE']:
|
||||||
if eventType.EV_KEY in cap:
|
if eventType.EV_KEY in cap:
|
||||||
@ -196,7 +206,7 @@ class driver(inputDriver):
|
|||||||
continue
|
continue
|
||||||
if len(cap[eventType.EV_KEY]) < 60:
|
if len(cap[eventType.EV_KEY]) < 60:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 60 keys):' + currDevice.name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 60 keys):' + currDevice.name,debug.debugLevel.INFO)
|
||||||
continue
|
continue
|
||||||
if mode == 'ALL':
|
if mode == 'ALL':
|
||||||
self.addDevice(currDevice)
|
self.addDevice(currDevice)
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
|
||||||
@ -210,9 +220,10 @@ class driver(inputDriver):
|
|||||||
self.addDevice(currDevice)
|
self.addDevice(currDevice)
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
||||||
self.iDeviceNo = len(evdev.list_devices())
|
self.iDeviceNo = len(evdev.list_devices())
|
||||||
self.updateMPiDevicesFD()
|
self.updateMPiDevicesFD()
|
||||||
|
|
||||||
def updateMPiDevicesFD(self):
|
def updateMPiDevicesFD(self):
|
||||||
try:
|
try:
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
|
Loading…
Reference in New Issue
Block a user