pub struct Keymap<Ctx, Ev: Debug, PKS, KS, I> { /* private fields */ }
Expand description
State for a keymap that handles input, and outputs HID keyboard reports.
Implementations§
Source§impl<Ctx: Context<Event = Ev> + SetKeymapContext, Ev: Copy + Debug + PartialEq, PKS, KS: KeyState<Context = Ctx, Event = Ev> + Copy, K: Key<Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS> + ?Sized, I: Index<usize, Output = K>> Keymap<Ctx, Ev, PKS, KS, I>
impl<Ctx: Context<Event = Ev> + SetKeymapContext, Ev: Copy + Debug + PartialEq, PKS, KS: KeyState<Context = Ctx, Event = Ev> + Copy, K: Key<Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS> + ?Sized, I: Index<usize, Output = K>> Keymap<Ctx, Ev, PKS, KS, I>
Sourcepub const fn new(key_definitions: I, context: Ctx) -> Self
pub const fn new(key_definitions: I, context: Ctx) -> 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.
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 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.
Trait Implementations§
Auto Trait Implementations§
impl<Ctx, Ev, PKS, KS, I> !Freeze for Keymap<Ctx, Ev, PKS, KS, I>
impl<Ctx, Ev, PKS, KS, I> !RefUnwindSafe for Keymap<Ctx, Ev, PKS, KS, I>
impl<Ctx, Ev, PKS, KS, I> Send for Keymap<Ctx, Ev, PKS, KS, I>
impl<Ctx, Ev, PKS, KS, I> !Sync for Keymap<Ctx, Ev, PKS, KS, I>
impl<Ctx, Ev, PKS, KS, I> Unpin for Keymap<Ctx, Ev, PKS, KS, I>
impl<Ctx, Ev, PKS, KS, I> UnwindSafe for Keymap<Ctx, Ev, PKS, KS, I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more