Skip to main content

Morse

Struct Morse 

Source
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: MorseProfile

The 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.

Source

pub fn new_from_vial( tap: Action, hold: Action, hold_after_tap: Action, double_tap: Action, profile: MorseProfile, ) -> Self

Source

pub fn new_with_actions( tap_actions: Vec<Action, MORSE_SIZE>, hold_actions: Vec<Action, MORSE_SIZE>, profile: MorseProfile, ) -> Self

Source

pub fn max_pattern_length(&self) -> usize

Source

pub fn try_predict_final_action( &self, pattern_start: MorsePattern, ) -> Option<Action>

Source

pub fn can_fire_early(&self, pattern: MorsePattern) -> bool

Source

pub fn has_pattern_or_continuation(&self, pattern: MorsePattern) -> bool

Source

pub fn get(&self, pattern: MorsePattern) -> Option<Action>

Source

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.

Trait Implementations§

Source§

impl Clone for Morse

Source§

fn clone(&self) -> Morse

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Morse

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Morse

Source§

fn default() -> Morse

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Morse

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Morse

Source§

impl MaxSize for Morse

Source§

const POSTCARD_MAX_SIZE: usize

The maximum possible size that the serialization of this type can have, in bytes.
Source§

impl PartialEq for Morse

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Morse

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Morse

§

impl RefUnwindSafe for Morse

§

impl Send for Morse

§

impl Sync for Morse

§

impl Unpin for Morse

§

impl UnsafeUnpin for Morse

§

impl UnwindSafe for Morse

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.