Skip to content

Basic support for braille display key modifiers#7503

Merged
michaelDCurran merged 4 commits into
nvaccess:masterfrom
BabbageCom:i6213
Oct 3, 2017
Merged

Basic support for braille display key modifiers#7503
michaelDCurran merged 4 commits into
nvaccess:masterfrom
BabbageCom:i6213

Conversation

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #6213

Description

This adds basic support for modifiers in braille display gestures that emulate keyboard gestures. For example, if you have baum key b10 assigned to kb:control and you combine b10 with the joystick found on baum displays, you will be able to perform keystrokes like control+upArrow, control+downArrow, etc. without explicitly defining them.

Testing performed:

Tested the example as noted above.

Known issues with pull request:

  • Combining modifiers with braille input (Single letter navigation from a braille terminal #7306) is not yet supported. That's why I call this basic support for modifiers.
  • This does not yet have unit tests. Since we actually have a braille module in unit tests, it should be possible to provide them. However, I'd like to have the current approach reviewed first, if possible.

	* For example, if L{self.id} is 'key1+key2', key1 is bound to 'kb:control' and key2 to 'kb:tab', this gesture should execute 'kb:control+tab'
	* Combining modifiers with braille input (#7306) is not yet supported
Comment thread source/braille.py
"""Retrieves modifier gestures from this display driver's L{gestureMap}
that are bound to modifier only keyboard emulate scripts.
@return: the ids of the display keys and the associated generalised modifier names
@rtype: generator of (set, set)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sets instead of tuples/lists? Sets have some fancy operator overloads, but that pattern is not used much in NVDA.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use sets because of these operator overloads.

Comment thread source/braille.py
gestureKeys = set(self.keyNames)
gestureModifiers = set()
for keys, modifiers in handler.display._getModifierGestures():
if keys<gestureKeys:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkager: see this line and lines below, which contain some set operator stuff.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume < means "subset of", but I'm not sure. That's why I am wondering if the benefit of overloaded operators is really a benefit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly.

Comment thread source/braille.py Outdated
for globalMap in globalMaps:
for scriptCls, gesture, scriptName in globalMap.getScriptsForAllGestures():
if gesture.startswith("br({source})".format(source=cls.name)) and scriptCls is globalCommands.GlobalCommands and scriptName.startswith("kb"):
script = scriptHandler._makeKbEmulateScript(scriptName)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ease of understanding, I think I'd prefer either calling keyboardHandler.KeyboardInputGesture.fromName(keyName) directly here, or adding a scriptHandler._makeKbEmulateGesture that is called from both here and scriptHandler._makeKbEmulateScript

Comment thread source/scriptHandler.py Outdated
# __name__ must be str; i.e. can't be unicode.
scriptName = scriptName.encode("mbcs")
func.__name__ = "script_%s" % scriptName
func.emuGesture = emuGesture

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed anymore?

@michaelDCurran

Copy link
Copy Markdown
Member

Is this ready to be incubated?

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

Sure.

@michaelDCurran

Copy link
Copy Markdown
Member

@LeonarddeR: could you please come up with an entry for the changes for developers section of what's new? Then I can merge this to master. Something referring to the fact it is no longer necessary to bind individual key combinations in braille display drivers...

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

I usually do not provide changes entries as my English grammar is not what it should be, but I will be more complete for new pull requests. How about the following:

  • Braille display gestures that emulate system keyboard key modifiers (such as control and alt) can now be combined with other emulated system keyboard keys without explicit definition.
    • For example: if you have a key on your display bound to the alt key and another display key to downArrow, combining these keys will result in the emulation of alt+downArrow.

@michaelDCurran

michaelDCurran commented Oct 3, 2017 via email

Copy link
Copy Markdown
Member

@michaelDCurran michaelDCurran merged commit f1ba4ca into nvaccess:master Oct 3, 2017
@nvaccessAuto nvaccessAuto added this to the 2017.4 milestone Oct 3, 2017
@LeonarddeR LeonarddeR added the BabbageWork Pull requests filed on behalf of Babbage B.V. label Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BabbageWork Pull requests filed on behalf of Babbage B.V. component/braille

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use braille display keys as modifier keys

4 participants