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

View File

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

View File

@ -276,18 +276,24 @@ class settingsManager():
environment['runtime']['processManager'] = processManager.processManager() environment['runtime']['processManager'] = processManager.processManager()
environment['runtime']['processManager'].initialize(environment) 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'] = inputManager.inputManager()
environment['runtime']['inputManager'].initialize(environment) environment['runtime']['inputManager'].initialize(environment)
environment['runtime']['screenManager'] = screenManager.screenManager()
environment['runtime']['screenManager'].initialize(environment)
environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'] = commandManager.commandManager()
environment['runtime']['commandManager'].initialize(environment) environment['runtime']['commandManager'].initialize(environment)
environment['runtime']['helpManager'] = helpManager.helpManager() environment['runtime']['helpManager'] = helpManager.helpManager()
environment['runtime']['helpManager'].initialize(environment) environment['runtime']['helpManager'].initialize(environment)
environment['runtime']['byteManager'] = byteManager.byteManager()
environment['runtime']['byteManager'].initialize(environment)
if environment['runtime']['inputManager'].getShortcutType() == 'KEY': if environment['runtime']['inputManager'].getShortcutType() == 'KEY':
if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if not os.path.exists(self.getSetting('keyboard','keyboardLayout')):
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')):
@ -309,9 +315,6 @@ class settingsManager():
else: else:
environment['runtime']['byteManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout')) 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'] = cursorManager.cursorManager()
environment['runtime']['cursorManager'].initialize(environment) environment['runtime']['cursorManager'].initialize(environment)
environment['runtime']['applicationManager'] = applicationManager.applicationManager() environment['runtime']['applicationManager'] = applicationManager.applicationManager()
@ -320,9 +323,6 @@ class settingsManager():
environment['runtime']['headLineManager'].initialize(environment) environment['runtime']['headLineManager'].initialize(environment)
environment['runtime']['tableManager'] = tableManager.tableManager() environment['runtime']['tableManager'] = tableManager.tableManager()
environment['runtime']['tableManager'].initialize(environment) 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('\/-------environment-------\/',debug.debugLevel.INFO, onAnyLevel=True)
environment['runtime']['debug'].writeDebugOut(str(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 global _evdevAvailableError
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
return return
self.updateInputDevices()
if _udevAvailable: if _udevAvailable:
self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev) self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
#else: #else: