detect device only once

This commit is contained in:
Chrys 2019-10-21 23:09:15 +02:00
parent d38c409518
commit 0279edf4ff
4 changed files with 25 additions and 19 deletions

View File

@ -22,11 +22,11 @@
# #
#--code-- #--code--
for i in /tmp/fenrirscreenreader-*.sock ; do #for i in /tmp/fenrirscreenreader-*.sock ; do
if [[ "$i" != "/tmp/fenrirscreenreader-deamon.sock" ]]; then #if [[ "$i" != "/tmp/fenrirscreenreader-deamon.sock" ]]; then
echo -n "setting set screen#suspendingScreen=pty" | socat - UNIX-CLIENT:$i # echo -n "setting set screen#suspendingScreen=pty" | socat - UNIX-CLIENT:$i
fi # fi
done #done
/usr/bin/urxvt -e ../src/fenrir -d -s ./xterm.conf -o "general.shell=./waitForKey2;remote#socketFile=/tmp/fenrirscreenreader-waitForKey2.sock" /usr/bin/urxvt -e ../src/fenrir -d -s ./xterm.conf -o "general.shell=./waitForKey2;remote#socketFile=/tmp/fenrirscreenreader-waitForKey2.sock"

View File

@ -83,9 +83,9 @@ class fenrirManager():
else: else:
self.environment['runtime']['inputManager'].writeEventBuffer() self.environment['runtime']['inputManager'].writeEventBuffer()
if self.environment['runtime']['inputManager'].noKeyPressed(): if self.environment['runtime']['inputManager'].noKeyPressed():
self.environment['runtime']['inputManager'].handleDeviceGrab()
self.modifierInput = False self.modifierInput = False
self.singleKeyCommand = False self.singleKeyCommand = False
self.environment['runtime']['inputManager'].handleDeviceGrab()
if self.environment['input']['keyForeward'] > 0: if self.environment['input']['keyForeward'] > 0:
self.environment['input']['keyForeward'] -=1 self.environment['input']['keyForeward'] -=1
self.environment['runtime']['commandManager'].executeDefaultTrigger('onKeyInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onKeyInput')
@ -201,11 +201,6 @@ class fenrirManager():
self.command = '' self.command = ''
def setProcessName(self, name = 'fenrir'): def setProcessName(self, name = 'fenrir'):
"""Attempts to set the process name to 'fenrir'.""" """Attempts to set the process name to 'fenrir'."""
#sys.argv[0] = name
# Disabling the import error of setproctitle.
# pylint: disable-msg=F0401
try: try:
from setproctitle import setproctitle from setproctitle import setproctitle
except ImportError: except ImportError:

View File

@ -6,7 +6,7 @@
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug
from fenrirscreenreader.core import inputData from fenrirscreenreader.core import inputData
import os, inspect, time import os, inspect, time, traceback
currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe())))) currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe()))))
fenrirPath = os.path.dirname(currentdir) fenrirPath = os.path.dirname(currentdir)
@ -61,14 +61,14 @@ class inputManager():
return return
if self.env['runtime']['screenManager'].getCurrScreenIgnored(): if self.env['runtime']['screenManager'].getCurrScreenIgnored():
while not self.ungrabAllDevices(): while not self.ungrabAllDevices():
time.sleep(0.2) time.sleep(0.25)
self.env['runtime']['debug'].writeDebugOut("retry ungrabAllDevices " ,debug.debugLevel.WARNING) self.env['runtime']['debug'].writeDebugOut("retry ungrabAllDevices " ,debug.debugLevel.WARNING)
print('try ungrabbing') print('try ungrabbing')
self.env['runtime']['debug'].writeDebugOut("All devices ungrabbed" ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("All devices ungrabbed" ,debug.debugLevel.INFO)
print('ungrabbed') print('ungrabbed')
else: else:
while not self.grabAllDevices(): while not self.grabAllDevices():
time.sleep(0.2) time.sleep(0.25)
self.env['runtime']['debug'].writeDebugOut("retry grabAllDevices" ,debug.debugLevel.WARNING) self.env['runtime']['debug'].writeDebugOut("retry grabAllDevices" ,debug.debugLevel.WARNING)
print('try grabbing') print('try grabbing')
print('grabbed') print('grabbed')

View File

@ -64,21 +64,31 @@ class driver(inputDriver):
monitor = pyudev.Monitor.from_netlink(context) monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='input') monitor.filter_by(subsystem='input')
monitor.start() monitor.start()
ignorePlug = False
while active.value: while active.value:
validDevices = [] validDevices = []
device = monitor.poll(1) device = monitor.poll(1)
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 currDevice.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
ignorePlug = True
if currDevice.phys.upper() in ['','SPEAKUP']:
ignorePlug = True
if 'BRLTTY' in currDevice.name.upper():
ignorePlug = True
if not ignorePlug:
virtual = '/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({'device': device.device_node, 'virtual': virtual}) validDevices.append({'device': device.device_node, 'virtual': virtual})
except: except:
pass pass
try: try:
device = monitor.poll(0.5) pollTimeout = 1
device = monitor.poll(pollTimeout)
except: except:
device = None device = None
ignorePlug = False
if validDevices: if validDevices:
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":validDevices}) eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":validDevices})
return time.time() return time.time()
@ -345,6 +355,7 @@ class driver(inputDriver):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
return True return True
try: try:
print(self.iDevices[fd])
self.iDevices[fd].grab() self.iDevices[fd].grab()
self.gDevices[fd] = True self.gDevices[fd] = True
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grab device ('+ str(self.iDevices[fd].name) + ')',debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grab device ('+ str(self.iDevices[fd].name) + ')',debug.debugLevel.INFO)