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>
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>
pub fn new( layer_lookup: LayerLookup<'a, LAYOUT_SIZE>, time_instance: u32, ) -> Self
Sourcepub fn set_time(&mut self, val: u32)
pub fn set_time(&mut self, val: u32)
Used to set the current time instance used for produced Layer TriggerEvents
Sourcepub fn set_layer(&mut self, layer: u8, state: State) -> TriggerEvent
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
Sourcepub fn lookup<const LSIZE: usize>(
&mut self,
event: TriggerEvent,
) -> Option<(u8, Vec<(u16, u16), LSIZE>)>
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
Sourcepub fn increment_time(&mut self)
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.
Sourcepub fn process_trigger<const LSIZE: usize>(
&mut self,
event: TriggerEvent,
) -> Result<(), ProcessError>
pub fn process_trigger<const LSIZE: usize>( &mut self, event: TriggerEvent, ) -> Result<(), ProcessError>
Process incoming triggers
Sourcepub fn off_state_lookups(&self) -> &[((u16, u16), u8, u16)]
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)
Sourcepub 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>,
)
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
Sourcepub fn finalize_triggers<const LSIZE: usize>(
&mut self,
) -> Vec<CapabilityRun, LSIZE>
pub fn finalize_triggers<const LSIZE: usize>( &mut self, ) -> Vec<CapabilityRun, LSIZE>
Finalize incoming triggers, update internal state and generate outgoing results