continue rework of input handling

This commit is contained in:
chrys
2016-09-03 02:22:56 +02:00
parent 063ab4917c
commit 9d63a30597
6 changed files with 18 additions and 17 deletions

View File

@ -11,7 +11,18 @@ class inputManager():
def shutdown(self, environment):
return environment
def proceedInputEvent(self, environment):
timeout = True
if not environment['input']['keyForeward']:
self.ignoreKeyRelease = 0
environment, timeout = environment['runtime']['inputDriver'].getInput(environment)
environment['input']['currShortcutString'] = self.getShortcutString(environment)
if not timeout:
environment['input']['lastInputTime'] = time.time()
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
self.ignoreKeyRelease += 1
if self.ignoreKeyRelease >= 2: # a hack... has to bee done more clean
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
return environment, timeout
def grabDevices(self, environment):
environment['runtime']['inputDriver'].grabDevices(environment)

View File

@ -24,6 +24,7 @@ class fenrir():
try:
self.handleProcess()
except Exception as e:
print(e)
self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR)
self.shutdown()

View File

@ -18,9 +18,7 @@ class input():
def shutdown(self, environment):
return environment
def getInput(self, environment):
timeout = True
if not environment['input']['keyForeward']:
self.ignoreKeyRelease = 0
try:
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
if r != []:
@ -49,14 +47,7 @@ class input():
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
self.releaseDevices()
time.sleep(0.01)
environment['input']['currShortcutString'] = self.getShortcutString(environment)
if not timeout:
environment['input']['lastInputTime'] = time.time()
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
self.ignoreKeyRelease += 1
if self.ignoreKeyRelease >= 2: # a hack... has to bee done more clean
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
return environment, timeout

View File

@ -4,8 +4,6 @@
class speech():
def __init__(self ):
pass
def initialize(self, environment):
self._es = None
self._isInitialized = False
try:
@ -14,6 +12,7 @@ class speech():
self._isInitialized = True
except:
self._initialized = False
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
@ -68,6 +67,3 @@ class speech():
if not self._isInitialized:
return False
return self._es.set_parameter(self._es.Parameter().Volume, int(volume * 200))
def shutdown(self):
pass