improve grabbing
This commit is contained in:
parent
4e14b4aa9d
commit
b9038f5982
@ -16,6 +16,6 @@ class command():
|
||||
def getDescription(self):
|
||||
return 'No description found'
|
||||
def run(self):
|
||||
pass
|
||||
self.env['runtime']['inputManager'].updateInputDevices()
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -166,7 +166,6 @@ class fenrirManager():
|
||||
#print('handleScreenUpdate:',time.time() - startTime)
|
||||
|
||||
def handlePlugInputDevice(self, event):
|
||||
self.environment['runtime']['inputManager'].updateInputDevices()
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
|
||||
|
||||
def handleHeartBeat(self, event):
|
||||
|
@ -14,7 +14,7 @@ class inputManager():
|
||||
def __init__(self):
|
||||
self.setLedState = True
|
||||
self.shortcutType = 'KEY'
|
||||
|
||||
self.toggleDeviceGrab = False
|
||||
def setShortcutType(self, shortcutType = 'KEY'):
|
||||
if shortcutType in ['KEY', 'BYTE']:
|
||||
self.shortcutType = shortcutType
|
||||
@ -39,6 +39,23 @@ class inputManager():
|
||||
self.env['runtime']['settingsManager'].shutdownDriver('inputDriver')
|
||||
def getInputEvent(self):
|
||||
return self.env['runtime']['inputDriver'].getInputEvent()
|
||||
def handleDeviceGrab(self, useCurrentScreen = False):
|
||||
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 self.env['runtime']['screenManager'].getCurrScreenIgnored():
|
||||
self.ungrabAllDevices()
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
else:
|
||||
self.grabAllDevices()
|
||||
self.toggleDeviceGrab = False
|
||||
def handleInputEvent(self, eventData):
|
||||
self.env['runtime']['debug'].writeDebugOut('DEBUG INPUT inputMan:' + str(eventData),debug.debugLevel.INFO)
|
||||
if not eventData:
|
||||
@ -118,14 +135,14 @@ class inputManager():
|
||||
try:
|
||||
self.env['runtime']['inputDriver'].ungrabAllDevices()
|
||||
except Exception as e:
|
||||
pass
|
||||
pass
|
||||
|
||||
def updateInputDevices(self):
|
||||
try:
|
||||
self.env['runtime']['inputDriver'].updateInputDevices()
|
||||
except:
|
||||
pass
|
||||
|
||||
self.handleDeviceGrab(True)
|
||||
def removeAllDevices(self):
|
||||
try:
|
||||
self.env['runtime']['inputDriver'].removeAllDevices()
|
||||
|
@ -12,7 +12,6 @@ class screenManager():
|
||||
def __init__(self):
|
||||
self.currScreenIgnored = False
|
||||
self.prevScreenIgnored = False
|
||||
self.toggleDeviceGrab = False
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['runtime']['settingsManager'].loadDriver(\
|
||||
@ -40,25 +39,12 @@ class screenManager():
|
||||
self.changeBrailleScreen()
|
||||
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
||||
self.update(eventData, 'onScreenChange')
|
||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||
def handleDeviceGrab(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||
return
|
||||
if self.getCurrScreenIgnored() != self.getPrevScreenIgnored():
|
||||
self.toggleDeviceGrab = True
|
||||
if self.toggleDeviceGrab:
|
||||
if self.env['runtime']['inputManager'].noKeyPressed():
|
||||
if self.getCurrScreenIgnored():
|
||||
self.env['runtime']['inputManager'].ungrabAllDevices()
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
else:
|
||||
self.env['runtime']['inputManager'].grabAllDevices()
|
||||
self.toggleDeviceGrab = False
|
||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||
|
||||
def handleScreenUpdate(self, eventData):
|
||||
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
||||
self.updateScreenIgnored()
|
||||
self.handleDeviceGrab()
|
||||
self.env['runtime']['inputManager'].handleDeviceGrab()
|
||||
if not self.getCurrScreenIgnored():
|
||||
self.update(eventData, 'onScreenUpdate')
|
||||
#if trigger == 'onUpdate' or self.isScreenChange() \
|
||||
|
@ -200,7 +200,6 @@ class driver(inputDriver):
|
||||
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
||||
self.iDeviceNo = len(evdev.list_devices())
|
||||
self.updateMPiDevicesFD()
|
||||
|
||||
def updateMPiDevicesFD(self):
|
||||
try:
|
||||
for fd in self.iDevices:
|
||||
@ -297,6 +296,8 @@ class driver(inputDriver):
|
||||
return
|
||||
try:
|
||||
self.iDevices[fd].grab()
|
||||
self.gDevices[fd] = True
|
||||
except IOError:
|
||||
self.gDevices[fd] = True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
|
||||
@ -305,7 +306,7 @@ class driver(inputDriver):
|
||||
return
|
||||
try:
|
||||
self.gDevices[fd] = False
|
||||
self.iDevices[fd].ungrab()
|
||||
self.iDevices[fd].ungrab()
|
||||
except:
|
||||
pass
|
||||
def removeDevice(self,fd):
|
||||
|
Loading…
Reference in New Issue
Block a user