fenrir/src/fenrir-package/core/inputManager.py

76 lines
3.0 KiB
Python
Raw Normal View History

#!/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
class inputManager():
def __init__(self):
pass
def initialize(self, environment):
environment['runtime']['settingsManager'].loadDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'), 'inputDriver')
def shutdown(self, environment):
environment['runtime']['inputManager'].releaseDevices(environment)
if environment['runtime']['inputDriver']:
environment['runtime']['inputDriver'].shutdown(environment)
def proceedInputEvent(self, environment):
2016-09-02 20:22:56 -04:00
timeout = True
2016-09-12 18:05:29 -04:00
event = environment['runtime']['inputDriver'].getInput(environment)
if event:
timeout = False
2016-09-16 19:59:38 -04:00
environment['input']['firstEvent'] = event
environment['input']['currEvent'] = event
#if not
#print(event)
2016-09-16 19:59:38 -04:00
return timeout
2016-09-12 17:29:16 -04:00
def grabDevices(self, environment):
2016-09-16 20:30:34 -04:00
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'):
environment['runtime']['inputDriver'].grabDevices(environment)
def releaseDevices(self, environment):
environment['runtime']['inputDriver'].releaseDevices()
def isConsumeInput(self, environment):
return environment['input']['consumeKey'] and \
not environment['input']['keyForeward'] or \
not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')
def passInput(self, environment):
2016-08-31 07:27:04 -04:00
try:
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)
environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR)
2016-09-12 17:29:16 -04:00
2016-09-16 19:59:38 -04:00
def getPrevDeepestInput(self, environment):
shortcut = []
shortcut.append(environment['input']['shortcutRepeat'])
shortcut.append(sorted(environment['input']['prevDeepestInput']))
def getPrevShortcut(self, environment):
shortcut = []
shortcut.append(environment['input']['shortcutRepeat'])
shortcut.append(sorted(environment['input']['prevInput']))
def getPrevShortcut(self, environment):
shortcut = []
shortcut.append(environment['input']['shortcutRepeat'])
shortcut.append(sorted(environment['input']['prevInput']))
2016-08-11 17:16:44 -04:00
def isFenrirKey(self,environment, event):
return str(event.code) in environment['input']['fenrirKey']
def getCommandForShortcut(self, environment, shortcut):
shortcut = shortcut.upper()
2016-09-16 19:59:38 -04:00
if not self.shortcutExists(environment, shortcut):
return ''
2016-09-16 19:59:38 -04:00
return environment['bindings'][shortcut].upper()
2016-09-16 19:59:38 -04:00
def shortcutExists(self, environment, shortcut):
return( str(shortcut).upper() in environment['bindings'])