add ungrab method

This commit is contained in:
chrys 2018-05-11 22:21:30 +02:00
parent ba3ad7719d
commit 0296590f08

View File

@ -241,7 +241,11 @@ class driver(inputDriver):
return return
for fd in self.iDevices: for fd in self.iDevices:
self.grabDevice(fd) self.grabDevice(fd)
def ungrabAllDevices(self):
if not self._initialized:
return
for fd in self.iDevices:
self.ungrabDevices(fd)
def grabDevice(self, fd): def grabDevice(self, fd):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
self.uDevices[fd] = None self.uDevices[fd] = None
@ -254,7 +258,6 @@ class driver(inputDriver):
dev = self.iDevices[fd] dev = self.iDevices[fd]
cap = dev.capabilities() cap = dev.capabilities()
del cap[0] del cap[0]
print(e)
self.uDevices[fd] = UInput( self.uDevices[fd] = UInput(
cap, cap,
dev.name, dev.name,
@ -266,11 +269,17 @@ class driver(inputDriver):
self.iDevices[fd].grab() self.iDevices[fd].grab()
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
def ungrabDevices(self,fd):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
return
try:
self.iDevices[fd].ungrab()
except:
pass
def removeDevice(self,fd): def removeDevice(self,fd):
self.clearEventBuffer() self.clearEventBuffer()
try: try:
self.iDevices[fd].ungrab() self.ungrabDevices(fd)
except: except:
pass pass
try: try: