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--
for i in /tmp/fenrirscreenreader-*.sock ; do
if [[ "$i" != "/tmp/fenrirscreenreader-deamon.sock" ]]; then
echo -n "setting set screen#suspendingScreen=pty" | socat - UNIX-CLIENT:$i
fi
done
#for i in /tmp/fenrirscreenreader-*.sock ; do
#if [[ "$i" != "/tmp/fenrirscreenreader-deamon.sock" ]]; then
# echo -n "setting set screen#suspendingScreen=pty" | socat - UNIX-CLIENT:$i
# fi
#done
/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:
self.environment['runtime']['inputManager'].writeEventBuffer()
if self.environment['runtime']['inputManager'].noKeyPressed():
self.environment['runtime']['inputManager'].handleDeviceGrab()
self.modifierInput = False
self.singleKeyCommand = False
self.environment['runtime']['inputManager'].handleDeviceGrab()
if self.environment['input']['keyForeward'] > 0:
self.environment['input']['keyForeward'] -=1
self.environment['runtime']['commandManager'].executeDefaultTrigger('onKeyInput')
@ -201,11 +201,6 @@ class fenrirManager():
self.command = ''
def setProcessName(self, name = 'fenrir'):
"""Attempts to set the process name to 'fenrir'."""
#sys.argv[0] = name
# Disabling the import error of setproctitle.
# pylint: disable-msg=F0401
try:
from setproctitle import setproctitle
except ImportError:

View File

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

View File

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