pub struct Morse {
pub profile: MorseProfile,
pub actions: LinearMap<MorsePattern, Action, MORSE_SIZE>,
}Expand description
Definition of a morse key.
A morse key is a key that behaves differently according to the pattern of a tap/hold sequence.
The maximum number of taps is limited to 15 by the internal u16 representation of MorsePattern.
There is a list of (pattern, corresponding action) pairs for each morse key:
The number of pairs is limited by MORSE_SIZE (from constants.rs, generated at build time).
Note: MORSE_SIZE is a wire-format capacity — on firmware it equals
MAX_PATTERNS_PER_KEY (from keyboard.toml), on host it’s a fixed upper bound.
Fields§
§profile: MorseProfileThe profile of this morse key, which defines the timing parameters, etc. If some of its fields are filled with None, the global default value will be used.
actions: LinearMap<MorsePattern, Action, MORSE_SIZE>The list of pattern -> action pairs, which can be triggered
Implementations§
Source§impl Morse
Wire format note: Morse uses a custom serde impl for the LinearMap
of actions. The on-wire shape is (MorseProfile, Vec<(u16, Action)>).
The morse_wire_format test below pins this contract.
impl Morse
Wire format note: Morse uses a custom serde impl for the LinearMap
of actions. The on-wire shape is (MorseProfile, Vec<(u16, Action)>).
The morse_wire_format test below pins this contract.
pub fn new_from_vial( tap: Action, hold: Action, hold_after_tap: Action, double_tap: Action, profile: MorseProfile, ) -> Self
pub fn new_with_actions( tap_actions: Vec<Action, MORSE_SIZE>, hold_actions: Vec<Action, MORSE_SIZE>, profile: MorseProfile, ) -> Self
pub fn max_pattern_length(&self) -> usize
pub fn try_predict_final_action( &self, pattern_start: MorsePattern, ) -> Option<Action>
pub fn can_fire_early(&self, pattern: MorsePattern) -> bool
pub fn has_pattern_or_continuation(&self, pattern: MorsePattern) -> bool
pub fn get(&self, pattern: MorsePattern) -> Option<Action>
Sourcepub fn put(
&mut self,
pattern: MorsePattern,
action: Action,
) -> Result<(), (MorsePattern, Action)>
pub fn put( &mut self, pattern: MorsePattern, action: Action, ) -> Result<(), (MorsePattern, Action)>
Insert or update an action for the given pattern.
An Action::No removes the pattern. Returns Err((pattern, action)) if the map is full.