add keyecho to tutorial mode

This commit is contained in:
chrys 2019-03-03 20:57:58 +01:00
parent 49c9645b8a
commit da8e28540e
4 changed files with 60 additions and 23 deletions

View File

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

View File

@ -37,14 +37,11 @@ class commandManager():
return None return None
if not os.path.exists(filepath): if not os.path.exists(filepath):
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not exists:" + filepath ,debug.debugLevel.WARNING) self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not exists:" + filepath ,debug.debugLevel.WARNING)
print('1')
return None return None
if os.path.isdir(filepath): if os.path.isdir(filepath):
print('2')
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath is a directory:" + filepath ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("loadFile: filepath is a directory:" + filepath ,debug.debugLevel.ERROR)
return None return None
if not os.access(filepath, os.R_OK): if not os.access(filepath, os.R_OK):
print('3')
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not readable:" + filepath ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not readable:" + filepath ,debug.debugLevel.ERROR)
return None return None
@ -218,7 +215,7 @@ class commandManager():
if self.env['runtime']['helpManager'].isTutorialMode() and section != 'help': 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) description = self.getCommandDescription(command, section)
self.env['runtime']['outputManager'].presentText(description, interrupt=True) self.env['runtime']['outputManager'].presentText(description, interrupt=False)
else: 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) self.runCommand(command, section)

View File

@ -68,6 +68,8 @@ class fenrirManager():
else: else:
if self.environment['runtime']['helpManager'].isTutorialMode(): if self.environment['runtime']['helpManager'].isTutorialMode():
self.environment['runtime']['inputManager'].clearEventBuffer() self.environment['runtime']['inputManager'].clearEventBuffer()
self.environment['runtime']['inputManager'].keyEcho(event['Data'])
if self.environment['runtime']['vmenuManager'].getActive(): if self.environment['runtime']['vmenuManager'].getActive():
self.environment['runtime']['inputManager'].clearEventBuffer() self.environment['runtime']['inputManager'].clearEventBuffer()

View File

@ -33,6 +33,7 @@ class inputManager():
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2) 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.lastDeepestInput = [] self.lastDeepestInput = []
self.lastEvent = None
self.env['input']['shortcutRepeat'] = 1 self.env['input']['shortcutRepeat'] = 1
self.lastInputTime = time.time() self.lastInputTime = time.time()
def shutdown(self): def shutdown(self):
@ -79,10 +80,12 @@ class inputManager():
time.sleep(value) time.sleep(value)
else: else:
self.env['runtime']['inputDriver'].sendKey(key, value) self.env['runtime']['inputDriver'].sendKey(key, value)
def getLastEvent(self):
return self.lastEvent
def handleInputEvent(self, eventData): def handleInputEvent(self, eventData):
#print(eventData)
if not eventData: if not eventData:
return return
self.lastEvent = eventData
# a hang apears.. try to fix # a hang apears.. try to fix
if self.env['input']['eventBuffer'] == []: if self.env['input']['eventBuffer'] == []:
if self.env['input']['currInput'] != []: if self.env['input']['currInput'] != []:
@ -265,6 +268,18 @@ class inputManager():
if not self.shortcutExists(shortcut): if not self.shortcutExists(shortcut):
return '' return ''
return self.env['bindings'][shortcut] 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): def shortcutExists(self, shortcut):
return(shortcut in self.env['bindings']) return(shortcut in self.env['bindings'])