continue rework of input handling
This commit is contained in:
parent
063ab4917c
commit
9d63a30597
2
TODO
2
TODO
@ -1,7 +1,7 @@
|
|||||||
ToDos in Priority order:
|
ToDos in Priority order:
|
||||||
|
|
||||||
- Known Bugs
|
- Known Bugs
|
||||||
gstreamer sounddriver doesnt work
|
gstreamer sounddriver doesnt work (i think it needs a Glib
|
||||||
|
|
||||||
- try to consume shortcuts
|
- try to consume shortcuts
|
||||||
grab keyboard exclusive [x]
|
grab keyboard exclusive [x]
|
||||||
|
@ -22,6 +22,8 @@ enabled=True
|
|||||||
|
|
||||||
# Select speech driver, options are speechd (default) or espeak:
|
# Select speech driver, options are speechd (default) or espeak:
|
||||||
driver=speechd
|
driver=speechd
|
||||||
|
#driver=espeak
|
||||||
|
|
||||||
|
|
||||||
# The rate selects how fast fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
|
# The rate selects how fast fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
|
||||||
rate=0.45
|
rate=0.45
|
||||||
|
@ -11,7 +11,18 @@ class inputManager():
|
|||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
return environment
|
||||||
def proceedInputEvent(self, environment):
|
def proceedInputEvent(self, environment):
|
||||||
|
timeout = True
|
||||||
|
if not environment['input']['keyForeward']:
|
||||||
|
self.ignoreKeyRelease = 0
|
||||||
environment, timeout = environment['runtime']['inputDriver'].getInput(environment)
|
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
|
return environment, timeout
|
||||||
def grabDevices(self, environment):
|
def grabDevices(self, environment):
|
||||||
environment['runtime']['inputDriver'].grabDevices(environment)
|
environment['runtime']['inputDriver'].grabDevices(environment)
|
||||||
|
@ -24,6 +24,7 @@ class fenrir():
|
|||||||
try:
|
try:
|
||||||
self.handleProcess()
|
self.handleProcess()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR)
|
self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR)
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
|
@ -18,9 +18,7 @@ class input():
|
|||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
return environment
|
||||||
def getInput(self, environment):
|
def getInput(self, environment):
|
||||||
timeout = True
|
|
||||||
if not environment['input']['keyForeward']:
|
|
||||||
self.ignoreKeyRelease = 0
|
|
||||||
try:
|
try:
|
||||||
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
|
||||||
if r != []:
|
if r != []:
|
||||||
@ -49,14 +47,7 @@ class input():
|
|||||||
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
|
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
|
||||||
self.releaseDevices()
|
self.releaseDevices()
|
||||||
time.sleep(0.01)
|
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
|
return environment, timeout
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
class speech():
|
class speech():
|
||||||
def __init__(self ):
|
def __init__(self ):
|
||||||
pass
|
|
||||||
def initialize(self, environment):
|
|
||||||
self._es = None
|
self._es = None
|
||||||
self._isInitialized = False
|
self._isInitialized = False
|
||||||
try:
|
try:
|
||||||
@ -14,6 +12,7 @@ class speech():
|
|||||||
self._isInitialized = True
|
self._isInitialized = True
|
||||||
except:
|
except:
|
||||||
self._initialized = False
|
self._initialized = False
|
||||||
|
def initialize(self, environment):
|
||||||
return environment
|
return environment
|
||||||
def shutdown(self, environment):
|
def shutdown(self, environment):
|
||||||
return environment
|
return environment
|
||||||
@ -68,6 +67,3 @@ class speech():
|
|||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return False
|
return False
|
||||||
return self._es.set_parameter(self._es.Parameter().Volume, int(volume * 200))
|
return self._es.set_parameter(self._es.Parameter().Volume, int(volume * 200))
|
||||||
|
|
||||||
def shutdown(self):
|
|
||||||
pass
|
|
||||||
|
Loading…
Reference in New Issue
Block a user