modifiers: Support Control and Alt

Control and Alt are special in that they aren't expected to switch levels, and so don't need to change what characters are output.

Use in layouts by adding `modifier: Control` or `modifier: Alt` in place of `text: "foo"`.

The latching of the modifier will force the keyboard to emit raw key presses and prevent it from outputting text.
This commit is contained in:
Dorota Czaplejewicz
2020-01-15 15:23:06 +00:00
parent c28f07fcfd
commit 92e9d994fe
13 changed files with 193 additions and 34 deletions

View File

@ -10,8 +10,11 @@ pub struct KeySym(pub String);
type View = String;
/// Use to send modified keypresses
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Modifier {
/// Control and Alt are the only modifiers
/// which doesn't interfere with levels,
/// so it's simple to implement as levels are deprecated in squeekboard.
Control,
Alt,
}
@ -27,8 +30,8 @@ pub enum Action {
/// When unlocked by pressing it or emitting a key
unlock: View,
},
/// Set this modifier TODO: release?
SetModifier(Modifier),
/// Hold this modifier for as long as the button is pressed
ApplyModifier(Modifier),
/// Submit some text
Submit {
/// Text to submit with input-method.