prepare for remake input handling, prepare other stuff

This commit is contained in:
chrys 2016-09-02 21:37:36 +02:00
parent 1998ca15e8
commit 7227f52ac7
81 changed files with 705 additions and 314 deletions

1
TODO
View File

@ -14,6 +14,7 @@ ToDos in Priority order:
possiblity to forewart shortcut [proxyshortcut] [x] possiblity to forewart shortcut [proxyshortcut] [x]
possiblity to forewart shortcut [pressing twice while timeout] [] possiblity to forewart shortcut [pressing twice while timeout] []
cleanup inputManager [-] cleanup inputManager [-]
split input driver out of the handler
- add setting for autodetect X - add setting for autodetect X
- dictonary for special chars and string replacements - dictonary for special chars and string replacements

View File

@ -60,6 +60,7 @@ suspendingScreen=1,2
autodetectSuspendingScreen=False autodetectSuspendingScreen=False
[keyboard] [keyboard]
driver=evdev
device=all device=all
# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. # gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems.
grabDevices=True grabDevices=True

View File

@ -27,6 +27,7 @@ suspendingScreen=1,2
autodetectSuspendingScreen=False autodetectSuspendingScreen=False
[keyboard] [keyboard]
driver=evdev
device=all device=all
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False

View File

@ -60,6 +60,7 @@ suspendingScreen=1,2
autodetectSuspendingScreen=False autodetectSuspendingScreen=False
[keyboard] [keyboard]
driver=evdev
device=all device=all
# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. # gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems.
grabDevices=True grabDevices=True

View File

@ -27,6 +27,7 @@ suspendingScreen=7
autodetectSuspendingScreen=False autodetectSuspendingScreen=False
[keyboard] [keyboard]
driver=evdev
device=all device=all
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False

View File

@ -3,9 +3,13 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -7,6 +7,12 @@ import termios
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['commandBuffer']['currClipboard'] = -1 environment['commandBuffer']['currClipboard'] = -1
del environment['commandBuffer']['clipboard'][:] del environment['commandBuffer']['clipboard'][:]
@ -14,5 +20,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -5,6 +5,12 @@ from utils import mark_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if (environment['commandBuffer']['Marks']['1'] == None) or \ if (environment['commandBuffer']['Marks']['1'] == None) or \
(environment['commandBuffer']['Marks']['2'] == None): (environment['commandBuffer']['Marks']['2'] == None):
@ -33,5 +39,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import char_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import char_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if (environment['screenData']['newCursorReview'] != None): if (environment['screenData']['newCursorReview'] != None):
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = environment['screenData']['newCursorReview'].copy()
@ -21,5 +27,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0: if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
@ -11,5 +17,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import line_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if environment['screenData']['newContentText'].strip() == '': if environment['screenData']['newContentText'].strip() == '':
environment['runtime']['outputManager'].presentText(environment, "screen is empty", soundIcon='EmptyLine', interrupt=True) environment['runtime']['outputManager'].presentText(environment, "screen is empty", soundIcon='EmptyLine', interrupt=True)
@ -11,5 +17,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -5,6 +5,12 @@ from utils import mark_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
if (environment['screenData']['newCursorReview'] != None): if (environment['screenData']['newCursorReview'] != None):
@ -21,5 +27,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -5,6 +5,12 @@ from utils import mark_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
if (environment['screenData']['newCursorReview'] != None): if (environment['screenData']['newCursorReview'] != None):
@ -21,5 +27,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import word_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -5,6 +5,12 @@ from utils import char_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if (environment['screenData']['newCursorReview'] != None): if (environment['screenData']['newCursorReview'] != None):
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = environment['screenData']['newCursorReview'].copy()
@ -24,5 +30,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
@ -16,5 +22,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -5,14 +5,13 @@ import datetime
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
#this is the way to load the settings:
# general is the section in the config file, timeFormat is the variable
# this has to been added to settings.conf in sectino [general]
# dateFormat="%A, %B %d, %Y"
# the following has to been added to core/settings.py to the key 'general'
# the settings.py is used for default values
# dateFormat="%A, %B %d, %Y"
dateFormat = environment['runtime']['settingsManager'].getSetting(environment,'general', 'dateFormat') dateFormat = environment['runtime']['settingsManager'].getSetting(environment,'general', 'dateFormat')
# get the time formatted # get the time formatted
@ -24,5 +23,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume')
@ -18,5 +24,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')
@ -18,5 +24,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')
@ -18,5 +24,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume')
@ -18,5 +24,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if (environment['screenData']['oldCursorReview'] == None) and \ if (environment['screenData']['oldCursorReview'] == None) and \
(environment['screenData']['newCursorReview'] == None): (environment['screenData']['newCursorReview'] == None):
@ -15,5 +21,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -7,6 +7,12 @@ import termios
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0: if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
@ -16,5 +22,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,11 +3,15 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['input']['keyForeward'] = True environment['input']['keyForeward'] = True
environment['runtime']['outputManager'].presentText(environment, 'Foreward next keypress', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'Foreward next keypress', interrupt=True)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume')
@ -18,5 +24,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')
@ -18,5 +24,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')
@ -18,5 +24,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import math
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume') value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume')
@ -18,5 +24,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import line_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
@ -21,5 +27,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -7,6 +7,12 @@ import termios
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0: if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
@ -16,5 +22,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,10 +3,14 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True) environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -7,6 +7,12 @@ import time
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
currClipboard = environment['commandBuffer']['currClipboard'] currClipboard = environment['commandBuffer']['currClipboard']
if currClipboard < 0: if currClipboard < 0:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import mark_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if (environment['commandBuffer']['Marks']['1'] == None) or \ if (environment['commandBuffer']['Marks']['1'] == None) or \
(environment['commandBuffer']['Marks']['2'] == None): (environment['commandBuffer']['Marks']['2'] == None):
@ -25,5 +31,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import char_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -7,6 +7,12 @@ import termios
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0: if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
@ -21,5 +27,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import line_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import word_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import char_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -7,6 +7,12 @@ import termios
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0: if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
@ -21,5 +27,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import line_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import word_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,10 +3,15 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['generalInformation']['running'] = False environment['generalInformation']['running'] = False
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['commandBuffer']['Marks']['1'] = None environment['commandBuffer']['Marks']['1'] = None
environment['commandBuffer']['Marks']['2'] = None environment['commandBuffer']['Marks']['2'] = None
@ -11,5 +17,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import char_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['screenData']['newCursorReview'] = {'x':0,'y':0} environment['screenData']['newCursorReview'] = {'x':0,'y':0}
@ -11,5 +17,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if environment['screenData']['newCursorReview'] == None: if environment['screenData']['newCursorReview'] == None:
environment['runtime']['outputManager'].presentText(environment, 'no review cursor', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'no review cursor', interrupt=True)
@ -21,5 +27,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,9 +3,13 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment['runtime']['outputManager'].interruptOutput(environment) environment['runtime']['outputManager'].interruptOutput(environment)
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -5,14 +5,13 @@ import datetime
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
#this is the way to load the settings:
# general is the section in the config file, timeFormat is the variable
# this has to been added to settings.conf in sectino [general]
# timeFormat=%I:%M%P
# the following has to been added to core/settings.py to the key 'general'
# the settings.py is used for default values
# 'timeFormat':"%I:%M%P",
timeFormat = environment['runtime']['settingsManager'].getSetting(environment,'general', 'timeFormat') timeFormat = environment['runtime']['settingsManager'].getSetting(environment,'general', 'timeFormat')
# get the time formatted # get the time formatted
@ -24,5 +23,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'autoReadIncomming', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'))) environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'autoReadIncomming', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming')))
@ -13,5 +19,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
@ -13,5 +19,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled') or \ if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled') or \
environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled') or \ environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled') or \
@ -19,5 +25,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
@ -13,5 +19,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
@ -13,5 +19,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'interruptOnKeyPress'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'interruptOnKeyPress'):
return environment return environment
@ -17,5 +23,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@ import time
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
# TTY Change # TTY Change
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
@ -26,5 +32,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
return environment return environment
@ -18,5 +24,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,8 +3,14 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho'):
return environment return environment
# detect deletion or chilling # detect deletion or chilling
@ -24,5 +30,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ from utils import word_utils
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho'):
return environment return environment
@ -44,5 +50,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charDeleteEcho'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charDeleteEcho'):
@ -29,5 +35,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'):
return environment return environment
@ -22,5 +28,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -4,6 +4,12 @@ import time
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'promote', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'promote', 'enabled'):
return environment return environment
@ -24,5 +30,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']:
@ -13,5 +19,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']:
return environment return environment
@ -12,5 +18,4 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command(): class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return ''
def run(self, environment): def run(self, environment):
if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']:
return environment return environment
@ -11,5 +17,3 @@ class command():
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self):
pass

View File

@ -8,7 +8,10 @@ from utils import debug
class commandManager(): class commandManager():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def loadCommands(self, environment, section='commands'): def loadCommands(self, environment, section='commands'):
commandFolder = "commands/" + section +"/" commandFolder = "commands/" + section +"/"
commandList = glob.glob(commandFolder+'*') commandList = glob.glob(commandFolder+'*')
@ -23,6 +26,7 @@ class commandManager():
command_mod = importlib.util.module_from_spec(spec) command_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(command_mod) spec.loader.exec_module(command_mod)
environment['commands'][section][fileName] = command_mod.command() environment['commands'][section][fileName] = command_mod.command()
environment['commands'][section][fileName].initialize(environment)
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Error while loading command:" + currCommand ,debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,"Error while loading command:" + currCommand ,debug.debugLevel.ERROR)

View File

@ -2,7 +2,10 @@
import time import time
input = { input = {
'currShortcut': {}, 'currInput': {},
'prevInput': {},
'currEvent': None,
'firstEvent': {},
'currShortcutString': '', 'currShortcutString': '',
'consumeKey': False, 'consumeKey': False,
'fenrirKey': ['82'], 'fenrirKey': ['82'],

View File

@ -1,75 +1,36 @@
#!/bin/python #!/bin/python
import evdev
from evdev import InputDevice, UInput
from select import select
import time import time
from utils import debug from utils import debug
class inputManager(): class inputManager():
def __init__(self): def __init__(self):
self.iDevices = {} pass
self.uDevices = {} def initialize(self, environment):
self.getInputDevices() return environment
self.grabDevices() def shutdown(self, environment):
self.ignoreKeyRelease = 0 return environment
def getInput(self, environment):
environment, timeout = environment['runtime']['inputDriver'].getInput(environment)
return environment, timeout
def grabDevices(self, environment):
environment['runtime']['inputDriver'].grabDevices(environment)
def proceedInputEvents(self, environment): def releaseDevices(self, environment):
timeout = True environment['runtime']['inputDriver'].releaseDevices(environment)
if not environment['input']['keyForeward']:
self.ignoreKeyRelease = 0 def isConsumeInput(self, environment):
try: return environment['input']['consumeKey'] and \
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) not environment['input']['keyForeward'] or \
if r != []:
timeout = False
for fd in r:
for event in self.iDevices[fd].read():
if self.isFenrirKey(environment, event):
environment['input']['consumeKey'] = not environment['input']['keyForeward'] and not environment['generalInformation']['suspend']
if self.isConsumeKeypress(environment):
self.writeUInput(self.uDevices[fd], event,environment)
keyString = ''
if self.isFenrirKey(environment, event):
keyString = 'FENRIR'
else:
keyString = str(event.code)
if event.type == evdev.ecodes.EV_KEY:
if event.value != 0:
environment['input']['currShortcut'][keyString] = 1 #event.value
else:
try:
del(environment['input']['currShortcut'][keyString])
except:
pass
except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"Error while inputHandling",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
self.freeDevices()
time.sleep(0.01)
environment['input']['currShortcutString'] = self.getShortcutString(environment)
if not timeout:
environment['input']['lastInputTime'] = time.time()
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
self.ignoreKeyRelease += 1
if self.ignoreKeyRelease >= 2: # a hack... has to bee done more clean
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
return environment, timeout
def isConsumeKeypress(self, environment):
return not environment['input']['consumeKey'] or \
environment['input']['keyForeward'] or \
not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices') not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')
def writeUInput(self, uDevice, event,environment): def passInput(self, environment):
try: try:
uDevice.write_event(event) environment['runtime']['inputDriver']
uDevice.syn()
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR)
return environment
def getShortcutString(self, environment): def getShortcutString(self, environment):
if environment['input']['currShortcut'] == {}: if environment['input']['currShortcut'] == {}:
return '' return ''
@ -78,50 +39,6 @@ class inputManager():
currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key)) currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key))
currShortcutStringList = sorted(currShortcutStringList) currShortcutStringList = sorted(currShortcutStringList)
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","") return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
def isFenrirKey(self,environment, event): def isFenrirKey(self,environment, event):
return str(event.code) in environment['input']['fenrirKey'] return str(event.code) in environment['input']['fenrirKey']
def getInputDevices(self):
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
def grabDevices(self):
# if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'):
# return
for fd in self.iDevices:
dev = self.iDevices[fd]
cap = dev.capabilities()
del cap[0]
self.uDevices[fd] = UInput(
cap,
dev.name,
#dev.info.vendor,
#dev.info.product,
#dev.version,
#dev.info.bustype,
#'/dev/uinput'
)
dev.grab()
def freeDevices(self):
for fd in self.iDevices:
try:
self.iDevices[fd].ungrab()
except:
pass
try:
self.iDevices[fd].close()
except:
pass
try:
self.uDevices[fd].close()
except:
pass
self.iDevices.clear()
self.uDevices.clear()
def __del__(self):
self.freeDevices()

View File

@ -4,6 +4,10 @@ from utils import debug
class outputManager(): class outputManager():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def presentText(self, environment, text, interrupt=True, soundIcon = ''): def presentText(self, environment, text, interrupt=True, soundIcon = ''):
environment['runtime']['debug'].writeDebugOut(environment,"presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO) environment['runtime']['debug'].writeDebugOut(environment,"presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO)
if self.playSoundIcon(environment, soundIcon, interrupt): if self.playSoundIcon(environment, soundIcon, interrupt):

View File

@ -1,13 +1,13 @@
#!/bin/python #!/bin/python
from _thread import allocate_lock
runtime = { runtime = {
'speechDriver': None, 'speechDriver': None,
'screenDriver': None, 'screenDriver': None,
'soundDriver': None, 'soundDriver': None,
'inputDriver': None,
'brailleDriver': None, 'brailleDriver': None,
'inputManager': None, 'inputManager': None,
'commandManager': None, 'commandManager': None,
'screenManager': None,
'debug':None, 'debug':None,
'globalLock': allocate_lock(),
} }

View File

@ -1,5 +1,7 @@
#!/bin/python #!/bin/python
import time
screenData = { screenData = {
'columns': 0, 'columns': 0,
'lines': 0, 'lines': 0,
@ -19,4 +21,5 @@ screenData = {
'newContentAttrib': b'', 'newContentAttrib': b'',
'oldTTY':'-1', 'oldTTY':'-1',
'newTTY':'0', 'newTTY':'0',
'lastScreenUpdate': time.time()
} }

View File

@ -0,0 +1,21 @@
#!/bin/python
import time
from utils import debug
class screenManager():
def __init__(self):
pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def update(self, environment):
environment['generalInformation']['suspend'] = self.isSuspendingScreen(environment)
if not environment['generalInformation']['suspend']:
environment = environment['runtime']['screenDriver'].update(environment)
return environment
def isSuspendingScreen(self, environment):
return environment['generalInformation']['suspend'] = environment['runtime']['screenDriver'].getCurrScreen() in \
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'suspendingScreen').split(',')

View File

@ -6,6 +6,7 @@ from configparser import ConfigParser
from core import inputManager from core import inputManager
from core import outputManager from core import outputManager
from core import commandManager from core import commandManager
from core import screenManager
from core import environment from core import environment
from core.settings import settings from core.settings import settings
from utils import debug from utils import debug
@ -13,7 +14,10 @@ from utils import debug
class settingsManager(): class settingsManager():
def __init__(self): def __init__(self):
self.settings = settings self.settings = settings
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.conf'): def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.conf'):
kbConfig = open(kbConfigPath,"r") kbConfig = open(kbConfigPath,"r")
while(True): while(True):
@ -155,6 +159,7 @@ class settingsManager():
driver_mod = importlib.util.module_from_spec(spec) driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod) spec.loader.exec_module(driver_mod)
environment['runtime']['speechDriver'] = driver_mod.speech() environment['runtime']['speechDriver'] = driver_mod.speech()
environment['runtime']['speechDriver'].initialize(environment)
return environment return environment
def loadSoundDriver(self, environment, driverName): def loadSoundDriver(self, environment, driverName):
@ -163,7 +168,8 @@ class settingsManager():
spec = importlib.util.spec_from_file_location(driverName, 'sound/' + driverName + '.py') spec = importlib.util.spec_from_file_location(driverName, 'sound/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec) driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod) spec.loader.exec_module(driver_mod)
environment['runtime']['soundDriver'] = driver_mod.sound() environment['runtime']['soundDriver'] = driver_mod.sound()
environment['runtime']['soundDriver'].initialize(environment)
return environment return environment
def loadScreenDriver(self, environment, driverName): def loadScreenDriver(self, environment, driverName):
@ -171,6 +177,15 @@ class settingsManager():
driver_mod = importlib.util.module_from_spec(spec) driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod) spec.loader.exec_module(driver_mod)
environment['runtime']['screenDriver'] = driver_mod.screen() environment['runtime']['screenDriver'] = driver_mod.screen()
environment['runtime']['screenDriver'].initialize(environment)
return environment
def loadInputDriver(self, environment, driverName):
spec = importlib.util.spec_from_file_location(driverName, 'input/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['inputDriver'] = driver_mod.screen()
environment['runtime']['inputDriver'].initialize(environment)
return environment return environment
def setFenrirKeys(self, environment, keys): def setFenrirKeys(self, environment, keys):
@ -215,9 +230,20 @@ class settingsManager():
else: else:
environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme'))
environment['runtime']['inputManager'] = inputManager.inputManager() if environment['runtime']['inputManager'] == None:
environment['runtime']['outputManager'] = outputManager.outputManager() environment['runtime']['inputManager'] = inputManager.inputManager()
environment['runtime']['commandManager'] = commandManager.commandManager() environment = environment['runtime']['inputManager'].initialize(environment)
if environment['runtime']['outputManager'] == None:
environment['runtime']['outputManager'] = outputManager.outputManager()
environment = environment['runtime']['outputManager'].initialize(environment)
if environment['runtime']['commandManager'] == None:
environment['runtime']['commandManager'] = commandManager.commandManager()
environment = environment['runtime']['commandManager'].initialize(environment)
if environment['runtime']['screenManager'] == None:
environment['runtime']['screenManager'] = screenManager.screenManager()
environment = environment['runtime']['screenManager'].initialize(environment)
environment = environment['runtime']['commandManager'].loadCommands(environment,'commands') environment = environment['runtime']['commandManager'].loadCommands(environment,'commands')
environment = environment['runtime']['commandManager'].loadCommands(environment,'onInput') environment = environment['runtime']['commandManager'].loadCommands(environment,'onInput')
environment = environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged') environment = environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged')
@ -228,7 +254,8 @@ class settingsManager():
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver')) environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver'))
environment = environment['runtime']['settingsManager'].loadSoundDriver(environment,\ environment = environment['runtime']['settingsManager'].loadSoundDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver')) environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver'))
environment = environment['runtime']['settingsManager'].loadInputDriver(environment,\
environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'))
environment['runtime']['debug'].writeDebugOut(environment,'\/-------environment-------\/',debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,'\/-------environment-------\/',debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(environment),debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,str(environment),debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,'\/-------settings.conf-------\/',debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,'\/-------settings.conf-------\/',debug.debugLevel.ERROR)

View File

@ -20,19 +20,17 @@ class fenrir():
def proceed(self): def proceed(self):
self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True) self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
#self.threadonInput.start()
while(self.environment['generalInformation']['running']): while(self.environment['generalInformation']['running']):
try: try:
self.handleProcess() self.handleProcess()
except Exception as e: except Exception as e:
self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR) self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR)
self.shutdown() self.shutdown()
def handleProcess(self): def handleProcess(self):
self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(self.environment) self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(self.environment)
try: try:
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment) self.environment = self.environment['runtime']['screenManager'].update(self.environment)
except Exception as e: except Exception as e:
self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR) self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR)
if not self.environment['input']['keyForeward']: if not self.environment['input']['keyForeward']:

View File

@ -0,0 +1,110 @@
#!/bin/python
import evdev
from evdev import InputDevice, UInput
from select import select
import time
from utils import debug
class input():
def __init__(self):
self.iDevices = {}
self.uDevices = {}
self.getInputDevices()
self.grabDevices()
self.ignoreKeyRelease = 0
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getInput(self, environment):
timeout = True
if not environment['input']['keyForeward']:
self.ignoreKeyRelease = 0
try:
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay'))
if r != []:
timeout = False
for fd in r:
for event in self.iDevices[fd].read():
if self.isFenrirKey(environment, event):
environment['input']['consumeKey'] = not environment['input']['keyForeward'] and not environment['generalInformation']['suspend']
if self.isConsumeKeypress(environment):
self.writeUInput(self.uDevices[fd], event,environment)
keyString = ''
if self.isFenrirKey(environment, event):
keyString = 'FENRIR'
else:
keyString = str(event.code)
if event.type == evdev.ecodes.EV_KEY:
if event.value != 0:
environment['input']['currShortcut'][keyString] = 1 #event.value
else:
try:
del(environment['input']['currShortcut'][keyString])
except:
pass
except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"Error while inputHandling",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
self.releaseDevices()
time.sleep(0.01)
environment['input']['currShortcutString'] = self.getShortcutString(environment)
if not timeout:
environment['input']['lastInputTime'] = time.time()
environment['input']['consumeKey'] = environment['input']['currShortcut'] != {} and environment['input']['consumeKey']
if (environment['input']['keyForeward'] and environment['input']['currShortcut'] == {}):
self.ignoreKeyRelease += 1
if self.ignoreKeyRelease >= 2: # a hack... has to bee done more clean
environment['input']['keyForeward'] = environment['input']['keyForeward'] and not environment['input']['currShortcut'] == {}
return environment, timeout
def writeUInput(self, uDevice, event,environment):
uDevice.write_event(event)
uDevice.syn()
def getInputDevices(self):
self.iDevices = map(evdev.InputDevice, (evdev.list_devices()))
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
def grabDevices(self):
# if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'):
# return
for fd in self.iDevices:
dev = self.iDevices[fd]
cap = dev.capabilities()
del cap[0]
self.uDevices[fd] = UInput(
cap,
dev.name,
#dev.info.vendor,
#dev.info.product,
#dev.version,
#dev.info.bustype,
#'/dev/uinput'
)
#dev.grab()
def releaseDevices(self):
for fd in self.iDevices:
try:
self.iDevices[fd].ungrab()
except:
pass
try:
self.iDevices[fd].close()
except:
pass
try:
self.uDevices[fd].close()
except:
pass
self.iDevices.clear()
self.uDevices.clear()
def __del__(self):
self.releaseDevices()

View File

@ -7,20 +7,30 @@ import re
from utils import debug from utils import debug
class screen(): class screen():
def __init__(self, device='/dev/vcsa'): def __init__(self):
self.vcsaDevicePath = device self.vcsaDevicePath = '/dev/vcsa'
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def insert_newlines(self, string, every=64): def insert_newlines(self, string, every=64):
return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
def getCurrScreen(self):
def analyzeScreen(self, environment, trigger='updateScreen'): try:
currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r')
currScreen = currScreenFile.read()[3:-1]
currScreenFile.close()
except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
return -1
return currScreen
def update(self, environment, trigger='updateScreen'):
newTTY = '' newTTY = ''
newContentBytes = b'' newContentBytes = b''
try: try:
# read screen # read screen
currTTY = open('/sys/devices/virtual/tty/tty0/active','r') newTTY = self.getCurrScreen()
newTTY = currTTY.read()[3:-1]
currTTY.close()
vcsa = open(self.vcsaDevicePath + newTTY,'rb',0) vcsa = open(self.vcsaDevicePath + newTTY,'rb',0)
newContentBytes = vcsa.read() newContentBytes = vcsa.read()
vcsa.close() vcsa.close()
@ -30,8 +40,6 @@ class screen():
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
return environment return environment
screenEncoding = environment['runtime']['settingsManager'].getSetting(environment,'screen', 'encoding') screenEncoding = environment['runtime']['settingsManager'].getSetting(environment,'screen', 'encoding')
environment['generalInformation']['suspend'] = newTTY in \
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'suspendingScreen').split(',')
# set new "old" values # set new "old" values
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes'] environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes']
environment['screenData']['oldContentText'] = environment['screenData']['newContentText'] environment['screenData']['oldContentText'] = environment['screenData']['newContentText']

View File

@ -18,8 +18,32 @@ class sound:
self.volume = 1 self.volume = 1
if not _gstreamerAvailable: if not _gstreamerAvailable:
return return
self.init() def initialize(self, environment):
if self._initialized:
return environment
if not _gstreamerAvailable:
return environment
self._player = Gst.ElementFactory.make('playbin', 'player')
bus = self._player.get_bus()
bus.add_signal_watch()
bus.connect("message", self._onPlayerMessage)
self._pipeline = Gst.Pipeline(name='fenrir-pipeline')
bus = self._pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", self._onPipelineMessage)
self._source = Gst.ElementFactory.make('audiotestsrc', 'src')
self._sink = Gst.ElementFactory.make('autoaudiosink', 'output')
self._pipeline.add(self._source)
self._pipeline.add(self._sink)
self._source.link(self._sink)
self._initialized = True
return environment
def shutdown(self, environment):
return environment
def _onPlayerMessage(self, bus, message): def _onPlayerMessage(self, bus, message):
if message.type == Gst.MessageType.EOS: if message.type == Gst.MessageType.EOS:
@ -58,30 +82,6 @@ class sound:
duration = int(1000 * tone.duration) duration = int(1000 * tone.duration)
GLib.timeout_add(duration, self._onTimeout, self._pipeline) GLib.timeout_add(duration, self._onTimeout, self._pipeline)
def init(self):
if self._initialized:
return
if not _gstreamerAvailable:
return
self._player = Gst.ElementFactory.make('playbin', 'player')
bus = self._player.get_bus()
bus.add_signal_watch()
bus.connect("message", self._onPlayerMessage)
self._pipeline = Gst.Pipeline(name='fenrir-pipeline')
bus = self._pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", self._onPipelineMessage)
self._source = Gst.ElementFactory.make('audiotestsrc', 'src')
self._sink = Gst.ElementFactory.make('autoaudiosink', 'output')
self._pipeline.add(self._source)
self._pipeline.add(self._sink)
self._source.link(self._sink)
self._initialized = True
def cancel(self, element=None): def cancel(self, element=None):
if not _gstreamerAvailable: if not _gstreamerAvailable:
return return

View File

@ -4,6 +4,10 @@ import subprocess
class sound(): class sound():
def __init__(self): def __init__(self):
self.volume = 1.0; self.volume = 1.0;
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def playFrequence(self, frequence, duration, adjustVolume): def playFrequence(self, frequence, duration, adjustVolume):
pass pass
def playSoundFile(self, filePath, interrupt = True): def playSoundFile(self, filePath, interrupt = True):

View File

@ -3,7 +3,9 @@
# Espeak driver # Espeak driver
class speech(): class speech():
def __init__(self, ): def __init__(self ):
pass
def initialize(self, environment):
self._es = None self._es = None
self._isInitialized = False self._isInitialized = False
try: try:
@ -12,12 +14,15 @@ class speech():
self._isInitialized = True self._isInitialized = True
except: except:
self._initialized = False self._initialized = False
return environment
def shutdown(self, environment):
return environment
def speak(self,text, queueable=True): def speak(self,text, queueable=True):
if not self._isInitialized: if not self._isInitialized:
return False return False
if queueable == False: self.cancel() if not queueable:
self.cancel()
self._es.synth(text) self._es.synth(text)
return True return True
@ -43,13 +48,13 @@ class speech():
def setPitch(self, pitch): def setPitch(self, pitch):
if not self._isInitialized: if not self._isInitialized:
return False return False
return self._es.set_parameter(self._es.Parameter().Pitch, int(pitch * 99))
def setRate(self, rate): def setRate(self, rate):
if not self._isInitialized: if not self._isInitialized:
return False return False
return self._es.set_parameter(self._es.Parameter().Rate, int(rate*450 + 80)) return self._es.set_parameter(self._es.Parameter().Rate, int(rate*450 + 80))
return self._es.set_parameter(self._es.Parameter().Pitch, int(pitch * 99))
def setModule(self, module): def setModule(self, module):
if not self._isInitialized: if not self._isInitialized:
return False return False

View File

@ -1,20 +1,61 @@
#!/usr/bin/python #!/usr/bin/python
# Generic speech driver # generic driver
class speech(): class speech():
def __init__(self, ): def __init__(self ):
self.gn = None pass
self.isInitialized = False def initialize(self, environment):
# try: self._isInitialized = False
return environment
def shutdown(self, environment):
return environment
def speak(self,text, queueable=True): def speak(self,text, queueable=True):
if queueable == False: self.stop() if not self._isInitialized:
self.gn.synth(text) return False
if not queueable:
self.cancel()
return True
def stop(self): def cancel(self):
self.gn.cancel() if not self._isInitialized:
return False
return True
def setCallback(self, callback):
pass
def clear_buffer(self): def clear_buffer(self):
pass if not self._isInitialized:
return False
return True
def setVoice(self, voice):
if not self._isInitialized:
return False
return True
def setPitch(self, pitch):
if not self._isInitialized:
return False
return True
def setRate(self, rate):
if not self._isInitialized:
return False
return True
def setModule(self, module):
if not self._isInitialized:
return False
def setLanguage(self, language):
if not self._isInitialized:
return False
return True
def setVolume(self, volume):
if not self._isInitialized:
return False
return True

View File

@ -13,8 +13,16 @@ class speech():
self._isInitialized = True self._isInitialized = True
except: except:
self._initialized = False self._initialized = False
def initialize(self, environment):
return environment
def shutdown(self, environment):
if not self._isInitialized:
return environment
self._isInitialized = False
self.cancel()
self._sd.close()
return environment
def speak(self,text, queueable=True): def speak(self,text, queueable=True):
if not self._isInitialized: if not self._isInitialized:
return False return False
@ -86,11 +94,4 @@ class speech():
if not self._isInitialized: if not self._isInitialized:
return False return False
self._sd.set_volume(int(-100 + volume * 200)) self._sd.set_volume(int(-100 + volume * 200))
def shutdown(self):
if not self._isInitialized:
return False
self._isInitialized = False
self.cancel()
self._sd.close()
return True