Merge branch 'master' into bleed
This commit is contained in:
commit
469488f2d3
@ -129,9 +129,9 @@ Cleanups:
|
|||||||
[X] first item
|
[X] first item
|
||||||
[X] last item
|
[X] last item
|
||||||
General:
|
General:
|
||||||
- [X] make it runable using pypy3
|
[X] make it runable using pypy3
|
||||||
|
[X] interrupt speech while entering an ignored screen
|
||||||
- [X] read ignorescreens from an file to be able to halt fenrir from outside
|
[X] read ignorescreens from an file to be able to halt fenrir from outside
|
||||||
- commands
|
- commands
|
||||||
[X] place last spoken to clipboard (Easy for contribution)
|
[X] place last spoken to clipboard (Easy for contribution)
|
||||||
- Improvend Headline Seperator and Multible Char Support
|
- Improvend Headline Seperator and Multible Char Support
|
||||||
@ -139,6 +139,8 @@ General:
|
|||||||
- autospeak indentation changes (useful for python programming)
|
- autospeak indentation changes (useful for python programming)
|
||||||
Braille Support:
|
Braille Support:
|
||||||
Driver:
|
Driver:
|
||||||
|
[X] evdev InputDriver
|
||||||
|
[X] grab/ ungrab devices on ignored screens
|
||||||
[X] PTY Input driver
|
[X] PTY Input driver
|
||||||
[X] new event for byte shortcuts (escape sequences)
|
[X] new event for byte shortcuts (escape sequences)
|
||||||
[X] create driver
|
[X] create driver
|
||||||
|
@ -17,5 +17,7 @@ for fd in iDevices:
|
|||||||
print('No. of keys: ' + str(len(cap[evdev.events.EV_KEY])))
|
print('No. of keys: ' + str(len(cap[evdev.events.EV_KEY])))
|
||||||
print('has Key 116: ' + str(116 in cap[evdev.events.EV_KEY]))
|
print('has Key 116: ' + str(116 in cap[evdev.events.EV_KEY]))
|
||||||
print('Is Mouse: ' + str(((evdev.events.EV_REL in cap) or (evdev.events.EV_ABS in cap))))
|
print('Is Mouse: ' + str(((evdev.events.EV_REL in cap) or (evdev.events.EV_ABS in cap))))
|
||||||
|
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||||
|
print(dev.capabilities(verbose=True))
|
||||||
print('----------------------')
|
print('----------------------')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
import signal, time, argparse
|
import signal, time, argparse, sys
|
||||||
|
|
||||||
from fenrirscreenreader.core import i18n
|
from fenrirscreenreader.core import i18n
|
||||||
from fenrirscreenreader.core import settingsManager
|
from fenrirscreenreader.core import settingsManager
|
||||||
@ -32,6 +32,7 @@ class fenrirManager():
|
|||||||
self.command = ''
|
self.command = ''
|
||||||
self.controlMode = True
|
self.controlMode = True
|
||||||
self.switchCtrlModeOnce = 0
|
self.switchCtrlModeOnce = 0
|
||||||
|
self.setProcessName()
|
||||||
def handleArgs(self):
|
def handleArgs(self):
|
||||||
args = None
|
args = None
|
||||||
parser = argparse.ArgumentParser(description="Fenrir Help")
|
parser = argparse.ArgumentParser(description="Fenrir Help")
|
||||||
@ -212,7 +213,32 @@ class fenrirManager():
|
|||||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, self.command)
|
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, self.command)
|
||||||
self.command = ''
|
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:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
setproctitle(name)
|
||||||
|
return True
|
||||||
|
|
||||||
|
try:
|
||||||
|
from ctypes import cdll, byref, create_string_buffer
|
||||||
|
libc = cdll.LoadLibrary('libc.so.6')
|
||||||
|
stringBuffer = create_string_buffer(len(name) + 1)
|
||||||
|
stringBuffer.value = bytes(name, 'UTF-8')
|
||||||
|
libc.prctl(15, byref(stringBuffer), 0, 0, 0)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return False
|
||||||
def shutdownRequest(self):
|
def shutdownRequest(self):
|
||||||
try:
|
try:
|
||||||
self.environment['runtime']['eventManager'].stopMainEventLoop()
|
self.environment['runtime']['eventManager'].stopMainEventLoop()
|
||||||
|
@ -40,14 +40,17 @@ class inputDriver():
|
|||||||
return False
|
return False
|
||||||
def toggleLedState(self, led = 0):
|
def toggleLedState(self, led = 0):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return
|
||||||
def grabDevices(self):
|
def grabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return
|
||||||
def releaseDevices(self):
|
def ungrabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return
|
||||||
|
def removeAllDevices(self):
|
||||||
|
if not self._initialized:
|
||||||
|
return
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return
|
||||||
self.releaseDevices()
|
self.removeAllDevices()
|
||||||
|
@ -109,10 +109,16 @@ class inputManager():
|
|||||||
|
|
||||||
def grabAllDevices(self):
|
def grabAllDevices(self):
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
|
try:
|
||||||
self.env['runtime']['inputDriver'].grabAllDevices()
|
self.env['runtime']['inputDriver'].grabAllDevices()
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
def ungrabAllDevices(self):
|
def ungrabAllDevices(self):
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
|
try:
|
||||||
self.env['runtime']['inputDriver'].ungrabAllDevices()
|
self.env['runtime']['inputDriver'].ungrabAllDevices()
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
def updateInputDevices(self):
|
def updateInputDevices(self):
|
||||||
try:
|
try:
|
||||||
@ -155,7 +161,10 @@ class inputManager():
|
|||||||
return eventName
|
return eventName
|
||||||
|
|
||||||
def clearEventBuffer(self):
|
def clearEventBuffer(self):
|
||||||
|
try:
|
||||||
self.env['runtime']['inputDriver'].clearEventBuffer()
|
self.env['runtime']['inputDriver'].clearEventBuffer()
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
def setLastDeepestInput(self, currentDeepestInput):
|
def setLastDeepestInput(self, currentDeepestInput):
|
||||||
self.lastDeepestInput = currentDeepestInput
|
self.lastDeepestInput = currentDeepestInput
|
||||||
def clearLastDeepInput(self):
|
def clearLastDeepInput(self):
|
||||||
|
@ -12,6 +12,7 @@ class screenManager():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.currScreenIgnored = False
|
self.currScreenIgnored = False
|
||||||
self.prevScreenIgnored = False
|
self.prevScreenIgnored = False
|
||||||
|
self.toggleDeviceGrab = False
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.env['runtime']['settingsManager'].loadDriver(\
|
self.env['runtime']['settingsManager'].loadDriver(\
|
||||||
@ -40,15 +41,24 @@ class screenManager():
|
|||||||
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
||||||
self.update(eventData, 'onScreenChange')
|
self.update(eventData, 'onScreenChange')
|
||||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||||
def handleScreenUpdate(self, eventData):
|
def handleDeviceGrab(self):
|
||||||
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
self.updateScreenIgnored()
|
return
|
||||||
if self.getCurrScreenIgnored() != self.getPrevScreenIgnored():
|
if self.getCurrScreenIgnored() != self.getPrevScreenIgnored():
|
||||||
|
self.toggleDeviceGrab = True
|
||||||
|
if self.toggleDeviceGrab:
|
||||||
|
if self.env['runtime']['inputManager'].noKeyPressed():
|
||||||
if self.getCurrScreenIgnored():
|
if self.getCurrScreenIgnored():
|
||||||
self.env['runtime']['inputManager'].ungrabAllDevices()
|
self.env['runtime']['inputManager'].ungrabAllDevices()
|
||||||
self.env['runtime']['outputManager'].interruptOutput()
|
self.env['runtime']['outputManager'].interruptOutput()
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['inputManager'].grabAllDevices()
|
self.env['runtime']['inputManager'].grabAllDevices()
|
||||||
|
self.toggleDeviceGrab = False
|
||||||
|
|
||||||
|
def handleScreenUpdate(self, eventData):
|
||||||
|
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
||||||
|
self.updateScreenIgnored()
|
||||||
|
self.handleDeviceGrab()
|
||||||
if not self.getCurrScreenIgnored():
|
if not self.getCurrScreenIgnored():
|
||||||
self.update(eventData, 'onScreenUpdate')
|
self.update(eventData, 'onScreenUpdate')
|
||||||
#if trigger == 'onUpdate' or self.isScreenChange() \
|
#if trigger == 'onUpdate' or self.isScreenChange() \
|
||||||
@ -158,13 +168,34 @@ class screenManager():
|
|||||||
return ''
|
return ''
|
||||||
if attributeFormatString == '':
|
if attributeFormatString == '':
|
||||||
return ''
|
return ''
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBGColor', self.env['runtime']['screenDriver'].getFenrirBGColor(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirBGColor', self.env['runtime']['screenDriver'].getFenrirBGColor(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFGColor', self.env['runtime']['screenDriver'].getFenrirFGColor(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirFGColor', self.env['runtime']['screenDriver'].getFenrirFGColor(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirUnderline', self.env['runtime']['screenDriver'].getFenrirUnderline(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirUnderline', self.env['runtime']['screenDriver'].getFenrirUnderline(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBold', self.env['runtime']['screenDriver'].getFenrirBold(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirBold', self.env['runtime']['screenDriver'].getFenrirBold(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBlink', self.env['runtime']['screenDriver'].getFenrirBlink(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirBlink', self.env['runtime']['screenDriver'].getFenrirBlink(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFontSize', self.env['runtime']['screenDriver'].getFenrirFontSize(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirFontSize', self.env['runtime']['screenDriver'].getFenrirFontSize(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFont', self.env['runtime']['screenDriver'].getFenrirFont(attribute))
|
attributeFormatString = attributeFormatString.replace('fenrirFont', self.env['runtime']['screenDriver'].getFenrirFont(attribute))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
return attributeFormatString
|
return attributeFormatString
|
||||||
def isSuspendingScreen(self, screen = None):
|
def isSuspendingScreen(self, screen = None):
|
||||||
if screen == None:
|
if screen == None:
|
||||||
@ -212,7 +243,6 @@ class screenManager():
|
|||||||
try:
|
try:
|
||||||
self.env['runtime']['screenDriver'].injectTextToScreen(text, screen)
|
self.env['runtime']['screenDriver'].injectTextToScreen(text, screen)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
|
||||||
self.env['runtime']['debug'].writeDebugOut('screenManager:injectTextToScreen ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('screenManager:injectTextToScreen ' + str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def changeBrailleScreen(self):
|
def changeBrailleScreen(self):
|
||||||
|
@ -153,7 +153,10 @@ class settingsManager():
|
|||||||
def shutdownDriver(self, driverType):
|
def shutdownDriver(self, driverType):
|
||||||
if self.env['runtime'][driverType] == None:
|
if self.env['runtime'][driverType] == None:
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
self.env['runtime'][driverType].shutdown()
|
self.env['runtime'][driverType].shutdown()
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
del self.env['runtime'][driverType]
|
del self.env['runtime'][driverType]
|
||||||
|
|
||||||
def setFenrirKeys(self, keys):
|
def setFenrirKeys(self, keys):
|
||||||
|
@ -20,7 +20,7 @@ class driver(inputDriver):
|
|||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if self._initialized:
|
if self._initialized:
|
||||||
self.releaseDevices()
|
self.removeAllDevices()
|
||||||
self._initialized = False
|
self._initialized = False
|
||||||
print('Input Debug Driver: Shutdown')
|
print('Input Debug Driver: Shutdown')
|
||||||
|
|
||||||
@ -51,17 +51,22 @@ class driver(inputDriver):
|
|||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
print('Input Debug Driver: toggleLedState')
|
print('Input Debug Driver: toggleLedState')
|
||||||
def grabDevices(self):
|
def grabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
print('Input Debug Driver: grabDevices')
|
print('Input Debug Driver: grabAllDevices')
|
||||||
def releaseDevices(self):
|
def ungrabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
print('Input Debug Driver: releaseDevices')
|
print('Input Debug Driver: ungrabAllDevices')
|
||||||
|
|
||||||
|
def removeAllDevices(self):
|
||||||
|
if not self._initialized:
|
||||||
|
return
|
||||||
|
print('Input Debug Driver: removeAllDevices')
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self._initialized:
|
if self._initialized:
|
||||||
self.releaseDevices()
|
self.removeAllDevices()
|
||||||
print('Input Debug Driver: __del__')
|
print('Input Debug Driver: __del__')
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ class driver(inputDriver):
|
|||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
self.updateInputDevices()
|
self.updateInputDevices()
|
||||||
if _udevAvailable:
|
#if _udevAvailable:
|
||||||
self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
|
# self.env['runtime']['processManager'].addCustomEventThread(self.plugInputDeviceWatchdogUdev)
|
||||||
else:
|
#else:
|
||||||
self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer)
|
# self.env['runtime']['processManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdogTimer)
|
||||||
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
||||||
def plugInputDeviceWatchdogUdev(self,active , eventQueue):
|
def plugInputDeviceWatchdogUdev(self,active , eventQueue):
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
@ -67,8 +67,8 @@ class driver(inputDriver):
|
|||||||
while active.value:
|
while active.value:
|
||||||
devices = monitor.poll(2)
|
devices = monitor.poll(2)
|
||||||
if devices:
|
if devices:
|
||||||
while monitor.poll(0.2):
|
while monitor.poll(1):
|
||||||
time.sleep(0.2)
|
pass
|
||||||
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None})
|
eventQueue.put({"Type":fenrirEventType.PlugInputDevice,"Data":None})
|
||||||
return time.time()
|
return time.time()
|
||||||
def plugInputDeviceWatchdogTimer(self, active):
|
def plugInputDeviceWatchdogTimer(self, active):
|
||||||
@ -119,6 +119,7 @@ class driver(inputDriver):
|
|||||||
return
|
return
|
||||||
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
||||||
try:
|
try:
|
||||||
|
if uDevice:
|
||||||
if self.gDevices[iDevice.fd]:
|
if self.gDevices[iDevice.fd]:
|
||||||
self.writeUInput(uDevice, event)
|
self.writeUInput(uDevice, event)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -134,7 +135,6 @@ class driver(inputDriver):
|
|||||||
return
|
return
|
||||||
uDevice.write_event(event)
|
uDevice.write_event(event)
|
||||||
uDevice.syn()
|
uDevice.syn()
|
||||||
time.sleep(0.00001)
|
|
||||||
|
|
||||||
def updateInputDevices(self, force = False, init = False):
|
def updateInputDevices(self, force = False, init = False):
|
||||||
if init:
|
if init:
|
||||||
@ -173,23 +173,20 @@ class driver(inputDriver):
|
|||||||
if 116 in cap[eventType.EV_KEY] and len(cap[eventType.EV_KEY]) < 10:
|
if 116 in cap[eventType.EV_KEY] and len(cap[eventType.EV_KEY]) < 10:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device Skipped (has 116):' + currDevice.name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device Skipped (has 116):' + currDevice.name,debug.debugLevel.INFO)
|
||||||
continue
|
continue
|
||||||
if len(cap[eventType.EV_KEY]) < 30:
|
if len(cap[eventType.EV_KEY]) < 60:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 30 keys):' + currDevice.name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 60 keys):' + currDevice.name,debug.debugLevel.INFO)
|
||||||
continue
|
continue
|
||||||
if mode == 'ALL':
|
if mode == 'ALL':
|
||||||
self.iDevices[currDevice.fd] = currDevice
|
self.addDevice(currDevice)
|
||||||
self.grabDevice(currDevice.fd)
|
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
|
||||||
elif mode == 'NOMICE':
|
elif mode == 'NOMICE':
|
||||||
if not ((eventType.EV_REL in cap) or (eventType.EV_ABS in cap)):
|
if not ((eventType.EV_REL in cap) or (eventType.EV_ABS in cap)):
|
||||||
self.iDevices[currDevice.fd] = currDevice
|
self.addDevice(currDevice)
|
||||||
self.grabDevice(currDevice.fd)
|
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device added (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device Skipped (NOMICE):' + currDevice.name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device Skipped (NOMICE):' + currDevice.name,debug.debugLevel.INFO)
|
||||||
elif currDevice.name.upper() in mode.split(','):
|
elif currDevice.name.upper() in mode.split(','):
|
||||||
self.iDevices[currDevice.fd] = currDevice
|
self.addDevice(currDevice)
|
||||||
self.grabDevice(currDevice.fd)
|
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile +' ' + currDevice.name +' '+ str(e),debug.debugLevel.INFO)
|
||||||
@ -250,11 +247,18 @@ class driver(inputDriver):
|
|||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
for fd in self.iDevices:
|
for fd in self.iDevices:
|
||||||
self.ungrabDevices(fd)
|
self.ungrabDevice(fd)
|
||||||
def grabDevice(self, fd):
|
def createUInputDev(self, fd):
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
self.uDevices[fd] = None
|
self.uDevices[fd] = None
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
|
test = self.uDevices[fd]
|
||||||
|
return
|
||||||
|
except KeyError:
|
||||||
|
self.uDevices[fd] = None
|
||||||
|
if self.uDevices[fd] != None:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.uDevices[fd] = UInput.from_device(self.iDevices[fd])
|
self.uDevices[fd] = UInput.from_device(self.iDevices[fd])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -270,23 +274,30 @@ class driver(inputDriver):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: init Uinput not possible: ' + str(e),debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
|
def addDevice(self, newDevice):
|
||||||
|
self.iDevices[newDevice.fd] = newDevice
|
||||||
|
self.createUInputDev(newDevice.fd)
|
||||||
|
self.grabDevice(newDevice.fd)
|
||||||
|
def grabDevice(self, fd):
|
||||||
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.iDevices[fd].grab()
|
self.iDevices[fd].grab()
|
||||||
self.gDevices[fd] = True
|
self.gDevices[fd] = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
|
||||||
def ungrabDevices(self,fd):
|
def ungrabDevice(self,fd):
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.iDevices[fd].ungrab()
|
|
||||||
self.gDevices[fd] = False
|
self.gDevices[fd] = False
|
||||||
|
self.iDevices[fd].ungrab()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
def removeDevice(self,fd):
|
def removeDevice(self,fd):
|
||||||
self.clearEventBuffer()
|
self.clearEventBuffer()
|
||||||
try:
|
try:
|
||||||
self.ungrabDevices(fd)
|
self.ungrabDevice(fd)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
@ -309,7 +320,7 @@ class driver(inputDriver):
|
|||||||
del(self.gDevices[fd])
|
del(self.gDevices[fd])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.MPiDevicesFD()
|
self.updateMPiDevicesFD()
|
||||||
|
|
||||||
def hasIDevices(self):
|
def hasIDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
|
Loading…
Reference in New Issue
Block a user