2016-07-07 13:43:31 -04:00
|
|
|
#!/bin/python
|
|
|
|
|
2016-08-11 08:37:46 -04:00
|
|
|
import time
|
2016-08-23 18:41:16 -04:00
|
|
|
from utils import debug
|
2016-07-07 15:40:10 -04:00
|
|
|
|
2016-07-07 13:43:31 -04:00
|
|
|
class inputManager():
|
|
|
|
def __init__(self):
|
2016-09-02 15:37:36 -04:00
|
|
|
pass
|
|
|
|
def initialize(self, environment):
|
|
|
|
return environment
|
|
|
|
def shutdown(self, environment):
|
|
|
|
return environment
|
2016-09-02 16:13:33 -04:00
|
|
|
def proceedInputEvent(self, environment):
|
2016-09-02 20:22:56 -04:00
|
|
|
timeout = True
|
2016-09-02 15:37:36 -04:00
|
|
|
environment, timeout = environment['runtime']['inputDriver'].getInput(environment)
|
2016-09-12 17:29:16 -04:00
|
|
|
return environment, timeout
|
|
|
|
|
2016-09-02 15:37:36 -04:00
|
|
|
def grabDevices(self, environment):
|
|
|
|
environment['runtime']['inputDriver'].grabDevices(environment)
|
|
|
|
|
|
|
|
def releaseDevices(self, environment):
|
2016-09-02 16:13:33 -04:00
|
|
|
environment['runtime']['inputDriver'].releaseDevices()
|
2016-09-02 15:37:36 -04:00
|
|
|
|
|
|
|
def isConsumeInput(self, environment):
|
|
|
|
return environment['input']['consumeKey'] and \
|
|
|
|
not environment['input']['keyForeward'] or \
|
2016-08-19 11:21:52 -04:00
|
|
|
not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')
|
2016-09-02 15:37:36 -04:00
|
|
|
|
|
|
|
def passInput(self, environment):
|
2016-08-31 07:27:04 -04:00
|
|
|
try:
|
2016-09-02 15:37:36 -04:00
|
|
|
environment['runtime']['inputDriver']
|
2016-09-02 12:08:44 -04:00
|
|
|
except Exception as e:
|
|
|
|
environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR)
|
2016-09-02 15:37:36 -04:00
|
|
|
environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR)
|
|
|
|
return environment
|
2016-09-12 17:29:16 -04:00
|
|
|
|
2016-07-08 12:33:32 -04:00
|
|
|
def getShortcutString(self, environment):
|
|
|
|
if environment['input']['currShortcut'] == {}:
|
|
|
|
return ''
|
|
|
|
currShortcutStringList = []
|
2016-07-10 12:34:44 -04:00
|
|
|
for key in environment['input']['currShortcut']:
|
2016-08-11 17:16:44 -04:00
|
|
|
currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key))
|
2016-07-10 12:34:44 -04:00
|
|
|
currShortcutStringList = sorted(currShortcutStringList)
|
2016-07-08 12:33:32 -04:00
|
|
|
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
|
2016-09-02 15:37:36 -04:00
|
|
|
|
2016-08-11 17:16:44 -04:00
|
|
|
def isFenrirKey(self,environment, event):
|
2016-09-02 15:37:36 -04:00
|
|
|
return str(event.code) in environment['input']['fenrirKey']
|