diff --git a/autostart/systemd/fenrir.service b/autostart/systemd/fenrir.service index 439a770d..eeeebd07 100644 --- a/autostart/systemd/fenrir.service +++ b/autostart/systemd/fenrir.service @@ -12,4 +12,7 @@ Restart=always #User=fenrirscreenreader [Install] -WantedBy=sound.target +# start as early as possible in boot process +#WantedBy=sound.target +# start as soon the login prompt is available +WantedBy=getty.target diff --git a/src/fenrir-daemon b/src/fenrir-daemon index 80a618a5..e813875c 100755 --- a/src/fenrir-daemon +++ b/src/fenrir-daemon @@ -22,7 +22,7 @@ def main(): if __name__ == "__main__": # for debug in foreground - #daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, foreground=True,chdir=os.path.dirname(os.path.realpath(fenrirVersion.__file__))) - daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, chdir=fenrirPath) + daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, foreground=True,chdir=fenrirPath) + #daemon = Daemonize(app="fenrir-daemon", pid=pidFile, action=main, chdir=fenrirPath) daemon.start() diff --git a/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py b/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py index fa2d364a..8e925bfe 100755 --- a/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py +++ b/src/fenrirscreenreader/commands/onPlugInputDevice/50000-UpdateDevices.py @@ -16,6 +16,6 @@ class command(): def getDescription(self): return 'No description found' def run(self): - self.env['runtime']['inputManager'].updateInputDevices() + pass def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 9f2a885a..399f4d56 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -166,6 +166,7 @@ class fenrirManager(): #print('handleScreenUpdate:',time.time() - startTime) def handlePlugInputDevice(self, event): + self.environment['runtime']['inputManager'].updateInputDevices() self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True) def handleHeartBeat(self, event): diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index 444e1947..27eff00e 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -282,6 +282,9 @@ class settingsManager(): environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'].initialize(environment) + environment['runtime']['helpManager'] = helpManager.helpManager() + environment['runtime']['helpManager'].initialize(environment) + environment['runtime']['byteManager'] = byteManager.byteManager() environment['runtime']['byteManager'].initialize(environment) @@ -313,8 +316,6 @@ class settingsManager(): environment['runtime']['cursorManager'].initialize(environment) environment['runtime']['applicationManager'] = applicationManager.applicationManager() environment['runtime']['applicationManager'].initialize(environment) - environment['runtime']['helpManager'] = helpManager.helpManager() - environment['runtime']['helpManager'].initialize(environment) environment['runtime']['headLineManager'] = headLineManager.headLineManager() environment['runtime']['headLineManager'].initialize(environment) environment['runtime']['tableManager'] = tableManager.tableManager() diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 6b784394..c4e8b454 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -54,8 +54,8 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) return self.updateInputDevices() - #if _udevAvailable: - # self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) + if _udevAvailable: + self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) #else: # self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer) self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog) @@ -65,10 +65,16 @@ class driver(inputDriver): monitor.filter_by(subsystem='input') monitor.start() while active.value: - devices = monitor.poll(2) - if devices: - while monitor.poll(1): + validDevice = False + device = monitor.poll(1) + while device: + try: + if not '/sys/devices/virtual/input/' in device.sys_path: + validDevice = True + device = monitor.poll(0.5) + except: pass + if validDevice: eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) return time.time() def plugInputDeviceWatchdogTimer(self, active): @@ -78,7 +84,7 @@ class driver(inputDriver): def inputWatchdog(self,active , eventQueue): try: while active.value: - r, w, x = select(self.iDevices, [], [], 0.5) + r, w, x = select(self.iDevices, [], [], 0.7) for fd in r: event = None foreward = False @@ -165,6 +171,8 @@ class driver(inputDriver): 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(): continue cap = currDevice.capabilities() @@ -194,12 +202,15 @@ class driver(inputDriver): self.updateMPiDevicesFD() def updateMPiDevicesFD(self): - for fd in self.iDevices: - if not fd in self.iDevicesFD: - self.iDevicesFD.append(fd) - for fd in self.iDevicesFD: - if not fd in self.iDevices: - self.iDevicesFD.remove(fd) + try: + for fd in self.iDevices: + if not fd in self.iDevicesFD: + self.iDevicesFD.append(fd) + for fd in self.iDevicesFD: + if not fd in self.iDevices: + self.iDevicesFD.remove(fd) + except: + pass def mapEvent(self, event): if not self._initialized: return None @@ -242,12 +253,14 @@ class driver(inputDriver): if not self._initialized: return for fd in self.iDevices: - self.grabDevice(fd) + self.grabDevice(fd) + def ungrabAllDevices(self): if not self._initialized: return for fd in self.iDevices: self.ungrabDevice(fd) + def createUInputDev(self, fd): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): self.uDevices[fd] = None @@ -275,9 +288,10 @@ class driver(inputDriver): self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR) return def addDevice(self, newDevice): - self.iDevices[newDevice.fd] = newDevice + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device added: ' + str(newDevice.fd) + ' ' +str(newDevice),debug.debugLevel.INFO) + self.iDevices[newDevice.fd] = newDevice + self.gDevices[newDevice.fd] = False self.createUInputDev(newDevice.fd) - self.grabDevice(newDevice.fd) def grabDevice(self, fd): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): return @@ -295,7 +309,7 @@ class driver(inputDriver): except: pass def removeDevice(self,fd): - self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' +str(self.iDevices[fd]),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' +str(self.iDevices[fd]),debug.debugLevel.INFO) self.clearEventBuffer() try: self.ungrabDevice(fd) @@ -340,6 +354,5 @@ class driver(inputDriver): self.removeDevice(fd) self.iDevices.clear() self.uDevices.clear() + self.gDevices.clear() self.iDeviceNo = 0 - -