more work on device detection still WIP
This commit is contained in:
parent
f11c9eed3c
commit
5847a8658c
@ -16,7 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
if not self.env['runtime']['screenManager'].isSuspendingScreen(): # remove if all works
|
self.env['runtime']['inputManager'].updateInputDevices()
|
||||||
self.env['runtime']['inputManager'].updateInputDevices()
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -163,9 +163,10 @@ class commandManager():
|
|||||||
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def executeDefaultTrigger(self, trigger):
|
def executeDefaultTrigger(self, trigger, force=False):
|
||||||
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
if not force:
|
||||||
return
|
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
||||||
|
return
|
||||||
for command in sorted(self.env['commands'][trigger]):
|
for command in sorted(self.env['commands'][trigger]):
|
||||||
if self.commandExists(command, trigger):
|
if self.commandExists(command, trigger):
|
||||||
try:
|
try:
|
||||||
|
@ -61,7 +61,7 @@ class eventManager():
|
|||||||
elif event['Type'] == fenrirEventType.BrailleInput:
|
elif event['Type'] == fenrirEventType.BrailleInput:
|
||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
||||||
pass
|
self.env['runtime']['fenrirManager'].handlePlugInputDevice(event)
|
||||||
elif event['Type'] == fenrirEventType.BrailleFlush:
|
elif event['Type'] == fenrirEventType.BrailleFlush:
|
||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.ScreenChanged:
|
elif event['Type'] == fenrirEventType.ScreenChanged:
|
||||||
|
@ -113,10 +113,10 @@ class fenrirManager():
|
|||||||
#print('handleScreenUpdate:',time.time() - startTime)
|
#print('handleScreenUpdate:',time.time() - startTime)
|
||||||
|
|
||||||
def handlePlugInputDevice(self, event):
|
def handlePlugInputDevice(self, event):
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('PlugInputDevice')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
|
||||||
|
|
||||||
def handleHeartBeat(self, event):
|
def handleHeartBeat(self, event):
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
||||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||||
|
|
||||||
def detectCommand(self):
|
def detectCommand(self):
|
||||||
|
@ -64,9 +64,6 @@ class driver():
|
|||||||
while active:
|
while active:
|
||||||
devices = monitor.poll(2)
|
devices = monitor.poll(2)
|
||||||
if devices:
|
if devices:
|
||||||
for device in devices:
|
|
||||||
if not active:
|
|
||||||
return
|
|
||||||
print('drin')
|
print('drin')
|
||||||
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":''})
|
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":''})
|
||||||
|
|
||||||
@ -80,28 +77,30 @@ class driver():
|
|||||||
return
|
return
|
||||||
def inputWatchdog(self,active , params):
|
def inputWatchdog(self,active , params):
|
||||||
deviceFd = []
|
deviceFd = []
|
||||||
for fd in params['dev']:
|
print('WD:',params['dev'],self.watchDog.value == 0)
|
||||||
deviceFd.append(fd)
|
|
||||||
while self.watchDog.value == 0:
|
while self.watchDog.value == 0:
|
||||||
if active.value == 0:
|
if active.value == 0:
|
||||||
return
|
return
|
||||||
r = []
|
r = []
|
||||||
while r == []:
|
while r == []:
|
||||||
|
deviceFd = list(params['dev'])
|
||||||
r, w, x = select(deviceFd, [], [], 2)
|
r, w, x = select(deviceFd, [], [], 2)
|
||||||
|
print('select',r, w, x)
|
||||||
self.watchDog.value = 0
|
self.watchDog.value = 0
|
||||||
def getInputEvent(self):
|
def getInputEvent(self):
|
||||||
if not self.hasIDevices():
|
if not self.hasIDevices():
|
||||||
self.watchDog.value = 1
|
self.watchDog.value = 1
|
||||||
return None
|
return None
|
||||||
event = None
|
event = None
|
||||||
r, w, x = select(self.iDevices, [], [], 0.0001)
|
r, w, x = select(self.iDevices, [], [], 0.00001)
|
||||||
|
print(self.iDevices,'read',r, w, x)
|
||||||
if r != []:
|
if r != []:
|
||||||
for fd in r:
|
for fd in r:
|
||||||
try:
|
try:
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
except:
|
except:
|
||||||
self.removeDevice(fd)
|
self.removeDevice(fd)
|
||||||
self.watchDog.value = 1
|
self.watchDog.value = 1
|
||||||
return None
|
return None
|
||||||
foreward = False
|
foreward = False
|
||||||
while(event):
|
while(event):
|
||||||
@ -153,7 +152,7 @@ class driver():
|
|||||||
if init:
|
if init:
|
||||||
self.removeAllDevices()
|
self.removeAllDevices()
|
||||||
deviceFileList = evdev.list_devices()
|
deviceFileList = evdev.list_devices()
|
||||||
if not force:
|
if not force and False:
|
||||||
if len(deviceFileList) == self.iDeviceNo:
|
if len(deviceFileList) == self.iDeviceNo:
|
||||||
return
|
return
|
||||||
mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper()
|
mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper()
|
||||||
@ -200,15 +199,15 @@ class driver():
|
|||||||
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR)
|
||||||
self.updateMPiDevicesFD()
|
|
||||||
self.iDeviceNo = len(evdev.list_devices())
|
self.iDeviceNo = len(evdev.list_devices())
|
||||||
|
self.updateMPiDevicesFD()
|
||||||
def updateMPiDevicesFD(self):
|
def updateMPiDevicesFD(self):
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
if not fd in self.iDevicesFD:
|
if not fd in self.iDevicesFD:
|
||||||
self.iDevicesFD.append(fd)
|
self.iDevicesFD.append(fd)
|
||||||
for fd in self.iDevicesFD:
|
for fd in self.iDevicesFD:
|
||||||
if not fd in self.iDevices:
|
if not fd in self.iDevices:
|
||||||
self.iDevicesFD.remove(fd)
|
self.iDevicesFD.remove(fd)
|
||||||
def mapEvent(self, event):
|
def mapEvent(self, event):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user