From cd58d24a7432435660ef49d7f4a5c07dd28ea941 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 20 Sep 2016 16:57:22 +0200 Subject: [PATCH] Update fenrir.py --- src/fenrir-package/fenrir.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 3df7b2fd..07e2dc54 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -35,18 +35,21 @@ class fenrir(): def handleProcess(self): timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment) + if not timeout: + self.prepareCommand() + if not (self.environment['runtime']['inputManager'].isConsumeInput(self.environment) or \ + self.environment['runtime']['inputManager'].isFenrirKeyPressed(self.environment) and + not self.environment['runtime']['commandManager'].isCommandQueued(self.environment): + self.environment['runtime']['inputManager'].writeEventBuffer(self.environment) + elif self.environment['runtime']['inputManager'].noKeyPressed(self.environment): + self.environment['runtime']['inputManager'].clearEventBuffer(self.environment) + try: self.environment['runtime']['screenManager'].update(self.environment) except Exception as e: print(e) - self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR) - if not timeout: - self.prepareCommand() - if not (self.environment['runtime']['inputManager'].isConsumeInput(self.environment) or \ - self.environment['runtime']['inputManager'].isFenrirKeyPressed(self.environment)): - self.environment['runtime']['inputManager'].writeEventBuffer(self.environment) - elif not self.environment['runtime']['commandManager'].isCommandQueued(self.environment) or self.environment['runtime']['inputManager'].noKeyPressed(self.environment): - self.environment['runtime']['inputManager'].clearEventBuffer(self.environment) + self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR) + self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput') self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged') @@ -55,15 +58,16 @@ class fenrir(): def prepareCommand(self): if self.environment['input']['keyForeward']: return - if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2: - return shortcut = self.environment['runtime']['inputManager'].getCurrShortcut(self.environment) command = self.environment['runtime']['inputManager'].getCommandForShortcut(self.environment, shortcut) self.environment['runtime']['commandManager'].queueCommand(self.environment, command) def handleCommands(self): - if self.environment['runtime']['commandManager'].isCommandQueued(self.environment): - self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands') + if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2: + return + if not self.environment['runtime']['commandManager'].isCommandQueued(self.environment): + return + self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands') def shutdownRequest(self): self.environment['generalInformation']['running'] = False