From 7227f52ac7cf9ffc72a60a0fbcfcacd0a6239d90 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 21:37:36 +0200 Subject: [PATCH] prepare for remake input handling, prepare other stuff --- TODO | 1 + config/settings/settings.conf | 1 + config/settings/settings.conf.chrys | 1 + config/settings/settings.conf.orig | 1 + config/settings/settings.conf.storm | 1 + .../commands/command_template.py | 8 +- .../commands/commands/clear_clipboard.py | 8 +- .../commands/copy_marked_to_clipboard.py | 8 +- .../commands/commands/curr_char.py | 8 +- .../commands/commands/curr_char_phonetic.py | 8 +- .../commands/commands/curr_clipboard.py | 8 +- .../commands/commands/curr_line.py | 9 +- .../commands/commands/curr_screen.py | 8 +- .../commands/curr_screen_after_cursor.py | 8 +- .../commands/curr_screen_before_cursor.py | 9 +- .../commands/commands/curr_word.py | 8 +- .../commands/commands/curr_word_phonetic.py | 8 +- .../commands/commands/cursor_position.py | 8 +- src/fenrir-package/commands/commands/date.py | 15 +- .../commands/commands/dec_sound_volume.py | 9 +- .../commands/commands/dec_speech_pitch.py | 8 +- .../commands/commands/dec_speech_rate.py | 8 +- .../commands/commands/dec_speech_volume.py | 9 +- .../commands/commands/exit_review.py | 8 +- .../commands/commands/first_clipboard.py | 8 +- .../commands/commands/foreward_keypress.py | 8 +- .../commands/commands/inc_sound_volume.py | 8 +- .../commands/commands/inc_speech_pitch.py | 8 +- .../commands/commands/inc_speech_rate.py | 8 +- .../commands/commands/inc_speech_volume.py | 8 +- .../commands/commands/indent_curr_line.py | 8 +- .../commands/commands/last_clipboard.py | 8 +- .../commands/commands/last_incomming.py | 8 +- .../commands/linux_paste_clipboard.py | 8 +- .../commands/commands/marked_text.py | 8 +- .../commands/commands/next_char.py | 8 +- .../commands/commands/next_clipboard.py | 8 +- .../commands/commands/next_line.py | 8 +- .../commands/commands/next_word.py | 8 +- .../commands/commands/prev_char.py | 8 +- .../commands/commands/prev_clipboard.py | 8 +- .../commands/commands/prev_line.py | 8 +- .../commands/commands/prev_word.py | 8 +- .../commands/commands/quit_fenrir.py | 9 +- .../commands/commands/remove_marks.py | 8 +- .../commands/commands/review_top.py | 8 +- .../commands/commands/set_mark.py | 8 +- .../commands/commands/shut_up.py | 8 +- src/fenrir-package/commands/commands/time.py | 15 +- .../commands/commands/toggle_autoRead.py | 8 +- .../commands/commands/toggle_braille.py | 8 +- .../commands/commands/toggle_output.py | 8 +- .../commands/commands/toggle_sound.py | 8 +- .../commands/commands/toggle_speech.py | 8 +- .../commands/onInput/10000-shut_up.py | 8 +- ...resent_char_if_cursor_change_horizontal.py | 9 +- ...-present_line_if_cursor_change_vertical.py | 9 +- .../onScreenChanged/50000-char_echo.py | 11 +- .../onScreenChanged/60000-word_echo.py | 9 +- .../onScreenChanged/65000-char_delete_echo.py | 9 +- .../onScreenChanged/70000-incomming.py | 9 +- .../75000-incomming_promote.py | 9 +- .../80000-screen_change_announcement.py | 9 +- .../85000-screen_chnage_reset_marks.py | 9 +- .../88000-screen_chnage_leve_review_mode.py | 8 +- src/fenrir-package/core/commandManager.py | 6 +- src/fenrir-package/core/input.py | 5 +- src/fenrir-package/core/inputManager.py | 129 ++++-------------- src/fenrir-package/core/outputManager.py | 4 + src/fenrir-package/core/runtime.py | 4 +- src/fenrir-package/core/screenData.py | 3 + src/fenrir-package/core/screenManager.py | 21 +++ src/fenrir-package/core/settingsManager.py | 39 +++++- src/fenrir-package/fenrir.py | 4 +- src/fenrir-package/input/evdev.py | 110 +++++++++++++++ src/fenrir-package/screen/linux.py | 28 ++-- src/fenrir-package/sound/gstreamer.py | 50 +++---- src/fenrir-package/sound/sox.py | 4 + src/fenrir-package/speech/espeak.py | 13 +- src/fenrir-package/speech/generic.py | 63 +++++++-- src/fenrir-package/speech/speechd.py | 21 +-- 81 files changed, 705 insertions(+), 314 deletions(-) create mode 100644 src/fenrir-package/core/screenManager.py create mode 100644 src/fenrir-package/input/evdev.py diff --git a/TODO b/TODO index 98b36831..77ccc081 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 2af9544f..7f187578 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -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 diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index a8cdc7f1..ed14a008 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -27,6 +27,7 @@ suspendingScreen=1,2 autodetectSuspendingScreen=False [keyboard] +driver=evdev device=all grabDevices=True ignoreShortcuts=False diff --git a/config/settings/settings.conf.orig b/config/settings/settings.conf.orig index 9265f1f0..7de76fb8 100644 --- a/config/settings/settings.conf.orig +++ b/config/settings/settings.conf.orig @@ -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 diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 6365297c..bcbeb8bf 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -27,6 +27,7 @@ suspendingScreen=7 autodetectSuspendingScreen=False [keyboard] +driver=evdev device=all grabDevices=True ignoreShortcuts=False diff --git a/src/fenrir-package/commands/command_template.py b/src/fenrir-package/commands/command_template.py index 8e090129..5a86d774 100644 --- a/src/fenrir-package/commands/command_template.py +++ b/src/fenrir-package/commands/command_template.py @@ -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 diff --git a/src/fenrir-package/commands/commands/clear_clipboard.py b/src/fenrir-package/commands/commands/clear_clipboard.py index cb157d8f..a5aba597 100644 --- a/src/fenrir-package/commands/commands/clear_clipboard.py +++ b/src/fenrir-package/commands/commands/clear_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/copy_marked_to_clipboard.py b/src/fenrir-package/commands/commands/copy_marked_to_clipboard.py index bc90773f..cd6ae5d9 100644 --- a/src/fenrir-package/commands/commands/copy_marked_to_clipboard.py +++ b/src/fenrir-package/commands/commands/copy_marked_to_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_char.py b/src/fenrir-package/commands/commands/curr_char.py index 522452fa..f55dae0a 100644 --- a/src/fenrir-package/commands/commands/curr_char.py +++ b/src/fenrir-package/commands/commands/curr_char.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_char_phonetic.py b/src/fenrir-package/commands/commands/curr_char_phonetic.py index 9c020be7..53161063 100644 --- a/src/fenrir-package/commands/commands/curr_char_phonetic.py +++ b/src/fenrir-package/commands/commands/curr_char_phonetic.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_clipboard.py b/src/fenrir-package/commands/commands/curr_clipboard.py index 92bd2b88..310debd9 100644 --- a/src/fenrir-package/commands/commands/curr_clipboard.py +++ b/src/fenrir-package/commands/commands/curr_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_line.py b/src/fenrir-package/commands/commands/curr_line.py index 41aeef24..66aa4fe4 100644 --- a/src/fenrir-package/commands/commands/curr_line.py +++ b/src/fenrir-package/commands/commands/curr_line.py @@ -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 + diff --git a/src/fenrir-package/commands/commands/curr_screen.py b/src/fenrir-package/commands/commands/curr_screen.py index 19accc2b..3857e32a 100644 --- a/src/fenrir-package/commands/commands/curr_screen.py +++ b/src/fenrir-package/commands/commands/curr_screen.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_screen_after_cursor.py b/src/fenrir-package/commands/commands/curr_screen_after_cursor.py index 957ee298..4c5bd99a 100644 --- a/src/fenrir-package/commands/commands/curr_screen_after_cursor.py +++ b/src/fenrir-package/commands/commands/curr_screen_after_cursor.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_screen_before_cursor.py b/src/fenrir-package/commands/commands/curr_screen_before_cursor.py index dab8db4b..eef51cc3 100644 --- a/src/fenrir-package/commands/commands/curr_screen_before_cursor.py +++ b/src/fenrir-package/commands/commands/curr_screen_before_cursor.py @@ -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 + diff --git a/src/fenrir-package/commands/commands/curr_word.py b/src/fenrir-package/commands/commands/curr_word.py index 8387a9a0..b180f39f 100644 --- a/src/fenrir-package/commands/commands/curr_word.py +++ b/src/fenrir-package/commands/commands/curr_word.py @@ -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 diff --git a/src/fenrir-package/commands/commands/curr_word_phonetic.py b/src/fenrir-package/commands/commands/curr_word_phonetic.py index d5566f6b..9a02b655 100644 --- a/src/fenrir-package/commands/commands/curr_word_phonetic.py +++ b/src/fenrir-package/commands/commands/curr_word_phonetic.py @@ -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 diff --git a/src/fenrir-package/commands/commands/cursor_position.py b/src/fenrir-package/commands/commands/cursor_position.py index f26cb70d..885fec8d 100644 --- a/src/fenrir-package/commands/commands/cursor_position.py +++ b/src/fenrir-package/commands/commands/cursor_position.py @@ -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 diff --git a/src/fenrir-package/commands/commands/date.py b/src/fenrir-package/commands/commands/date.py index 8ea846c9..cb413d3e 100644 --- a/src/fenrir-package/commands/commands/date.py +++ b/src/fenrir-package/commands/commands/date.py @@ -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 diff --git a/src/fenrir-package/commands/commands/dec_sound_volume.py b/src/fenrir-package/commands/commands/dec_sound_volume.py index d713c28f..22ea23a1 100644 --- a/src/fenrir-package/commands/commands/dec_sound_volume.py +++ b/src/fenrir-package/commands/commands/dec_sound_volume.py @@ -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 + diff --git a/src/fenrir-package/commands/commands/dec_speech_pitch.py b/src/fenrir-package/commands/commands/dec_speech_pitch.py index 69001a4f..2057467e 100644 --- a/src/fenrir-package/commands/commands/dec_speech_pitch.py +++ b/src/fenrir-package/commands/commands/dec_speech_pitch.py @@ -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 diff --git a/src/fenrir-package/commands/commands/dec_speech_rate.py b/src/fenrir-package/commands/commands/dec_speech_rate.py index 893ea5ba..2f6c1baa 100644 --- a/src/fenrir-package/commands/commands/dec_speech_rate.py +++ b/src/fenrir-package/commands/commands/dec_speech_rate.py @@ -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 diff --git a/src/fenrir-package/commands/commands/dec_speech_volume.py b/src/fenrir-package/commands/commands/dec_speech_volume.py index adf7ba95..e62cc51d 100644 --- a/src/fenrir-package/commands/commands/dec_speech_volume.py +++ b/src/fenrir-package/commands/commands/dec_speech_volume.py @@ -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 + diff --git a/src/fenrir-package/commands/commands/exit_review.py b/src/fenrir-package/commands/commands/exit_review.py index fe272749..434ada45 100644 --- a/src/fenrir-package/commands/commands/exit_review.py +++ b/src/fenrir-package/commands/commands/exit_review.py @@ -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 diff --git a/src/fenrir-package/commands/commands/first_clipboard.py b/src/fenrir-package/commands/commands/first_clipboard.py index f2682aaa..2997edd9 100644 --- a/src/fenrir-package/commands/commands/first_clipboard.py +++ b/src/fenrir-package/commands/commands/first_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/foreward_keypress.py b/src/fenrir-package/commands/commands/foreward_keypress.py index 427b05e8..8285d43a 100644 --- a/src/fenrir-package/commands/commands/foreward_keypress.py +++ b/src/fenrir-package/commands/commands/foreward_keypress.py @@ -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 diff --git a/src/fenrir-package/commands/commands/inc_sound_volume.py b/src/fenrir-package/commands/commands/inc_sound_volume.py index a74c7eb2..e8d86455 100644 --- a/src/fenrir-package/commands/commands/inc_sound_volume.py +++ b/src/fenrir-package/commands/commands/inc_sound_volume.py @@ -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 diff --git a/src/fenrir-package/commands/commands/inc_speech_pitch.py b/src/fenrir-package/commands/commands/inc_speech_pitch.py index 8e0d3c25..a824fd94 100644 --- a/src/fenrir-package/commands/commands/inc_speech_pitch.py +++ b/src/fenrir-package/commands/commands/inc_speech_pitch.py @@ -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 diff --git a/src/fenrir-package/commands/commands/inc_speech_rate.py b/src/fenrir-package/commands/commands/inc_speech_rate.py index 9f870821..a8ba4540 100644 --- a/src/fenrir-package/commands/commands/inc_speech_rate.py +++ b/src/fenrir-package/commands/commands/inc_speech_rate.py @@ -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 diff --git a/src/fenrir-package/commands/commands/inc_speech_volume.py b/src/fenrir-package/commands/commands/inc_speech_volume.py index 7dfe778c..bee269ce 100644 --- a/src/fenrir-package/commands/commands/inc_speech_volume.py +++ b/src/fenrir-package/commands/commands/inc_speech_volume.py @@ -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 diff --git a/src/fenrir-package/commands/commands/indent_curr_line.py b/src/fenrir-package/commands/commands/indent_curr_line.py index 8aeceeb0..14fa4384 100644 --- a/src/fenrir-package/commands/commands/indent_curr_line.py +++ b/src/fenrir-package/commands/commands/indent_curr_line.py @@ -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 diff --git a/src/fenrir-package/commands/commands/last_clipboard.py b/src/fenrir-package/commands/commands/last_clipboard.py index 79d818eb..2731f041 100644 --- a/src/fenrir-package/commands/commands/last_clipboard.py +++ b/src/fenrir-package/commands/commands/last_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/last_incomming.py b/src/fenrir-package/commands/commands/last_incomming.py index a8d9801c..d3605c18 100644 --- a/src/fenrir-package/commands/commands/last_incomming.py +++ b/src/fenrir-package/commands/commands/last_incomming.py @@ -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 diff --git a/src/fenrir-package/commands/commands/linux_paste_clipboard.py b/src/fenrir-package/commands/commands/linux_paste_clipboard.py index 03f99ea9..c55ae53d 100644 --- a/src/fenrir-package/commands/commands/linux_paste_clipboard.py +++ b/src/fenrir-package/commands/commands/linux_paste_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/marked_text.py b/src/fenrir-package/commands/commands/marked_text.py index f753bfba..6f38d7ef 100644 --- a/src/fenrir-package/commands/commands/marked_text.py +++ b/src/fenrir-package/commands/commands/marked_text.py @@ -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 diff --git a/src/fenrir-package/commands/commands/next_char.py b/src/fenrir-package/commands/commands/next_char.py index 8d56b49c..7ebe13ac 100644 --- a/src/fenrir-package/commands/commands/next_char.py +++ b/src/fenrir-package/commands/commands/next_char.py @@ -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 diff --git a/src/fenrir-package/commands/commands/next_clipboard.py b/src/fenrir-package/commands/commands/next_clipboard.py index 39676a34..dbf11bc7 100644 --- a/src/fenrir-package/commands/commands/next_clipboard.py +++ b/src/fenrir-package/commands/commands/next_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/next_line.py b/src/fenrir-package/commands/commands/next_line.py index 3a9d2f9c..6daf4ee4 100644 --- a/src/fenrir-package/commands/commands/next_line.py +++ b/src/fenrir-package/commands/commands/next_line.py @@ -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 diff --git a/src/fenrir-package/commands/commands/next_word.py b/src/fenrir-package/commands/commands/next_word.py index fed0bb63..2f9b1537 100644 --- a/src/fenrir-package/commands/commands/next_word.py +++ b/src/fenrir-package/commands/commands/next_word.py @@ -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 diff --git a/src/fenrir-package/commands/commands/prev_char.py b/src/fenrir-package/commands/commands/prev_char.py index 73cecad9..03313a0b 100644 --- a/src/fenrir-package/commands/commands/prev_char.py +++ b/src/fenrir-package/commands/commands/prev_char.py @@ -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 diff --git a/src/fenrir-package/commands/commands/prev_clipboard.py b/src/fenrir-package/commands/commands/prev_clipboard.py index 364513f9..3dfcbd22 100644 --- a/src/fenrir-package/commands/commands/prev_clipboard.py +++ b/src/fenrir-package/commands/commands/prev_clipboard.py @@ -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 diff --git a/src/fenrir-package/commands/commands/prev_line.py b/src/fenrir-package/commands/commands/prev_line.py index 8cc223ff..e4b79808 100644 --- a/src/fenrir-package/commands/commands/prev_line.py +++ b/src/fenrir-package/commands/commands/prev_line.py @@ -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 diff --git a/src/fenrir-package/commands/commands/prev_word.py b/src/fenrir-package/commands/commands/prev_word.py index 4cc7db43..b89fcfea 100644 --- a/src/fenrir-package/commands/commands/prev_word.py +++ b/src/fenrir-package/commands/commands/prev_word.py @@ -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 diff --git a/src/fenrir-package/commands/commands/quit_fenrir.py b/src/fenrir-package/commands/commands/quit_fenrir.py index 4946c0ea..e8b85bcf 100644 --- a/src/fenrir-package/commands/commands/quit_fenrir.py +++ b/src/fenrir-package/commands/commands/quit_fenrir.py @@ -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 + diff --git a/src/fenrir-package/commands/commands/remove_marks.py b/src/fenrir-package/commands/commands/remove_marks.py index cd35b41a..c09932a4 100644 --- a/src/fenrir-package/commands/commands/remove_marks.py +++ b/src/fenrir-package/commands/commands/remove_marks.py @@ -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 diff --git a/src/fenrir-package/commands/commands/review_top.py b/src/fenrir-package/commands/commands/review_top.py index 187f8843..b671ca6f 100644 --- a/src/fenrir-package/commands/commands/review_top.py +++ b/src/fenrir-package/commands/commands/review_top.py @@ -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 diff --git a/src/fenrir-package/commands/commands/set_mark.py b/src/fenrir-package/commands/commands/set_mark.py index a45192d5..4f7cef13 100644 --- a/src/fenrir-package/commands/commands/set_mark.py +++ b/src/fenrir-package/commands/commands/set_mark.py @@ -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 diff --git a/src/fenrir-package/commands/commands/shut_up.py b/src/fenrir-package/commands/commands/shut_up.py index 680e4d83..7a7d7f57 100644 --- a/src/fenrir-package/commands/commands/shut_up.py +++ b/src/fenrir-package/commands/commands/shut_up.py @@ -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 diff --git a/src/fenrir-package/commands/commands/time.py b/src/fenrir-package/commands/commands/time.py index a93a4769..80c6dff0 100644 --- a/src/fenrir-package/commands/commands/time.py +++ b/src/fenrir-package/commands/commands/time.py @@ -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 diff --git a/src/fenrir-package/commands/commands/toggle_autoRead.py b/src/fenrir-package/commands/commands/toggle_autoRead.py index c947d640..d6d72069 100644 --- a/src/fenrir-package/commands/commands/toggle_autoRead.py +++ b/src/fenrir-package/commands/commands/toggle_autoRead.py @@ -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 diff --git a/src/fenrir-package/commands/commands/toggle_braille.py b/src/fenrir-package/commands/commands/toggle_braille.py index f3451f7b..9edb6f30 100644 --- a/src/fenrir-package/commands/commands/toggle_braille.py +++ b/src/fenrir-package/commands/commands/toggle_braille.py @@ -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 diff --git a/src/fenrir-package/commands/commands/toggle_output.py b/src/fenrir-package/commands/commands/toggle_output.py index 62045c19..7ffac132 100644 --- a/src/fenrir-package/commands/commands/toggle_output.py +++ b/src/fenrir-package/commands/commands/toggle_output.py @@ -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 diff --git a/src/fenrir-package/commands/commands/toggle_sound.py b/src/fenrir-package/commands/commands/toggle_sound.py index e103f5af..bd86c2ac 100644 --- a/src/fenrir-package/commands/commands/toggle_sound.py +++ b/src/fenrir-package/commands/commands/toggle_sound.py @@ -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 diff --git a/src/fenrir-package/commands/commands/toggle_speech.py b/src/fenrir-package/commands/commands/toggle_speech.py index f4e2af75..ba6390c8 100644 --- a/src/fenrir-package/commands/commands/toggle_speech.py +++ b/src/fenrir-package/commands/commands/toggle_speech.py @@ -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 diff --git a/src/fenrir-package/commands/onInput/10000-shut_up.py b/src/fenrir-package/commands/onInput/10000-shut_up.py index a05ad97c..48c5b13d 100644 --- a/src/fenrir-package/commands/onInput/10000-shut_up.py +++ b/src/fenrir-package/commands/onInput/10000-shut_up.py @@ -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 diff --git a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py index 5f5c74f3..fb4dd633 100644 --- a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py @@ -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 + diff --git a/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py b/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py index 45ebcc67..8766e4b1 100644 --- a/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py +++ b/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/50000-char_echo.py b/src/fenrir-package/commands/onScreenChanged/50000-char_echo.py index 0706029d..abdc3ffe 100644 --- a/src/fenrir-package/commands/onScreenChanged/50000-char_echo.py +++ b/src/fenrir-package/commands/onScreenChanged/50000-char_echo.py @@ -3,8 +3,14 @@ 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', 'charEcho'): return environment # detect deletion or chilling @@ -24,5 +30,4 @@ class command(): return environment def setCallback(self, callback): pass - def shutdown(self): - pass + diff --git a/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py b/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py index ad3375fa..540f504a 100644 --- a/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py +++ b/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py b/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py index 0e909c90..1ff28c81 100644 --- a/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py +++ b/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/70000-incomming.py b/src/fenrir-package/commands/onScreenChanged/70000-incomming.py index a6af947e..615f4aa8 100644 --- a/src/fenrir-package/commands/onScreenChanged/70000-incomming.py +++ b/src/fenrir-package/commands/onScreenChanged/70000-incomming.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py b/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py index 7518aed6..93bf711b 100644 --- a/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py +++ b/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/80000-screen_change_announcement.py b/src/fenrir-package/commands/onScreenChanged/80000-screen_change_announcement.py index 91b1b7a5..c00162f7 100644 --- a/src/fenrir-package/commands/onScreenChanged/80000-screen_change_announcement.py +++ b/src/fenrir-package/commands/onScreenChanged/80000-screen_change_announcement.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/85000-screen_chnage_reset_marks.py b/src/fenrir-package/commands/onScreenChanged/85000-screen_chnage_reset_marks.py index 468f6227..15d9de89 100644 --- a/src/fenrir-package/commands/onScreenChanged/85000-screen_chnage_reset_marks.py +++ b/src/fenrir-package/commands/onScreenChanged/85000-screen_chnage_reset_marks.py @@ -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 + diff --git a/src/fenrir-package/commands/onScreenChanged/88000-screen_chnage_leve_review_mode.py b/src/fenrir-package/commands/onScreenChanged/88000-screen_chnage_leve_review_mode.py index 361cff25..a65dd920 100644 --- a/src/fenrir-package/commands/onScreenChanged/88000-screen_chnage_leve_review_mode.py +++ b/src/fenrir-package/commands/onScreenChanged/88000-screen_chnage_leve_review_mode.py @@ -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 diff --git a/src/fenrir-package/core/commandManager.py b/src/fenrir-package/core/commandManager.py index 977f8101..e1ddc36c 100644 --- a/src/fenrir-package/core/commandManager.py +++ b/src/fenrir-package/core/commandManager.py @@ -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) diff --git a/src/fenrir-package/core/input.py b/src/fenrir-package/core/input.py index 308e384e..4198f10e 100644 --- a/src/fenrir-package/core/input.py +++ b/src/fenrir-package/core/input.py @@ -2,7 +2,10 @@ import time input = { -'currShortcut': {}, +'currInput': {}, +'prevInput': {}, +'currEvent': None, +'firstEvent': {}, 'currShortcutString': '', 'consumeKey': False, 'fenrirKey': ['82'], diff --git a/src/fenrir-package/core/inputManager.py b/src/fenrir-package/core/inputManager.py index b66c1ebd..bd64ec89 100644 --- a/src/fenrir-package/core/inputManager.py +++ b/src/fenrir-package/core/inputManager.py @@ -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 + pass + 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 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'] == {} - - return environment, timeout - - 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) - + 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() - - + return str(event.code) in environment['input']['fenrirKey'] diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index 99147b56..7cb5f36b 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -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): diff --git a/src/fenrir-package/core/runtime.py b/src/fenrir-package/core/runtime.py index 6074042e..39a3b755 100644 --- a/src/fenrir-package/core/runtime.py +++ b/src/fenrir-package/core/runtime.py @@ -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(), } diff --git a/src/fenrir-package/core/screenData.py b/src/fenrir-package/core/screenData.py index 7b570176..16c16804 100644 --- a/src/fenrir-package/core/screenData.py +++ b/src/fenrir-package/core/screenData.py @@ -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() } diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py new file mode 100644 index 00000000..906d2721 --- /dev/null +++ b/src/fenrir-package/core/screenManager.py @@ -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(',') + diff --git a/src/fenrir-package/core/settingsManager.py b/src/fenrir-package/core/settingsManager.py index 351e8c89..1ecc90ef 100644 --- a/src/fenrir-package/core/settingsManager.py +++ b/src/fenrir-package/core/settingsManager.py @@ -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): @@ -163,7 +168,8 @@ class settingsManager(): spec = importlib.util.spec_from_file_location(driverName, 'sound/' + driverName + '.py') driver_mod = importlib.util.module_from_spec(spec) 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 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')) - environment['runtime']['inputManager'] = inputManager.inputManager() - environment['runtime']['outputManager'] = outputManager.outputManager() - environment['runtime']['commandManager'] = commandManager.commandManager() + 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) diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 1e68083d..bf5f96d7 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -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']: diff --git a/src/fenrir-package/input/evdev.py b/src/fenrir-package/input/evdev.py new file mode 100644 index 00000000..3598e334 --- /dev/null +++ b/src/fenrir-package/input/evdev.py @@ -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() + + diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index b1d0ea60..ab0951a3 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -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 analyzeScreen(self, environment, trigger='updateScreen'): + 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 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'] diff --git a/src/fenrir-package/sound/gstreamer.py b/src/fenrir-package/sound/gstreamer.py index d9912c85..4bc99063 100644 --- a/src/fenrir-package/sound/gstreamer.py +++ b/src/fenrir-package/sound/gstreamer.py @@ -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 diff --git a/src/fenrir-package/sound/sox.py b/src/fenrir-package/sound/sox.py index 24cec2fe..d84f278f 100644 --- a/src/fenrir-package/sound/sox.py +++ b/src/fenrir-package/sound/sox.py @@ -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): diff --git a/src/fenrir-package/speech/espeak.py b/src/fenrir-package/speech/espeak.py index e71405bb..15a9063b 100644 --- a/src/fenrir-package/speech/espeak.py +++ b/src/fenrir-package/speech/espeak.py @@ -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 diff --git a/src/fenrir-package/speech/generic.py b/src/fenrir-package/speech/generic.py index 44b65ad0..46698fb2 100644 --- a/src/fenrir-package/speech/generic.py +++ b/src/fenrir-package/speech/generic.py @@ -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 diff --git a/src/fenrir-package/speech/speechd.py b/src/fenrir-package/speech/speechd.py index c001b819..599ca3f8 100644 --- a/src/fenrir-package/speech/speechd.py +++ b/src/fenrir-package/speech/speechd.py @@ -13,8 +13,16 @@ 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: return False @@ -86,11 +94,4 @@ class speech(): if not self._isInitialized: 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 +