Skip to content

Commit 06bf71f

Browse files
authored
Merge 2d72db0 into d344442
2 parents d344442 + 2d72db0 commit 06bf71f

5 files changed

Lines changed: 133 additions & 13 deletions

File tree

source/brailleDisplayDrivers/freedomScientific.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,18 @@ def script_toggleRightWizWheelAction(self, _gesture):
566566
"reportCurrentLine": ("br(freedomScientific):dot1+dot4+brailleSpaceBar",),
567567
"showGui": ("br(freedomScientific):dot1+dot3+dot4+dot5+brailleSpaceBar",),
568568
"braille_toggleTether": ("br(freedomScientific):leftGDFButton+rightGDFButton",),
569+
# Based on corresponding assignments in JAWS, modifing where Shift goes
570+
"braille_toggleControl": ("br(freedomscientific):dot3+dot8+brailleSpaceBar",),
571+
"braille_toggleAlt": ("br(freedomscientific):dot6+dot8+brailleSpaceBar",),
572+
"braille_toggleWindows": ("br(freedomscientific):dot4+dot8+brailleSpaceBar",),
573+
"braille_toggleNVDAKey": ("br(freedomscientific):dot5+dot8+brailleSpaceBar",),
574+
"braille_toggleShift": ("br(freedomscientific):dot7+dot8+brailleSpaceBar",),
575+
"braille_toggleControlShift": ("br(freedomscientific):dot3+dot7+dot8+brailleSpaceBar",),
576+
"braille_toggleAltShift": ("br(freedomscientific):dot6+dot7+dot8+brailleSpaceBar",),
577+
"braille_toggleWindowsShift": ("br(freedomscientific):dot4+dot7+dot8+brailleSpaceBar",),
578+
"braille_toggleNVDAKeyShift": ("br(freedomscientific):dot5+dot7+dot8+brailleSpaceBar",),
579+
"braille_toggleControlAlt": ("br(freedomscientific):dot3+dot6+dot8+brailleSpaceBar",),
580+
"braille_toggleControlAltShift": ("br(freedomscientific):dot3+dot6+dot7+dot8+brailleSpaceBar",),
569581
}
570582
})
571583

source/brailleInput.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _translate(self, endWord: bool) -> bool:
133133
data = u"".join([chr(cell | LOUIS_DOTS_IO_START) for cell in self.bufferBraille[:pos]])
134134
mode = louis.dotsIO | louis.noUndefinedDots
135135
if (not self.currentFocusIsTextObj or self.currentModifiers) and self._table.contracted:
136-
mode |= louis.partialTrans
136+
mode |= louis.partialTrans
137137
self.bufferText = louis.backTranslate(
138138
[os.path.join(brailleTables.TABLES_DIR, self._table.fileName),
139139
"braille-patterns.cti"],
@@ -262,22 +262,32 @@ def input(self, dots: int):
262262
self._reportUntranslated(pos)
263263

264264
def toggleModifier(self, modifier: str):
265+
self.toggleModifiers([modifier])
266+
267+
def toggleModifiers(self, modifiers: List[str]):
265268
# Check modifier validity
266-
isModifier: bool = keyboardHandler.KeyboardInputGesture.fromName(modifier).isModifier
267-
if not isModifier:
268-
raise ValueError("%r is not a valid modifier"%modifier)
269-
if modifier in self.currentModifiers:
270-
self.currentModifiers.discard(modifier)
269+
validModifiers: bool = all(
270+
keyboardHandler.KeyboardInputGesture.fromName(m).isModifier
271+
for m in modifiers)
272+
if not validModifiers:
273+
raise ValueError("%r contains unknown modifiers" % modifiers)
274+
275+
# Ensure input buffer is clear for the modified key
276+
if self.bufferText:
277+
self._translate(True)
278+
279+
toToggle: frozenset[str] = frozenset(modifiers)
280+
added = toToggle - self.currentModifiers
281+
removed = toToggle & self.currentModifiers
282+
self.currentModifiers.difference_update(toToggle)
283+
self.currentModifiers.update(added)
284+
for modifier in added:
285+
speech.speakMessage(keyLabels.getKeyCombinationLabel(modifier))
286+
for modifier in removed:
271287
# Translators: Reported when a braille input modifier is released.
272288
speech.speakMessage(_("{modifier} released").format(
273289
modifier=keyLabels.getKeyCombinationLabel(modifier)
274290
))
275-
else: # modifier not in self.currentModifiers
276-
self.currentModifiers.add(modifier)
277-
# Translators: Reported when a braille input modifier is pressed.
278-
speech.speakMessage(_("{modifier} pressed").format(
279-
modifier=keyLabels.getKeyCombinationLabel(modifier)
280-
))
281291

282292
def enter(self):
283293
"""Translates any braille input and presses the enter key.

source/globalCommands.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,6 +3043,72 @@ def script_braille_toggleWindows(self, gesture):
30433043
def script_braille_toggleNVDAKey(self, gesture):
30443044
brailleInput.handler.toggleModifier("NVDA")
30453045

3046+
@script(
3047+
# Translators: Input help mode message for a braille command.
3048+
description=_(
3049+
"Virtually toggles the control and shift keys to emulate a "
3050+
"keyboard shortcut with braille input"),
3051+
category=inputCore.SCRCAT_KBEMU,
3052+
bypassInputHelp=True
3053+
)
3054+
def script_braille_toggleControlShift(self, gesture):
3055+
brailleInput.handler.toggleModifiers(["control", "shift"])
3056+
3057+
@script(
3058+
# Translators: Input help mode message for a braille command.
3059+
description=_(
3060+
"Virtually toggles the alt and shift keys to emulate a "
3061+
"keyboard shortcut with braille input"),
3062+
category=inputCore.SCRCAT_KBEMU,
3063+
bypassInputHelp=True
3064+
)
3065+
def script_braille_toggleAltShift(self, gesture):
3066+
brailleInput.handler.toggleModifiers(["alt", "shift"])
3067+
3068+
@script(
3069+
# Translators: Input help mode message for a braille command.
3070+
description=_(
3071+
"Virtually toggles the left windows and shift keys to emulate a "
3072+
"keyboard shortcut with braille input"),
3073+
category=inputCore.SCRCAT_KBEMU,
3074+
bypassInputHelp=True
3075+
)
3076+
def script_braille_toggleWindowsShift(self, gesture):
3077+
brailleInput.handler.toggleModifiers(["leftWindows", "shift"])
3078+
3079+
@script(
3080+
# Translators: Input help mode message for a braille command.
3081+
description=_(
3082+
"Virtually toggles the NVDA and shift keys to emulate a "
3083+
"keyboard shortcut with braille input"),
3084+
category=inputCore.SCRCAT_KBEMU,
3085+
bypassInputHelp=True
3086+
)
3087+
def script_braille_toggleNVDAKeyShift(self, gesture):
3088+
brailleInput.handler.toggleModifiers(["NVDA", "shift"])
3089+
3090+
@script(
3091+
# Translators: Input help mode message for a braille command.
3092+
description=_(
3093+
"Virtually toggles the control and alt keys to emulate a "
3094+
"keyboard shortcut with braille input"),
3095+
category=inputCore.SCRCAT_KBEMU,
3096+
bypassInputHelp=True
3097+
)
3098+
def script_braille_toggleControlAlt(self, gesture):
3099+
brailleInput.handler.toggleModifiers(["control", "alt"])
3100+
3101+
@script(
3102+
# Translators: Input help mode message for a braille command.
3103+
description=_(
3104+
"Virtually toggles the control, alt, and shift keys to emulate a "
3105+
"keyboard shortcut with braille input"),
3106+
category=inputCore.SCRCAT_KBEMU,
3107+
bypassInputHelp=True
3108+
)
3109+
def script_braille_toggleControlAltShift(self, gesture):
3110+
brailleInput.handler.toggleModifiers(["control", "alt", "shift"])
3111+
30463112
@script(
30473113
description=_(
30483114
# Translators: Input help mode message for reload plugins command.

user_docs/en/changes.t2t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ What's New in NVDA
1414
- For this to work, you must be running Microsoft Word 365/2016 build 14326 or later.
1515
- MathType equations must also be manually converted to Office Math by selecting each and choosing Equation options -> Convert to Office Math in the context menu.
1616
-
17+
- Added commands for toggling multiple modifiers simultaneously with a Braille display (#13152)
1718
-
1819

1920
== Changes ==
@@ -25,6 +26,7 @@ What's New in NVDA
2526
- Updated Unicode Common Locale Data Repository (CLDR) to 40.0. (#12999)
2627
- ``NVDA+Numpad Delete`` reports the location of the caret or focused object by default. (#13060)
2728
- ``NVDA+Shift+Numpad Delete`` reports the location of the review cursor. (#13060)
29+
- Added default bindings for toggling modifier keys to Freedom Scientific displays (#13152)
2830
-
2931

3032
== Bug Fixes ==

user_docs/en/userGuide.t2t

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,26 @@ Dot 8 translates any braille input and presses the enter key.
774774
Pressing dot 7 + dot 8 translates any braille input, but without adding a space or pressing enter.
775775
%kc:endInclude
776776

777+
+++ Inputting keyboard shortcuts +++[BrailleKeyboardShortcuts]
778+
NVDA supports inputting keyboard shortcuts and emulating keypresses using the braille display.
779+
This emulation comes in two forms: assigning a Braille input directly to some key press and using the virtual modifier keys.
780+
781+
Commonly-used keys, such as the arrow keys or pressing Alt to reach menus, can be mapped directly to Braille inputs.
782+
The driver for each Braille display comes pre-equipped with some of these assignments.
783+
You can change these assignments or add new emulated keys from the [Input Gestures dialog #InputGestures].
784+
785+
While this approach is useful for commonly-pressed or unique keys (such as Tab), you may not want to assign a unique set of keys to each keyboard shortcut.
786+
To allow emulating keypresses where modifier keys are held down, NVDA provides commands to toggle the control, alt, shift, windows, and NVDA keys, along with commands for some combinations of those keys.
787+
To use these toggles, first press the command (or sequence of commands) for the modifier keys you want pressed, than input the character that's part of the keyboard shortcut you want to input.
788+
For example, to produce control+f, use the "Toggle control key" command and then type an f,
789+
and to input control+alt+t, use either the "Toggle control key" and "Toggle alt key" commands, in either order, or the "Toggle control and alt keys" command, followed by typing a t.
790+
791+
If you accidentally toggle modifier keys, running the toggle command again will remove the modifier.
792+
793+
When typing in contracted Braille, using the modifier toggle keys will cause your input to be translated just as if you had pressed dots 7+8.
794+
In addition, the emulated keypress cannot reflect Braille typed before the modifier key was pressed.
795+
This means that, to type alt+2 with a Braille code that uses a number sign, you must first toggle Alt and then type a number sign.
796+
777797
+ Vision +[Vision]
778798
While NVDA is primarily aimed at blind or vision impaired people who primarily use speech and/or braille to operate a computer, it also provides built-in facilities to change the contents of the screen.
779799
Within NVDA, such a visual aid is called a vision enhancement provider.
@@ -2344,7 +2364,6 @@ Search for the broader language (such as English or French), then locate the var
23442364
Select any languages desired and use the "add" button to add them.
23452365
Once added, restart NVDA.
23462366

2347-
23482367
Please see this Microsoft article for a list of available voices: https://support.microsoft.com/en-us/windows/appendix-a-supported-languages-and-voices-4486e345-7730-53da-fcfe-55cc64300f01
23492368

23502369
+ Supported Braille Displays +[SupportedBrailleDisplays]
@@ -2414,6 +2433,17 @@ Please see the display's documentation for descriptions of where these keys can
24142433
| escape key | brailleSpaceBar+dot1+dot5 |
24152434
| windows key | brailleSpaceBar+dot2+dot4+dot5+dot6 |
24162435
| space key | brailleSpaceBar |
2436+
| Toggle control key | brailleSpaceBar+dot3+dot8 |
2437+
| Toggle alt key | brailleSpaceBar+dot6+dot8 |
2438+
| Toggle windows key | brailleSpaceBar+dot4+dot8 |
2439+
| Toggle NVDA key | brailleSpaceBar+dot5+dot8 |
2440+
| Toggle shift key | brailleSpaceBar+dot7+dot8 |
2441+
| Toggle control and shift keys | brailleSpaceBar+dot3+dot7+dot8 |
2442+
| Toggle alt and shift keys | brailleSpaceBar+dot6+dot7+dot8 |
2443+
| Toggle windows and shift keys | brailleSpaceBar+dot4+dot7+dot8 |
2444+
| Toggle NVDA and shift keys | brailleSpaceBar+dot5+dot7+dot8 |
2445+
| Toggle control and alt keys | brailleSpaceBar+dot3+dot6+dot8 |
2446+
| Toggle control, alt, and shift keys | brailleSpaceBar+dot3+dot6+dot7+dot8 |
24172447
| windows+d key (minimize all applications) | brailleSpaceBar+dot1+dot2+dot3+dot4+dot5+dot6 |
24182448
| Report Current Line | brailleSpaceBar+dot1+dot4 |
24192449
| NVDA menu | brailleSpaceBar+dot1+dot3+dot4+dot5 |

0 commit comments

Comments
 (0)