From 6728dd5745a7f41bd92df4ca3983b50bf3628058 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 27 Jun 2018 22:40:59 +0200 Subject: [PATCH 01/12] do not handle numlock multible times --- src/fenrirscreenreader/core/inputManager.py | 40 ++++++--------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index 5df3291b..1f93125c 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -12,7 +12,6 @@ fenrirPath = os.path.dirname(currentdir) class inputManager(): def __init__(self): - self.setLedState = True self.shortcutType = 'KEY' self.executeDeviceGrab = False def setShortcutType(self, shortcutType = 'KEY'): @@ -63,6 +62,7 @@ class inputManager(): self.grabAllDevices() self.executeDeviceGrab = False def handleInputEvent(self, eventData): + print(eventData) if not eventData: return self.env['input']['prevInput'] = self.env['input']['currInput'].copy() @@ -73,7 +73,6 @@ class inputManager(): self.env['input']['currInput'] = sorted(self.env['input']['currInput']) elif len(self.env['input']['currInput']) == 0: self.env['input']['shortcutRepeat'] = 1 - self.setLedState = self.handleLedStates(eventData) self.lastInputTime = time.time() elif eventData['EventState'] == 1: if not eventData['EventName'] in self.env['input']['currInput']: @@ -87,7 +86,7 @@ class inputManager(): self.env['input']['shortcutRepeat'] += 1 else: self.env['input']['shortcutRepeat'] = 1 - self.setLedState = self.handleLedStates(eventData) + self.handleLedStates(eventData) self.lastInputTime = time.time() elif eventData['EventState'] == 2: self.lastInputTime = time.time() @@ -101,35 +100,18 @@ class inputManager(): self.env['runtime']['debug'].writeDebugOut("currInput " + str(self.env['input']['currInput'] ) ,debug.debugLevel.INFO) if self.noKeyPressed(): self.env['input']['prevInput'] = [] - self.setLedState = True self.handleDeviceGrab() def handleLedStates(self, mEvent): - if not self.setLedState: - return self.setLedState - if mEvent['EventName'] == 'KEY_NUMLOCK': - if mEvent['EventState'] == 1 and not self.env['input']['newNumLock'] == 1: - self.env['runtime']['inputDriver'].toggleLedState() - return False - if mEvent['EventState'] == 0 and not self.env['input']['newNumLock'] == 0: - self.env['runtime']['inputDriver'].toggleLedState() - return False - if mEvent['EventName'] == 'KEY_CAPSLOCK': - if mEvent['EventState'] == 1 and not self.env['input']['newCapsLock'] == 1: - self.env['runtime']['inputDriver'].toggleLedState(1) - return False - if mEvent['EventState'] == 0 and not self.env['input']['newCapsLock'] == 0: - self.env['runtime']['inputDriver'].toggleLedState(1) - return False - if mEvent['EventName'] == 'KEY_SCROLLLOCK': - if mEvent['EventState'] == 1 and not self.env['input']['newScrollLock'] == 1: - self.env['runtime']['inputDriver'].toggleLedState(2) - return False - if mEvent['EventState'] == 0 and not self.env['input']['newScrollLock'] == 0: - self.env['runtime']['inputDriver'].toggleLedState(2) - return False - return self.setLedState - + try: + if mEvent['EventName'] == 'KEY_NUMLOCK': + self.env['runtime']['inputDriver'].toggleLedState() + elif mEvent['EventName'] == 'KEY_CAPSLOCK': + self.env['runtime']['inputDriver'].toggleLedState(1) + elif mEvent['EventName'] == 'KEY_SCROLLLOCK': + self.env['runtime']['inputDriver'].toggleLedState(2) + except: + pass def grabAllDevices(self): if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): try: From 4fdb3a5b61c60e175ed198eb28bb3868ecd23534 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 00:01:03 +0200 Subject: [PATCH 02/12] improve event fire --- .../inputDriver/evdevDriver.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index 90743f96..c71e5a76 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -114,7 +114,8 @@ class driver(inputDriver): eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) eventFired = True else: - if not event.type in [0,4]: + pass + if event.type in [2,3]: foreward = True event = self.iDevices[fd].read_one() @@ -262,12 +263,13 @@ class driver(inputDriver): return False ledState = self.getLedState(led) for i in self.iDevices: - # 17 LEDs - if 17 in self.iDevices[i].capabilities(): - if ledState == 1: - self.iDevices[i].set_led(led , 0) - else: - self.iDevices[i].set_led(led , 1) + if self.gDevices[i]: + # 17 LEDs + if 17 in self.iDevices[i].capabilities(): + if ledState == 1: + self.iDevices[i].set_led(led , 0) + else: + self.iDevices[i].set_led(led , 1) def grabAllDevices(self): if not self._initialized: return From cc7caf4ec162a7003f41cd6d75fdeea432f1d3d8 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Thu, 28 Jun 2018 09:50:29 +0200 Subject: [PATCH 03/12] remove unneded function --- src/fenrirscreenreader/inputDriver/evdevDriver.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index c71e5a76..db3b31c8 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -84,9 +84,6 @@ class driver(inputDriver): if validDevices: eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":validDevices}) return time.time() - def plugInputDeviceWatchdogTimer(self, active): - time.sleep(10) - return None def inputWatchdog(self,active , eventQueue): try: From e1696ee0772683589bcc6efdcf9f6555434c8949 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Thu, 28 Jun 2018 10:10:01 +0200 Subject: [PATCH 04/12] Update evdevDriver.py --- .../inputDriver/evdevDriver.py | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/fenrirscreenreader/inputDriver/evdevDriver.py b/src/fenrirscreenreader/inputDriver/evdevDriver.py index db3b31c8..fa50a48c 100644 --- a/src/fenrirscreenreader/inputDriver/evdevDriver.py +++ b/src/fenrirscreenreader/inputDriver/evdevDriver.py @@ -88,11 +88,12 @@ class driver(inputDriver): def inputWatchdog(self,active , eventQueue): try: while active.value: - r, w, x = select(self.iDevices, [], [], 0.7) - for fd in r: - event = None - foreward = False - eventFired = False + r, w, x = select(self.iDevices, [], [], 0.8) + event = None + foundKeyInSequence = False + foreward = False + eventFired = False + for fd in r: try: event = self.iDevices[fd].read_one() except: @@ -100,25 +101,26 @@ class driver(inputDriver): while(event): self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.type == evdev.events.EV_KEY: + if not foundKeyInSequence: + foundKeyInSequence = True if event.code != 0: currMapEvent = self.mapEvent(event) if not currMapEvent: - foreward = True + continue 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 + continue + if currMapEvent['EventState'] in [0,1,2]: + eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) + eventFired = True else: - pass if event.type in [2,3]: foreward = True event = self.iDevices[fd].read_one() - if foreward and not eventFired: - self.writeEventBuffer() - self.clearEventBuffer() + if not foundKeyInSequence: + 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) From af4e5cb9c4f2773e371e7f81455fa9f7b3992a37 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 13:03:11 +0200 Subject: [PATCH 05/12] Update inputManager.py --- src/fenrirscreenreader/core/inputManager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index 1f93125c..72cc6478 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -62,9 +62,12 @@ class inputManager(): self.grabAllDevices() self.executeDeviceGrab = False def handleInputEvent(self, eventData): - print(eventData) + #print(eventData) if not eventData: return + # a hang apears.. try to fix + if self.env['input']['eventBuffer'] != []: + self.env['input']['currInput'] = [] self.env['input']['prevInput'] = self.env['input']['currInput'].copy() if eventData['EventState'] == 0: if eventData['EventName'] in self.env['input']['currInput']: From f270fd069164091f6a091f3465f344335a8a21cb Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 14:35:36 +0200 Subject: [PATCH 06/12] Update inputManager.py --- src/fenrirscreenreader/core/inputManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index 72cc6478..86241ea7 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -66,7 +66,7 @@ class inputManager(): if not eventData: return # a hang apears.. try to fix - if self.env['input']['eventBuffer'] != []: + if self.env['input']['eventBuffer'] == []: self.env['input']['currInput'] = [] self.env['input']['prevInput'] = self.env['input']['currInput'].copy() if eventData['EventState'] == 0: From d95d9fc1e6fbfbe4e3e4df00cda0005824503cdd Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 14:44:13 +0200 Subject: [PATCH 07/12] Update inputManager.py --- src/fenrirscreenreader/core/inputManager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index 86241ea7..e451d911 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -67,7 +67,10 @@ class inputManager(): return # a hang apears.. try to fix if self.env['input']['eventBuffer'] == []: - self.env['input']['currInput'] = [] + if self.env['input']['currInput'] != []: + self.env['input']['currInput'] = [] + self.env['input']['shortcutRepeat'] = 1 + self.env['input']['prevInput'] = self.env['input']['currInput'].copy() if eventData['EventState'] == 0: if eventData['EventName'] in self.env['input']['currInput']: From 6033d19b716d15342f2c3cb6c2c366e1680a625b Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 14:45:49 +0200 Subject: [PATCH 08/12] Update known bugs.txt --- known bugs.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/known bugs.txt b/known bugs.txt index 600862da..2a250e5b 100644 --- a/known bugs.txt +++ b/known bugs.txt @@ -1,8 +1,6 @@ Known Bugs (Problems with the logic ): - word echo triggers twice if there are two spaces after an word and you arrow over them - spellcheck triggers twice if there are two spaces after an word and you arrow over them -[] Sometimes Numblock hangs and make shortcuts not detect (critical) (workaround - press numlock again until shortcuts are working again) -[] Numlock/ Capslock is sometimes out of Sync (normal) [] lag when stopping speech for speechd speech driver [] lag when start speaking with generic speech driver [W] setup.py fails on raspian From 1f676571bc657091ebc8246e4ff190416f4520bd Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 15:02:06 +0200 Subject: [PATCH 09/12] Update known bugs.txt --- known bugs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/known bugs.txt b/known bugs.txt index 2a250e5b..c9fe3ef4 100644 --- a/known bugs.txt +++ b/known bugs.txt @@ -6,7 +6,7 @@ Known Bugs (Problems with the logic ): [W] setup.py fails on raspian Glitches (improve diff results): -currently None +[] full line is spoken on pressing 2 keys at same time wishes: - whole status line in irssi is spoken insteed of just the changes (lilmike) From 3e379ad80718ae5af192419d233a74c819112aa1 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 15:02:55 +0200 Subject: [PATCH 10/12] Update known bugs.txt --- known bugs.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/known bugs.txt b/known bugs.txt index c9fe3ef4..5851944c 100644 --- a/known bugs.txt +++ b/known bugs.txt @@ -2,7 +2,8 @@ Known Bugs (Problems with the logic ): - word echo triggers twice if there are two spaces after an word and you arrow over them - spellcheck triggers twice if there are two spaces after an word and you arrow over them [] lag when stopping speech for speechd speech driver -[] lag when start speaking with generic speech driver +[] lag when start speaking with generic speech driver# +[] Wifi led is disabled on fenrir start (sync LEDs on grabbing/ ungrabbing) [W] setup.py fails on raspian Glitches (improve diff results): From dc935b296e4df630424379235b1c8cebbb2e6345 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 16:48:39 +0200 Subject: [PATCH 11/12] Delete known bugs.txt --- known bugs.txt | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 known bugs.txt diff --git a/known bugs.txt b/known bugs.txt deleted file mode 100644 index 5851944c..00000000 --- a/known bugs.txt +++ /dev/null @@ -1,15 +0,0 @@ -Known Bugs (Problems with the logic ): -- word echo triggers twice if there are two spaces after an word and you arrow over them -- spellcheck triggers twice if there are two spaces after an word and you arrow over them -[] lag when stopping speech for speechd speech driver -[] lag when start speaking with generic speech driver# -[] Wifi led is disabled on fenrir start (sync LEDs on grabbing/ ungrabbing) -[W] setup.py fails on raspian - -Glitches (improve diff results): -[] full line is spoken on pressing 2 keys at same time - -wishes: -- whole status line in irssi is spoken insteed of just the changes (lilmike) -- whole status line in vim is spoken insteed of just the changes (lilmike) - From f52a1be1bcbce25595ce5d04bb090f6c697c6aa2 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 23:59:56 +0200 Subject: [PATCH 12/12] respeckt puctuation in headline compression --- src/fenrirscreenreader/core/punctuationManager.py | 3 ++- src/fenrirscreenreader/core/textManager.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/punctuationManager.py b/src/fenrirscreenreader/core/punctuationManager.py index 0c8592a1..d665141f 100644 --- a/src/fenrirscreenreader/core/punctuationManager.py +++ b/src/fenrirscreenreader/core/punctuationManager.py @@ -57,7 +57,8 @@ class punctuationManager(): else: resultText = resultText.replace(str(key),' ' +str(item) + ' ') return resultText - + def isPuctuation(self, char): + return char in self.env['punctuation']['PUNCTDICT'] def proceedPunctuation(self, text, ignorePunctuation=False): resultText = text resultText = self.useCustomDict(resultText, self.env['punctuation']['CUSTOMDICT']) diff --git a/src/fenrirscreenreader/core/textManager.py b/src/fenrirscreenreader/core/textManager.py index b68aad34..05633f30 100644 --- a/src/fenrirscreenreader/core/textManager.py +++ b/src/fenrirscreenreader/core/textManager.py @@ -31,6 +31,9 @@ class textManager(): newText += text[lastPos:span[0]] numberOfChars = len(text[span[0]:span[1]]) name = text[span[0]:span[1]][:2] + if not self.env['runtime']['punctuationManager'].isPuctuation(name[0]): + lastPos = span[1] + continue if name[0] == name[1]: newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: @@ -45,6 +48,9 @@ class textManager(): result += text[lastPos:span[0]] numberOfChars = len(newText[span[0]:span[1]]) name = newText[span[0]:span[1]][:2] + if not self.env['runtime']['punctuationManager'].isPuctuation(name[0]): + lastPos = span[1] + continue if name[0] == name[1]: result += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: