Merge branch 'numlock' into bleed

This commit is contained in:
chrys 2018-06-29 00:39:07 +02:00
commit 9746471dc8
5 changed files with 50 additions and 70 deletions

View File

@ -1,16 +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
[] 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
Glitches (improve diff results):
currently None
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)

View File

@ -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,8 +62,15 @@ class inputManager():
self.grabAllDevices()
self.executeDeviceGrab = False
def handleInputEvent(self, eventData):
#print(eventData)
if not eventData:
return
# a hang apears.. try to fix
if self.env['input']['eventBuffer'] == []:
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']:
@ -73,7 +79,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 +92,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 +106,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:
try:
if mEvent['EventName'] == 'KEY_NUMLOCK':
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:
elif mEvent['EventName'] == 'KEY_CAPSLOCK':
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:
elif mEvent['EventName'] == 'KEY_SCROLLLOCK':
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
except:
pass
def grabAllDevices(self):
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
try:

View File

@ -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'])

View File

@ -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:

View File

@ -84,18 +84,16 @@ 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:
while active.value:
r, w, x = select(self.iDevices, [], [], 0.7)
r, w, x = select(self.iDevices, [], [], 0.8)
event = None
foundKeyInSequence = False
foreward = False
eventFired = False
for fd in r:
event = None
foreward = False
eventFired = False
try:
event = self.iDevices[fd].read_one()
except:
@ -103,24 +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:
if not event.type in [0,4]:
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)
@ -262,12 +262,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