Merge branch 'bleed'

This commit is contained in:
chrys 2018-05-22 19:55:57 +02:00
commit 1968e436eb
7 changed files with 1530 additions and 32 deletions

1459
logs/fenrir.log Normal file

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,7 @@ class command():
def getDescription(self): def getDescription(self):
return 'No description found' return 'No description found'
def run(self): def run(self):
self.env['runtime']['inputManager'].updateInputDevices() pass
#self.env['runtime']['inputManager'].updateInputDevices()
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -166,6 +166,7 @@ class fenrirManager():
#print('handleScreenUpdate:',time.time() - startTime) #print('handleScreenUpdate:',time.time() - startTime)
def handlePlugInputDevice(self, event): def handlePlugInputDevice(self, event):
self.environment['runtime']['inputManager'].handlePlugInputDevice(event['Data'])
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True) self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
def handleHeartBeat(self, event): def handleHeartBeat(self, event):

View File

@ -136,10 +136,12 @@ class inputManager():
self.env['runtime']['inputDriver'].ungrabAllDevices() self.env['runtime']['inputDriver'].ungrabAllDevices()
except Exception as e: except Exception as e:
pass pass
def handlePlugInputDevice(self, eventData):
def updateInputDevices(self): self.env['runtime']['inputManager'].updateInputDevices(eventData)
def updateInputDevices(self, newDevice = None):
try: try:
self.env['runtime']['inputDriver'].updateInputDevices() self.env['runtime']['inputDriver'].updateInputDevices(newDevice)
except: except:
pass pass
self.handleDeviceGrab(True) self.handleDeviceGrab(True)

View File

@ -136,16 +136,19 @@ class screenManager():
newScreenText.split('\n')) newScreenText.split('\n'))
diffList = list(diff) diffList = list(diff)
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'newLinePause') and not typing: if not typing:
self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+') self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+')
else: else:
self.env['screen']['newDelta'] = ''.join(x[2:] for x in diffList if x[0] == '+') self.env['screen']['newDelta'] = ''.join(x[2:] for x in diffList if x[0] == '+')
self.env['screen']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') self.env['screen']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-')
# track highlighted # track highlighted
if self.env['screen']['oldContentAttrib'] != self.env['screen']['newContentAttrib']: try:
if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): if self.env['screen']['oldContentAttrib'] != self.env['screen']['newContentAttrib']:
self.env['screen']['newAttribDelta'], self.env['screen']['newCursorAttrib'] = screen_utils.trackHighlights(self.env['screen']['oldContentAttrib'], self.env['screen']['newContentAttrib'], self.env['screen']['newContentText'], self.env['screen']['columns']) if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'):
self.env['screen']['newAttribDelta'], self.env['screen']['newCursorAttrib'] = screen_utils.trackHighlights(self.env['screen']['oldContentAttrib'], self.env['screen']['newContentAttrib'], self.env['screen']['newContentText'], self.env['screen']['columns'])
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('screenManager:update:highlight: ' + str(e),debug.debugLevel.ERROR)
def formatAttributes(self, attribute, attributeFormatString = None): def formatAttributes(self, attribute, attributeFormatString = None):
if not attributeFormatString: if not attributeFormatString:

View File

@ -65,21 +65,22 @@ class driver(inputDriver):
monitor.filter_by(subsystem='input') monitor.filter_by(subsystem='input')
monitor.start() monitor.start()
while active.value: while active.value:
validDevice = False validDevices = []
device = monitor.poll(1) device = monitor.poll(1)
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:
validDevice = True if device.device_node:
device = monitor.poll(0.5) validDevices.append(str(device.device_node))
device = monitor.poll(0.1)
except: except:
pass pass
if validDevice: if validDevices:
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":validDevices})
return time.time() return time.time()
def plugInputDeviceWatchdogTimer(self, active): def plugInputDeviceWatchdogTimer(self, active):
time.sleep(10) time.sleep(10)
return time.time() return None
def inputWatchdog(self,active , eventQueue): def inputWatchdog(self,active , eventQueue):
try: try:
@ -142,24 +143,38 @@ class driver(inputDriver):
uDevice.write_event(event) uDevice.write_event(event)
uDevice.syn() uDevice.syn()
def updateInputDevices(self, force = False, init = False): def updateInputDevices(self, newDevices = None, init = False):
if init: if init:
self.removeAllDevices() self.removeAllDevices()
deviceFileList = evdev.list_devices()
if not force and False: deviceFileList = None
if newDevices and not init:
deviceFileList = newDevices
else:
deviceFileList = evdev.list_devices()
if len(deviceFileList) == self.iDeviceNo: if len(deviceFileList) == self.iDeviceNo:
return return
if not deviceFileList:
return
mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper()
iDevicesFiles = [] iDevicesFiles = []
for device in self.iDevices: for device in self.iDevices:
iDevicesFiles.append(self.iDevices[device].fn) iDevicesFiles.append(self.iDevices[device].fn)
if len(iDevicesFiles) == len(deviceFileList):
return
eventType = evdev.events eventType = evdev.events
for deviceFile in deviceFileList: for deviceFile in deviceFileList:
try: try:
self.env['runtime']['debug'].writeDebugOut('loop start',debug.debugLevel.ERROR)
if not deviceFile:
continue
if deviceFile == '':
continue
if deviceFile in iDevicesFiles: if deviceFile in iDevicesFiles:
continue continue
self.env['runtime']['debug'].writeDebugOut('open(deviceFile)',debug.debugLevel.ERROR)
try: try:
open(deviceFile) open(deviceFile)
except Exception as e: except Exception as e:
@ -168,22 +183,34 @@ class driver(inputDriver):
# 3 pos absolute # 3 pos absolute
# 2 pos relative # 2 pos relative
# 1 Keys # 1 Keys
currDevice = evdev.InputDevice(deviceFile) self.env['runtime']['debug'].writeDebugOut('currDevice = evdev.InputDevice(deviceFile)',debug.debugLevel.ERROR)
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']: self.env['runtime']['debug'].writeDebugOut('naming',debug.debugLevel.ERROR)
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
self.env['runtime']['debug'].writeDebugOut('loaded name:'+ str(currDevice.name),debug.debugLevel.ERROR)
except:
pass
self.env['runtime']['debug'].writeDebugOut('cap = currDevice.capabilities()',debug.debugLevel.ERROR)
cap = currDevice.capabilities() cap = currDevice.capabilities()
self.env['runtime']['debug'].writeDebugOut('cap = currDevice.capabilities() fin',debug.debugLevel.ERROR)
if mode in ['ALL','NOMICE']: if mode in ['ALL','NOMICE']:
if eventType.EV_KEY in cap: if eventType.EV_KEY in cap:
self.env['runtime']['debug'].writeDebugOut('eventType.EV_KEY in cap NoOfCaps: '+ str(cap) ,debug.debugLevel.ERROR)
if 116 in cap[eventType.EV_KEY] and len(cap[eventType.EV_KEY]) < 10: if 116 in cap[eventType.EV_KEY] and len(cap[eventType.EV_KEY]) < 10:
self.env['runtime']['debug'].writeDebugOut('Device Skipped (has 116):' + currDevice.name,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('Device Skipped (has 116):' + currDevice.name,debug.debugLevel.INFO)
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)
@ -192,14 +219,18 @@ class driver(inputDriver):
self.addDevice(currDevice) self.addDevice(currDevice)
self.env['runtime']['debug'].writeDebugOut('Device added (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('Device added (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
else: else:
self.env['runtime']['debug'].writeDebugOut('Device Skipped (NOMICE):' + currDevice.name,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('Device Skipped (NOMICE):' + currDevice.name,debug.debugLevel.INFO)
else:
self.env['runtime']['debug'].writeDebugOut('Device Skipped (no EV_KEY):' + currDevice.name,debug.debugLevel.INFO)
elif currDevice.name.upper() in mode.split(','): elif currDevice.name.upper() in mode.split(','):
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)
self.env['runtime']['debug'].writeDebugOut('loop end',debug.debugLevel.ERROR)
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:

View File

@ -10,6 +10,7 @@ from fenrirscreenreader.core.inputDriver import inputDriver
class driver(inputDriver): class driver(inputDriver):
def __init__(self): def __init__(self):
self._isInitialized = False
inputDriver.__init__(self) inputDriver.__init__(self)
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment