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 [pressing twice while timeout] []
cleanup inputManager [-]
split input driver out of the handler
- add setting for autodetect X
- dictonary for special chars and string replacements

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,14 +5,13 @@ import datetime
class command():
def __init__(self):
pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
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')
# get the time formatted
@ -24,5 +23,3 @@ class command():
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,14 +5,13 @@ import datetime
class command():
def __init__(self):
pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
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')
# get the time formatted
@ -24,5 +23,3 @@ class command():
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -3,6 +3,12 @@
class command():
def __init__(self):
pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def getDescription(self):
return 'No Description found'
def run(self, environment):
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
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,75 +1,36 @@
#!/bin/python
import evdev
from evdev import InputDevice, UInput
from select import select
import time
from utils import debug
class inputManager():
def __init__(self):
self.iDevices = {}
self.uDevices = {}
self.getInputDevices()
self.grabDevices()
self.ignoreKeyRelease = 0
def proceedInputEvents(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.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'] == {}
def initialize(self, environment):
return environment
def shutdown(self, environment):
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 isConsumeKeypress(self, environment):
return not environment['input']['consumeKey'] or \
environment['input']['keyForeward'] or \
def releaseDevices(self, environment):
environment['runtime']['inputDriver'].releaseDevices(environment)
def isConsumeInput(self, environment):
return environment['input']['consumeKey'] and \
not environment['input']['keyForeward'] or \
not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')
def writeUInput(self, uDevice, event,environment):
def passInput(self, environment):
try:
uDevice.write_event(event)
uDevice.syn()
environment['runtime']['inputDriver']
except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR)
return environment
def getShortcutString(self, environment):
if environment['input']['currShortcut'] == {}:
return ''
@ -78,50 +39,6 @@ class inputManager():
currShortcutStringList.append("%s-%s" % (environment['input']['currShortcut'][key], key))
currShortcutStringList = sorted(currShortcutStringList)
return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","")
def isFenrirKey(self,environment, event):
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():
def __init__(self):
pass
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def presentText(self, environment, text, interrupt=True, soundIcon = ''):
environment['runtime']['debug'].writeDebugOut(environment,"presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO)
if self.playSoundIcon(environment, soundIcon, interrupt):

View File

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

View File

@ -1,5 +1,7 @@
#!/bin/python
import time
screenData = {
'columns': 0,
'lines': 0,
@ -19,4 +21,5 @@ screenData = {
'newContentAttrib': b'',
'oldTTY':'-1',
'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 outputManager
from core import commandManager
from core import screenManager
from core import environment
from core.settings import settings
from utils import debug
@ -13,7 +14,10 @@ from utils import debug
class settingsManager():
def __init__(self):
self.settings = settings
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.conf'):
kbConfig = open(kbConfigPath,"r")
while(True):
@ -155,6 +159,7 @@ class settingsManager():
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['speechDriver'] = driver_mod.speech()
environment['runtime']['speechDriver'].initialize(environment)
return environment
def loadSoundDriver(self, environment, driverName):
@ -164,6 +169,7 @@ class settingsManager():
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['soundDriver'] = driver_mod.sound()
environment['runtime']['soundDriver'].initialize(environment)
return environment
def loadScreenDriver(self, environment, driverName):
@ -171,6 +177,15 @@ class settingsManager():
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
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
def setFenrirKeys(self, environment, keys):
@ -215,9 +230,20 @@ class settingsManager():
else:
environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme'))
if environment['runtime']['inputManager'] == None:
environment['runtime']['inputManager'] = inputManager.inputManager()
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,'onInput')
environment = environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged')
@ -228,7 +254,8 @@ class settingsManager():
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver'))
environment = environment['runtime']['settingsManager'].loadSoundDriver(environment,\
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,str(environment),debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,'\/-------settings.conf-------\/',debug.debugLevel.ERROR)

View File

@ -20,19 +20,17 @@ class fenrir():
def proceed(self):
self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
#self.threadonInput.start()
while(self.environment['generalInformation']['running']):
try:
self.handleProcess()
except Exception as e:
self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR)
self.shutdown()
def handleProcess(self):
self.environment, timeout = self.environment['runtime']['inputManager'].proceedInputEvents(self.environment)
try:
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment)
self.environment = self.environment['runtime']['screenManager'].update(self.environment)
except Exception as e:
self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR)
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
class screen():
def __init__(self, device='/dev/vcsa'):
self.vcsaDevicePath = device
def __init__(self):
self.vcsaDevicePath = '/dev/vcsa'
def initialize(self, environment):
return environment
def shutdown(self, environment):
return environment
def insert_newlines(self, string, every=64):
return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
def getCurrScreen(self):
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 analyzeScreen(self, environment, trigger='updateScreen'):
def update(self, environment, trigger='updateScreen'):
newTTY = ''
newContentBytes = b''
try:
# read screen
currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
newTTY = currTTY.read()[3:-1]
currTTY.close()
newTTY = self.getCurrScreen()
vcsa = open(self.vcsaDevicePath + newTTY,'rb',0)
newContentBytes = vcsa.read()
vcsa.close()
@ -30,8 +40,6 @@ class screen():
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
return environment
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
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes']
environment['screenData']['oldContentText'] = environment['screenData']['newContentText']

View File

@ -18,8 +18,32 @@ class sound:
self.volume = 1
if not _gstreamerAvailable:
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):
if message.type == Gst.MessageType.EOS:
@ -58,30 +82,6 @@ class sound:
duration = int(1000 * tone.duration)
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):
if not _gstreamerAvailable:
return

View File

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

View File

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

View File

@ -1,20 +1,61 @@
#!/usr/bin/python
# Generic speech driver
# generic driver
class speech():
def __init__(self, ):
self.gn = None
self.isInitialized = False
# try:
def __init__(self ):
pass
def initialize(self, environment):
self._isInitialized = False
return environment
def shutdown(self, environment):
return environment
def speak(self,text, queueable=True):
if queueable == False: self.stop()
self.gn.synth(text)
if not self._isInitialized:
return False
if not queueable:
self.cancel()
return True
def stop(self):
self.gn.cancel()
def cancel(self):
if not self._isInitialized:
return False
return True
def setCallback(self, callback):
pass
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,7 +13,15 @@ class speech():
self._isInitialized = True
except:
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):
if not self._isInitialized:
@ -87,10 +95,3 @@ class speech():
return False
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