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):
|
||||
return 'No description found'
|
||||
def run(self):
|
||||
playSound = False
|
||||
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:
|
||||
if not self.isTempDisable():
|
||||
self.env['runtime']['outputManager'].playSoundIcon(soundIcon = 'accept', interrupt=True)
|
||||
else:
|
||||
self.resetTempDisable()
|
||||
lastTime = time.time()
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def setTempDisable(self):
|
||||
self.tempDisable = True
|
||||
def resetTempDisable(self):
|
||||
self.tempDisable = False
|
||||
def isTempDisable(self):
|
||||
return self.tempDisable
|
||||
|
@ -154,8 +154,13 @@ class fenrirManager():
|
||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||
#print('handleScreenUpdate:',time.time() - startTime)
|
||||
def handlePlugInputDevice(self, event):
|
||||
try:
|
||||
self.environment['runtime']['inputManager'].setLastDetectedDevices(event['Data'])
|
||||
except:
|
||||
pass
|
||||
self.environment['runtime']['inputManager'].handlePlugInputDevice(event['Data'])
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onPlugInputDevice', force=True)
|
||||
self.environment['runtime']['inputManager'].setLastDetectedDevices(None)
|
||||
def handleHeartBeat(self, event):
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||
|
@ -14,6 +14,7 @@ class inputManager():
|
||||
def __init__(self):
|
||||
self.shortcutType = 'KEY'
|
||||
self.executeDeviceGrab = False
|
||||
self.lastDetectedDevices = None
|
||||
def setShortcutType(self, shortcutType = 'KEY'):
|
||||
if shortcutType in ['KEY', 'BYTE']:
|
||||
self.shortcutType = shortcutType
|
||||
@ -152,19 +153,8 @@ class inputManager():
|
||||
except Exception as e:
|
||||
pass
|
||||
def handlePlugInputDevice(self, eventData):
|
||||
playSound = False
|
||||
for deviceEntry in eventData:
|
||||
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):
|
||||
try:
|
||||
self.env['runtime']['inputDriver'].updateInputDevices(newDevice)
|
||||
@ -341,3 +331,7 @@ class inputManager():
|
||||
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
|
||||
def isValidKey(self, key):
|
||||
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