merge
This commit is contained in:
commit
28494517e6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*\.pyc
|
*\.pyc
|
||||||
fenrir.egg-info/
|
fenrir.egg-info/
|
||||||
|
dist/
|
||||||
|
BIN
dist/fenrir-0.1a0-py3.5.egg
vendored
BIN
dist/fenrir-0.1a0-py3.5.egg
vendored
Binary file not shown.
@ -22,8 +22,6 @@ class command():
|
|||||||
# detect deletion or chilling
|
# detect deletion or chilling
|
||||||
if self.env['screenData']['newCursor']['x'] <= self.env['screenData']['oldCursor']['x']:
|
if self.env['screenData']['newCursor']['x'] <= self.env['screenData']['oldCursor']['x']:
|
||||||
return
|
return
|
||||||
if self.env['runtime']['inputManager'].noKeyPressed():
|
|
||||||
return
|
|
||||||
# is there any change?
|
# is there any change?
|
||||||
if not self.environment['runtime']['screenManager'].isDelta():
|
if not self.environment['runtime']['screenManager'].isDelta():
|
||||||
return
|
return
|
||||||
|
@ -19,12 +19,13 @@ class command():
|
|||||||
def run(self):
|
def run(self):
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
|
||||||
return
|
return
|
||||||
|
|
||||||
# detect typing or chilling
|
# detect typing or chilling
|
||||||
if self.env['screenData']['newCursor']['x'] >= self.env['screenData']['oldCursor']['x']:
|
if self.env['screenData']['newCursor']['x'] >= self.env['screenData']['oldCursor']['x']:
|
||||||
return
|
return
|
||||||
|
|
||||||
# More than just a deletion happend
|
# More than just a deletion happend
|
||||||
|
|
||||||
if self.environment['runtime']['screenManager'].isDelta():
|
if self.environment['runtime']['screenManager'].isDelta():
|
||||||
return
|
return
|
||||||
# no deletion
|
# no deletion
|
||||||
@ -32,8 +33,10 @@ class command():
|
|||||||
return
|
return
|
||||||
if self.env['runtime']['inputManager'].noKeyPressed():
|
if self.env['runtime']['inputManager'].noKeyPressed():
|
||||||
return
|
return
|
||||||
|
|
||||||
# too much for a single backspace...
|
# 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
|
return
|
||||||
|
|
||||||
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True, ignorePunctuation=True, announceCapital=True)
|
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True, ignorePunctuation=True, announceCapital=True)
|
||||||
|
@ -50,6 +50,8 @@ class command():
|
|||||||
self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
|
self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].presentText(announce, interrupt=True)
|
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
|
self.env['commandsIgnore']['onScreenUpdate']['INCOMING_IGNORE'] = True
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -10,17 +10,17 @@ from core import inputEvent
|
|||||||
|
|
||||||
class inputManager():
|
class inputManager():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.setLedState = True
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.env['runtime']['settingsManager'].loadDriver(\
|
self.env['runtime']['settingsManager'].loadDriver(\
|
||||||
self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver')
|
self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver')
|
||||||
# init LEDs with current state
|
# 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']['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']['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.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
|
||||||
self.grabDevices()
|
self.grabDevices()
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ class inputManager():
|
|||||||
if len(self.env['input']['currInput']) == 0:
|
if len(self.env['input']['currInput']) == 0:
|
||||||
self.env['input']['prevDeepestInput'] = []
|
self.env['input']['prevDeepestInput'] = []
|
||||||
self.env['input']['shortcutRepeat'] = 1
|
self.env['input']['shortcutRepeat'] = 1
|
||||||
|
self.handleLedStates(mEvent)
|
||||||
self.env['input']['lastInputTime'] = time.time()
|
self.env['input']['lastInputTime'] = time.time()
|
||||||
elif mEvent['EventState'] == 1:
|
elif mEvent['EventState'] == 1:
|
||||||
if not mEvent['EventName'] in self.env['input']['currInput']:
|
if not mEvent['EventName'] in self.env['input']['currInput']:
|
||||||
@ -56,22 +57,55 @@ class inputManager():
|
|||||||
self.env['input']['shortcutRepeat'] += 1
|
self.env['input']['shortcutRepeat'] += 1
|
||||||
else:
|
else:
|
||||||
self.env['input']['shortcutRepeat'] = 1
|
self.env['input']['shortcutRepeat'] = 1
|
||||||
|
self.handleLedStates(mEvent)
|
||||||
self.env['input']['lastInputTime'] = time.time()
|
self.env['input']['lastInputTime'] = time.time()
|
||||||
elif mEvent['EventState'] == 2:
|
elif mEvent['EventState'] == 2:
|
||||||
pass
|
self.env['input']['lastInputTime'] = time.time()
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
|
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']['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']['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)
|
self.env['runtime']['debug'].writeDebugOut("currInput " + str(self.env['input']['currInput'] ) ,debug.debugLevel.INFO)
|
||||||
if self.noKeyPressed():
|
if self.noKeyPressed():
|
||||||
self.env['input']['prevInput'] = []
|
self.env['input']['prevInput'] = []
|
||||||
|
self.setLedState = True
|
||||||
return eventReceived
|
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):
|
def grabDevices(self):
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
self.env['runtime']['inputDriver'].grabDevices()
|
self.env['runtime']['inputDriver'].grabDevices()
|
||||||
|
@ -35,15 +35,16 @@ class driver():
|
|||||||
for fd in r:
|
for fd in r:
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
while(event):
|
while(event):
|
||||||
if not event:
|
|
||||||
return None
|
|
||||||
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
||||||
if event.code != 0:
|
if event.type == evdev.events.EV_KEY:
|
||||||
currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event)
|
if event.code != 0:
|
||||||
if not currMapEvent:
|
currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event)
|
||||||
return currMapEvent
|
if not currMapEvent:
|
||||||
if currMapEvent['EventState'] in [0,1,2]:
|
return currMapEvent
|
||||||
return currMapEvent
|
if currMapEvent['EventState'] in [0,1,2]:
|
||||||
|
return currMapEvent
|
||||||
|
|
||||||
|
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -96,34 +97,25 @@ class driver():
|
|||||||
return mEvent
|
return mEvent
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getNumlock(self):
|
def getLedState(self, led = 0):
|
||||||
if self.ledDevices == {}:
|
# 0 = Numlock
|
||||||
return True
|
# 1 = Capslock
|
||||||
if self.ledDevices == None:
|
# 2 = Rollen
|
||||||
return True
|
|
||||||
for fd, dev in self.ledDevices.items():
|
|
||||||
return 0 in dev.leds()
|
|
||||||
return True
|
|
||||||
|
|
||||||
def getCapslock(self):
|
|
||||||
if self.ledDevices == {}:
|
if self.ledDevices == {}:
|
||||||
return False
|
return False
|
||||||
if self.ledDevices == None:
|
if self.ledDevices == None:
|
||||||
return False
|
return False
|
||||||
for fd, dev in self.ledDevices.items():
|
for fd, dev in self.ledDevices.items():
|
||||||
return 1 in dev.leds()
|
return led 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 False
|
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):
|
def grabDevices(self):
|
||||||
# leve the old code until the new one is better tested
|
# leve the old code until the new one is better tested
|
||||||
# for fd in self.iDevices:
|
# for fd in self.iDevices:
|
||||||
|
@ -34,7 +34,7 @@ class driver():
|
|||||||
currScreen = self.env['screenData']['newTTY']
|
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')
|
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:
|
except Exception as e:
|
||||||
print(e)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
for i in apps:
|
for i in apps:
|
||||||
@ -52,8 +52,7 @@ class driver():
|
|||||||
self.env['screenData']['newApplication'] = i[0]
|
self.env['screenData']['newApplication'] = i[0]
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
return
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def getIgnoreScreens(self):
|
def getIgnoreScreens(self):
|
||||||
|
@ -11,14 +11,17 @@ class driver():
|
|||||||
def __init__(self ):
|
def __init__(self ):
|
||||||
self._es = None
|
self._es = None
|
||||||
self._isInitialized = False
|
self._isInitialized = False
|
||||||
|
|
||||||
|
def initialize(self, environment):
|
||||||
|
self.env = environment
|
||||||
try:
|
try:
|
||||||
from espeak import espeak
|
from espeak import espeak
|
||||||
self._es = espeak
|
self._es = espeak
|
||||||
self._isInitialized = True
|
self._isInitialized = True
|
||||||
except:
|
except Exception as e:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
self._initialized = False
|
self._initialized = False
|
||||||
def initialize(self, environment):
|
|
||||||
self.env = environment
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -12,15 +12,18 @@ class driver():
|
|||||||
self._sd = None
|
self._sd = None
|
||||||
self._isInitialized = False
|
self._isInitialized = False
|
||||||
self._language = ''
|
self._language = ''
|
||||||
|
|
||||||
|
def initialize(self, environment):
|
||||||
|
self.env = environment
|
||||||
try:
|
try:
|
||||||
import speechd
|
import speechd
|
||||||
self._sd = speechd.SSIPClient('fenrir')
|
self._sd = speechd.SSIPClient('fenrir')
|
||||||
self._punct = speechd.PunctuationMode()
|
self._punct = speechd.PunctuationMode()
|
||||||
self._isInitialized = True
|
self._isInitialized = True
|
||||||
except:
|
except Exception as e:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
self._initialized = False
|
self._initialized = False
|
||||||
def initialize(self, environment):
|
|
||||||
self.env = environment
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
|
@ -7,6 +7,9 @@ import time
|
|||||||
devices = map(evdev.InputDevice, (evdev.list_devices()))
|
devices = map(evdev.InputDevice, (evdev.list_devices()))
|
||||||
devices = {dev.fd: dev for dev in 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:
|
while True:
|
||||||
r, w, x = select(devices, [], [])
|
r, w, x = select(devices, [], [])
|
||||||
if r != []:
|
if r != []:
|
||||||
|
Loading…
Reference in New Issue
Block a user