Skip to main content

Combo

Struct Combo 

Source
pub struct Combo {
    pub actions: Vec<KeyAction, COMBO_SIZE>,
    pub output: KeyAction,
    pub layer: Option<u8>,
}
Expand description

Configuration data for a combo.

A combo triggers an output action when a set of keys are pressed simultaneously. The maximum number of trigger keys is determined by COMBO_SIZE (from constants.rs, generated at build time from keyboard.toml on firmware or fixed upper bound on host). Actions are stored in a Vec — only meaningful keys are present (no KeyAction::No padding).

Note: COMBO_SIZE is a wire-format capacity — on firmware it equals COMBO_MAX_LENGTH (from keyboard.toml), on host it’s a fixed upper bound.

Fields§

§actions: Vec<KeyAction, COMBO_SIZE>§output: KeyAction§layer: Option<u8>

Implementations§

Source§

impl Combo

Source

pub fn new<I: IntoIterator<Item = KeyAction>>( actions: I, output: KeyAction, layer: Option<u8>, ) -> Self

Create a new combo from an iterator of key actions.

Actions equal to KeyAction::No are filtered out. If there are more non-No actions than COMBO_SIZE, excess actions are silently dropped.

Source

pub fn empty() -> Self

Get an empty combo.

Source

pub fn size(&self) -> usize

Returns the number of key actions in the combo.

Source

pub fn find_key_action_index(&self, key_action: &KeyAction) -> Option<usize>

Find the index of a key action in the combo.

Source

pub fn contains(&self, key_action: &KeyAction) -> bool

Check whether the combo contains the given key action.

Trait Implementations§

Source§

impl Clone for Combo

Source§

fn clone(&self) -> Combo

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 Combo

Source§

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

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

impl<'de> Deserialize<'de> for Combo

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 Combo

Source§

impl MaxSize for Combo

Source§

const POSTCARD_MAX_SIZE: usize

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

impl PartialEq for Combo

Source§

fn eq(&self, other: &Combo) -> 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 Combo

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
Source§

impl StructuralPartialEq for Combo

Auto Trait Implementations§

§

impl Freeze for Combo

§

impl RefUnwindSafe for Combo

§

impl Send for Combo

§

impl Sync for Combo

§

impl Unpin for Combo

§

impl UnsafeUnpin for Combo

§

impl UnwindSafe for Combo

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.