Skip to content

Commit

Permalink
toggle braille capability
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Jan 28, 2024
1 parent 83983ab commit 4226a65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
24 changes: 21 additions & 3 deletions core/core-agnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
ctx = Context()

# We want to get the settings from the talon file but then update
# them locally here so we can change them globally via expose talon actions
# them locally here so we can change them globally via expose talon actions
def initialize_settings():
ctx.settings["user.echo_dictation"]: bool = settings.get("user.echo_dictation", True)
ctx.settings["user.echo_context"]: bool = settings.get("user.echo_context", False)
ctx.settings["user.echo_braille"]: bool = settings.get("user.echo_braille", True)

# initialize the settings only after the user settings have been loaded
app.register('ready', initialize_settings)
Expand Down Expand Up @@ -48,17 +49,34 @@ def cancel_current_speaker():
def braille(text: str):
"""Output braille with the screenreader"""

def toggle_braille():
"""Toggles braille on and off"""
if actions.user.braille_enabled():
actions.user.tts("braille disabled")
ctx.settings["user.echo_braille"] = False
else:
actions.user.tts("braille enabled")
ctx.settings["user.echo_braille"] = True

def echo_dictation_enabled() -> bool:
"""Returns true if echo dictation is enabled"""
# Catch potential race condition where settings haven't been loaded yet
# Catch potential race condition where settings haven't been loaded at startup
try:
return ctx.settings["user.echo_dictation"]
except:
return False

def braille_enabled() -> bool:
"""Returns true if braille is enabled"""
# Catch potential race condition where settings haven't been loaded at startup
try:
return ctx.settings["user.echo_braille"]
except:
return False

def echo_context_enabled() -> bool:
"""Returns true if echo context is enabled"""
# Catch potential race condition where settings haven't been loaded yet
# Catch potential race condition where settings haven't been loaded at startup
try:
return ctx.settings["user.echo_context"]
except:
Expand Down
2 changes: 1 addition & 1 deletion core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)

mod.setting(
"braille_output",
"echo_braille",
type=bool,
default=False,
desc="If true, outputs braille through your screenreader",
Expand Down
2 changes: 2 additions & 0 deletions sight-free-global.talon
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ toggle (key | keypress) sound:
(swtich | change) voice:
user.switch_voice()

toggle braille:
user.toggle_braille()
2 changes: 1 addition & 1 deletion sight-free-settings.talon
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ settings():
user.start_screenreader_on_startup = false

# Output dictated text to braille display through your screen reader
user.braille_output = false
user.echo_braille = false

# To prevent errors from accidental key presses, play a sound each time a key is pressed
user.sound_on_keypress = false
Expand Down

0 comments on commit 4226a65

Please sign in to comment.