Update evdevDriver.py
This commit is contained in:
parent
20f500257e
commit
36ad12f265
@ -50,7 +50,6 @@ class driver():
|
|||||||
try:
|
try:
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
except:
|
except:
|
||||||
#print('jow')
|
|
||||||
self.removeDevice(fd)
|
self.removeDevice(fd)
|
||||||
return None
|
return None
|
||||||
foreward = False
|
foreward = False
|
||||||
@ -98,8 +97,7 @@ class driver():
|
|||||||
|
|
||||||
def updateInputDevices(self, force = False, init = False):
|
def updateInputDevices(self, force = False, init = False):
|
||||||
if init:
|
if init:
|
||||||
self.iDevices = {}
|
self.removeAllDevices()
|
||||||
self.iDeviceNo = 0
|
|
||||||
deviceFileList = evdev.list_devices()
|
deviceFileList = evdev.list_devices()
|
||||||
if not force:
|
if not force:
|
||||||
if len(deviceFileList) == self.iDeviceNo:
|
if len(deviceFileList) == self.iDeviceNo:
|
||||||
@ -113,7 +111,6 @@ class driver():
|
|||||||
for deviceFile in deviceFileList:
|
for deviceFile in deviceFileList:
|
||||||
try:
|
try:
|
||||||
if deviceFile in iDevicesFiles:
|
if deviceFile in iDevicesFiles:
|
||||||
print('skip')
|
|
||||||
continue
|
continue
|
||||||
open(deviceFile)
|
open(deviceFile)
|
||||||
# 3 pos absolute
|
# 3 pos absolute
|
||||||
@ -182,11 +179,12 @@ class driver():
|
|||||||
self.iDevices[i].set_led(led , 0)
|
self.iDevices[i].set_led(led , 0)
|
||||||
else:
|
else:
|
||||||
self.iDevices[i].set_led(led , 1)
|
self.iDevices[i].set_led(led , 1)
|
||||||
def grabDevices(self):
|
def grabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
self.grabDevice()
|
self.grabDevice(fd)
|
||||||
|
|
||||||
def grabDevice(self, fd):
|
def grabDevice(self, fd):
|
||||||
try:
|
try:
|
||||||
self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn)
|
self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn)
|
||||||
@ -207,21 +205,7 @@ class driver():
|
|||||||
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)
|
||||||
# leve the old code until the new one is better tested
|
|
||||||
# for fd in self.iDevices:
|
|
||||||
# dev = self.iDevices[fd]
|
|
||||||
# cap = dev.capabilities()
|
|
||||||
# del cap[0]
|
|
||||||
# self.uDevices[fd] = UInput(
|
|
||||||
# cap,
|
|
||||||
# dev.name,
|
|
||||||
# #dev.info.vendor,
|
|
||||||
# #dev.info.product,
|
|
||||||
# #dev.version,
|
|
||||||
# #dev.info.bustype,
|
|
||||||
# #'/dev/uinput'
|
|
||||||
# )
|
|
||||||
# dev.grab()
|
|
||||||
def removeDevice(self,fd):
|
def removeDevice(self,fd):
|
||||||
self.clearEventBuffer()
|
self.clearEventBuffer()
|
||||||
try:
|
try:
|
||||||
@ -253,7 +237,7 @@ class driver():
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def releaseDevices(self):
|
def removeAllDevices(self):
|
||||||
if not self.hasIDevices():
|
if not self.hasIDevices():
|
||||||
return
|
return
|
||||||
devices = self.iDevices.copy()
|
devices = self.iDevices.copy()
|
||||||
@ -261,6 +245,7 @@ class driver():
|
|||||||
self.removeDevice(fd)
|
self.removeDevice(fd)
|
||||||
self.iDevices.clear()
|
self.iDevices.clear()
|
||||||
self.uDevices.clear()
|
self.uDevices.clear()
|
||||||
|
self.iDeviceNo = 0
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
|
Loading…
Reference in New Issue
Block a user