Experimental fix for evdev failures.
This commit is contained in:
parent
e76ca9889a
commit
09391bfe84
@ -72,14 +72,16 @@ class driver(inputDriver):
|
||||
self.env['runtime']['debug'].writeDebugOut('plugInputDeviceWatchdogUdev:' + str(device), debug.debugLevel.INFO)
|
||||
try:
|
||||
try:
|
||||
if device.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||
# FIX: Check if attributes exist before accessing them
|
||||
if hasattr(device, 'name') and device.name and device.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||
ignorePlug = True
|
||||
if device.phys.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||
if hasattr(device, 'phys') and device.phys and device.phys.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||
ignorePlug = True
|
||||
if 'BRLTTY' in device.name.upper():
|
||||
if hasattr(device, 'name') and device.name and 'BRLTTY' in device.name.upper():
|
||||
ignorePlug = True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut("plugInputDeviceWatchdogUdev CHECK NAME CRASH: " + str(e), debug.debugLevel.ERROR)
|
||||
|
||||
if not ignorePlug:
|
||||
virtual = '/sys/devices/virtual/input/' in device.sys_path
|
||||
if device.device_node:
|
||||
@ -89,7 +91,7 @@ class driver(inputDriver):
|
||||
try:
|
||||
pollTimeout = 1
|
||||
device = monitor.poll(pollTimeout)
|
||||
except:
|
||||
except Exception:
|
||||
device = None
|
||||
ignorePlug = False
|
||||
if validDevices:
|
||||
@ -146,7 +148,7 @@ class driver(inputDriver):
|
||||
if uDevice:
|
||||
if self.gDevices[iDevice.fd]:
|
||||
self.writeUInput(uDevice, event)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def writeUInput(self, uDevice, event):
|
||||
@ -191,7 +193,7 @@ class driver(inputDriver):
|
||||
try:
|
||||
with open(deviceFile) as f:
|
||||
pass
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
continue
|
||||
# 3 pos absolute
|
||||
# 2 pos relative
|
||||
@ -201,11 +203,12 @@ class driver(inputDriver):
|
||||
except:
|
||||
continue
|
||||
try:
|
||||
if currDevice.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||
# FIX: Check if attributes exist before accessing them
|
||||
if hasattr(currDevice, 'name') and currDevice.name and currDevice.name.upper() in ['', 'SPEAKUP', 'FENRIR-UINPUT']:
|
||||
continue
|
||||
if currDevice.phys.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||
if hasattr(currDevice, 'phys') and currDevice.phys and currDevice.phys.upper() in ['', 'SPEAKUP', 'FENRIR-UINPUT']:
|
||||
continue
|
||||
if 'BRLTTY' in currDevice.name.upper():
|
||||
if hasattr(currDevice, 'name') and currDevice.name and 'BRLTTY' in currDevice.name.upper():
|
||||
continue
|
||||
except:
|
||||
pass
|
||||
@ -233,7 +236,11 @@ class driver(inputDriver):
|
||||
self.addDevice(currDevice)
|
||||
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 +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
||||
try:
|
||||
device_name = currDevice.name if hasattr(currDevice, 'name') else "unknown"
|
||||
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile + ' ' + device_name + ' ' + str(e), debug.debugLevel.INFO)
|
||||
except:
|
||||
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile + ' ' + str(e), debug.debugLevel.INFO)
|
||||
self.iDeviceNo = len(evdev.list_devices())
|
||||
self.updateMPiDevicesFD()
|
||||
|
||||
@ -247,6 +254,7 @@ class driver(inputDriver):
|
||||
self.iDevicesFD.remove(fd)
|
||||
except:
|
||||
pass
|
||||
|
||||
def mapEvent(self, event):
|
||||
if not self._initialized:
|
||||
return None
|
||||
@ -268,7 +276,7 @@ class driver(inputDriver):
|
||||
mEvent['EventState'] = event.value
|
||||
mEvent['EventType'] = event.type
|
||||
return mEvent
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def getLedState(self, led=0):
|
||||
@ -281,6 +289,7 @@ class driver(inputDriver):
|
||||
if led in dev.leds():
|
||||
return True
|
||||
return False
|
||||
|
||||
def toggleLedState(self, led=0):
|
||||
if not self.hasIDevices():
|
||||
return False
|
||||
@ -293,6 +302,7 @@ class driver(inputDriver):
|
||||
self.iDevices[i].set_led(led, 0)
|
||||
else:
|
||||
self.iDevices[i].set_led(led, 1)
|
||||
|
||||
def grabAllDevices(self):
|
||||
if not self._initialized:
|
||||
return True
|
||||
@ -301,6 +311,7 @@ class driver(inputDriver):
|
||||
if not self.gDevices[fd]:
|
||||
ok = ok and self.grabDevice(fd)
|
||||
return ok
|
||||
|
||||
def ungrabAllDevices(self):
|
||||
if not self._initialized:
|
||||
return True
|
||||
@ -309,6 +320,7 @@ class driver(inputDriver):
|
||||
if self.gDevices[fd]:
|
||||
ok = ok and self.ungrabDevice(fd)
|
||||
return ok
|
||||
|
||||
def createUInputDev(self, fd):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||
self.uDevices[fd] = None
|
||||
@ -336,6 +348,7 @@ class driver(inputDriver):
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e), debug.debugLevel.ERROR)
|
||||
return
|
||||
|
||||
def addDevice(self, newDevice):
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device added: ' + str(newDevice.fd) + ' ' + str(newDevice), debug.debugLevel.INFO)
|
||||
try:
|
||||
@ -360,6 +373,9 @@ class driver(inputDriver):
|
||||
def grabDevice(self, fd):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||
return True
|
||||
|
||||
# FIX: Handle exception variable scope correctly
|
||||
grab_error = None
|
||||
try:
|
||||
self.iDevices[fd].grab()
|
||||
self.gDevices[fd] = True
|
||||
@ -371,19 +387,26 @@ class driver(inputDriver):
|
||||
try:
|
||||
self.uDevices[fd].write(e.EV_KEY, key, 0) # 0 = key up
|
||||
self.uDevices[fd].syn()
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('Failed to reset modifier key: ' + str(e), debug.debugLevel.WARNING)
|
||||
except Exception as mod_error:
|
||||
self.env['runtime']['debug'].writeDebugOut('Failed to reset modifier key: ' + str(mod_error), debug.debugLevel.WARNING)
|
||||
except IOError:
|
||||
if not self.gDevices[fd]:
|
||||
return False
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
|
||||
except Exception as ex:
|
||||
grab_error = ex
|
||||
|
||||
if grab_error:
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(grab_error), debug.debugLevel.ERROR)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def ungrabDevice(self, fd):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||
return True
|
||||
|
||||
# FIX: Handle exception variable scope correctly
|
||||
ungrab_error = None
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
self.gDevices[fd] = False
|
||||
@ -391,11 +414,15 @@ class driver(inputDriver):
|
||||
except IOError:
|
||||
if self.gDevices[fd]:
|
||||
return False
|
||||
# self.gDevices[fd] = False
|
||||
# #self.removeDevice(fd)
|
||||
except Exception as e:
|
||||
except Exception as ex:
|
||||
ungrab_error = ex
|
||||
|
||||
if ungrab_error:
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: ungrabing not possible: ' + str(ungrab_error), debug.debugLevel.ERROR)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def removeDevice(self, fd):
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' + str(self.iDevices[fd]), debug.debugLevel.INFO)
|
||||
self.clearEventBuffer()
|
||||
|
Loading…
x
Reference in New Issue
Block a user