more work on device detection still WIP

This commit is contained in:
chrys 2017-08-02 22:35:03 +02:00
parent f11c9eed3c
commit 5847a8658c
5 changed files with 17 additions and 18 deletions

View File

@ -16,7 +16,6 @@ class command():
def getDescription(self):
return 'No description found'
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):
pass

View File

@ -163,9 +163,10 @@ class commandManager():
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
def executeDefaultTrigger(self, trigger):
if self.env['runtime']['screenManager'].isSuspendingScreen():
return
def executeDefaultTrigger(self, trigger, force=False):
if not force:
if self.env['runtime']['screenManager'].isSuspendingScreen():
return
for command in sorted(self.env['commands'][trigger]):
if self.commandExists(command, trigger):
try:

View File

@ -61,7 +61,7 @@ class eventManager():
elif event['Type'] == fenrirEventType.BrailleInput:
pass
elif event['Type'] == fenrirEventType.PlugInputDevice:
pass
self.env['runtime']['fenrirManager'].handlePlugInputDevice(event)
elif event['Type'] == fenrirEventType.BrailleFlush:
pass
elif event['Type'] == fenrirEventType.ScreenChanged:

View File

@ -113,10 +113,10 @@ class fenrirManager():
#print('handleScreenUpdate:',time.time() - startTime)
def handlePlugInputDevice(self, event):
self.environment['runtime']['commandManager'].executeDefaultTrigger('PlugInputDevice')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
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)
def detectCommand(self):

View File

@ -64,9 +64,6 @@ class driver():
while active:
devices = monitor.poll(2)
if devices:
for device in devices:
if not active:
return
print('drin')
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":''})
@ -80,21 +77,23 @@ class driver():
return
def inputWatchdog(self,active , params):
deviceFd = []
for fd in params['dev']:
deviceFd.append(fd)
print('WD:',params['dev'],self.watchDog.value == 0)
while self.watchDog.value == 0:
if active.value == 0:
return
r = []
while r == []:
deviceFd = list(params['dev'])
r, w, x = select(deviceFd, [], [], 2)
print('select',r, w, x)
self.watchDog.value = 0
def getInputEvent(self):
if not self.hasIDevices():
self.watchDog.value = 1
return 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 != []:
for fd in r:
try:
@ -153,7 +152,7 @@ class driver():
if init:
self.removeAllDevices()
deviceFileList = evdev.list_devices()
if not force:
if not force and False:
if len(deviceFileList) == self.iDeviceNo:
return
mode = self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper()
@ -200,8 +199,8 @@ class driver():
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR)
self.updateMPiDevicesFD()
self.iDeviceNo = len(evdev.list_devices())
self.updateMPiDevicesFD()
def updateMPiDevicesFD(self):
for fd in self.iDevices:
if not fd in self.iDevicesFD: