Compare commits
25 Commits
2025.02.26
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
4672592dba | ||
|
6b84a8e9bc | ||
|
3212962a5b | ||
|
9e9cb883e7 | ||
|
7a12992b88 | ||
|
26a8c8cf86 | ||
|
bbfd2790a9 | ||
|
6edb743c23 | ||
|
a1fcee9a45 | ||
|
4e6e6e2d17 | ||
|
7a87fb51bb | ||
|
676c2b07a9 | ||
|
2dda73ac87 | ||
|
f68a1af223 | ||
|
5ab66f6978 | ||
|
2cc2fda28c | ||
|
c99d0f6ee1 | ||
|
1552b962a1 | ||
|
09391bfe84 | ||
|
e76ca9889a | ||
|
73206ce393 | ||
|
4966b87ba1 | ||
|
145cab6221 | ||
|
e46926f145 | ||
|
8cd50c5070 |
@ -4,7 +4,7 @@
|
|||||||
# the entrys are seperated with :===: in words colon tripple equal colon ( to not collide with substitutions)
|
# the entrys are seperated with :===: in words colon tripple equal colon ( to not collide with substitutions)
|
||||||
[levelDict]
|
[levelDict]
|
||||||
none:===:
|
none:===:
|
||||||
some:===:-$~+*-/\@#
|
some:===:-$~+*-/\@#_
|
||||||
most:===:.,:-$~+*-/\@!#%^&*()[]}{<>;
|
most:===:.,:-$~+*-/\@!#%^&*()[]}{<>;
|
||||||
all:===:!"#$%& \'()*+,-./:;<=>?@[\\]^_`{|}~
|
all:===:!"#$%& \'()*+,-./:;<=>?@[\\]^_`{|}~
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# the entrys are seperated with :===: in words colon tripple equal colon ( to not collide with substitutions)
|
# the entrys are seperated with :===: in words colon tripple equal colon ( to not collide with substitutions)
|
||||||
[levelDict]
|
[levelDict]
|
||||||
none:===:
|
none:===:
|
||||||
some:===:-$~+*-/\@
|
some:===:-$~+*-/\@_
|
||||||
most:===:.,:-$~+*-/\@!#%^&*()[]}{<>;
|
most:===:.,:-$~+*-/\@!#%^&*()[]}{<>;
|
||||||
all:===:!"#$%& \'()*+,-./:;<=>?@[\\]^_`{|}~
|
all:===:!"#$%& \'()*+,-./:;<=>?@[\\]^_`{|}~
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# the entrys are seperated with :===: in words colon tripple equal colon ( to not collide with substitutions)
|
# the entrys are seperated with :===: in words colon tripple equal colon ( to not collide with substitutions)
|
||||||
[levelDict]
|
[levelDict]
|
||||||
none:===:
|
none:===:
|
||||||
some:===:-$~+*-/\@
|
some:===:-$~+*-/\@_
|
||||||
most:===:.,:-$~+*-/\@!#%^&*()[]}{<>;
|
most:===:.,:-$~+*-/\@!#%^&*()[]}{<>;
|
||||||
all:===:!"#$%& \'()*+,-./:;<=>?@[\\]^_`{|}~
|
all:===:!"#$%& \'()*+,-./:;<=>?@[\\]^_`{|}~
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ theme=default
|
|||||||
|
|
||||||
# Sound volume controls how loud the sounds for your selected soundpack are.
|
# Sound volume controls how loud the sounds for your selected soundpack are.
|
||||||
# 0 is quietest, 1.0 is loudest.
|
# 0 is quietest, 1.0 is loudest.
|
||||||
volume=1.0
|
volume=0.7
|
||||||
|
|
||||||
# shell commands for generic sound driver
|
# shell commands for generic sound driver
|
||||||
# the folowing variable are substituted
|
# the folowing variable are substituted
|
||||||
@ -92,8 +92,8 @@ fenrirMaxRate=450
|
|||||||
driver=vcsaDriver
|
driver=vcsaDriver
|
||||||
encoding=auto
|
encoding=auto
|
||||||
screenUpdateDelay=0.05
|
screenUpdateDelay=0.05
|
||||||
suspendingScreen=
|
ignoreScreen=
|
||||||
autodetectSuspendingScreen=True
|
autodetectIgnoreScreen=True
|
||||||
|
|
||||||
[keyboard]
|
[keyboard]
|
||||||
driver=evdevDriver
|
driver=evdevDriver
|
||||||
@ -131,7 +131,7 @@ punctuationProfile=default
|
|||||||
punctuationLevel=some
|
punctuationLevel=some
|
||||||
respectPunctuationPause=True
|
respectPunctuationPause=True
|
||||||
newLinePause=True
|
newLinePause=True
|
||||||
numberOfClipboards=10
|
numberOfClipboards=50
|
||||||
# used path for "export_clipboard_to_file"
|
# used path for "export_clipboard_to_file"
|
||||||
# $user is replaced by username
|
# $user is replaced by username
|
||||||
#clipboardExportPath=/home/$user/fenrirClipboard
|
#clipboardExportPath=/home/$user/fenrirClipboard
|
||||||
@ -190,7 +190,7 @@ enableSettingsRemote=True
|
|||||||
enableCommandRemote=True
|
enableCommandRemote=True
|
||||||
|
|
||||||
[barrier]
|
[barrier]
|
||||||
enabled=True
|
enabled=False
|
||||||
leftBarriers=│└┌─
|
leftBarriers=│└┌─
|
||||||
rightBarriers=│┘┐─
|
rightBarriers=│┘┐─
|
||||||
|
|
||||||
|
10
install.sh
10
install.sh
@ -1,12 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
#Basic install script for Fenrir.
|
#Basic install script for Fenrir.
|
||||||
read -p "This will install Fenrir. Press ctrl+C to cancel, or enter to continue." continue
|
read -rp "This will install Fenrir. Press ctrl+C to cancel, or enter to continue."
|
||||||
|
|
||||||
# Fenrir main application
|
# Fenrir main application
|
||||||
install -m755 -d /opt/fenrirscreenreader
|
install -m755 -d /opt/fenrirscreenreader
|
||||||
cp -af src/* /opt/fenrirscreenreader
|
cp -af src/* /opt/fenrirscreenreader
|
||||||
|
|
||||||
ln -fs /opt/fenrirscreenreader/fenrir-daemon /usr/bin/fenrir-daemon
|
|
||||||
ln -fs /opt/fenrirscreenreader/fenrir /usr/bin/fenrir
|
ln -fs /opt/fenrirscreenreader/fenrir /usr/bin/fenrir
|
||||||
# tools
|
# tools
|
||||||
install -m755 -d /usr/share/fenrirscreenreader/tools
|
install -m755 -d /usr/share/fenrirscreenreader/tools
|
||||||
@ -33,8 +32,9 @@ cp -af config/sound/template /usr/share/sounds/fenrirscreenreader/template
|
|||||||
# config
|
# config
|
||||||
if [ -f "/etc/fenrirscreenreader/settings/settings.conf" ]; then
|
if [ -f "/etc/fenrirscreenreader/settings/settings.conf" ]; then
|
||||||
echo "Do you want to overwrite your current global settings? (y/n)"
|
echo "Do you want to overwrite your current global settings? (y/n)"
|
||||||
read yn
|
read -r yn
|
||||||
if [ $yn = "Y" -o $yn = "y" ]; then
|
yn="${yn:0:1}"
|
||||||
|
if [[ "${yn^}" == "Y" ]]; then
|
||||||
mv /etc/fenrirscreenreader/settings/settings.conf /etc/fenrirscreenreader/settings/settings.conf.bak
|
mv /etc/fenrirscreenreader/settings/settings.conf /etc/fenrirscreenreader/settings/settings.conf.bak
|
||||||
echo "Your old settings.conf has been backed up to settings.conf.bak."
|
echo "Your old settings.conf has been backed up to settings.conf.bak."
|
||||||
install -m644 -D "config/settings/settings.conf" /etc/fenrirscreenreader/settings/settings.conf
|
install -m644 -D "config/settings/settings.conf" /etc/fenrirscreenreader/settings/settings.conf
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
evdev>=1.1.2
|
daemonize
|
||||||
daemonize>=2.5.0
|
evdev
|
||||||
dbus-python>=1.2.8
|
|
||||||
pyudev>=0.21.0
|
|
||||||
pexpect
|
pexpect
|
||||||
pyttsx3
|
pyenchant
|
||||||
pyte>=0.7.0
|
pyperclip
|
||||||
|
pyte
|
||||||
|
pyudev
|
||||||
|
pyxdg
|
||||||
|
setproctitle
|
||||||
|
8
setup.py
8
setup.py
@ -99,8 +99,10 @@ setup(
|
|||||||
"evdev>=1.1.2",
|
"evdev>=1.1.2",
|
||||||
"daemonize>=2.5.0",
|
"daemonize>=2.5.0",
|
||||||
"dbus-python>=1.2.8",
|
"dbus-python>=1.2.8",
|
||||||
|
"pyperclip",
|
||||||
"pyudev>=0.21.0",
|
"pyudev>=0.21.0",
|
||||||
"setuptools",
|
"setuptools",
|
||||||
|
"setproctitle",
|
||||||
"pexpect",
|
"pexpect",
|
||||||
"pyte>=0.7.0",
|
"pyte>=0.7.0",
|
||||||
],
|
],
|
||||||
@ -111,10 +113,10 @@ if not forceSettingsFlag:
|
|||||||
# create settings file from example if not exist
|
# create settings file from example if not exist
|
||||||
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
|
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
|
||||||
try:
|
try:
|
||||||
copyfile('/etc/fenrirscreenreader/settings/settings.conf.example', '/etc/fenrirscreenreader/settings/settings.conf')
|
copyfile('config/fenrirscreenreader/settings/settings.conf', '/etc/fenrirscreenreader/settings/settings.conf')
|
||||||
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
|
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
|
||||||
except:
|
except OSError as e:
|
||||||
pass
|
print(f"Could not copy settings file to destination: {e}")
|
||||||
else:
|
else:
|
||||||
print('settings.conf file found. It is not overwritten automatical')
|
print('settings.conf file found. It is not overwritten automatical')
|
||||||
|
|
||||||
|
@ -5,15 +5,17 @@
|
|||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
import subprocess, os
|
import os
|
||||||
from subprocess import Popen, PIPE
|
import importlib
|
||||||
import _thread
|
import _thread
|
||||||
|
import pyperclip
|
||||||
|
|
||||||
class command():
|
class command():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment, scriptPath=''):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
|
self.scriptPath = scriptPath
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
@ -22,56 +24,48 @@ class command():
|
|||||||
_thread.start_new_thread(self._threadRun , ())
|
_thread.start_new_thread(self._threadRun , ())
|
||||||
def _threadRun(self):
|
def _threadRun(self):
|
||||||
try:
|
try:
|
||||||
|
# Check if clipboard is empty
|
||||||
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
|
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
|
||||||
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
|
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Get current clipboard content
|
||||||
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
|
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
|
||||||
user = self.env['general']['currUser']
|
|
||||||
|
# Remember original display environment variable if it exists
|
||||||
# First try to find xclip in common locations
|
originalDisplay = os.environ.get('DISPLAY', '')
|
||||||
xclip_paths = [
|
success = False
|
||||||
'/usr/bin/xclip',
|
|
||||||
'/bin/xclip',
|
# Try different display options
|
||||||
'/usr/local/bin/xclip'
|
for i in range(10):
|
||||||
]
|
display = f":{i}"
|
||||||
|
try:
|
||||||
xclip_path = None
|
# Set display environment variable
|
||||||
for path in xclip_paths:
|
os.environ['DISPLAY'] = display
|
||||||
if os.path.isfile(path) and os.access(path, os.X_OK):
|
# Attempt to set clipboard content
|
||||||
xclip_path = path
|
importlib.reload(pyperclip) # Weird workaround for some distros
|
||||||
|
pyperclip.copy(clipboard)
|
||||||
|
# If we get here without exception, we found a working display
|
||||||
|
success = True
|
||||||
break
|
break
|
||||||
|
except Exception:
|
||||||
if not xclip_path:
|
# Failed for this display, try next one
|
||||||
self.env['runtime']['outputManager'].presentText(
|
continue
|
||||||
'xclip not found in common locations',
|
|
||||||
interrupt=True
|
# Restore original display setting
|
||||||
)
|
if originalDisplay:
|
||||||
return
|
os.environ['DISPLAY'] = originalDisplay
|
||||||
|
|
||||||
for display in range(10):
|
|
||||||
p = Popen(
|
|
||||||
['su', user, '-p', '-c', f"{xclip_path} -d :{display} -selection clipboard"],
|
|
||||||
stdin=PIPE, stdout=PIPE, stderr=PIPE, preexec_fn=os.setpgrp
|
|
||||||
)
|
|
||||||
stdout, stderr = p.communicate(input=clipboard.encode('utf-8'))
|
|
||||||
|
|
||||||
self.env['runtime']['outputManager'].interruptOutput()
|
|
||||||
|
|
||||||
stderr = stderr.decode('utf-8')
|
|
||||||
stdout = stdout.decode('utf-8')
|
|
||||||
|
|
||||||
if stderr == '':
|
|
||||||
break
|
|
||||||
|
|
||||||
if stderr != '':
|
|
||||||
self.env['runtime']['outputManager'].presentText(stderr, soundIcon='', interrupt=False)
|
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].presentText('exported to the X session.', interrupt=True)
|
os.environ.pop('DISPLAY', None)
|
||||||
|
|
||||||
|
# Notify the user of the result
|
||||||
|
if success:
|
||||||
|
self.env['runtime']['outputManager'].presentText(_('exported to the X session.'), interrupt=True)
|
||||||
|
else:
|
||||||
|
self.env['runtime']['outputManager'].presentText(_('failed to export to X clipboard. No available display found.'), interrupt=True)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['outputManager'].presentText(str(e), soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(str(e), soundIcon='', interrupt=False)
|
||||||
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
import subprocess, os
|
import importlib
|
||||||
from subprocess import Popen, PIPE
|
|
||||||
import _thread
|
import _thread
|
||||||
|
import pyperclip
|
||||||
|
import os
|
||||||
|
|
||||||
class command():
|
class command():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@ -22,33 +24,41 @@ class command():
|
|||||||
_thread.start_new_thread(self._threadRun , ())
|
_thread.start_new_thread(self._threadRun , ())
|
||||||
def _threadRun(self):
|
def _threadRun(self):
|
||||||
try:
|
try:
|
||||||
# Find xclip path
|
# Remember original display environment variable if it exists
|
||||||
xclip_paths = ['/usr/bin/xclip', '/bin/xclip', '/usr/local/bin/xclip']
|
originalDisplay = os.environ.get('DISPLAY', '')
|
||||||
xclip_path = None
|
clipboardContent = None
|
||||||
for path in xclip_paths:
|
|
||||||
if os.path.isfile(path) and os.access(path, os.X_OK):
|
# Try different display options
|
||||||
xclip_path = path
|
for i in range(10):
|
||||||
break
|
display = f":{i}"
|
||||||
if not xclip_path:
|
try:
|
||||||
self.env['runtime']['outputManager'].presentText('xclip not found in common locations', interrupt=True)
|
# Set display environment variable
|
||||||
return
|
os.environ['DISPLAY'] = display
|
||||||
xClipboard = ''
|
# Attempt to get clipboard content
|
||||||
for display in range(10):
|
importlib.reload(pyperclip) # Weird workaround for some distros
|
||||||
p = Popen('su ' + self.env['general']['currUser'] + ' -p -c "' + xclip_path + ' -d :' + str(display) + ' -o"', stdout=PIPE, stderr=PIPE, shell=True)
|
clipboardContent = pyperclip.paste()
|
||||||
stdout, stderr = p.communicate()
|
# If we get here without exception, we found a working display
|
||||||
self.env['runtime']['outputManager'].interruptOutput()
|
if clipboardContent:
|
||||||
stderr = stderr.decode('utf-8')
|
break
|
||||||
xClipboard = stdout.decode('utf-8')
|
except Exception:
|
||||||
if (stderr == ''):
|
# Failed for this display, try next one
|
||||||
break
|
continue
|
||||||
if stderr != '':
|
|
||||||
self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False)
|
# Restore original display setting
|
||||||
|
if originalDisplay:
|
||||||
|
os.environ['DISPLAY'] = originalDisplay
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', xClipboard)
|
os.environ.pop('DISPLAY', None)
|
||||||
|
|
||||||
|
# Process the clipboard content if we found any
|
||||||
|
if clipboardContent and isinstance(clipboardContent, str):
|
||||||
|
self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', clipboardContent)
|
||||||
self.env['runtime']['outputManager'].presentText('Import to Clipboard', soundIcon='CopyToClipboard', interrupt=True)
|
self.env['runtime']['outputManager'].presentText('Import to Clipboard', soundIcon='CopyToClipboard', interrupt=True)
|
||||||
self.env['runtime']['outputManager'].presentText(xClipboard, soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(clipboardContent, soundIcon='', interrupt=False)
|
||||||
|
else:
|
||||||
|
self.env['runtime']['outputManager'].presentText('No text found in clipboard or no accessible display', interrupt=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(str(e), soundIcon='', interrupt=False)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -35,12 +35,18 @@ class command():
|
|||||||
if not (self.env['runtime']['byteManager'].getLastByteKey() in [b'^[[A',b'^[[B']):
|
if not (self.env['runtime']['byteManager'].getLastByteKey() in [b'^[[A',b'^[[B']):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Get the current cursor's line from both old and new content
|
||||||
prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||||
currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||||
|
|
||||||
|
is_blank = currLine.strip() == ''
|
||||||
|
|
||||||
if prevLine == currLine:
|
if prevLine == currLine:
|
||||||
if self.env['screen']['newDelta'] != '':
|
if self.env['screen']['newDelta'] != '':
|
||||||
return
|
return
|
||||||
if not currLine.isspace():
|
|
||||||
|
announce = currLine
|
||||||
|
if not is_blank:
|
||||||
currPrompt = currLine.find('$')
|
currPrompt = currLine.find('$')
|
||||||
rootPrompt = currLine.find('#')
|
rootPrompt = currLine.find('#')
|
||||||
if currPrompt <= 0:
|
if currPrompt <= 0:
|
||||||
@ -55,13 +61,13 @@ class command():
|
|||||||
else:
|
else:
|
||||||
announce = currLine
|
announce = currLine
|
||||||
|
|
||||||
if currLine.isspace():
|
if is_blank:
|
||||||
self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False)
|
self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].presentText(announce, interrupt=True, flush=False)
|
self.env['runtime']['outputManager'].presentText(announce, interrupt=True, flush=False)
|
||||||
|
|
||||||
self.env['commandsIgnore']['onScreenUpdate']['CHAR_DELETE_ECHO'] = True
|
self.env['commandsIgnore']['onScreenUpdate']['CHAR_DELETE_ECHO'] = True
|
||||||
self.env['commandsIgnore']['onScreenUpdate']['CHAR_ECHO'] = True
|
self.env['commandsIgnore']['onScreenUpdate']['CHAR_ECHO'] = True
|
||||||
self.env['commandsIgnore']['onScreenUpdate']['INCOMING_IGNORE'] = True
|
self.env['commandsIgnore']['onScreenUpdate']['INCOMING_IGNORE'] = True
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class attributeManager():
|
|||||||
cursorPos = cursor.copy()
|
cursorPos = cursor.copy()
|
||||||
try:
|
try:
|
||||||
attribute = self.getAttributeByXY( cursorPos['x'], cursorPos['y'])
|
attribute = self.getAttributeByXY( cursorPos['x'], cursorPos['y'])
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
self.setLastCursorAttribute(attribute)
|
self.setLastCursorAttribute(attribute)
|
||||||
if not self.isLastCursorAttributeChange():
|
if not self.isLastCursorAttributeChange():
|
||||||
@ -155,13 +155,13 @@ class attributeManager():
|
|||||||
attributeFormatString = attributeFormatString.replace('fenrirFGColor', _(attribute[0]))
|
attributeFormatString = attributeFormatString.replace('fenrirFGColor', _(attribute[0]))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFGColor', '')
|
attributeFormatString = attributeFormatString.replace('fenrirFGColor', '')
|
||||||
|
|
||||||
# 1 BG color (name)
|
# 1 BG color (name)
|
||||||
try:
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBGColor', _(attribute[1]))
|
attributeFormatString = attributeFormatString.replace('fenrirBGColor', _(attribute[1]))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBGColor', '')
|
attributeFormatString = attributeFormatString.replace('fenrirBGColor', '')
|
||||||
|
|
||||||
# 2 bold (True/ False)
|
# 2 bold (True/ False)
|
||||||
try:
|
try:
|
||||||
if attribute[2]:
|
if attribute[2]:
|
||||||
@ -169,7 +169,7 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBold', '')
|
attributeFormatString = attributeFormatString.replace('fenrirBold', '')
|
||||||
|
|
||||||
# 3 italics (True/ False)
|
# 3 italics (True/ False)
|
||||||
try:
|
try:
|
||||||
if attribute[3]:
|
if attribute[3]:
|
||||||
@ -177,7 +177,7 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirItalics', '')
|
attributeFormatString = attributeFormatString.replace('fenrirItalics', '')
|
||||||
|
|
||||||
# 4 underline (True/ False)
|
# 4 underline (True/ False)
|
||||||
try:
|
try:
|
||||||
if attribute[4]:
|
if attribute[4]:
|
||||||
@ -185,7 +185,7 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirUnderline', '')
|
attributeFormatString = attributeFormatString.replace('fenrirUnderline', '')
|
||||||
|
|
||||||
# 5 strikethrough (True/ False)
|
# 5 strikethrough (True/ False)
|
||||||
try:
|
try:
|
||||||
if attribute[5]:
|
if attribute[5]:
|
||||||
@ -193,7 +193,7 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirStrikethrough', '')
|
attributeFormatString = attributeFormatString.replace('fenrirStrikethrough', '')
|
||||||
|
|
||||||
# 6 reverse (True/ False)
|
# 6 reverse (True/ False)
|
||||||
try:
|
try:
|
||||||
if attribute[6]:
|
if attribute[6]:
|
||||||
@ -201,7 +201,7 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirReverse', '')
|
attributeFormatString = attributeFormatString.replace('fenrirReverse', '')
|
||||||
|
|
||||||
# 7 blink (True/ False)
|
# 7 blink (True/ False)
|
||||||
try:
|
try:
|
||||||
if attribute[7]:
|
if attribute[7]:
|
||||||
@ -209,7 +209,7 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirBlink', '')
|
attributeFormatString = attributeFormatString.replace('fenrirBlink', '')
|
||||||
|
|
||||||
# 8 font size (int/ string)
|
# 8 font size (int/ string)
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
@ -223,14 +223,14 @@ class attributeManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFontSize', _('default'))
|
attributeFormatString = attributeFormatString.replace('fenrirFontSize', _('default'))
|
||||||
|
|
||||||
# 9 font family (string)
|
# 9 font family (string)
|
||||||
try:
|
try:
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFont', attribute[9])
|
attributeFormatString = attributeFormatString.replace('fenrirFont', attribute[9])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
attributeFormatString = attributeFormatString.replace('fenrirFont', _('default'))
|
attributeFormatString = attributeFormatString.replace('fenrirFont', _('default'))
|
||||||
|
|
||||||
return attributeFormatString
|
return attributeFormatString
|
||||||
def trackHighlights(self):
|
def trackHighlights(self):
|
||||||
result = ''
|
result = ''
|
||||||
@ -287,4 +287,4 @@ class attributeManager():
|
|||||||
useful = True
|
useful = True
|
||||||
|
|
||||||
return useful
|
return useful
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class barrierManager():
|
|||||||
def updateBarrierChange(self, isBarrier):
|
def updateBarrierChange(self, isBarrier):
|
||||||
self.prefIsBarrier = self.currIsBarrier
|
self.prefIsBarrier = self.currIsBarrier
|
||||||
self.currIsBarrier = isBarrier
|
self.currIsBarrier = isBarrier
|
||||||
|
|
||||||
def resetBarrierChange(self):
|
def resetBarrierChange(self):
|
||||||
self.currIsBarrier = False
|
self.currIsBarrier = False
|
||||||
self.prefIsBarrier = False
|
self.prefIsBarrier = False
|
||||||
@ -38,7 +38,7 @@ class barrierManager():
|
|||||||
self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierStart', interrupt=doInterrupt)
|
self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierStart', interrupt=doInterrupt)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierEnd', interrupt=doInterrupt)
|
self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierEnd', interrupt=doInterrupt)
|
||||||
|
|
||||||
if not isBarrier:
|
if not isBarrier:
|
||||||
sayLine = ''
|
sayLine = ''
|
||||||
return isBarrier, sayLine
|
return isBarrier, sayLine
|
||||||
|
@ -27,7 +27,7 @@ class commandManager():
|
|||||||
|
|
||||||
# scripts for scriptKey
|
# scripts for scriptKey
|
||||||
self.env['runtime']['commandManager'].loadScriptCommands()
|
self.env['runtime']['commandManager'].loadScriptCommands()
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
for commandFolder in self.env['general']['commandFolderList']:
|
for commandFolder in self.env['general']['commandFolderList']:
|
||||||
self.env['runtime']['commandManager'].shutdownCommands(commandFolder)
|
self.env['runtime']['commandManager'].shutdownCommands(commandFolder)
|
||||||
@ -99,7 +99,7 @@ class commandManager():
|
|||||||
self.env['runtime']['debug'].writeDebugOut("loadCommands: Loading command:" + command ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("loadCommands: Loading command:" + command ,debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def loadScriptCommands(self, section='commands', scriptPath=''):
|
def loadScriptCommands(self, section='commands', scriptPath=''):
|
||||||
if scriptPath =='':
|
if scriptPath =='':
|
||||||
scriptPath = self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath')
|
scriptPath = self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath')
|
||||||
@ -159,18 +159,24 @@ class commandManager():
|
|||||||
self.env['runtime']['debug'].writeDebugOut("Loading script:" + fileName ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Loading script:" + fileName ,debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def shutdownCommands(self, section):
|
def shutdownCommands(self, section):
|
||||||
|
# Check if the section exists in the commands dictionary
|
||||||
|
if section not in self.env['commands']:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("shutdownCommands: section not found:" + section, debug.debugLevel.WARNING)
|
||||||
|
return
|
||||||
|
|
||||||
for command in sorted(self.env['commands'][section]):
|
for command in sorted(self.env['commands'][section]):
|
||||||
try:
|
try:
|
||||||
self.env['commands'][section][command].shutdown()
|
self.env['commands'][section][command].shutdown()
|
||||||
del self.env['commands'][section][command]
|
del self.env['commands'][section][command]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Shutdown command:" + section + "." + command ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Shutdown command:" + section + "." + command, debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def executeSwitchTrigger(self, trigger, unLoadScript, loadScript):
|
def executeSwitchTrigger(self, trigger, unLoadScript, loadScript):
|
||||||
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
if self.env['runtime']['screenManager'].isIgnoredScreen():
|
||||||
return
|
return
|
||||||
#unload
|
#unload
|
||||||
oldScript = unLoadScript
|
oldScript = unLoadScript
|
||||||
@ -193,7 +199,7 @@ class commandManager():
|
|||||||
|
|
||||||
def executeDefaultTrigger(self, trigger, force=False):
|
def executeDefaultTrigger(self, trigger, force=False):
|
||||||
if not force:
|
if not force:
|
||||||
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
if self.env['runtime']['screenManager'].isIgnoredScreen():
|
||||||
return
|
return
|
||||||
for command in sorted(self.env['commands'][trigger]):
|
for command in sorted(self.env['commands'][trigger]):
|
||||||
if self.commandExists(command, trigger):
|
if self.commandExists(command, trigger):
|
||||||
@ -208,7 +214,7 @@ class commandManager():
|
|||||||
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command + str(e) ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command + str(e) ,debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def executeCommand(self, command, section = 'commands'):
|
def executeCommand(self, command, section = 'commands'):
|
||||||
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
if self.env['runtime']['screenManager'].isIgnoredScreen():
|
||||||
return
|
return
|
||||||
if self.commandExists(command, section):
|
if self.commandExists(command, section):
|
||||||
try:
|
try:
|
||||||
@ -222,7 +228,7 @@ class commandManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
|
|
||||||
def runCommand(self, command, section = 'commands'):
|
def runCommand(self, command, section = 'commands'):
|
||||||
if self.commandExists(command, section):
|
if self.commandExists(command, section):
|
||||||
try:
|
try:
|
||||||
@ -231,7 +237,7 @@ class commandManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("runCommand command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("runCommand command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
||||||
self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
|
self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
|
||||||
|
|
||||||
def getCommandDescription(self, command, section = 'commands'):
|
def getCommandDescription(self, command, section = 'commands'):
|
||||||
if self.commandExists(command, section):
|
if self.commandExists(command, section):
|
||||||
try:
|
try:
|
||||||
@ -239,7 +245,7 @@ class commandManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('commandManager.getCommandDescription:' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('commandManager.getCommandDescription:' + str(e),debug.debugLevel.ERROR)
|
||||||
self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
|
self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
|
||||||
|
|
||||||
def commandExists(self, command, section = 'commands'):
|
def commandExists(self, command, section = 'commands'):
|
||||||
try:
|
try:
|
||||||
return( command in self.env['commands'][section])
|
return( command in self.env['commands'][section])
|
||||||
|
@ -11,6 +11,14 @@ class cursorManager():
|
|||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
|
def shouldProcessNumpadCommands(self):
|
||||||
|
"""
|
||||||
|
Check if numpad commands should be processed based on numlock state
|
||||||
|
Return True if numlock is OFF (commands should work)
|
||||||
|
Return False if numlock is ON (let keys type numbers)
|
||||||
|
"""
|
||||||
|
# Return False if numlock is ON
|
||||||
|
return not self.env['input']['newNumLock']
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
def clearMarks(self):
|
def clearMarks(self):
|
||||||
@ -47,7 +55,7 @@ class cursorManager():
|
|||||||
return
|
return
|
||||||
self.env['screen']['oldCursorReview'] = None
|
self.env['screen']['oldCursorReview'] = None
|
||||||
self.env['screen']['newCursorReview'] = None
|
self.env['screen']['newCursorReview'] = None
|
||||||
|
|
||||||
def isCursorHorizontalMove(self):
|
def isCursorHorizontalMove(self):
|
||||||
return self.env['screen']['newCursor']['x'] != self.env['screen']['oldCursor']['x']
|
return self.env['screen']['newCursor']['x'] != self.env['screen']['oldCursor']['x']
|
||||||
|
|
||||||
@ -56,7 +64,7 @@ class cursorManager():
|
|||||||
|
|
||||||
def isReviewMode(self):
|
def isReviewMode(self):
|
||||||
return self.env['screen']['newCursorReview'] != None
|
return self.env['screen']['newCursorReview'] != None
|
||||||
|
|
||||||
def enterReviewModeCurrTextCursor(self, overwrite=False):
|
def enterReviewModeCurrTextCursor(self, overwrite=False):
|
||||||
if self.isReviewMode() and not overwrite:
|
if self.isReviewMode() and not overwrite:
|
||||||
return
|
return
|
||||||
@ -73,7 +81,7 @@ class cursorManager():
|
|||||||
self.env['screen']['oldCursorReview'] = self.env['screen']['newCursorReview']
|
self.env['screen']['oldCursorReview'] = self.env['screen']['newCursorReview']
|
||||||
self.env['screen']['newCursorReview']['x'] = x
|
self.env['screen']['newCursorReview']['x'] = x
|
||||||
self.env['screen']['newCursorReview']['y'] = y
|
self.env['screen']['newCursorReview']['y'] = y
|
||||||
|
|
||||||
def isApplicationWindowSet(self):
|
def isApplicationWindowSet(self):
|
||||||
try:
|
try:
|
||||||
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
|
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
|
||||||
@ -108,7 +116,7 @@ class cursorManager():
|
|||||||
|
|
||||||
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
|
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
|
||||||
self.env['commandBuffer']['windowArea'][currApp] = {}
|
self.env['commandBuffer']['windowArea'][currApp] = {}
|
||||||
|
|
||||||
if x1 * y1 <= \
|
if x1 * y1 <= \
|
||||||
x2 * y2:
|
x2 * y2:
|
||||||
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
|
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
|
||||||
|
@ -36,14 +36,14 @@ class debugManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
def writeDebugOut(self, text, level = debug.debugLevel.DEACTIVE, onAnyLevel=False):
|
def writeDebugOut(self, text, level = debug.debugLevel.DEACTIVE, onAnyLevel=False):
|
||||||
|
|
||||||
mode = self.env['runtime']['settingsManager'].getSetting('general','debugMode')
|
mode = self.env['runtime']['settingsManager'].getSetting('general','debugMode')
|
||||||
if mode == '':
|
if mode == '':
|
||||||
mode = 'FILE'
|
mode = 'FILE'
|
||||||
mode = mode.upper().split(',')
|
mode = mode.upper().split(',')
|
||||||
fileMode = 'FILE' in mode
|
fileMode = 'FILE' in mode
|
||||||
printMode = 'PRINT' in mode
|
printMode = 'PRINT' in mode
|
||||||
|
|
||||||
if (self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') < int(level)) and \
|
if (self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') < int(level)) and \
|
||||||
not (onAnyLevel and self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') > int(debug.debugLevel.DEACTIVE)) :
|
not (onAnyLevel and self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') > int(debug.debugLevel.DEACTIVE)) :
|
||||||
if self._fileOpened:
|
if self._fileOpened:
|
||||||
@ -52,12 +52,15 @@ class debugManager():
|
|||||||
else:
|
else:
|
||||||
if not self._fileOpened and fileMode:
|
if not self._fileOpened and fileMode:
|
||||||
self.openDebugFile()
|
self.openDebugFile()
|
||||||
|
timestamp = str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'))
|
||||||
if onAnyLevel:
|
if onAnyLevel:
|
||||||
msg = 'ANY '+ str(level) + ' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'))
|
levelInfo = 'INFO ANY'
|
||||||
else:
|
else:
|
||||||
msg = str(level) +' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')
|
levelInfo = str(level)
|
||||||
)
|
|
||||||
msg += ': ' + text
|
# Changed order: text comes first, then level and timestamp
|
||||||
|
msg = text + ' - ' + levelInfo + ' ' + timestamp
|
||||||
|
|
||||||
if printMode:
|
if printMode:
|
||||||
print(msg)
|
print(msg)
|
||||||
if fileMode:
|
if fileMode:
|
||||||
|
@ -21,7 +21,7 @@ class eventManager():
|
|||||||
self.env = environment
|
self.env = environment
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
self.cleanEventQueue()
|
self.cleanEventQueue()
|
||||||
|
|
||||||
def proceedEventLoop(self):
|
def proceedEventLoop(self):
|
||||||
event = self._eventQueue.get()
|
event = self._eventQueue.get()
|
||||||
st = time.time()
|
st = time.time()
|
||||||
|
@ -23,11 +23,11 @@ class fenrirManager():
|
|||||||
raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable')
|
raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable')
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True)
|
self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True)
|
||||||
signal.signal(signal.SIGINT, self.captureSignal)
|
signal.signal(signal.SIGINT, self.captureSignal)
|
||||||
signal.signal(signal.SIGTERM, self.captureSignal)
|
signal.signal(signal.SIGTERM, self.captureSignal)
|
||||||
|
|
||||||
self.isInitialized = True
|
self.isInitialized = True
|
||||||
self.modifierInput = False
|
self.modifierInput = False
|
||||||
self.singleKeyCommand = False
|
self.singleKeyCommand = False
|
||||||
@ -42,10 +42,10 @@ class fenrirManager():
|
|||||||
|
|
||||||
def handleInput(self, event):
|
def handleInput(self, event):
|
||||||
self.environment['runtime']['debug'].writeDebugOut('DEBUG INPUT fenrirMan:' + str(event), debug.debugLevel.INFO)
|
self.environment['runtime']['debug'].writeDebugOut('DEBUG INPUT fenrirMan:' + str(event), debug.debugLevel.INFO)
|
||||||
|
|
||||||
if not event['Data']:
|
if not event['Data']:
|
||||||
event['Data'] = self.environment['runtime']['inputManager'].getInputEvent()
|
event['Data'] = self.environment['runtime']['inputManager'].getInputEvent()
|
||||||
|
|
||||||
if event['Data']:
|
if event['Data']:
|
||||||
event['Data']['EventName'] = self.environment['runtime']['inputManager'].convertEventName(event['Data']['EventName'])
|
event['Data']['EventName'] = self.environment['runtime']['inputManager'].convertEventName(event['Data']['EventName'])
|
||||||
self.environment['runtime']['inputManager'].handleInputEvent(event['Data'])
|
self.environment['runtime']['inputManager'].handleInputEvent(event['Data'])
|
||||||
@ -54,8 +54,8 @@ class fenrirManager():
|
|||||||
|
|
||||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||||
|
|
||||||
if self.environment['runtime']['screenManager'].isSuspendingScreen():
|
if self.environment['runtime']['screenManager'].isIgnoredScreen():
|
||||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||||
else:
|
else:
|
||||||
if self.environment['runtime']['helpManager'].isTutorialMode():
|
if self.environment['runtime']['helpManager'].isTutorialMode():
|
||||||
@ -74,7 +74,7 @@ class fenrirManager():
|
|||||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||||
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.modifierInput = False
|
self.modifierInput = False
|
||||||
self.singleKeyCommand = False
|
self.singleKeyCommand = False
|
||||||
@ -83,7 +83,7 @@ class fenrirManager():
|
|||||||
|
|
||||||
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')
|
||||||
|
|
||||||
def handleByteInput(self, event):
|
def handleByteInput(self, event):
|
||||||
@ -124,14 +124,14 @@ class fenrirManager():
|
|||||||
|
|
||||||
def handleScreenUpdate(self, event):
|
def handleScreenUpdate(self, event):
|
||||||
self.environment['runtime']['screenManager'].handleScreenUpdate(event['Data'])
|
self.environment['runtime']['screenManager'].handleScreenUpdate(event['Data'])
|
||||||
|
|
||||||
if time.time() - self.environment['runtime']['inputManager'].getLastInputTime() >= 0.3:
|
if time.time() - self.environment['runtime']['inputManager'].getLastInputTime() >= 0.3:
|
||||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||||
|
|
||||||
if (self.environment['runtime']['cursorManager'].isCursorVerticalMove() or
|
if (self.environment['runtime']['cursorManager'].isCursorVerticalMove() or
|
||||||
self.environment['runtime']['cursorManager'].isCursorHorizontalMove()):
|
self.environment['runtime']['cursorManager'].isCursorHorizontalMove()):
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onCursorChange')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onCursorChange')
|
||||||
|
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
|
||||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||||
|
|
||||||
@ -150,17 +150,17 @@ class fenrirManager():
|
|||||||
def detectShortcutCommand(self):
|
def detectShortcutCommand(self):
|
||||||
if self.environment['input']['keyForeward'] > 0:
|
if self.environment['input']['keyForeward'] > 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(self.environment['input']['prevInput']) > len(self.environment['input']['currInput']):
|
if len(self.environment['input']['prevInput']) > len(self.environment['input']['currInput']):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.environment['runtime']['inputManager'].isKeyPress():
|
if self.environment['runtime']['inputManager'].isKeyPress():
|
||||||
self.modifierInput = self.environment['runtime']['inputManager'].currKeyIsModifier()
|
self.modifierInput = self.environment['runtime']['inputManager'].currKeyIsModifier()
|
||||||
else:
|
else:
|
||||||
if not self.environment['runtime']['inputManager'].noKeyPressed():
|
if not self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
if self.singleKeyCommand:
|
if self.singleKeyCommand:
|
||||||
self.singleKeyCommand = len(self.environment['input']['currInput']) == 1
|
self.singleKeyCommand = len(self.environment['input']['currInput']) == 1
|
||||||
|
|
||||||
if not(self.singleKeyCommand and self.environment['runtime']['inputManager'].noKeyPressed()):
|
if not(self.singleKeyCommand and self.environment['runtime']['inputManager'].noKeyPressed()):
|
||||||
currentShortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
currentShortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
||||||
self.command = self.environment['runtime']['inputManager'].getCommandForShortcut(currentShortcut)
|
self.command = self.environment['runtime']['inputManager'].getCommandForShortcut(currentShortcut)
|
||||||
@ -220,7 +220,7 @@ class fenrirManager():
|
|||||||
self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True)
|
self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True)
|
||||||
self.environment['runtime']['eventManager'].cleanEventQueue()
|
self.environment['runtime']['eventManager'].cleanEventQueue()
|
||||||
time.sleep(0.6)
|
time.sleep(0.6)
|
||||||
|
|
||||||
for currentManager in self.environment['general']['managerList']:
|
for currentManager in self.environment['general']['managerList']:
|
||||||
if self.environment['runtime'][currentManager]:
|
if self.environment['runtime'][currentManager]:
|
||||||
self.environment['runtime'][currentManager].shutdown()
|
self.environment['runtime'][currentManager].shutdown()
|
||||||
|
@ -42,6 +42,25 @@ class inputDriver():
|
|||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return True
|
return True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def forceUngrab(self):
|
||||||
|
"""Emergency method to release grabbed devices in case of failure"""
|
||||||
|
if not self._initialized:
|
||||||
|
return True
|
||||||
|
try:
|
||||||
|
# Try standard ungrab first
|
||||||
|
return self.ungrabAllDevices()
|
||||||
|
except Exception as e:
|
||||||
|
# Just log the failure and inform the user
|
||||||
|
if hasattr(self, 'env') and 'runtime' in self.env and 'debug' in self.env['runtime']:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut(
|
||||||
|
f"Emergency device release failed: {str(e)}",
|
||||||
|
debug.debugLevel.ERROR
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print(f"Emergency device release failed: {str(e)}")
|
||||||
|
return False
|
||||||
|
|
||||||
def hasIDevices(self):
|
def hasIDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return False
|
return False
|
||||||
|
@ -49,6 +49,7 @@ class inputManager():
|
|||||||
return event
|
return event
|
||||||
def setExecuteDeviceGrab(self, newExecuteDeviceGrab = True):
|
def setExecuteDeviceGrab(self, newExecuteDeviceGrab = True):
|
||||||
self.executeDeviceGrab = newExecuteDeviceGrab
|
self.executeDeviceGrab = newExecuteDeviceGrab
|
||||||
|
|
||||||
def handleDeviceGrab(self, force = False):
|
def handleDeviceGrab(self, force = False):
|
||||||
if force:
|
if force:
|
||||||
self.setExecuteDeviceGrab()
|
self.setExecuteDeviceGrab()
|
||||||
@ -61,17 +62,38 @@ class inputManager():
|
|||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
self.executeDeviceGrab = False
|
self.executeDeviceGrab = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Add maximum retries to prevent infinite loops
|
||||||
|
maxRetries = 5
|
||||||
|
retryCount = 0
|
||||||
|
grabTimeout = 3 # Timeout in seconds
|
||||||
|
startTime = time.time()
|
||||||
|
|
||||||
if self.env['runtime']['screenManager'].getCurrScreenIgnored():
|
if self.env['runtime']['screenManager'].getCurrScreenIgnored():
|
||||||
while not self.ungrabAllDevices():
|
while not self.ungrabAllDevices():
|
||||||
|
retryCount += 1
|
||||||
|
if retryCount >= maxRetries or (time.time() - startTime) > grabTimeout:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("Failed to ungrab devices after multiple attempts", debug.debugLevel.ERROR)
|
||||||
|
# Force a release of devices if possible through alternative means
|
||||||
|
try:
|
||||||
|
self.env['runtime']['inputDriver'].forceUngrab()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
break
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
self.env['runtime']['debug'].writeDebugOut("retry ungrabAllDevices " ,debug.debugLevel.WARNING)
|
self.env['runtime']['debug'].writeDebugOut(f"retry ungrabAllDevices {retryCount}/{maxRetries}", debug.debugLevel.WARNING)
|
||||||
self.env['runtime']['debug'].writeDebugOut("All devices ungrabbed" ,debug.debugLevel.INFO)
|
|
||||||
else:
|
else:
|
||||||
while not self.grabAllDevices():
|
while not self.grabAllDevices():
|
||||||
|
retryCount += 1
|
||||||
|
if retryCount >= maxRetries or (time.time() - startTime) > grabTimeout:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("Failed to grab devices after multiple attempts", debug.debugLevel.ERROR)
|
||||||
|
# Continue without grabbing input - limited functionality but not locked
|
||||||
|
break
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
self.env['runtime']['debug'].writeDebugOut("retry grabAllDevices" ,debug.debugLevel.WARNING)
|
self.env['runtime']['debug'].writeDebugOut(f"retry grabAllDevices {retryCount}/{maxRetries}", debug.debugLevel.WARNING)
|
||||||
self.env['runtime']['debug'].writeDebugOut("All devices grabbed" ,debug.debugLevel.INFO)
|
|
||||||
self.executeDeviceGrab = False
|
self.executeDeviceGrab = False
|
||||||
|
|
||||||
def sendKeys(self, keyMacro):
|
def sendKeys(self, keyMacro):
|
||||||
for e in keyMacro:
|
for e in keyMacro:
|
||||||
key = ''
|
key = ''
|
||||||
@ -252,17 +274,39 @@ class inputManager():
|
|||||||
def getCurrShortcut(self, inputSequence = None):
|
def getCurrShortcut(self, inputSequence = None):
|
||||||
shortcut = []
|
shortcut = []
|
||||||
shortcut.append(self.env['input']['shortcutRepeat'])
|
shortcut.append(self.env['input']['shortcutRepeat'])
|
||||||
|
|
||||||
|
numpadKeys = ['KEY_KP0', 'KEY_KP1', 'KEY_KP2', 'KEY_KP3', 'KEY_KP4',
|
||||||
|
'KEY_KP5', 'KEY_KP6', 'KEY_KP7', 'KEY_KP8', 'KEY_KP9',
|
||||||
|
'KEY_KPDOT', 'KEY_KPPLUS', 'KEY_KPMINUS', 'KEY_KPASTERISK',
|
||||||
|
'KEY_KPSLASH', 'KEY_KPENTER', 'KEY_KPEQUAL']
|
||||||
if inputSequence:
|
if inputSequence:
|
||||||
|
# Check if any key in the sequence is a numpad key and numlock is ON
|
||||||
|
# If numlock is ON and any key in the sequence is a numpad key, return an empty shortcut
|
||||||
|
if not self.env['runtime']['cursorManager'].shouldProcessNumpadCommands():
|
||||||
|
for key in inputSequence:
|
||||||
|
if key in numpadKeys:
|
||||||
|
# Return an empty/invalid shortcut that won't match any command
|
||||||
|
return "[]"
|
||||||
|
|
||||||
shortcut.append(inputSequence)
|
shortcut.append(inputSequence)
|
||||||
else:
|
else:
|
||||||
|
# Same check for current input
|
||||||
|
|
||||||
|
if not self.env['runtime']['cursorManager'].shouldProcessNumpadCommands():
|
||||||
|
for key in self.env['input']['currInput']:
|
||||||
|
if key in numpadKeys:
|
||||||
|
# Return an empty/invalid shortcut that won't match any command
|
||||||
|
return "[]"
|
||||||
|
|
||||||
shortcut.append(self.env['input']['currInput'])
|
shortcut.append(self.env['input']['currInput'])
|
||||||
|
|
||||||
if len(self.env['input']['prevInput']) < len(self.env['input']['currInput']):
|
if len(self.env['input']['prevInput']) < len(self.env['input']['currInput']):
|
||||||
if self.env['input']['shortcutRepeat'] > 1 and not self.shortcutExists(str(shortcut)):
|
if self.env['input']['shortcutRepeat'] > 1 and not self.shortcutExists(str(shortcut)):
|
||||||
shortcut = []
|
shortcut = []
|
||||||
self.env['input']['shortcutRepeat'] = 1
|
self.env['input']['shortcutRepeat'] = 1
|
||||||
shortcut.append(self.env['input']['shortcutRepeat'])
|
shortcut.append(self.env['input']['shortcutRepeat'])
|
||||||
shortcut.append(self.env['input']['currInput'])
|
shortcut.append(self.env['input']['currInput'])
|
||||||
self.env['runtime']['debug'].writeDebugOut("currShortcut " + str(shortcut) ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("currShortcut " + str(shortcut), debug.debugLevel.INFO)
|
||||||
return str(shortcut)
|
return str(shortcut)
|
||||||
|
|
||||||
def currKeyIsModifier(self):
|
def currKeyIsModifier(self):
|
||||||
|
@ -22,7 +22,7 @@ class outputManager():
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
self.env['runtime']['settingsManager'].shutdownDriver('soundDriver')
|
self.env['runtime']['settingsManager'].shutdownDriver('soundDriver')
|
||||||
self.env['runtime']['settingsManager'].shutdownDriver('speechDriver')
|
self.env['runtime']['settingsManager'].shutdownDriver('speechDriver')
|
||||||
|
|
||||||
def presentText(self, text, interrupt=True, soundIcon='', ignorePunctuation=False, announceCapital=False, flush=True):
|
def presentText(self, text, interrupt=True, soundIcon='', ignorePunctuation=False, announceCapital=False, flush=True):
|
||||||
if text == '':
|
if text == '':
|
||||||
return
|
return
|
||||||
@ -58,13 +58,13 @@ class outputManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("setting speech language in outputManager.speakText", debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("setting speech language in outputManager.speakText", debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['speechDriver'].setVoice(self.env['runtime']['settingsManager'].getSetting('speech', 'voice'))
|
self.env['runtime']['speechDriver'].setVoice(self.env['runtime']['settingsManager'].getSetting('speech', 'voice'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Error while setting speech voice in outputManager.speakText", debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Error while setting speech voice in outputManager.speakText", debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if announceCapital:
|
if announceCapital:
|
||||||
self.env['runtime']['speechDriver'].setPitch(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'capitalPitch'))
|
self.env['runtime']['speechDriver'].setPitch(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'capitalPitch'))
|
||||||
@ -73,13 +73,13 @@ class outputManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("setting speech pitch in outputManager.speakText", debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("setting speech pitch in outputManager.speakText", debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['speechDriver'].setRate(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate'))
|
self.env['runtime']['speechDriver'].setRate(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("setting speech rate in outputManager.speakText", debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("setting speech rate in outputManager.speakText", debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['speechDriver'].setModule(self.env['runtime']['settingsManager'].getSetting('speech', 'module'))
|
self.env['runtime']['speechDriver'].setModule(self.env['runtime']['settingsManager'].getSetting('speech', 'module'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -91,7 +91,7 @@ class outputManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("setting speech volume in outputManager.speakText ", debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("setting speech volume in outputManager.speakText ", debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'newLinePause'):
|
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'newLinePause'):
|
||||||
cleanText = text.replace('\n', ' , ')
|
cleanText = text.replace('\n', ' , ')
|
||||||
|
@ -20,7 +20,7 @@ class processManager():
|
|||||||
self.addSimpleEventThread(fenrirEventType.HeartBeat, self.heartBeatTimer, multiprocess=True)
|
self.addSimpleEventThread(fenrirEventType.HeartBeat, self.heartBeatTimer, multiprocess=True)
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
self.terminateAllProcesses()
|
self.terminateAllProcesses()
|
||||||
|
|
||||||
def terminateAllProcesses(self):
|
def terminateAllProcesses(self):
|
||||||
for proc in self._Processes:
|
for proc in self._Processes:
|
||||||
#try:
|
#try:
|
||||||
|
@ -172,7 +172,7 @@ class remoteManager():
|
|||||||
self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True)
|
self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('export_clipboard_to_file:run: Filepath:'+ clipboardFile +' trace:' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('export_clipboard_to_file:run: Filepath:'+ clipboardFile +' trace:' + str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def saveSettings(self, settingConfigPath = None):
|
def saveSettings(self, settingConfigPath = None):
|
||||||
if not settingConfigPath:
|
if not settingConfigPath:
|
||||||
settingConfigPath = self.env['runtime']['settingsManager'].getSettingsFile()
|
settingConfigPath = self.env['runtime']['settingsManager'].getSettingsFile()
|
||||||
|
@ -59,7 +59,7 @@ class screenManager():
|
|||||||
if self.isCurrScreenIgnoredChanged():
|
if self.isCurrScreenIgnoredChanged():
|
||||||
self.env['runtime']['inputManager'].setExecuteDeviceGrab()
|
self.env['runtime']['inputManager'].setExecuteDeviceGrab()
|
||||||
self.env['runtime']['inputManager'].handleDeviceGrab()
|
self.env['runtime']['inputManager'].handleDeviceGrab()
|
||||||
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
if not self.isIgnoredScreen(self.env['screen']['newTTY']):
|
||||||
self.update(eventData, 'onScreenChange')
|
self.update(eventData, 'onScreenChange')
|
||||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||||
else:
|
else:
|
||||||
@ -81,7 +81,7 @@ class screenManager():
|
|||||||
return self.prevScreenIgnored
|
return self.prevScreenIgnored
|
||||||
def updateScreenIgnored(self):
|
def updateScreenIgnored(self):
|
||||||
self.prevScreenIgnored = self.currScreenIgnored
|
self.prevScreenIgnored = self.currScreenIgnored
|
||||||
self.currScreenIgnored = self.isSuspendingScreen(self.env['screen']['newTTY'])
|
self.currScreenIgnored = self.isIgnoredScreen(self.env['screen']['newTTY'])
|
||||||
def update(self, eventData, trigger='onUpdate'):
|
def update(self, eventData, trigger='onUpdate'):
|
||||||
# set new "old" values
|
# set new "old" values
|
||||||
self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes']
|
self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes']
|
||||||
@ -174,16 +174,16 @@ class screenManager():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('screenManager:update:highlight: ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('screenManager:update:highlight: ' + str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def isSuspendingScreen(self, screen = None):
|
def isIgnoredScreen(self, screen = None):
|
||||||
if screen == None:
|
if screen == None:
|
||||||
screen = self.env['screen']['newTTY']
|
screen = self.env['screen']['newTTY']
|
||||||
ignoreScreens = []
|
ignoreScreens = []
|
||||||
fixIgnoreScreens = self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen')
|
fixIgnoreScreens = self.env['runtime']['settingsManager'].getSetting('screen', 'ignoreScreen')
|
||||||
if fixIgnoreScreens != '':
|
if fixIgnoreScreens != '':
|
||||||
ignoreScreens.extend(fixIgnoreScreens.split(','))
|
ignoreScreens.extend(fixIgnoreScreens.split(','))
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
|
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectIgnoreScreen'):
|
||||||
ignoreScreens.extend(self.env['screen']['autoIgnoreScreens'])
|
ignoreScreens.extend(self.env['screen']['autoIgnoreScreens'])
|
||||||
self.env['runtime']['debug'].writeDebugOut('screenManager:isSuspendingScreen ignore:' + str(ignoreScreens) + ' current:'+ str(screen ), debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('screenManager:isIgnoredScreen ignore:' + str(ignoreScreens) + ' current:'+ str(screen ), debug.debugLevel.INFO)
|
||||||
return (screen in ignoreScreens)
|
return (screen in ignoreScreens)
|
||||||
|
|
||||||
def isScreenChange(self):
|
def isScreenChange(self):
|
||||||
|
@ -40,8 +40,8 @@ settingsData = {
|
|||||||
'driver': 'vcsaDriver',
|
'driver': 'vcsaDriver',
|
||||||
'encoding': 'auto',
|
'encoding': 'auto',
|
||||||
'screenUpdateDelay': 0.1,
|
'screenUpdateDelay': 0.1,
|
||||||
'suspendingScreen': '',
|
'ignoreScreen': '',
|
||||||
'autodetectSuspendingScreen': False,
|
'autodetectIgnoreScreen': False,
|
||||||
},
|
},
|
||||||
'general':{
|
'general':{
|
||||||
'debugLevel': debug.debugLevel.DEACTIVE,
|
'debugLevel': debug.debugLevel.DEACTIVE,
|
||||||
|
@ -29,7 +29,7 @@ class speechDriver():
|
|||||||
return
|
return
|
||||||
if not queueable:
|
if not queueable:
|
||||||
self.cancel()
|
self.cancel()
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
|
@ -34,7 +34,7 @@ class tableManager():
|
|||||||
return ''
|
return ''
|
||||||
def setRowColumnSep(self, columnSep = ''):
|
def setRowColumnSep(self, columnSep = ''):
|
||||||
self.rowColumnSep = columnSep
|
self.rowColumnSep = columnSep
|
||||||
|
|
||||||
def setHeadLine(self, headLine = ''):
|
def setHeadLine(self, headLine = ''):
|
||||||
self.setHeadColumnSep()
|
self.setHeadColumnSep()
|
||||||
self.setRowColumnSep()
|
self.setRowColumnSep()
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
version = "2025.02.26"
|
version = "2025.04.28"
|
||||||
codeName = "master"
|
codeName = "master"
|
||||||
|
@ -59,7 +59,7 @@ class driver(inputDriver):
|
|||||||
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
self.env['runtime']['processManager'].addCustomEventThread(self.inputWatchdog)
|
||||||
self._initialized = True
|
self._initialized = True
|
||||||
|
|
||||||
def plugInputDeviceWatchdogUdev(self,active , eventQueue):
|
def plugInputDeviceWatchdogUdev(self, active, eventQueue):
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
monitor = pyudev.Monitor.from_netlink(context)
|
monitor = pyudev.Monitor.from_netlink(context)
|
||||||
monitor.filter_by(subsystem='input')
|
monitor.filter_by(subsystem='input')
|
||||||
@ -72,31 +72,33 @@ class driver(inputDriver):
|
|||||||
self.env['runtime']['debug'].writeDebugOut('plugInputDeviceWatchdogUdev:' + str(device), debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('plugInputDeviceWatchdogUdev:' + str(device), debug.debugLevel.INFO)
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
if device.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
# FIX: Check if attributes exist before accessing them
|
||||||
|
if hasattr(device, 'name') and device.name and device.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||||
ignorePlug = True
|
ignorePlug = True
|
||||||
if device.phys.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
if hasattr(device, 'phys') and device.phys and device.phys.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
||||||
ignorePlug = True
|
ignorePlug = True
|
||||||
if 'BRLTTY' in device.name.upper():
|
if hasattr(device, 'name') and device.name and 'BRLTTY' in device.name.upper():
|
||||||
ignorePlug = True
|
ignorePlug = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("plugInputDeviceWatchdogUdev CHECK NAME CRASH: " + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("plugInputDeviceWatchdogUdev CHECK NAME CRASH: " + str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
if not ignorePlug:
|
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 Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("plugInputDeviceWatchdogUdev APPEND CRASH: " + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("plugInputDeviceWatchdogUdev APPEND CRASH: " + str(e), debug.debugLevel.ERROR)
|
||||||
try:
|
try:
|
||||||
pollTimeout = 1
|
pollTimeout = 1
|
||||||
device = monitor.poll(pollTimeout)
|
device = monitor.poll(pollTimeout)
|
||||||
except:
|
except Exception:
|
||||||
device = None
|
device = None
|
||||||
ignorePlug = False
|
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()
|
||||||
|
|
||||||
def inputWatchdog(self,active , eventQueue):
|
def inputWatchdog(self, active, eventQueue):
|
||||||
try:
|
try:
|
||||||
while active.value:
|
while active.value:
|
||||||
r, w, x = select(self.iDevices, [], [], 0.8)
|
r, w, x = select(self.iDevices, [], [], 0.8)
|
||||||
@ -111,7 +113,7 @@ class driver(inputDriver):
|
|||||||
self.removeDevice(fd)
|
self.removeDevice(fd)
|
||||||
while(event):
|
while(event):
|
||||||
self.env['runtime']['debug'].writeDebugOut('inputWatchdog: EVENT:' + str(event), debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('inputWatchdog: EVENT:' + str(event), debug.debugLevel.INFO)
|
||||||
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
|
self.env['input']['eventBuffer'].append([self.iDevices[fd], self.uDevices[fd], event])
|
||||||
if event.type == evdev.events.EV_KEY:
|
if event.type == evdev.events.EV_KEY:
|
||||||
if not foundKeyInSequence:
|
if not foundKeyInSequence:
|
||||||
foundKeyInSequence = True
|
foundKeyInSequence = True
|
||||||
@ -123,11 +125,11 @@ class driver(inputDriver):
|
|||||||
if not isinstance(currMapEvent['EventName'], str):
|
if not isinstance(currMapEvent['EventName'], str):
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
continue
|
continue
|
||||||
if currMapEvent['EventState'] in [0,1,2]:
|
if currMapEvent['EventState'] in [0, 1, 2]:
|
||||||
eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()})
|
eventQueue.put({"Type": fenrirEventType.KeyboardInput, "Data": currMapEvent.copy()})
|
||||||
eventFired = True
|
eventFired = True
|
||||||
else:
|
else:
|
||||||
if event.type in [2,3]:
|
if event.type in [2, 3]:
|
||||||
foreward = True
|
foreward = True
|
||||||
|
|
||||||
event = self.iDevices[fd].read_one()
|
event = self.iDevices[fd].read_one()
|
||||||
@ -136,7 +138,7 @@ class driver(inputDriver):
|
|||||||
self.writeEventBuffer()
|
self.writeEventBuffer()
|
||||||
self.clearEventBuffer()
|
self.clearEventBuffer()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("INPUT WATCHDOG CRASH: "+str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("INPUT WATCHDOG CRASH: " + str(e), debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def writeEventBuffer(self):
|
def writeEventBuffer(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
@ -146,7 +148,7 @@ class driver(inputDriver):
|
|||||||
if uDevice:
|
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:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def writeUInput(self, uDevice, event):
|
def writeUInput(self, uDevice, event):
|
||||||
@ -156,7 +158,7 @@ class driver(inputDriver):
|
|||||||
time.sleep(0.0000002)
|
time.sleep(0.0000002)
|
||||||
uDevice.syn()
|
uDevice.syn()
|
||||||
|
|
||||||
def updateInputDevices(self, newDevices = None, init = False):
|
def updateInputDevices(self, newDevices=None, init=False):
|
||||||
if init:
|
if init:
|
||||||
self.removeAllDevices()
|
self.removeAllDevices()
|
||||||
|
|
||||||
@ -191,7 +193,7 @@ class driver(inputDriver):
|
|||||||
try:
|
try:
|
||||||
with open(deviceFile) as f:
|
with open(deviceFile) as f:
|
||||||
pass
|
pass
|
||||||
except Exception as e:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
# 3 pos absolute
|
# 3 pos absolute
|
||||||
# 2 pos relative
|
# 2 pos relative
|
||||||
@ -201,22 +203,23 @@ class driver(inputDriver):
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if currDevice.name.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
# FIX: Check if attributes exist before accessing them
|
||||||
|
if hasattr(currDevice, 'name') and currDevice.name and currDevice.name.upper() in ['', 'SPEAKUP', 'FENRIR-UINPUT']:
|
||||||
continue
|
continue
|
||||||
if currDevice.phys.upper() in ['','SPEAKUP','FENRIR-UINPUT']:
|
if hasattr(currDevice, 'phys') and currDevice.phys and currDevice.phys.upper() in ['', 'SPEAKUP', 'FENRIR-UINPUT']:
|
||||||
continue
|
continue
|
||||||
if 'BRLTTY' in currDevice.name.upper():
|
if hasattr(currDevice, 'name') and currDevice.name and 'BRLTTY' in currDevice.name.upper():
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
cap = currDevice.capabilities()
|
cap = currDevice.capabilities()
|
||||||
if mode in ['ALL','NOMICE']:
|
if mode in ['ALL', 'NOMICE']:
|
||||||
if eventType.EV_KEY in cap:
|
if eventType.EV_KEY in cap:
|
||||||
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]) < 60:
|
if len(cap[eventType.EV_KEY]) < 60:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device Skipped (< 60 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.addDevice(currDevice)
|
self.addDevice(currDevice)
|
||||||
@ -224,16 +227,20 @@ class driver(inputDriver):
|
|||||||
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.addDevice(currDevice)
|
self.addDevice(currDevice)
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device Skipped (no EV_KEY):' + currDevice.name,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device Skipped (no EV_KEY):' + currDevice.name, debug.debugLevel.INFO)
|
||||||
elif currDevice.name.upper() in mode.split(','):
|
elif currDevice.name.upper() in mode.split(','):
|
||||||
self.addDevice(currDevice)
|
self.addDevice(currDevice)
|
||||||
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)
|
try:
|
||||||
|
device_name = currDevice.name if hasattr(currDevice, 'name') else "unknown"
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile + ' ' + device_name + ' ' + str(e), debug.debugLevel.INFO)
|
||||||
|
except:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("Device Skipped (Exception): " + deviceFile + ' ' + str(e), debug.debugLevel.INFO)
|
||||||
self.iDeviceNo = len(evdev.list_devices())
|
self.iDeviceNo = len(evdev.list_devices())
|
||||||
self.updateMPiDevicesFD()
|
self.updateMPiDevicesFD()
|
||||||
|
|
||||||
@ -247,6 +254,7 @@ class driver(inputDriver):
|
|||||||
self.iDevicesFD.remove(fd)
|
self.iDevicesFD.remove(fd)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def mapEvent(self, event):
|
def mapEvent(self, event):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return None
|
return None
|
||||||
@ -266,12 +274,12 @@ class driver(inputDriver):
|
|||||||
mEvent['EventSec'] = event.sec
|
mEvent['EventSec'] = event.sec
|
||||||
mEvent['EventUsec'] = event.usec
|
mEvent['EventUsec'] = event.usec
|
||||||
mEvent['EventState'] = event.value
|
mEvent['EventState'] = event.value
|
||||||
mEvent['EventType'] = event.type
|
mEvent['EventType'] = event.type
|
||||||
return mEvent
|
return mEvent
|
||||||
except Exception as e:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getLedState(self, led = 0):
|
def getLedState(self, led=0):
|
||||||
if not self.hasIDevices():
|
if not self.hasIDevices():
|
||||||
return False
|
return False
|
||||||
# 0 = Numlock
|
# 0 = Numlock
|
||||||
@ -281,7 +289,8 @@ class driver(inputDriver):
|
|||||||
if led in dev.leds():
|
if led in dev.leds():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
def toggleLedState(self, led = 0):
|
|
||||||
|
def toggleLedState(self, led=0):
|
||||||
if not self.hasIDevices():
|
if not self.hasIDevices():
|
||||||
return False
|
return False
|
||||||
ledState = self.getLedState(led)
|
ledState = self.getLedState(led)
|
||||||
@ -290,9 +299,10 @@ class driver(inputDriver):
|
|||||||
# 17 LEDs
|
# 17 LEDs
|
||||||
if 17 in self.iDevices[i].capabilities():
|
if 17 in self.iDevices[i].capabilities():
|
||||||
if ledState == 1:
|
if ledState == 1:
|
||||||
self.iDevices[i].set_led(led , 0)
|
self.iDevices[i].set_led(led, 0)
|
||||||
else:
|
else:
|
||||||
self.iDevices[i].set_led(led , 1)
|
self.iDevices[i].set_led(led, 1)
|
||||||
|
|
||||||
def grabAllDevices(self):
|
def grabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return True
|
return True
|
||||||
@ -301,6 +311,7 @@ class driver(inputDriver):
|
|||||||
if not self.gDevices[fd]:
|
if not self.gDevices[fd]:
|
||||||
ok = ok and self.grabDevice(fd)
|
ok = ok and self.grabDevice(fd)
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def ungrabAllDevices(self):
|
def ungrabAllDevices(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return True
|
return True
|
||||||
@ -309,6 +320,7 @@ class driver(inputDriver):
|
|||||||
if self.gDevices[fd]:
|
if self.gDevices[fd]:
|
||||||
ok = ok and self.ungrabDevice(fd)
|
ok = ok and self.ungrabDevice(fd)
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def createUInputDev(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
|
||||||
@ -324,20 +336,21 @@ class driver(inputDriver):
|
|||||||
self.uDevices[fd] = UInput.from_device(self.iDevices[fd], name='fenrir-uinput', phys='fenrir-uinput')
|
self.uDevices[fd] = UInput.from_device(self.iDevices[fd], name='fenrir-uinput', phys='fenrir-uinput')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: compat fallback: ' + str(e),debug.debugLevel.WARNING)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: compat fallback: ' + str(e), debug.debugLevel.WARNING)
|
||||||
dev = self.iDevices[fd]
|
dev = self.iDevices[fd]
|
||||||
cap = dev.capabilities()
|
cap = dev.capabilities()
|
||||||
del cap[0]
|
del cap[0]
|
||||||
self.uDevices[fd] = UInput(
|
self.uDevices[fd] = UInput(
|
||||||
cap,
|
cap,
|
||||||
name = 'fenrir-uinput',
|
name='fenrir-uinput',
|
||||||
phys = 'fenrir-uinput'
|
phys='fenrir-uinput'
|
||||||
)
|
)
|
||||||
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):
|
def addDevice(self, newDevice):
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device added: ' + str(newDevice.fd) + ' ' +str(newDevice),debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device added: ' + str(newDevice.fd) + ' ' + str(newDevice), debug.debugLevel.INFO)
|
||||||
try:
|
try:
|
||||||
self.iDevices[newDevice.fd] = newDevice
|
self.iDevices[newDevice.fd] = newDevice
|
||||||
self.createUInputDev(newDevice.fd)
|
self.createUInputDev(newDevice.fd)
|
||||||
@ -360,10 +373,13 @@ class driver(inputDriver):
|
|||||||
def grabDevice(self, fd):
|
def grabDevice(self, fd):
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# FIX: Handle exception variable scope correctly
|
||||||
|
grab_error = None
|
||||||
try:
|
try:
|
||||||
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)
|
||||||
# Reset modifier keys on successful grab
|
# Reset modifier keys on successful grab
|
||||||
if self.uDevices[fd]:
|
if self.uDevices[fd]:
|
||||||
modifierKeys = [e.KEY_LEFTCTRL, e.KEY_RIGHTCTRL, e.KEY_LEFTALT, e.KEY_RIGHTALT, e.KEY_LEFTSHIFT, e.KEY_RIGHTSHIFT]
|
modifierKeys = [e.KEY_LEFTCTRL, e.KEY_RIGHTCTRL, e.KEY_LEFTALT, e.KEY_RIGHTALT, e.KEY_LEFTSHIFT, e.KEY_RIGHTSHIFT]
|
||||||
@ -371,33 +387,44 @@ class driver(inputDriver):
|
|||||||
try:
|
try:
|
||||||
self.uDevices[fd].write(e.EV_KEY, key, 0) # 0 = key up
|
self.uDevices[fd].write(e.EV_KEY, key, 0) # 0 = key up
|
||||||
self.uDevices[fd].syn()
|
self.uDevices[fd].syn()
|
||||||
except Exception as e:
|
except Exception as mod_error:
|
||||||
self.env['runtime']['debug'].writeDebugOut('Failed to reset modifier key: ' + str(e), debug.debugLevel.WARNING)
|
self.env['runtime']['debug'].writeDebugOut('Failed to reset modifier key: ' + str(mod_error), debug.debugLevel.WARNING)
|
||||||
except IOError:
|
except IOError:
|
||||||
if not self.gDevices[fd]:
|
if not self.gDevices[fd]:
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as ex:
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
|
grab_error = ex
|
||||||
|
|
||||||
|
if grab_error:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(grab_error), debug.debugLevel.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def ungrabDevice(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 True
|
return True
|
||||||
|
|
||||||
|
# FIX: Handle exception variable scope correctly
|
||||||
|
ungrab_error = None
|
||||||
try:
|
try:
|
||||||
self.iDevices[fd].ungrab()
|
self.iDevices[fd].ungrab()
|
||||||
self.gDevices[fd] = False
|
self.gDevices[fd] = False
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: ungrab device ('+ str(self.iDevices[fd].name) + ')',debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: ungrab device (' + str(self.iDevices[fd].name) + ')', debug.debugLevel.INFO)
|
||||||
except IOError:
|
except IOError:
|
||||||
if self.gDevices[fd]:
|
if self.gDevices[fd]:
|
||||||
return False
|
return False
|
||||||
# self.gDevices[fd] = False
|
except Exception as ex:
|
||||||
# #self.removeDevice(fd)
|
ungrab_error = ex
|
||||||
except Exception as e:
|
|
||||||
|
if ungrab_error:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: ungrabing not possible: ' + str(ungrab_error), debug.debugLevel.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
def removeDevice(self,fd):
|
|
||||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' +str(self.iDevices[fd]),debug.debugLevel.INFO)
|
def removeDevice(self, fd):
|
||||||
|
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: device removed: ' + str(fd) + ' ' + str(self.iDevices[fd]), debug.debugLevel.INFO)
|
||||||
self.clearEventBuffer()
|
self.clearEventBuffer()
|
||||||
try:
|
try:
|
||||||
self.ungrabDevice(fd)
|
self.ungrabDevice(fd)
|
||||||
@ -452,4 +479,4 @@ class driver(inputDriver):
|
|||||||
self.iDevices.clear()
|
self.iDevices.clear()
|
||||||
self.uDevices.clear()
|
self.uDevices.clear()
|
||||||
self.gDevices.clear()
|
self.gDevices.clear()
|
||||||
self.iDeviceNo = 0
|
self.iDeviceNo = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user