From 22189b3ac847746c952b7e17cd64301e683551ad Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 26 Mar 2018 08:55:26 +0200 Subject: [PATCH] cleanup --- TODO v2.0 | 2 +- src/fenrirscreenreader/core/eventManager.py | 9 +++++++-- src/fenrirscreenreader/core/fenrirManager.py | 4 ++-- src/fenrirscreenreader/core/generalData.py | 2 +- src/fenrirscreenreader/core/inputManager.py | 7 +++++++ src/fenrirscreenreader/core/settingsManager.py | 8 +++----- src/fenrirscreenreader/inputDriver/ptyDriver.py | 4 ++++ 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/TODO v2.0 b/TODO v2.0 index 1195f789..46ac723d 100644 --- a/TODO v2.0 +++ b/TODO v2.0 @@ -90,7 +90,7 @@ Driver (screen, input): [X] Load escape sequence shortcuts [X] controll modes (vim like mode to not collide with application shortcuts) [X] create keyboard layout - [W]set flag that it is used in emulation + [X]set flag that it is used in emulation [] write/ consume them (controll it at all) [] ATK input driver (don't grab on graphical interface) https://git.linux-a11y.org/AIT/pyatspi2/src/master/examples/keypress.py diff --git a/src/fenrirscreenreader/core/eventManager.py b/src/fenrirscreenreader/core/eventManager.py index 2ad784b8..dc6d095b 100644 --- a/src/fenrirscreenreader/core/eventManager.py +++ b/src/fenrirscreenreader/core/eventManager.py @@ -7,7 +7,7 @@ from fenrirscreenreader.core import debug from fenrirscreenreader.core.eventData import fenrirEventType from queue import Empty -import time +import time, platform from multiprocessing import Queue from multiprocessing.sharedctypes import Value from ctypes import c_bool @@ -28,7 +28,12 @@ class eventManager(): self.eventDispatcher(event) #print('NET loop ' + str(time.time() - st)) def eventDispatcher(self, event): - self.env['runtime']['debug'].writeDebugOut('eventManager:eventDispatcher:start: event:' + str(event['Type']) + ' QueueSize:' + str( self._eventQueue.qsize()),debug.debugLevel.INFO) + if platform.system() == 'Darwin': + self.env['runtime']['debug'].writeDebugOut('eventManager:eventDispatcher:start: event:' + str(event['Type']) + ' QueueSize:Not Implemented',debug.debugLevel.INFO) + else: + self.env['runtime']['debug'].writeDebugOut('eventManager:eventDispatcher:start: event:' + str(event['Type']) + ' QueueSize:' + str( self._eventQueue.qsize()),debug.debugLevel.INFO) + + if not event: return if not event['Type']: diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 0504742a..37b04dd3 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -69,7 +69,7 @@ class fenrirManager(): if self.environment['runtime']['helpManager'].isTutorialMode(): self.environment['runtime']['inputManager'].clearEventBuffer() - self.detectCommand() + self.detectShortcutCommand() if self.modifierInput: self.environment['runtime']['inputManager'].clearEventBuffer() @@ -167,7 +167,7 @@ class fenrirManager(): self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, command) if self.command != '': self.command = '' - def detectCommand(self): + def detectShortcutCommand(self): if self.environment['input']['keyForeward'] > 0: return if self.environment['runtime']['inputManager'].isKeyPress(): diff --git a/src/fenrirscreenreader/core/generalData.py b/src/fenrirscreenreader/core/generalData.py index d66d2496..26e6ac79 100644 --- a/src/fenrirscreenreader/core/generalData.py +++ b/src/fenrirscreenreader/core/generalData.py @@ -11,7 +11,7 @@ generalData = { 'tutorialMode': False, 'currUser':'', 'prevUser':'', -'managerList':['processManager', 'punctuationManager', 'cursorManager', 'applicationManager', 'commandManager' +'managerList':['processManager', 'punctuationManager', 'byteManager', 'cursorManager', 'applicationManager', 'commandManager' , 'screenManager', 'inputManager','outputManager', 'helpManager', 'memoryManager', 'eventManager', 'debug'], 'commandFolderList':['commands','onInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice' ,'onApplicationChange','onSwitchApplicationProfile','help',], diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index ed81ebad..30bd072e 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -13,6 +13,13 @@ fenrirPath = os.path.dirname(currentdir) class inputManager(): def __init__(self): self.setLedState = True + self.shortcutType = 'KEY' + + def setShortcutType(self, shortcutType = 'KEY'): + if shortcutType in ['KEY', 'BYTE']: + self.shortcutType = shortcutType + def getShortcutType(self): + return self.shortcutType def initialize(self, environment): self.env = environment self.env['runtime']['settingsManager'].loadDriver(\ diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index 06d39eb0..f563527e 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -33,7 +33,6 @@ class settingsManager(): def __init__(self): self.settings = settingsData self.settingArgDict = {} - self.shortcutType = 'KEY' def initialize(self, environment): self.env = environment def shutdown(self): @@ -222,8 +221,7 @@ class settingsManager(): # TODO needs cleanup use dict #self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty') self.setSetting('keyboard', 'keyboardLayout', 'pty') - self.shortcutType = 'BYTE' - self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log') + self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log') self.setFenrirKeys(self.getSetting('general','fenrirKeys')) self.setScriptKeys(self.getSetting('general','scriptKeys')) @@ -268,7 +266,7 @@ class settingsManager(): environment['runtime']['byteManager'] = byteManager.byteManager() environment['runtime']['byteManager'].initialize(environment) - if self.shortcutType == 'KEY': + if environment['runtime']['inputManager'].getShortcutType() == 'KEY': if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')) @@ -278,7 +276,7 @@ class settingsManager(): environment['runtime']['inputManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout')) else: environment['runtime']['inputManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout')) - elif self.shortcutType == 'BYTE': + elif environment['runtime']['inputManager'].getShortcutType() == 'BYTE': if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')) diff --git a/src/fenrirscreenreader/inputDriver/ptyDriver.py b/src/fenrirscreenreader/inputDriver/ptyDriver.py index 22175126..2685b18c 100644 --- a/src/fenrirscreenreader/inputDriver/ptyDriver.py +++ b/src/fenrirscreenreader/inputDriver/ptyDriver.py @@ -11,3 +11,7 @@ from fenrirscreenreader.core.inputDriver import inputDriver class driver(inputDriver): def __init__(self): inputDriver.__init__(self) + def initialize(self, environment): + self.env = environment + self.env['runtime']['inputManager'].setShortcutType('BYTE') + self._isInitialized = True