Struct LayerState

Source
pub struct LayerState<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> { /* private fields */ }

Implementations§

Source§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

Source

pub fn new( layer_lookup: LayerLookup<'a, LAYOUT_SIZE>, time_instance: u32, ) -> Self

Source

pub fn set_time(&mut self, val: u32)

Used to set the current time instance used for produced Layer TriggerEvents

Source

pub fn set_layer(&mut self, layer: u8, state: State) -> TriggerEvent

Set layer state If layer already has the state enable, disable and vice versa

Source

pub fn lookup<const LSIZE: usize>( &mut self, event: TriggerEvent, ) -> Option<(u8, Vec<(u16, u16), LSIZE>)>

Lookup effective layer for scancode Depending on the incoming state use either a full-lookup or cached value

Returns None if no lookup was successful Otherwise returns a list of Trigger::Result mappings to process

Source

pub fn increment_time(&mut self)

Increment time instance Per the design of KLL, each processing loop of events takes place in a single instance. Before processing any events, make sure to call this function to increment the internal time state which is needed to properly schedule generated events.

Source

pub fn process_trigger<const LSIZE: usize>( &mut self, event: TriggerEvent, ) -> Result<(), ProcessError>

Process incoming triggers

Source

pub fn off_state_lookups(&self) -> &[((u16, u16), u8, u16)]

Off state lookups Used to keep track of possibly off-states that need a reverse lookup Cleared each processing loop. ((trigger_guide, result_guide), ttype, index)

Source

pub fn process_off_state_lookups<const MAX_LAYER_LOOKUP_SIZE: usize, const MAX_EVENTS: usize>( &mut self, generate_event: &dyn Fn(usize) -> TriggerEventIterator<MAX_EVENTS>, )

Process off state lookups To maintain state use a callback function to evaluate input off states

Source

pub fn finalize_triggers<const LSIZE: usize>( &mut self, ) -> Vec<CapabilityRun, LSIZE>

Finalize incoming triggers, update internal state and generate outgoing results

Auto Trait Implementations§

§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> Freeze for LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> RefUnwindSafe for LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> Send for LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> Sync for LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> Unpin for LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

§

impl<'a, const LAYOUT_SIZE: usize, const STATE_SIZE: usize, const MAX_LAYERS: usize, const MAX_ACTIVE_LAYERS: usize, const MAX_ACTIVE_TRIGGERS: usize, const MAX_LAYER_STACK_CACHE: usize, const MAX_OFF_STATE_LOOKUP: usize> UnwindSafe for LayerState<'a, LAYOUT_SIZE, STATE_SIZE, MAX_LAYERS, MAX_ACTIVE_LAYERS, MAX_ACTIVE_TRIGGERS, MAX_LAYER_STACK_CACHE, MAX_OFF_STATE_LOOKUP>

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