prepare for remake input handling, prepare other stuff

This commit is contained in:
chrys 2016-09-02 22:13:33 +02:00
parent 7227f52ac7
commit 1887810e69
7 changed files with 13 additions and 12 deletions

View File

@ -10,14 +10,14 @@ class inputManager():
return environment return environment
def shutdown(self, environment): def shutdown(self, environment):
return environment return environment
def getInput(self, environment): def proceedInputEvent(self, environment):
environment, timeout = environment['runtime']['inputDriver'].getInput(environment) environment, timeout = environment['runtime']['inputDriver'].getInput(environment)
return environment, timeout return environment, timeout
def grabDevices(self, environment): def grabDevices(self, environment):
environment['runtime']['inputDriver'].grabDevices(environment) environment['runtime']['inputDriver'].grabDevices(environment)
def releaseDevices(self, environment): def releaseDevices(self, environment):
environment['runtime']['inputDriver'].releaseDevices(environment) environment['runtime']['inputDriver'].releaseDevices()
def isConsumeInput(self, environment): def isConsumeInput(self, environment):
return environment['input']['consumeKey'] and \ return environment['input']['consumeKey'] and \

View File

@ -9,5 +9,6 @@ runtime = {
'inputManager': None, 'inputManager': None,
'commandManager': None, 'commandManager': None,
'screenManager': None, 'screenManager': None,
'outputManager': None,
'debug':None, 'debug':None,
} }

View File

@ -16,6 +16,6 @@ class screenManager():
return environment return environment
def isSuspendingScreen(self, environment): def isSuspendingScreen(self, environment):
return environment['generalInformation']['suspend'] = environment['runtime']['screenDriver'].getCurrScreen() in \ return environment['runtime']['screenDriver'].getCurrScreen() in \
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'suspendingScreen').split(',') environment['runtime']['settingsManager'].getSetting(environment,'screen', 'suspendingScreen').split(',')

View File

@ -184,7 +184,7 @@ class settingsManager():
spec = importlib.util.spec_from_file_location(driverName, 'input/' + driverName + '.py') spec = importlib.util.spec_from_file_location(driverName, 'input/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec) driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod) spec.loader.exec_module(driver_mod)
environment['runtime']['inputDriver'] = driver_mod.screen() environment['runtime']['inputDriver'] = driver_mod.input()
environment['runtime']['inputDriver'].initialize(environment) environment['runtime']['inputDriver'].initialize(environment)
return environment return environment

View File

@ -28,7 +28,7 @@ class fenrir():
self.shutdown() self.shutdown()
def handleProcess(self): def handleProcess(self):
self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(self.environment) self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvent(self.environment)
try: try:
self.environment = self.environment['runtime']['screenManager'].update(self.environment) self.environment = self.environment['runtime']['screenManager'].update(self.environment)
except Exception as e: except Exception as e:
@ -58,10 +58,11 @@ class fenrir():
if self.environment['runtime']['debug'] != None: if self.environment['runtime']['debug'] != None:
self.environment['runtime']['debug'].closeDebugFile() self.environment['runtime']['debug'].closeDebugFile()
if self.environment['runtime']['soundDriver'] != None: if self.environment['runtime']['soundDriver'] != None:
self.environment['runtime']['soundDriver'].shutdown() self.environment['runtime']['soundDriver'].shutdown(environment)
if self.environment['runtime']['speechDriver'] != None: if self.environment['runtime']['speechDriver'] != None:
self.environment['runtime']['speechDriver'].shutdown() self.environment['runtime']['speechDriver'].shutdown(environment)
self.environment['runtime']['inputManager'].freeDevices() self.environment['runtime']['inputManager'].releaseDevices(self.environment)
self.environment = None
app = fenrir() app = fenrir()
app.proceed() app.proceed()

View File

@ -16,14 +16,15 @@ class screen():
def insert_newlines(self, string, every=64): def insert_newlines(self, string, every=64):
return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
def getCurrScreen(self): def getCurrScreen(self):
currScreen = -1
try: try:
currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r')
currScreen = currScreenFile.read()[3:-1] currScreen = currScreenFile.read()[3:-1]
currScreenFile.close() currScreenFile.close()
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
return -1
return currScreen return currScreen
def update(self, environment, trigger='updateScreen'): def update(self, environment, trigger='updateScreen'):
newTTY = '' newTTY = ''

View File

@ -18,5 +18,3 @@ class sound():
pass pass
def setVolume(self, volume): def setVolume(self, volume):
self.volume = volume self.volume = volume
def shutdown(self):
pass