pub struct Keymap<I: Index<usize, Output = R>, R, Ctx, Ev: Debug, PKS, KS, S> { /* private fields */ }Expand description
State for a keymap that handles input, and outputs HID keyboard reports.
Implementations§
Source§impl<I: Debug + Index<usize, Output = R>, R: Copy + Debug, Ctx: Debug + Context<Event = Ev> + SetKeymapContext, Ev: Copy + Debug, PKS: Debug, KS: Copy + Debug + From<NoOpKeyState>, S: System<R, Ref = R, Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS>> Keymap<I, R, Ctx, Ev, PKS, KS, S>
impl<I: Debug + Index<usize, Output = R>, R: Copy + Debug, Ctx: Debug + Context<Event = Ev> + SetKeymapContext, Ev: Copy + Debug, PKS: Debug, KS: Copy + Debug + From<NoOpKeyState>, S: System<R, Ref = R, Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS>> Keymap<I, R, Ctx, Ev, PKS, KS, S>
Sourcepub const fn new(key_refs: I, context: Ctx, key_system: S) -> Self
pub const fn new(key_refs: I, context: Ctx, key_system: S) -> Self
Constructs a new keymap with the given key definitions and context.
Sourcepub fn set_callback(&mut self, callback_id: KeymapCallback, callback_fn: fn())
pub fn set_callback(&mut self, callback_id: KeymapCallback, callback_fn: fn())
Registers the given callback to the keymap.
Only one callback is set for each callback id.
Sourcepub fn set_callback_extern(
&mut self,
callback_id: KeymapCallback,
callback_fn: extern "C" fn(),
)
pub fn set_callback_extern( &mut self, callback_id: KeymapCallback, callback_fn: extern "C" fn(), )
Registers the given callback to the keymap.
Only one callback is set for each callback id.
Sourcepub fn set_ms_per_tick(&mut self, ms_per_tick: u8)
pub fn set_ms_per_tick(&mut self, ms_per_tick: u8)
Sets the number of ms per tick().
Sourcepub fn handle_input(&mut self, ev: Event)
pub fn handle_input(&mut self, ev: Event)
Handles input events.
Discards the input event if the input queue is full.
Sourcepub fn pressed_keys(&self) -> Vec<KeyOutput, { MAX_PRESSED_KEYS }>
pub fn pressed_keys(&self) -> Vec<KeyOutput, { MAX_PRESSED_KEYS }>
Returns the the pressed key outputs.
Sourcepub fn handle_input_after_time(
&mut self,
delta_ms: u32,
ev: Event,
) -> Option<u32>
pub fn handle_input_after_time( &mut self, delta_ms: u32, ev: Event, ) -> Option<u32>
Handles input events.
Discards the input event if the input queue is full.
Returns the time in ms until the next scheduled event, if any. (Time until next tick, if any, will always be >0, so 0 can be used as “NO EVENTS”)
Sourcepub fn tick_to_next_scheduled_event(&mut self) -> Option<u32>
pub fn tick_to_next_scheduled_event(&mut self) -> Option<u32>
If the event scheduler has a next scheduled event, it ticks the keymap forward to that event, returning the time in ms until the following event.
Otherwise, does nothing and returns None.
Sourcepub fn report_output(&mut self) -> KeymapOutput
pub fn report_output(&mut self) -> KeymapOutput
Updates the keymap indicating a report is sent; returns the reportable keymap output.
Sourcepub fn requires_polling(&self) -> bool
pub fn requires_polling(&self) -> bool
Whether the keymap has pending state that requires polling.