Trait System

Source
pub trait System<R>: Debug {
    type Ref: Copy;
    type Context: Copy;
    type Event: Copy + Debug + PartialEq;
    type PendingKeyState;
    type KeyState;

    // Required methods
    fn new_pressed_key(
        &self,
        keymap_index: u16,
        context: &Self::Context,
        key_ref: Self::Ref,
    ) -> (PressedKeyResult<R, Self::PendingKeyState, Self::KeyState>, KeyEvents<Self::Event>);
    fn update_pending_state(
        &self,
        pending_state: &mut Self::PendingKeyState,
        keymap_index: u16,
        context: &Self::Context,
        key_ref: Self::Ref,
        event: Event<Self::Event>,
    ) -> (Option<NewPressedKey<R>>, KeyEvents<Self::Event>);

    // Provided methods
    fn update_state(
        &self,
        _key_state: &mut Self::KeyState,
        _ref: &Self::Ref,
        _context: &Self::Context,
        _keymap_index: u16,
        _event: Event<Self::Event>,
    ) -> KeyEvents<Self::Event> { ... }
    fn key_output(
        &self,
        _ref: &Self::Ref,
        _key_state: &Self::KeyState,
    ) -> Option<KeyOutput> { ... }
}
Expand description

The interface for key System behaviour.

A System has an associated Ref, Context, Event, and KeyState.

The generic PK is used as the type of the PressedKey that the Key produces. (e.g. layered::LayeredKey’s pressed key state passes-through to the keys of its layers).

Required Associated Types§

Source

type Ref: Copy

Used to identify the key definition in the keymap.

Source

type Context: Copy

The associated Context is used to provide state that may affect behaviour when pressing the key. (e.g. the behaviour of layered::LayeredKey depends on which layers are active in layered::Context).

Source

type Event: Copy + Debug + PartialEq

The associated Event is to be handled by the associated Context, pending key states, and key states.

Source

type PendingKeyState

Associated pending key state.

Source

type KeyState

Associated key state type.

Required Methods§

Source

fn new_pressed_key( &self, keymap_index: u16, context: &Self::Context, key_ref: Self::Ref, ) -> (PressedKeyResult<R, Self::PendingKeyState, Self::KeyState>, KeyEvents<Self::Event>)

Produces a pressed key value, and may yield some ScheduledEvents. (e.g. tap_hold::Key schedules a tap_hold::Event::TapHoldTimeout so that holding the key resolves as a hold).

Source

fn update_pending_state( &self, pending_state: &mut Self::PendingKeyState, keymap_index: u16, context: &Self::Context, key_ref: Self::Ref, event: Event<Self::Event>, ) -> (Option<NewPressedKey<R>>, KeyEvents<Self::Event>)

Update the given pending key state with the given impl.

Provided Methods§

Source

fn update_state( &self, _key_state: &mut Self::KeyState, _ref: &Self::Ref, _context: &Self::Context, _keymap_index: u16, _event: Event<Self::Event>, ) -> KeyEvents<Self::Event>

Used to update the KeyState’s state, and possibly yield event(s).

Source

fn key_output( &self, _ref: &Self::Ref, _key_state: &Self::KeyState, ) -> Option<KeyOutput>

Output for the pressed key state.

Implementors§

Source§

impl<K: Debug + Keys> System<Ref> for smart_keymap::key::composite::System<K>

Source§

impl<R> System<R> for smart_keymap::key::caps_word::System

Source§

impl<R> System<R> for smart_keymap::key::custom::System

Source§

impl<R, Keys: Debug + Index<usize, Output = Key>> System<R> for smart_keymap::key::callback::System<Keys>

Source§

impl<R, Keys: Debug + Index<usize, Output = Key>> System<R> for smart_keymap::key::keyboard::System<Keys>

Source§

impl<R, Keys: Debug + Index<usize, Output = Key>> System<R> for smart_keymap::key::sticky::System<Keys>

Source§

impl<R: Copy + Debug + PartialEq, Keys: Debug + Index<usize, Output = Key<R>>, AuxiliaryKeys: Debug + Index<usize, Output = AuxiliaryKey<R>>> System<R> for smart_keymap::key::chorded::System<R, Keys, AuxiliaryKeys>

Source§

impl<R: Copy + Debug + PartialEq, ModifierKeys: Debug + Index<usize, Output = ModifierKey>, LayeredKeys: Debug + Index<usize, Output = LayeredKey<R>>> System<R> for smart_keymap::key::layered::System<R, ModifierKeys, LayeredKeys>

Source§

impl<R: Copy + Debug, Keys: Debug + Index<usize, Output = Key<R>>> System<R> for smart_keymap::key::tap_dance::System<R, Keys>

Source§

impl<R: Copy + Debug, Keys: Debug + Index<usize, Output = Key<R>>> System<R> for smart_keymap::key::tap_hold::System<R, Keys>