This commit is contained in:
chrys 2018-05-23 01:12:31 +02:00
parent 14902dbab9
commit d3bec267af
4 changed files with 50 additions and 34 deletions

View File

@ -14,7 +14,7 @@ class inputManager():
def __init__(self):
self.setLedState = True
self.shortcutType = 'KEY'
self.toggleDeviceGrab = False
self.executeDeviceGrab = False
def setShortcutType(self, shortcutType = 'KEY'):
if shortcutType in ['KEY', 'BYTE']:
self.shortcutType = shortcutType
@ -24,6 +24,8 @@ class inputManager():
self.env = environment
self.env['runtime']['settingsManager'].loadDriver(\
self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver')
self.updateInputDevices()
# init LEDs with current state
self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getLedState()
self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
@ -39,27 +41,25 @@ class inputManager():
self.env['runtime']['settingsManager'].shutdownDriver('inputDriver')
def getInputEvent(self):
return self.env['runtime']['inputDriver'].getInputEvent()
def handleDeviceGrab(self, useCurrentScreen = False):
def setExecuteDeviceGrab(self, newExecuteDeviceGrab = True):
self.executeDeviceGrab = newExecuteDeviceGrab
def handleDeviceGrab(self):
if not self.executeDeviceGrab:
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
return
if useCurrentScreen:
self.toggleDeviceGrab = True
else:
if self.env['runtime']['screenManager'].getCurrScreenIgnored() != self.env['runtime']['screenManager'].getPrevScreenIgnored():
self.toggleDeviceGrab = True
if self.toggleDeviceGrab:
if self.noKeyPressed():
if not self.noKeyPressed():
return
if self.env['runtime']['screenManager'].getCurrScreenIgnored():
self.ungrabAllDevices()
self.env['runtime']['outputManager'].interruptOutput()
else:
self.grabAllDevices()
self.toggleDeviceGrab = False
self.executeDeviceGrab = False
def handleInputEvent(self, eventData):
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT inputMan:' + str(eventData),debug.debugLevel.INFO)
if not eventData:
return
self.handleDeviceGrab()
self.env['input']['prevInput'] = self.env['input']['currInput'].copy()
if eventData['EventState'] == 0:
if eventData['EventName'] in self.env['input']['currInput']:
@ -97,6 +97,8 @@ class inputManager():
if self.noKeyPressed():
self.env['input']['prevInput'] = []
self.setLedState = True
else:
self.handleDeviceGrab()
def handleLedStates(self, mEvent):
if not self.setLedState:
@ -144,7 +146,9 @@ class inputManager():
self.env['runtime']['inputDriver'].updateInputDevices(newDevice)
except:
pass
self.handleDeviceGrab(True)
self.setExecuteDeviceGrab()
if newDevice:
self.handleDeviceGrab()
def removeAllDevices(self):
try:
self.env['runtime']['inputDriver'].removeAllDevices()

View File

@ -19,6 +19,9 @@ class screenManager():
self.getCurrScreen()
self.getCurrScreen()
self.getSessionInformation()
self.updateScreenIgnored()
self.updateScreenIgnored()
def getCurrScreen(self):
try:
self.env['runtime']['screenDriver'].getCurrScreen()
@ -32,9 +35,16 @@ class screenManager():
def shutdown(self):
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
def isCurrScreenIgnoredChanged(self):
return self.getCurrScreenIgnored() != self.getPrevScreenIgnored()
def hanldeScreenChange(self, eventData):
self.getCurrScreen()
self.updateScreenIgnored()
if self.isCurrScreenIgnoredChanged():
self.env['runtime']['inputManager'].setExecuteDeviceGrab()
self.env['runtime']['inputManager'].handleDeviceGrab()
self.getSessionInformation()
if self.isScreenChange():
self.changeBrailleScreen()
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
@ -44,6 +54,8 @@ class screenManager():
def handleScreenUpdate(self, eventData):
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
self.updateScreenIgnored()
if self.isCurrScreenIgnoredChanged():
self.env['runtime']['inputManager'].setExecuteDeviceGrab()
self.env['runtime']['inputManager'].handleDeviceGrab()
if not self.getCurrScreenIgnored():
self.update(eventData, 'onScreenUpdate')

View File

@ -276,18 +276,24 @@ class settingsManager():
environment['runtime']['processManager'] = processManager.processManager()
environment['runtime']['processManager'].initialize(environment)
environment['runtime']['outputManager'] = outputManager.outputManager()
environment['runtime']['outputManager'].initialize(environment)
environment['runtime']['byteManager'] = byteManager.byteManager()
environment['runtime']['byteManager'].initialize(environment)
environment['runtime']['inputManager'] = inputManager.inputManager()
environment['runtime']['inputManager'].initialize(environment)
environment['runtime']['screenManager'] = screenManager.screenManager()
environment['runtime']['screenManager'].initialize(environment)
environment['runtime']['commandManager'] = commandManager.commandManager()
environment['runtime']['commandManager'].initialize(environment)
environment['runtime']['helpManager'] = helpManager.helpManager()
environment['runtime']['helpManager'].initialize(environment)
environment['runtime']['byteManager'] = byteManager.byteManager()
environment['runtime']['byteManager'].initialize(environment)
if environment['runtime']['inputManager'].getShortcutType() == 'KEY':
if not os.path.exists(self.getSetting('keyboard','keyboardLayout')):
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')):
@ -309,9 +315,6 @@ class settingsManager():
else:
environment['runtime']['byteManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout'))
environment['runtime']['outputManager'] = outputManager.outputManager()
environment['runtime']['outputManager'].initialize(environment)
environment['runtime']['cursorManager'] = cursorManager.cursorManager()
environment['runtime']['cursorManager'].initialize(environment)
environment['runtime']['applicationManager'] = applicationManager.applicationManager()
@ -320,9 +323,6 @@ class settingsManager():
environment['runtime']['headLineManager'].initialize(environment)
environment['runtime']['tableManager'] = tableManager.tableManager()
environment['runtime']['tableManager'].initialize(environment)
if environment['runtime']['screenManager'] == None:
environment['runtime']['screenManager'] = screenManager.screenManager()
environment['runtime']['screenManager'].initialize(environment)
environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.INFO, onAnyLevel=True)
environment['runtime']['debug'].writeDebugOut(str(environment), debug.debugLevel.INFO, onAnyLevel=True)

View File

@ -53,7 +53,7 @@ class driver(inputDriver):
global _evdevAvailableError
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
return
self.updateInputDevices()
if _udevAvailable:
self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
#else: