create byte command detection infra and try out fire a command
This commit is contained in:
parent
88c12a3331
commit
11681120ca
@ -45,7 +45,6 @@ class eventManager():
|
|||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
||||||
self.env['runtime']['fenrirManager'].handlePlugInputDevice(event)
|
self.env['runtime']['fenrirManager'].handlePlugInputDevice(event)
|
||||||
pass
|
|
||||||
elif event['Type'] == fenrirEventType.BrailleFlush:
|
elif event['Type'] == fenrirEventType.BrailleFlush:
|
||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.ScreenChanged:
|
elif event['Type'] == fenrirEventType.ScreenChanged:
|
||||||
@ -54,6 +53,8 @@ class eventManager():
|
|||||||
self.env['runtime']['fenrirManager'].handleHeartBeat(event)
|
self.env['runtime']['fenrirManager'].handleHeartBeat(event)
|
||||||
elif event['Type'] == fenrirEventType.ExecuteCommand:
|
elif event['Type'] == fenrirEventType.ExecuteCommand:
|
||||||
self.env['runtime']['fenrirManager'].handleExecuteCommand(event)
|
self.env['runtime']['fenrirManager'].handleExecuteCommand(event)
|
||||||
|
elif event['Type'] == fenrirEventType.ByteInput:
|
||||||
|
self.env['runtime']['fenrirManager'].handleByteInput(event)
|
||||||
def isMainEventLoopRunning(self):
|
def isMainEventLoopRunning(self):
|
||||||
return self.running.value == 1
|
return self.running.value == 1
|
||||||
def startMainEventLoop(self):
|
def startMainEventLoop(self):
|
||||||
|
@ -83,6 +83,10 @@ class fenrirManager():
|
|||||||
self.environment['input']['keyForeward'] -=1
|
self.environment['input']['keyForeward'] -=1
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||||
#print('handleInput:',time.time() - startTime)
|
#print('handleInput:',time.time() - startTime)
|
||||||
|
def handleByteInput(self, event):
|
||||||
|
if event['Data'] == b'':
|
||||||
|
return
|
||||||
|
self.detectByteCommand(event['Data'])
|
||||||
def handleExecuteCommand(self, event):
|
def handleExecuteCommand(self, event):
|
||||||
if event['Data'] == '':
|
if event['Data'] == '':
|
||||||
return
|
return
|
||||||
@ -131,7 +135,12 @@ class fenrirManager():
|
|||||||
def handleHeartBeat(self, event):
|
def handleHeartBeat(self, event):
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
||||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
#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):
|
def detectCommand(self):
|
||||||
if self.environment['input']['keyForeward'] > 0:
|
if self.environment['input']['keyForeward'] > 0:
|
||||||
return
|
return
|
||||||
|
@ -150,6 +150,9 @@ class driver(screenDriver):
|
|||||||
print('pre stdin')
|
print('pre stdin')
|
||||||
try:
|
try:
|
||||||
msgBytes = self.readAll(sys.stdin.fileno())
|
msgBytes = self.readAll(sys.stdin.fileno())
|
||||||
|
eventQueue.put({"Type":fenrirEventType.ByteInput,
|
||||||
|
"Data":msgBytes
|
||||||
|
})
|
||||||
except (EOFError, OSError):
|
except (EOFError, OSError):
|
||||||
running = False
|
running = False
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user