try remove sound for virtual devices

This commit is contained in:
Chrys 2019-08-24 18:26:40 +02:00
parent 55e9f9e4b4
commit 0e8ebc43b4
5 changed files with 59 additions and 58 deletions

View File

@ -1,22 +0,0 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'No description found'
def run(self):
pass
#self.env['runtime']['inputManager'].updateInputDevices()
def setCallback(self, callback):
pass

View File

@ -1,25 +0,0 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
import time
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
self.lastTime = time.time()
def shutdown(self):
pass
def getDescription(self):
return 'No description found'
def run(self):
if time.time() - self.lastTime > 2:
self.env['runtime']['outputManager'].playSoundIcon(soundIcon = 'accept', interrupt=True)
lastTime = time.time()
def setCallback(self, callback):
pass

View File

@ -0,0 +1,35 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
import time
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
self.lastTime = time.time()
self.tempDisable = False
def shutdown(self):
pass
def getDescription(self):
return 'No description found'
def run(self):
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

View File

@ -132,11 +132,11 @@ class inputManager():
def handleLedStates(self, mEvent): def handleLedStates(self, mEvent):
try: try:
if mEvent['EventName'] == 'KEY_NUMLOCK': if mEvent['EventName'] == 'KEY_NUMLOCK':
self.env['runtime']['inputDriver'].toggleLedState() self.env['runtime']['inputDriver'].toggleLedState()
elif mEvent['EventName'] == 'KEY_CAPSLOCK': elif mEvent['EventName'] == 'KEY_CAPSLOCK':
self.env['runtime']['inputDriver'].toggleLedState(1) self.env['runtime']['inputDriver'].toggleLedState(1)
elif mEvent['EventName'] == 'KEY_SCROLLLOCK': elif mEvent['EventName'] == 'KEY_SCROLLLOCK':
self.env['runtime']['inputDriver'].toggleLedState(2) self.env['runtime']['inputDriver'].toggleLedState(2)
except: except:
pass pass
def grabAllDevices(self): def grabAllDevices(self):
@ -144,7 +144,7 @@ class inputManager():
try: try:
self.env['runtime']['inputDriver'].grabAllDevices() self.env['runtime']['inputDriver'].grabAllDevices()
except Exception as e: except Exception as e:
pass pass
def ungrabAllDevices(self): def ungrabAllDevices(self):
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
try: try:
@ -152,8 +152,19 @@ class inputManager():
except Exception as e: except Exception as e:
pass pass
def handlePlugInputDevice(self, eventData): def handlePlugInputDevice(self, eventData):
self.env['runtime']['inputManager'].updateInputDevices(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): def updateInputDevices(self, newDevice = None):
try: try:
self.env['runtime']['inputDriver'].updateInputDevices(newDevice) self.env['runtime']['inputDriver'].updateInputDevices(newDevice)

View File

@ -70,13 +70,13 @@ class driver(inputDriver):
while device: while device:
self.env['runtime']['debug'].writeDebugOut('plugInputDeviceWatchdogUdev:' + str(device), debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('plugInputDeviceWatchdogUdev:' + str(device), debug.debugLevel.INFO)
try: try:
#if not '/sys/devices/virtual/input/' in device.sys_path: virtual = '/sys/devices/virtual/input/' in device.sys_path
if device.device_node: if device.device_node:
validDevices.append(str(device.device_node)) validDevices.append({'device': device.device_node, 'virtual': virtual})
except: except:
pass pass
try: try:
device = monitor.poll(0.1) device = monitor.poll(0.5)
except: except:
device = None device = None
if validDevices: if validDevices:
@ -149,6 +149,8 @@ class driver(inputDriver):
deviceFileList = None deviceFileList = None
if newDevices and not init: if newDevices and not init:
if not isinstance(newDevices, list):
newDevices = [newDevices]
deviceFileList = newDevices deviceFileList = newDevices
else: else:
deviceFileList = evdev.list_devices() deviceFileList = evdev.list_devices()