Skip to main content

System

Trait System 

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> { ... }
    fn pending_output(
        &self,
        _pending_key_state: &Self::PendingKeyState,
    ) -> 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§

type Ref: Copy

Used to identify the key definition in the keymap.

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

type Event: Copy + Debug + PartialEq

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

type PendingKeyState

Associated pending key state.

type KeyState

Associated key state type.

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>)

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

Delays are from this call. When the keymap replaces a pending key with another pending key (e.g. chorded passthrough to tap-hold), it backdates those After delays by time already spent on this press.

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§

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

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

Output for the pressed key state.

fn pending_output( &self, _pending_key_state: &Self::PendingKeyState, ) -> Option<KeyOutput>

HID while a pending session is live.

Default: no output until the pending key resolves. crate::keymap::Keymap includes this in pressed-key HID and aggregated modifiers while a pending session is live.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl System<Ref> for smart_keymap::init::key_system::System

§

impl<R, Keys, AuxiliaryKeys, const MAX_CHORDS: usize, const MAX_CHORD_SIZE: usize, const MAX_OVERLAPPING_CHORD_SIZE: usize, const MAX_PRESSED_INDICES: usize> System<R> for smart_keymap::key::chorded::System<R, Keys, AuxiliaryKeys, MAX_CHORDS, MAX_CHORD_SIZE, MAX_OVERLAPPING_CHORD_SIZE, MAX_PRESSED_INDICES>
where R: Copy + Debug + PartialEq, Keys: Debug + Index<usize, Output = Key<R, MAX_CHORDS, MAX_CHORD_SIZE, MAX_OVERLAPPING_CHORD_SIZE, MAX_PRESSED_INDICES>> + AsRef<[Key<R, MAX_CHORDS, MAX_CHORD_SIZE, MAX_OVERLAPPING_CHORD_SIZE, MAX_PRESSED_INDICES>]>, AuxiliaryKeys: Debug + Index<usize, Output = AuxiliaryKey<R, MAX_CHORDS, MAX_CHORD_SIZE, MAX_PRESSED_INDICES>>,

§

type Ref = Ref

§

type Context = Context<MAX_CHORDS, MAX_CHORD_SIZE, MAX_PRESSED_INDICES>

§

type Event = Event

§

type PendingKeyState = PendingKeyState<MAX_CHORDS, MAX_CHORD_SIZE, MAX_PRESSED_INDICES>

§

type KeyState = KeyState

§

impl<R, Keys, AuxiliaryKeys, const MAX_SEQUENCES: usize, const MAX_SEQUENCE_LEN: usize, const MAX_OVERLAPPING: usize> System<R> for smart_keymap::key::sequence::System<R, Keys, AuxiliaryKeys, MAX_SEQUENCES, MAX_SEQUENCE_LEN, MAX_OVERLAPPING>
where R: Copy + Debug + PartialEq, Keys: Debug + Index<usize, Output = Key<R, MAX_OVERLAPPING>> + AsRef<[Key<R, MAX_OVERLAPPING>]>, AuxiliaryKeys: Debug + Index<usize, Output = AuxiliaryKey<R>>,

§

type Ref = Ref

§

type Context = Context<MAX_SEQUENCES, MAX_SEQUENCE_LEN>

§

type Event = Event

§

type PendingKeyState = PendingKeyState

§

type KeyState = KeyState

§

impl<R, Keys, const ALT_REPEAT_RULE_COUNT: usize> System<R> for smart_keymap::key::history::System<R, Keys, ALT_REPEAT_RULE_COUNT>
where R: Debug, Keys: Debug + Index<usize, Output = AdaptiveKey>,

§

type Ref = Ref

§

type Context = Context<ALT_REPEAT_RULE_COUNT>

§

type Event = Event

§

type PendingKeyState = PendingKeyState

§

type KeyState = KeyState

§

impl<R, Keys, const INSTRUCTION_COUNT: usize> System<R> for smart_keymap::key::automation::System<R, Keys, INSTRUCTION_COUNT>
where R: Copy + Debug, Keys: Debug + Index<usize, Output = Key>,

§

type Ref = Ref

§

type Context = Context<INSTRUCTION_COUNT>

§

type Event = Event

§

type PendingKeyState = PendingKeyState

§

type KeyState = KeyState

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

type Ref = Ref

§

type Context = Context<LAYER_COUNT, CONDITIONAL_LAYER_COUNT>

§

type Event = LayerEvent

§

type PendingKeyState = PendingKeyState

§

type KeyState = ModifierKeyState

§

impl<R> System<R> for smart_keymap::key::caps_word::System<R>
where R: Debug,

§

impl<R> System<R> for smart_keymap::key::custom::System<R>
where R: Debug,

§

impl<R> System<R> for smart_keymap::key::key_lock::System<R>
where R: Debug,