diff --git a/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py b/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py new file mode 100644 index 00000000..4d5f92d2 --- /dev/null +++ b/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py @@ -0,0 +1,23 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return 'No description found' + def run(self): + if self.env['runtime']['helpManager'].isTutorialMode(): + self.env['runtime']['inputManager'].keyEcho(event) + + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/core/commandManager.py b/src/fenrirscreenreader/core/commandManager.py index 9615acde..cce6bbac 100644 --- a/src/fenrirscreenreader/core/commandManager.py +++ b/src/fenrirscreenreader/core/commandManager.py @@ -37,14 +37,11 @@ class commandManager(): return None if not os.path.exists(filepath): self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not exists:" + filepath ,debug.debugLevel.WARNING) - print('1') return None if os.path.isdir(filepath): - print('2') self.env['runtime']['debug'].writeDebugOut("loadFile: filepath is a directory:" + filepath ,debug.debugLevel.ERROR) return None if not os.access(filepath, os.R_OK): - print('3') self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not readable:" + filepath ,debug.debugLevel.ERROR) return None @@ -149,18 +146,18 @@ class commandManager(): if not self.env['runtime']['inputManager'].isValidKey(key.upper()): self.env['runtime']['debug'].writeDebugOut("invalid key : "+ key.upper() + ' script:' + fileName ,debug.debugLevel.WARNING) invalid = True - break + break shortcutKeys.append(key.upper()) if invalid: - continue + continue if not 'KEY_SCRIPT' in shortcutKeys: - shortcutKeys.append('KEY_SCRIPT') + shortcutKeys.append('KEY_SCRIPT') shortcut.append(1) shortcut.append(sorted(shortcutKeys)) - self.env['bindings'][str(shortcut)] = fileName.upper() + self.env['bindings'][str(shortcut)] = fileName.upper() except Exception as e: self.env['runtime']['debug'].writeDebugOut("Loading script:" + fileName ,debug.debugLevel.ERROR) - self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) continue def shutdownCommands(self, section): for command in sorted(self.env['commands'][section]): @@ -177,36 +174,36 @@ class commandManager(): return #unload oldScript = unLoadScript - if self.commandExists(oldScript, trigger): + if self.commandExists(oldScript, trigger): try: self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.unload:" + trigger + "." + oldScript ,debug.debugLevel.INFO) - self.env['commands'][trigger][oldScript].unload() + self.env['commands'][trigger][oldScript].unload() except Exception as e: self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + oldScript ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) #load newScript = loadScript - if self.commandExists(newScript, trigger): + if self.commandExists(newScript, trigger): try: self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.load:" + trigger + "." + newScript ,debug.debugLevel.INFO) - self.env['commands'][trigger][newScript].load() + self.env['commands'][trigger][newScript].load() except Exception as e: self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR) - self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) def executeDefaultTrigger(self, trigger, force=False): if not force: if self.env['runtime']['screenManager'].isSuspendingScreen(): return for command in sorted(self.env['commands'][trigger]): - if self.commandExists(command, trigger): + if self.commandExists(command, trigger): try: if self.env['commandsIgnore'][trigger][command[command.find('-')+1:]+'_IGNORE']: self.env['commandsIgnore'][trigger][command[command.find('-')+1:]+'_IGNORE'] = False - self.env['runtime']['debug'].writeDebugOut("Ignore trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut("Ignore trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO) else: - self.env['runtime']['debug'].writeDebugOut("Executing trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO) - self.env['commands'][trigger][command].run() + self.env['runtime']['debug'].writeDebugOut("Executing trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO) + self.env['commands'][trigger][command].run() except Exception as e: self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command + str(e) ,debug.debugLevel.ERROR) @@ -216,11 +213,11 @@ class commandManager(): if self.commandExists(command, section): try: if self.env['runtime']['helpManager'].isTutorialMode() and section != 'help': - self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO) description = self.getCommandDescription(command, section) - self.env['runtime']['outputManager'].presentText(description, interrupt=True) + self.env['runtime']['outputManager'].presentText(description, interrupt=False) else: - self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO) self.runCommand(command, section) except Exception as e: self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR) diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 2a6c6f7c..7d147bd6 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -68,6 +68,8 @@ class fenrirManager(): else: if self.environment['runtime']['helpManager'].isTutorialMode(): self.environment['runtime']['inputManager'].clearEventBuffer() + self.environment['runtime']['inputManager'].keyEcho(event['Data']) + if self.environment['runtime']['vmenuManager'].getActive(): self.environment['runtime']['inputManager'].clearEventBuffer() @@ -112,11 +114,11 @@ class fenrirManager(): return # default - self.environment['runtime']['commandManager'].executeCommand( command, 'commands') + self.environment['runtime']['commandManager'].executeCommand( command, 'commands') def handleRemoteIncomming(self, event): if not event['Data']: return - self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data']) + self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data']) def handleScreenChange(self, event): self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data']) ''' diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index dcc91f21..cbf241fd 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -33,6 +33,7 @@ class inputManager(): self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2) self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock'] self.lastDeepestInput = [] + self.lastEvent = None self.env['input']['shortcutRepeat'] = 1 self.lastInputTime = time.time() def shutdown(self): @@ -79,10 +80,12 @@ class inputManager(): time.sleep(value) else: self.env['runtime']['inputDriver'].sendKey(key, value) + def getLastEvent(self): + return self.lastEvent def handleInputEvent(self, eventData): - #print(eventData) if not eventData: return + self.lastEvent = eventData # a hang apears.. try to fix if self.env['input']['eventBuffer'] == []: if self.env['input']['currInput'] != []: @@ -265,6 +268,18 @@ class inputManager(): if not self.shortcutExists(shortcut): return '' return self.env['bindings'][shortcut] + def keyEcho(self, eventData = None): + if not eventData: + eventData = self.env['runtime']['inputManager'].getLastEvent() + if not eventData: + return + keyName = '' + if eventData['EventState'] == 1: + keyName = eventData['EventName'].lower() + if keyName.startswith('key_'): + keyName = keyName[4:] + self.env['runtime']['outputManager'].presentText(_(keyName), interrupt=True) + def shortcutExists(self, shortcut): return(shortcut in self.env['bindings'])