Struct Keymap

Source
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, S: System<R, Ref = R, Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS>> Keymap<I, R, Ctx, Ev, PKS, KS, S>
where KS: From<NoOpKeyState> + Copy + Debug,

Source

pub const fn new(key_refs: I, context: Ctx, key_system: S) -> 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<I: Debug + Index<usize, Output = R>, R: Debug, Ctx: Debug, Ev: Debug, PKS: Debug, KS: Debug, S: System<R, Ref = R, Context = Ctx, Event = Ev, PendingKeyState = PKS, KeyState = KS>> Debug for Keymap<I, R, Ctx, Ev, PKS, KS, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, R, Ctx, Ev, PKS, KS, S> !Freeze for Keymap<I, R, Ctx, Ev, PKS, KS, S>

§

impl<I, R, Ctx, Ev, PKS, KS, S> !RefUnwindSafe for Keymap<I, R, Ctx, Ev, PKS, KS, S>

§

impl<I, R, Ctx, Ev, PKS, KS, S> Send for Keymap<I, R, Ctx, Ev, PKS, KS, S>
where I: Send, S: Send, Ctx: Send, R: Send, PKS: Send, KS: Send, Ev: Send,

§

impl<I, R, Ctx, Ev, PKS, KS, S> !Sync for Keymap<I, R, Ctx, Ev, PKS, KS, S>

§

impl<I, R, Ctx, Ev, PKS, KS, S> Unpin for Keymap<I, R, Ctx, Ev, PKS, KS, S>
where I: Unpin, S: Unpin, Ctx: Unpin, R: Unpin, PKS: Unpin, KS: Unpin, Ev: Unpin,

§

impl<I, R, Ctx, Ev, PKS, KS, S> UnwindSafe for Keymap<I, R, Ctx, Ev, PKS, KS, S>

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.