From 11681120ca857b6cd0d83e9723335d4485af427c Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 24 Mar 2018 22:50:27 +0100 Subject: [PATCH] create byte command detection infra and try out fire a command --- src/fenrirscreenreader/core/eventManager.py | 3 ++- src/fenrirscreenreader/core/fenrirManager.py | 11 ++++++++++- src/fenrirscreenreader/screenDriver/ptyDriver.py | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/fenrirscreenreader/core/eventManager.py b/src/fenrirscreenreader/core/eventManager.py index f6b49958..2ad784b8 100644 --- a/src/fenrirscreenreader/core/eventManager.py +++ b/src/fenrirscreenreader/core/eventManager.py @@ -45,7 +45,6 @@ class eventManager(): pass elif event['Type'] == fenrirEventType.PlugInputDevice: self.env['runtime']['fenrirManager'].handlePlugInputDevice(event) - pass elif event['Type'] == fenrirEventType.BrailleFlush: pass elif event['Type'] == fenrirEventType.ScreenChanged: @@ -54,6 +53,8 @@ class eventManager(): self.env['runtime']['fenrirManager'].handleHeartBeat(event) elif event['Type'] == fenrirEventType.ExecuteCommand: self.env['runtime']['fenrirManager'].handleExecuteCommand(event) + elif event['Type'] == fenrirEventType.ByteInput: + self.env['runtime']['fenrirManager'].handleByteInput(event) def isMainEventLoopRunning(self): return self.running.value == 1 def startMainEventLoop(self): diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 84f4a0e7..dbae5a7f 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -83,6 +83,10 @@ class fenrirManager(): self.environment['input']['keyForeward'] -=1 self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') #print('handleInput:',time.time() - startTime) + def handleByteInput(self, event): + if event['Data'] == b'': + return + self.detectByteCommand(event['Data']) def handleExecuteCommand(self, event): if event['Data'] == '': return @@ -131,7 +135,12 @@ class fenrirManager(): def handleHeartBeat(self, event): self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True) #self.environment['runtime']['outputManager'].brailleText(flush=False) - + def detectByteCommand(self, escapeSequence): + command = '' + if escapeSequence == b'a': + command = 'TIME' + self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, command) + def detectCommand(self): if self.environment['input']['keyForeward'] > 0: return diff --git a/src/fenrirscreenreader/screenDriver/ptyDriver.py b/src/fenrirscreenreader/screenDriver/ptyDriver.py index 94f8977a..7c0aa075 100644 --- a/src/fenrirscreenreader/screenDriver/ptyDriver.py +++ b/src/fenrirscreenreader/screenDriver/ptyDriver.py @@ -150,6 +150,9 @@ class driver(screenDriver): print('pre stdin') try: msgBytes = self.readAll(sys.stdin.fileno()) + eventQueue.put({"Type":fenrirEventType.ByteInput, + "Data":msgBytes + }) except (EOFError, OSError): running = False break