From 0bba78174648fc6865815e0250cf33af6ccf23ce Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 9 Apr 2018 13:44:54 +0200 Subject: [PATCH 01/13] Update README.md --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6eb7b3fd..1d7bcc00 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ This software is licensed under the LGPL v3 . - ReadWrite permission - /dev/input - /dev/uinput +- "ptyDriver" terminal emulation input driver + - python-pyte # Screen Drivers: 1. "vcsaDriver" screen driver for linux VCSA devices @@ -28,28 +30,36 @@ This software is licensed under the LGPL v3 . - /dev/tty[1-64] - /dev/vcsa[1-64] - read logind DBUS - +- "ptyDriver" terminal emulation driver + - python-pyte +- "dummyDriver" just a dummy + # Speech Drivers: -1. "EspeakDriver" speech driver for Espeak or Espeak-NG: +- "genericDriver" (default) sound driver for sound as subprocess: + - espeak or espeak-ng +- "espeakDriver" speech driver for Espeak or Espeak-NG: - python-espeak - "speechdDriver" speech driver for Speech-dispatcher: - Speech-dispatcher - python-speechd -2. "dummyDriver" speech driver for debugging +- "dummyDriver" no speech +- "debugDriver" speech driver for debugging # Braille Drivers: -1. "BrlttyDriver" braille driver (WIP): +- "BrlttyDriver" braille driver (WIP): - brltty (configured and running) - python-brlapi -2. "dummyDriver" Braille driver for debugging +- "dummyDriver" (default) no braille +- "debugDriver" Braille driver for debugging # Sound Drivers: -1. "genericDriver" sound driver for sound as subprocess: +- "genericDriver" (default) sound driver for sound as subprocess: - Sox 2. "gstreamerDriver" sound driver for gstreamer - gstreamer >=1.0 - GLib -3. "dummyDriver" sound driver for debugging +- "dummyDriver" no sound +- "debugDriver" sound driver for debugging # Extras: 1. spellchecker From f98a0333559305bc530070e3606017e3ff79373b Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 9 Apr 2018 13:47:13 +0200 Subject: [PATCH 02/13] Update README.md --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1d7bcc00..c9b7a4de 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,12 @@ This software is licensed under the LGPL v3 . 1. "evdevDriver" input driver for linux evdev - python-evdev >=0.6.3 - python-pyudev -- This is commonly referred to as python3-evdev by your distribution +2. This is commonly referred to as python3-evdev by your distribution - loaded uinput kernel module - ReadWrite permission - /dev/input - /dev/uinput -- "ptyDriver" terminal emulation input driver +3. "ptyDriver" terminal emulation input driver - python-pyte # Screen Drivers: @@ -30,36 +30,36 @@ This software is licensed under the LGPL v3 . - /dev/tty[1-64] - /dev/vcsa[1-64] - read logind DBUS -- "ptyDriver" terminal emulation driver +2. "ptyDriver" terminal emulation driver - python-pyte -- "dummyDriver" just a dummy +3. "dummyDriver" just a dummy # Speech Drivers: -- "genericDriver" (default) sound driver for sound as subprocess: +1. "genericDriver" (default) sound driver for sound as subprocess: - espeak or espeak-ng -- "espeakDriver" speech driver for Espeak or Espeak-NG: +2. "espeakDriver" speech driver for Espeak or Espeak-NG: - python-espeak -- "speechdDriver" speech driver for Speech-dispatcher: +3. "speechdDriver" speech driver for Speech-dispatcher: - Speech-dispatcher - python-speechd -- "dummyDriver" no speech -- "debugDriver" speech driver for debugging +4. "dummyDriver" no speech +5. "debugDriver" speech driver for debugging # Braille Drivers: -- "BrlttyDriver" braille driver (WIP): +1. "BrlttyDriver" braille driver (WIP): - brltty (configured and running) - python-brlapi -- "dummyDriver" (default) no braille -- "debugDriver" Braille driver for debugging +2. "dummyDriver" (default) no braille +3. "debugDriver" Braille driver for debugging # Sound Drivers: -- "genericDriver" (default) sound driver for sound as subprocess: +1. "genericDriver" (default) sound driver for sound as subprocess: - Sox 2. "gstreamerDriver" sound driver for gstreamer - gstreamer >=1.0 - GLib -- "dummyDriver" no sound -- "debugDriver" sound driver for debugging +3. "dummyDriver" no sound +4. "debugDriver" sound driver for debugging # Extras: 1. spellchecker @@ -82,7 +82,7 @@ Settings "settings.conf" is located in the "config" directory or after installat Take care to use drivers from the config matching your installed drivers. By default it uses: - sound driver: genericDriver (via sox, could configured in settings.conf) -- speech driver: speechdDriver +- speech driver: genericDriver (via espeak or espeak-ng, could configured in settings.conf) - braille driver: brlttyDriver (WIP) - input driver: evdevDriver From 9ff73d67bc668873d34d774f8bf51c0cf0dd7899 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 9 Apr 2018 17:03:12 +0200 Subject: [PATCH 03/13] Update processManager.py --- src/fenrirscreenreader/core/processManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fenrirscreenreader/core/processManager.py b/src/fenrirscreenreader/core/processManager.py index bc1af5a0..86811655 100644 --- a/src/fenrirscreenreader/core/processManager.py +++ b/src/fenrirscreenreader/core/processManager.py @@ -71,7 +71,7 @@ class processManager(): else: function(self.running, eventQueue) except Exception as e: - self.env['runtime']['debug'].writeDebugOut('processManager:customEventWorkerThread:function():' + str(e),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut('processManager:customEventWorkerThread:function('+str(function)+'):' + str(e),debug.debugLevel.ERROR) if runOnce: break @@ -88,7 +88,7 @@ class processManager(): else: Data = function(self.running) except Exception as e: - self.env['runtime']['debug'].writeDebugOut('processManager:simpleEventWorkerThread:function():' + str(e),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut('processManager:simpleEventWorkerThread:function('+str(function)+'):' + str(e),debug.debugLevel.ERROR) self.env['runtime']['eventManager'].putToEventQueue(event, Data) if runOnce: break From 190b3e04abfeed096b02d7caec789697585de3a2 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 11 Apr 2018 02:00:26 +0200 Subject: [PATCH 04/13] Revert "improve device detection" This reverts commit f32de7920470c2781a92ce8776b4f0946fd763b2. --- src/fenrirscreenreader/core/fenrirManager.py | 2 +- src/fenrirscreenreader/core/generalData.py | 4 ++-- src/fenrirscreenreader/core/inputManager.py | 1 + src/fenrirscreenreader/inputDriver/evdevDriver.py | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 5254bf9e..0c0c8d5d 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -225,7 +225,7 @@ class fenrirManager(): self.environment['runtime']['eventManager'].stopMainEventLoop() self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True) self.environment['runtime']['eventManager'].cleanEventQueue() - time.sleep(0.6) + time.sleep(1) for currManager in self.environment['general']['managerList']: if self.environment['runtime'][currManager]: self.environment['runtime'][currManager].shutdown() diff --git a/src/fenrirscreenreader/core/generalData.py b/src/fenrirscreenreader/core/generalData.py index c50fff4b..c4b41633 100644 --- a/src/fenrirscreenreader/core/generalData.py +++ b/src/fenrirscreenreader/core/generalData.py @@ -11,8 +11,8 @@ generalData = { 'tutorialMode': False, 'currUser':'', 'prevUser':'', -'managerList':[ 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager' - , 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager','processManager', 'debug'], +'managerList':['processManager', 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager' + , 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager', 'debug'], 'commandFolderList':['commands','onKeyInput', 'onByteInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice' ,'onApplicationChange','onSwitchApplicationProfile','help',], } diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index b74f4ef9..30bd072e 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -24,6 +24,7 @@ class inputManager(): self.env = environment self.env['runtime']['settingsManager'].loadDriver(\ self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver') + self.updateInputDevices() # init LEDs with current state self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState() self.env['input']['oldNumLock'] = self.env['input']['newNumLock'] diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 7b51a83d..d3332c9d 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -52,7 +52,6 @@ class driver(inputDriver): global _evdevAvailableError self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) return - self.updateInputDevices() if _udevAvailable: self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) else: @@ -62,12 +61,14 @@ class driver(inputDriver): context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) monitor.filter_by(subsystem='input') + # wait until start process finished + time.sleep(8) monitor.start() while active.value: devices = monitor.poll(2) if devices: while monitor.poll(0.2): - time.sleep(0.2) + time.sleep(0.1) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) return time.time() def plugInputDeviceWatchdogTimer(self, active): From b5f7526345e0b2e527cc58c421a6614b84ecf426 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 13 Apr 2018 23:42:18 +0200 Subject: [PATCH 05/13] Revert "Merge pull request #21 from chrys87/nocrash" This reverts commit ddecf331f6de81d06adf629de7c836cf284dd60e, reversing changes made to 9ff73d67bc668873d34d774f8bf51c0cf0dd7899. --- src/fenrirscreenreader/core/fenrirManager.py | 2 +- src/fenrirscreenreader/core/generalData.py | 4 ++-- src/fenrirscreenreader/core/inputManager.py | 1 - src/fenrirscreenreader/inputDriver/evdevDriver.py | 5 ++--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 0c0c8d5d..5254bf9e 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -225,7 +225,7 @@ class fenrirManager(): self.environment['runtime']['eventManager'].stopMainEventLoop() self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True) self.environment['runtime']['eventManager'].cleanEventQueue() - time.sleep(1) + time.sleep(0.6) for currManager in self.environment['general']['managerList']: if self.environment['runtime'][currManager]: self.environment['runtime'][currManager].shutdown() diff --git a/src/fenrirscreenreader/core/generalData.py b/src/fenrirscreenreader/core/generalData.py index c4b41633..c50fff4b 100644 --- a/src/fenrirscreenreader/core/generalData.py +++ b/src/fenrirscreenreader/core/generalData.py @@ -11,8 +11,8 @@ generalData = { 'tutorialMode': False, 'currUser':'', 'prevUser':'', -'managerList':['processManager', 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager' - , 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager', 'debug'], +'managerList':[ 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager' + , 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager','processManager', 'debug'], 'commandFolderList':['commands','onKeyInput', 'onByteInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice' ,'onApplicationChange','onSwitchApplicationProfile','help',], } diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index 30bd072e..b74f4ef9 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -24,7 +24,6 @@ class inputManager(): self.env = environment self.env['runtime']['settingsManager'].loadDriver(\ self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver') - self.updateInputDevices() # init LEDs with current state self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState() self.env['input']['oldNumLock'] = self.env['input']['newNumLock'] diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index d3332c9d..7b51a83d 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -52,6 +52,7 @@ class driver(inputDriver): global _evdevAvailableError self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) return + self.updateInputDevices() if _udevAvailable: self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) else: @@ -61,14 +62,12 @@ class driver(inputDriver): context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) monitor.filter_by(subsystem='input') - # wait until start process finished - time.sleep(8) monitor.start() while active.value: devices = monitor.poll(2) if devices: while monitor.poll(0.2): - time.sleep(0.1) + time.sleep(0.2) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None}) return time.time() def plugInputDeviceWatchdogTimer(self, active): From dab2d4ca75b80b1e8be289aaf1edcfd4a720efba Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 15 Apr 2018 15:43:03 +0200 Subject: [PATCH 06/13] add debug --- .../inputDriver/evdevDriver.py | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 7b51a83d..9a55422c 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -75,38 +75,41 @@ class driver(inputDriver): return time.time() def inputWatchdog(self,active , eventQueue): - while active.value: - r, w, x = select(self.iDevices, [], [], 0.5) - for fd in r: - event = None - foreward = False - eventFired = False - try: - event = self.iDevices[fd].read_one() - except: - self.removeDevice(fd) - while(event): - self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) - if event.type == evdev.events.EV_KEY: - if event.code != 0: - currMapEvent = self.mapEvent(event) - if not currMapEvent: - foreward = True - if not isinstance(currMapEvent['EventName'], str): - foreward = True - if not foreward or eventFired: - if currMapEvent['EventState'] in [0,1,2]: - eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) - eventFired = True - else: - if not event.type in [0,4]: - foreward = True - - event = self.iDevices[fd].read_one() - if foreward and not eventFired: - self.writeEventBuffer() - self.clearEventBuffer() - + try: + while active.value: + r, w, x = select(self.iDevices, [], [], 0.5) + for fd in r: + event = None + foreward = False + eventFired = False + try: + event = self.iDevices[fd].read_one() + except: + self.removeDevice(fd) + while(event): + self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) + if event.type == evdev.events.EV_KEY: + if event.code != 0: + currMapEvent = self.mapEvent(event) + if not currMapEvent: + foreward = True + if not isinstance(currMapEvent['EventName'], str): + foreward = True + if not foreward or eventFired: + if currMapEvent['EventState'] in [0,1,2]: + eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) + eventFired = True + else: + if not event.type in [0,4]: + foreward = True + + event = self.iDevices[fd].read_one() + if foreward and not eventFired: + self.writeEventBuffer() + self.clearEventBuffer() + except Exception as e: + self.env['runtime']['debug'].writeDebugOut("INPUT WATCHDOG CRASH: "+str(e),debug.debugLevel.ERROR) + def handleInputEvent(self, event): return @@ -184,7 +187,6 @@ class driver(inputDriver): self.grabDevice(currDevice.fd) self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) except Exception as e: - print(e) self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO) self.iDeviceNo = len(evdev.list_devices()) self.updateMPiDevicesFD() From 1c9d2ca1b7c1bc1284a98ccabbdf16377d089a09 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 24 Apr 2018 13:12:14 +0200 Subject: [PATCH 07/13] Update genericDriver.py --- src/fenrirscreenreader/speechDriver/genericDriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/speechDriver/genericDriver.py b/src/fenrirscreenreader/speechDriver/genericDriver.py index 31f16db9..f936a352 100644 --- a/src/fenrirscreenreader/speechDriver/genericDriver.py +++ b/src/fenrirscreenreader/speechDriver/genericDriver.py @@ -180,7 +180,7 @@ class driver(speechDriver): try: self.env['runtime']['debug'].writeDebugOut('speechDriver:worker:' + ' '.join(popenSpeechCommand),debug.debugLevel.INFO) self.lock.acquire(True) - self.proc = Popen(popenSpeechCommand, shell=False) + self.proc = Popen(popenSpeechCommand, stdin=None, stdout=None, stderr=None shell=False) self.lock.release() self.proc.wait() except Exception as e: From 863938506a51aa3d31e85526679dfe4524c3aed5 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 24 Apr 2018 13:12:41 +0200 Subject: [PATCH 08/13] Update genericDriver.py --- src/fenrirscreenreader/soundDriver/genericDriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/soundDriver/genericDriver.py b/src/fenrirscreenreader/soundDriver/genericDriver.py index d3eec5f6..c599fe9b 100644 --- a/src/fenrirscreenreader/soundDriver/genericDriver.py +++ b/src/fenrirscreenreader/soundDriver/genericDriver.py @@ -37,7 +37,7 @@ class driver(soundDriver): word = word.replace('fenrirFreqDuration', str(duration)) word = word.replace('fenrirFrequence', str(frequence)) popenFrequenceCommand[idx] = word - self.proc = subprocess.Popen(popenFrequenceCommand, shell=False) + self.proc = subprocess.Popen(popenFrequenceCommand, stdin=None, stdout=None, stderr=None, shell=False) self.soundType = 'frequence' def playSoundFile(self, filePath, interrupt = True): if not self._initialized: From e20183aaa9399dfe596932f4d2745f00b534a5ba Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 24 Apr 2018 13:13:10 +0200 Subject: [PATCH 09/13] Update genericDriver.py --- src/fenrirscreenreader/speechDriver/genericDriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/speechDriver/genericDriver.py b/src/fenrirscreenreader/speechDriver/genericDriver.py index f936a352..3aaecfbe 100644 --- a/src/fenrirscreenreader/speechDriver/genericDriver.py +++ b/src/fenrirscreenreader/speechDriver/genericDriver.py @@ -180,7 +180,7 @@ class driver(speechDriver): try: self.env['runtime']['debug'].writeDebugOut('speechDriver:worker:' + ' '.join(popenSpeechCommand),debug.debugLevel.INFO) self.lock.acquire(True) - self.proc = Popen(popenSpeechCommand, stdin=None, stdout=None, stderr=None shell=False) + self.proc = Popen(popenSpeechCommand, stdin=None, stdout=None, stderr=None, shell=False) self.lock.release() self.proc.wait() except Exception as e: From ba3ad7719dae2354a8b22ee6008538039ae29289 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 11 May 2018 22:17:38 +0200 Subject: [PATCH 10/13] use device insteed of fn --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 9a55422c..e4770715 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -247,13 +247,14 @@ class driver(inputDriver): self.uDevices[fd] = None return try: - self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn) + self.uDevices[fd] = UInput.from_device(self.iDevices[fd]) except Exception as e: try: self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: compat fallback: ' + str(e),debug.debugLevel.WARNING) dev = self.iDevices[fd] cap = dev.capabilities() del cap[0] + print(e) self.uDevices[fd] = UInput( cap, dev.name, From 0296590f085fad3f7e8575189cacf311fcdd2563 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 11 May 2018 22:21:30 +0200 Subject: [PATCH 11/13] add ungrab method --- .../inputDriver/evdevDriver.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index e4770715..feb9f97e 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -241,7 +241,11 @@ class driver(inputDriver): return for fd in self.iDevices: self.grabDevice(fd) - + def ungrabAllDevices(self): + if not self._initialized: + return + for fd in self.iDevices: + self.ungrabDevices(fd) def grabDevice(self, fd): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): self.uDevices[fd] = None @@ -254,7 +258,6 @@ class driver(inputDriver): dev = self.iDevices[fd] cap = dev.capabilities() del cap[0] - print(e) self.uDevices[fd] = UInput( cap, dev.name, @@ -266,11 +269,17 @@ class driver(inputDriver): self.iDevices[fd].grab() except Exception as e: self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR) - + def ungrabDevices(self,fd): + if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): + return + try: + self.iDevices[fd].ungrab() + except: + pass def removeDevice(self,fd): self.clearEventBuffer() try: - self.iDevices[fd].ungrab() + self.ungrabDevices(fd) except: pass try: From 101004a5f912f319bc7c24797358a773370823fd Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 11 May 2018 22:25:57 +0200 Subject: [PATCH 12/13] catch driver method calls --- src/fenrirscreenreader/core/screenManager.py | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/fenrirscreenreader/core/screenManager.py b/src/fenrirscreenreader/core/screenManager.py index 28ec2815..2a1add43 100644 --- a/src/fenrirscreenreader/core/screenManager.py +++ b/src/fenrirscreenreader/core/screenManager.py @@ -15,15 +15,25 @@ class screenManager(): self.env = environment self.env['runtime']['settingsManager'].loadDriver(\ self.env['runtime']['settingsManager'].getSetting('screen', 'driver'), 'screenDriver') - self.env['runtime']['screenDriver'].getCurrScreen() - self.env['runtime']['screenDriver'].getCurrScreen() - self.env['runtime']['screenDriver'].getSessionInformation() - + self.getCurrScreen() + self.getCurrScreen() + self.getSessionInformation() + def getCurrScreen(self): + try: + self.env['runtime']['screenDriver'].getCurrScreen() + except: + pass + def getSessionInformation(self): + try: + self.env['runtime']['screenDriver'].getSessionInformation() + except: + pass + def shutdown(self): self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') def hanldeScreenChange(self, eventData): - self.env['runtime']['screenDriver'].getCurrScreen() - self.env['runtime']['screenDriver'].getSessionInformation() + self.getCurrScreen() + self.getSessionInformation() if self.isScreenChange(): self.changeBrailleScreen() if not self.isSuspendingScreen(self.env['screen']['newTTY']): From eacb26f340277786cab88fe3ffae4fad58183274 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 11 May 2018 23:16:18 +0200 Subject: [PATCH 13/13] grab/ungrab on ignorescreen, stop speech --- src/fenrirscreenreader/core/inputManager.py | 5 +++- src/fenrirscreenreader/core/outputManager.py | 7 ++++-- src/fenrirscreenreader/core/screenManager.py | 25 +++++++++++++++---- .../inputDriver/evdevDriver.py | 19 +++++++++++--- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index b74f4ef9..9977c8a7 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -110,7 +110,10 @@ class inputManager(): def grabAllDevices(self): if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): self.env['runtime']['inputDriver'].grabAllDevices() - + def ungrabAllDevices(self): + if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): + self.env['runtime']['inputDriver'].ungrabAllDevices() + def updateInputDevices(self): try: self.env['runtime']['inputDriver'].updateInputDevices() diff --git a/src/fenrirscreenreader/core/outputManager.py b/src/fenrirscreenreader/core/outputManager.py index c6090120..5cb82e49 100644 --- a/src/fenrirscreenreader/core/outputManager.py +++ b/src/fenrirscreenreader/core/outputManager.py @@ -228,8 +228,11 @@ class outputManager(): offsetText = offsetText[offsetStart: offsetEnd] return offsetText def interruptOutput(self): - self.env['runtime']['speechDriver'].cancel() - self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO) + try: + self.env['runtime']['speechDriver'].cancel() + self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO) + except: + pass def clearFlushTime(self): self.setFlushTime(0.0) diff --git a/src/fenrirscreenreader/core/screenManager.py b/src/fenrirscreenreader/core/screenManager.py index 2a1add43..426e086c 100644 --- a/src/fenrirscreenreader/core/screenManager.py +++ b/src/fenrirscreenreader/core/screenManager.py @@ -10,7 +10,8 @@ import time, os, re, difflib class screenManager(): def __init__(self): - pass + self.currScreenIgnored = False + self.prevScreenIgnored = False def initialize(self, environment): self.env = environment self.env['runtime']['settingsManager'].loadDriver(\ @@ -40,15 +41,28 @@ class screenManager(): self.update(eventData, 'onScreenChange') self.env['screen']['lastScreenUpdate'] = time.time() def handleScreenUpdate(self, eventData): - self.env['screen']['oldApplication'] = self.env['screen']['newApplication'] - if not self.isSuspendingScreen(self.env['screen']['newTTY']): + self.env['screen']['oldApplication'] = self.env['screen']['newApplication'] + self.updateScreenIgnored() + if self.getCurrScreenIgnored() != self.getPrevScreenIgnored(): + if self.getCurrScreenIgnored(): + self.env['runtime']['inputManager'].ungrabAllDevices() + self.env['runtime']['outputManager'].interruptOutput() + else: + self.env['runtime']['inputManager'].grabAllDevices() + if not self.getCurrScreenIgnored(): self.update(eventData, 'onScreenUpdate') #if trigger == 'onUpdate' or self.isScreenChange() \ # or len(self.env['screen']['newDelta']) > 6: # self.env['runtime']['screenDriver'].getCurrApplication() self.env['screen']['lastScreenUpdate'] = time.time() + def getCurrScreenIgnored(self): + return self.currScreenIgnored + def getPrevScreenIgnored(self): + return self.prevScreenIgnored + def updateScreenIgnored(self): + self.prevScreenIgnored = self.currScreenIgnored + self.currScreenIgnored = self.isSuspendingScreen(self.env['screen']['newTTY']) def update(self, eventData, trigger='onUpdate'): - # set new "old" values self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes'] self.env['screen']['oldContentText'] = self.env['screen']['newContentText'] @@ -60,6 +74,7 @@ class screenManager(): self.env['screen']['oldAttribDelta'] = self.env['screen']['newAttribDelta'] self.env['screen']['oldNegativeDelta'] = self.env['screen']['newNegativeDelta'] self.env['screen']['newContentBytes'] = eventData['bytes'] + # get metadata like cursor or screensize self.env['screen']['lines'] = int( eventData['lines']) self.env['screen']['columns'] = int( eventData['columns']) @@ -135,7 +150,7 @@ class screenManager(): if self.env['screen']['oldContentAttrib'] != self.env['screen']['newContentAttrib']: 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']) - + def formatAttributes(self, attribute, attributeFormatString = None): if not attributeFormatString: attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString') diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index feb9f97e..ff317cd7 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -40,6 +40,7 @@ class driver(inputDriver): self.iDevices = {} self.iDevicesFD = self._manager.list() self.uDevices = {} + self.gDevices = {} self.iDeviceNo = 0 self.watchDog = Value(c_bool, True) def initialize(self, environment): @@ -116,8 +117,12 @@ class driver(inputDriver): def writeEventBuffer(self): if not self._initialized: return - for iDevice, uDevice, event in self.env['input']['eventBuffer']: - self.writeUInput(uDevice, event) + for iDevice, uDevice, event in self.env['input']['eventBuffer']: + try: + if self.gDevices[iDevice.fd]: + self.writeUInput(uDevice, event) + except Exception as e: + pass def clearEventBuffer(self): if not self._initialized: @@ -240,7 +245,7 @@ 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 @@ -267,6 +272,7 @@ class driver(inputDriver): return try: self.iDevices[fd].grab() + self.gDevices[fd] = True except Exception as e: self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR) def ungrabDevices(self,fd): @@ -274,6 +280,7 @@ class driver(inputDriver): return try: self.iDevices[fd].ungrab() + self.gDevices[fd] = False except: pass def removeDevice(self,fd): @@ -298,7 +305,11 @@ class driver(inputDriver): del(self.uDevices[fd]) except: pass - self.updateMPiDevicesFD() + try: + del(self.gDevices[fd]) + except: + pass + self.MPiDevicesFD() def hasIDevices(self): if not self._initialized: