Struct Keymap

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

Source

pub const fn new(key_definitions: I, context: Ctx) -> Self

Constructs a new keymap with the given key definitions and context.

Source

pub fn init(&mut self)

Initializes or resets the keyboard to an initial state.

Source

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.

Source

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.

Source

pub fn set_ms_per_tick(&mut self, ms_per_tick: u8)

Sets the number of ms per tick().

Source

pub fn handle_input(&mut self, ev: Event)

Handles input events.

Source

pub fn tick(&mut self)

Advances the state of the keymap by one tick.

Source

pub fn pressed_keys(&self) -> Vec<KeyOutput, { MAX_PRESSED_KEYS }>

Returns the the pressed key outputs.

Source

pub fn report_output(&mut self) -> KeymapOutput

Updates the keymap indicating a report is sent; returns the reportable keymap output.

Trait Implementations§

Source§

impl<Ctx: Debug, Ev: Debug, PKS: Debug, KS: Debug, K: Key<Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS> + ?Sized, I: Index<usize, Output = K>> Debug for Keymap<Ctx, Ev, PKS, KS, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where I: Send, Ctx: Send, PKS: Send, KS: Send, Ev: Send,

§

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>
where I: Unpin, Ctx: Unpin, PKS: Unpin, KS: Unpin, Ev: Unpin,

§

impl<Ctx, Ev, PKS, KS, I> UnwindSafe for Keymap<Ctx, Ev, PKS, KS, I>
where I: UnwindSafe, Ctx: UnwindSafe, PKS: UnwindSafe, KS: UnwindSafe, Ev: UnwindSafe,

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.