add compat for older evdev versions.

This commit is contained in:
chrys87 2017-01-31 10:37:39 +01:00 committed by GitHub
parent 958faa34fd
commit 7c71ebd451

View File

@ -161,7 +161,28 @@ class driver():
self.ledDevices[i].set_led(led , 1)
def grabDevices(self):
if not self._initialized:
return None
return None
try:
for fd in self.iDevices:
try:
self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn)
except:
try:
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: compat fallback: ' + str(e),debug.debugLevel.ERROR)
dev = self.iDevices[fd]
cap = dev.capabilities()
del cap[0]
self.uDevices[fd] = UInput(
cap,
dev.name,
)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR)
return
try:
self.iDevices[fd].grab()
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
# leve the old code until the new one is better tested
# for fd in self.iDevices:
# dev = self.iDevices[fd]
@ -175,14 +196,10 @@ class driver():
# #dev.version,
# #dev.info.bustype,
# #'/dev/uinput'
# )
# )
# dev.grab()
for fd in self.iDevices:
try:
self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn)
self.iDevices[fd].grab()
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
def releaseDevices(self):
if not self._initialized:
return None