diff --git a/src/fenrirscreenreader/commands/onPlugInputDevice/plugSound.py b/src/fenrirscreenreader/commands/onPlugInputDevice/plugSound.py index 425c21c0..3ac6b82d 100755 --- a/src/fenrirscreenreader/commands/onPlugInputDevice/plugSound.py +++ b/src/fenrirscreenreader/commands/onPlugInputDevice/plugSound.py @@ -19,17 +19,17 @@ class command(): def getDescription(self): return 'No description found' def run(self): - if time.time() - self.lastTime > 5: - if not self.isTempDisable(): + 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: self.env['runtime']['outputManager'].playSoundIcon(soundIcon = 'accept', interrupt=True) - else: - self.resetTempDisable() - lastTime = time.time() + 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 diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index 259132e4..55fcce36 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -121,7 +121,7 @@ class fenrirManager(): self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data']) def handleScreenChange(self, event): self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data']) - ''' + ''' if self.environment['runtime']['applicationManager'].isApplicationChange(): self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \ @@ -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) diff --git a/src/fenrirscreenreader/core/inputManager.py b/src/fenrirscreenreader/core/inputManager.py index 6ce3d667..7758b766 100644 --- a/src/fenrirscreenreader/core/inputManager.py +++ b/src/fenrirscreenreader/core/inputManager.py @@ -13,7 +13,8 @@ fenrirPath = os.path.dirname(currentdir) class inputManager(): def __init__(self): self.shortcutType = 'KEY' - self.executeDeviceGrab = False + 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