make device list available in plug trigger
This commit is contained in:
parent
9657d23c4f
commit
2c81540634
@ -19,17 +19,17 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
if time.time() - self.lastTime > 5:
|
playSound = False
|
||||||
if not self.isTempDisable():
|
deviceList = self.env['runtime']['inputManager'].getLastDetectedDevices()
|
||||||
|
try:
|
||||||
|
for deviceEntry in deviceList:
|
||||||
|
# dont play sounds for virtual devices
|
||||||
|
playSound = playSound or not deviceEntry['virtual']
|
||||||
|
except:
|
||||||
|
playSound = True
|
||||||
|
if playSound:
|
||||||
|
if time.time() - self.lastTime > 5:
|
||||||
self.env['runtime']['outputManager'].playSoundIcon(soundIcon = 'accept', interrupt=True)
|
self.env['runtime']['outputManager'].playSoundIcon(soundIcon = 'accept', interrupt=True)
|
||||||
else:
|
lastTime = time.time()
|
||||||
self.resetTempDisable()
|
|
||||||
lastTime = time.time()
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
def setTempDisable(self):
|
|
||||||
self.tempDisable = True
|
|
||||||
def resetTempDisable(self):
|
|
||||||
self.tempDisable = False
|
|
||||||
def isTempDisable(self):
|
|
||||||
return self.tempDisable
|
|
||||||
|
@ -121,7 +121,7 @@ class fenrirManager():
|
|||||||
self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data'])
|
self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data'])
|
||||||
def handleScreenChange(self, event):
|
def handleScreenChange(self, event):
|
||||||
self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data'])
|
self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data'])
|
||||||
'''
|
'''
|
||||||
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
||||||
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
||||||
@ -154,8 +154,13 @@ class fenrirManager():
|
|||||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||||
#print('handleScreenUpdate:',time.time() - startTime)
|
#print('handleScreenUpdate:',time.time() - startTime)
|
||||||
def handlePlugInputDevice(self, event):
|
def handlePlugInputDevice(self, event):
|
||||||
|
try:
|
||||||
|
self.environment['runtime']['inputManager'].setLastDetectedDevices(event['Data'])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.environment['runtime']['inputManager'].handlePlugInputDevice(event['Data'])
|
self.environment['runtime']['inputManager'].handlePlugInputDevice(event['Data'])
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
|
||||||
|
self.environment['runtime']['inputManager'].setLastDetectedDevices(None)
|
||||||
def handleHeartBeat(self, event):
|
def handleHeartBeat(self, event):
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
||||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||||
|
@ -13,7 +13,8 @@ fenrirPath = os.path.dirname(currentdir)
|
|||||||
class inputManager():
|
class inputManager():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.shortcutType = 'KEY'
|
self.shortcutType = 'KEY'
|
||||||
self.executeDeviceGrab = False
|
self.executeDeviceGrab = False
|
||||||
|
self.lastDetectedDevices = None
|
||||||
def setShortcutType(self, shortcutType = 'KEY'):
|
def setShortcutType(self, shortcutType = 'KEY'):
|
||||||
if shortcutType in ['KEY', 'BYTE']:
|
if shortcutType in ['KEY', 'BYTE']:
|
||||||
self.shortcutType = shortcutType
|
self.shortcutType = shortcutType
|
||||||
@ -152,19 +153,8 @@ class inputManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
def handlePlugInputDevice(self, eventData):
|
def handlePlugInputDevice(self, eventData):
|
||||||
playSound = False
|
|
||||||
for deviceEntry in eventData:
|
for deviceEntry in eventData:
|
||||||
self.env['runtime']['inputManager'].updateInputDevices(deviceEntry['device'])
|
self.env['runtime']['inputManager'].updateInputDevices(deviceEntry['device'])
|
||||||
# dont play sounds for virtual devices
|
|
||||||
try:
|
|
||||||
playSound = playSound or not deviceEntry['virtual']
|
|
||||||
except:
|
|
||||||
playSound = True
|
|
||||||
if not playSound:
|
|
||||||
try:
|
|
||||||
self.env['commands']['onPlugInputDevice']['PLUGSOUND'].setTempDisable()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
def updateInputDevices(self, newDevice = None):
|
def updateInputDevices(self, newDevice = None):
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['inputDriver'].updateInputDevices(newDevice)
|
self.env['runtime']['inputDriver'].updateInputDevices(newDevice)
|
||||||
@ -341,3 +331,7 @@ class inputManager():
|
|||||||
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
|
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
|
||||||
def isValidKey(self, key):
|
def isValidKey(self, key):
|
||||||
return key in inputData.keyNames
|
return key in inputData.keyNames
|
||||||
|
def setLastDetectedDevices(self, devices):
|
||||||
|
self.lastDetectedDevices =devices
|
||||||
|
def getLastDetectedDevices(self):
|
||||||
|
return self.lastDetectedDevices
|
||||||
|
Loading…
Reference in New Issue
Block a user