This commit is contained in:
chrys 2016-10-22 20:31:37 +02:00
commit 28494517e6
11 changed files with 90 additions and 53 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
__pycache__/
*\.pyc
fenrir.egg-info/
dist/

Binary file not shown.

View File

@ -22,8 +22,6 @@ class command():
# detect deletion or chilling
if self.env['screenData']['newCursor']['x'] <= self.env['screenData']['oldCursor']['x']:
return
if self.env['runtime']['inputManager'].noKeyPressed():
return
# is there any change?
if not self.environment['runtime']['screenManager'].isDelta():
return

View File

@ -19,12 +19,13 @@ class command():
def run(self):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
return
# detect typing or chilling
if self.env['screenData']['newCursor']['x'] >= self.env['screenData']['oldCursor']['x']:
return
# More than just a deletion happend
if self.environment['runtime']['screenManager'].isDelta():
return
# no deletion
@ -32,8 +33,10 @@ class command():
return
if self.env['runtime']['inputManager'].noKeyPressed():
return
# too much for a single backspace...
if len(self.env['screenData']['newNegativeDelta']) >= 2:
# word begin produce a diff wiht len == 2 |a | others with 1 |a|
if len(self.env['screenData']['newNegativeDelta']) > 2:
return
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True, ignorePunctuation=True, announceCapital=True)

View File

@ -50,6 +50,8 @@ class command():
self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else:
self.env['runtime']['outputManager'].presentText(announce, interrupt=True)
self.env['commandsIgnore']['onScreenUpdate']['CHAR_DELETE_ECHO'] = True
self.env['commandsIgnore']['onScreenUpdate']['CHAR_ECHO'] = True
self.env['commandsIgnore']['onScreenUpdate']['INCOMING_IGNORE'] = True
def setCallback(self, callback):
pass

View File

@ -10,17 +10,17 @@ from core import inputEvent
class inputManager():
def __init__(self):
pass
self.setLedState = True
def initialize(self, environment):
self.env = environment
self.env['runtime']['settingsManager'].loadDriver(\
self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver')
# init LEDs with current state
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getNumlock()
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState()
self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
self.env['input']['newCapsLock'] = self.env['runtime']['inputDriver'].getCapslock()
self.env['input']['newCapsLock'] = self.env['runtime']['inputDriver'].getLedState(1)
self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock']
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getScrollLock()
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2)
self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
self.grabDevices()
@ -43,6 +43,7 @@ class inputManager():
if len(self.env['input']['currInput']) == 0:
self.env['input']['prevDeepestInput'] = []
self.env['input']['shortcutRepeat'] = 1
self.handleLedStates(mEvent)
self.env['input']['lastInputTime'] = time.time()
elif mEvent['EventState'] == 1:
if not mEvent['EventName'] in self.env['input']['currInput']:
@ -56,22 +57,55 @@ class inputManager():
self.env['input']['shortcutRepeat'] += 1
else:
self.env['input']['shortcutRepeat'] = 1
self.handleLedStates(mEvent)
self.env['input']['lastInputTime'] = time.time()
elif mEvent['EventState'] == 2:
pass
self.env['input']['lastInputTime'] = time.time()
else:
pass
self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getNumlock()
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState()
self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock']
self.env['input']['newCapsLock'] = self.env['runtime']['inputDriver'].getCapslock()
self.env['input']['newCapsLock'] = self.env['runtime']['inputDriver'].getLedState(1)
self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getScrollLock()
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2)
self.env['runtime']['debug'].writeDebugOut("currInput " + str(self.env['input']['currInput'] ) ,debug.debugLevel.INFO)
if self.noKeyPressed():
self.env['input']['prevInput'] = []
self.setLedState = True
return eventReceived
def handleLedStates(self, mEvent):
if not self.setLedState:
return
if mEvent['EventName'] == 'KEY_NUMLOCK':
if mEvent['EventState'] == 1 and not self.env['input']['newNumLock'] == 1:
self.env['runtime']['inputDriver'].toggleLedState()
self.setLedState = False
return
if mEvent['EventState'] == 0 and not self.env['input']['newNumLock'] == 0:
self.env['runtime']['inputDriver'].toggleLedState()
self.setLedState = False
return
if mEvent['EventName'] == 'KEY_CAPSLOCK':
if mEvent['EventState'] == 1 and not self.env['input']['newCapsLock'] == 1:
self.env['runtime']['inputDriver'].toggleLedState(1)
self.setLedState = False
return
if mEvent['EventState'] == 0 and not self.env['input']['newCapsLock'] == 0:
self.env['runtime']['inputDriver'].toggleLedState(1)
self.setLedState = False
return
if mEvent['EventName'] == 'KEY_SCROLLLOCK':
if mEvent['EventState'] == 1 and not self.env['input']['newScrollLock'] == 1:
self.env['runtime']['inputDriver'].toggleLedState(2)
self.setLedState = False
return
if mEvent['EventState'] == 0 and not self.env['input']['newScrollLock'] == 0:
self.env['runtime']['inputDriver'].toggleLedState(2)
self.setLedState = False
return
def grabDevices(self):
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
self.env['runtime']['inputDriver'].grabDevices()

View File

@ -35,15 +35,16 @@ class driver():
for fd in r:
event = self.iDevices[fd].read_one()
while(event):
if not event:
return None
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
if event.code != 0:
currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event)
if not currMapEvent:
return currMapEvent
if currMapEvent['EventState'] in [0,1,2]:
return currMapEvent
if event.type == evdev.events.EV_KEY:
if event.code != 0:
currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event)
if not currMapEvent:
return currMapEvent
if currMapEvent['EventState'] in [0,1,2]:
return currMapEvent
event = self.iDevices[fd].read_one()
return None
@ -96,34 +97,25 @@ class driver():
return mEvent
except Exception as e:
return None
def getNumlock(self):
if self.ledDevices == {}:
return True
if self.ledDevices == None:
return True
for fd, dev in self.ledDevices.items():
return 0 in dev.leds()
return True
def getCapslock(self):
def getLedState(self, led = 0):
# 0 = Numlock
# 1 = Capslock
# 2 = Rollen
if self.ledDevices == {}:
return False
if self.ledDevices == None:
return False
for fd, dev in self.ledDevices.items():
return 1 in dev.leds()
return False
def getScrollLock(self):
if self.ledDevices == {}:
return False
if self.ledDevices == None:
return False
for fd, dev in self.ledDevices.items():
return 2 in dev.leds()
return led in dev.leds()
return False
def toggleLedState(self, led = 0):
ledState = self.getLedState(led)
for i in self.ledDevices:
if ledState == 1:
self.ledDevices[i].set_led(led , 0)
else:
self.ledDevices[i].set_led(led , 1)
def grabDevices(self):
# leve the old code until the new one is better tested
# for fd in self.iDevices:

View File

@ -34,7 +34,7 @@ class driver():
currScreen = self.env['screenData']['newTTY']
apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n')
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return
try:
for i in apps:
@ -52,8 +52,7 @@ class driver():
self.env['screenData']['newApplication'] = i[0]
return
except Exception as e:
print(e)
return
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return
def getIgnoreScreens(self):

View File

@ -11,14 +11,17 @@ class driver():
def __init__(self ):
self._es = None
self._isInitialized = False
def initialize(self, environment):
self.env = environment
try:
from espeak import espeak
self._es = espeak
self._isInitialized = True
except:
except Exception as e:
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self._initialized = False
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass

View File

@ -12,15 +12,18 @@ class driver():
self._sd = None
self._isInitialized = False
self._language = ''
def initialize(self, environment):
self.env = environment
try:
import speechd
self._sd = speechd.SSIPClient('fenrir')
self._punct = speechd.PunctuationMode()
self._isInitialized = True
except:
except Exception as e:
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self._initialized = False
def initialize(self, environment):
self.env = environment
def shutdown(self):
if not self._isInitialized:
return

View File

@ -7,6 +7,9 @@ import time
devices = map(evdev.InputDevice, (evdev.list_devices()))
devices = {dev.fd: dev for dev in devices}
for fd in devices:
for i in devices[fd].capabilities(True):
print(devices[fd].fn,devices[fd].name,i)
while True:
r, w, x = select(devices, [], [])
if r != []: