fire event for plug only once
This commit is contained in:
parent
d4a4605d6b
commit
09e3969531
@ -54,8 +54,8 @@ class driver(inputDriver):
|
|||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
self.updateInputDevices()
|
self.updateInputDevices()
|
||||||
#if _udevAvailable:
|
if _udevAvailable:
|
||||||
# self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
|
self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
|
||||||
#else:
|
#else:
|
||||||
# self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer)
|
# self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer)
|
||||||
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
||||||
@ -65,11 +65,18 @@ class driver(inputDriver):
|
|||||||
monitor.filter_by(subsystem='input')
|
monitor.filter_by(subsystem='input')
|
||||||
monitor.start()
|
monitor.start()
|
||||||
while active.value:
|
while active.value:
|
||||||
devices = monitor.poll(2)
|
validDevice = False
|
||||||
if devices:
|
device = monitor.poll(1)
|
||||||
while monitor.poll(1):
|
while device:
|
||||||
|
try:
|
||||||
|
if not '/sys/devices/virtual/input/' in device.sys_path:
|
||||||
|
validDevice = True
|
||||||
|
device = monitor.poll(0.7)
|
||||||
|
except:
|
||||||
pass
|
pass
|
||||||
|
if validDevice:
|
||||||
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None})
|
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None})
|
||||||
|
print('fired',device)
|
||||||
return time.time()
|
return time.time()
|
||||||
def plugInputDeviceWatchdogTimer(self, active):
|
def plugInputDeviceWatchdogTimer(self, active):
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
@ -192,6 +199,7 @@ class driver(inputDriver):
|
|||||||
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
||||||
self.iDeviceNo = len(evdev.list_devices())
|
self.iDeviceNo = len(evdev.list_devices())
|
||||||
self.updateMPiDevicesFD()
|
self.updateMPiDevicesFD()
|
||||||
|
print(self.gDevices)
|
||||||
|
|
||||||
def updateMPiDevicesFD(self):
|
def updateMPiDevicesFD(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user