[][src]Struct keytokey::Keyboard

pub struct Keyboard<'a, T: USBKeyOut> {
    pub output: T,
    // some fields omitted
}

the main keyboard struct

add handlers wit add_handler, then call add_keypress/add_key_release/add_timeout to start processing keys.

Fields

output: T

Implementations

impl<'a, T: USBKeyOut> Keyboard<'a, T>[src]

pub fn new(output: T) -> Keyboard<'a, T>[src]

pub fn add_handler(
    &mut self,
    handler: Box<dyn ProcessKeys<T> + Send + 'a>
) -> HandlerID
[src]

add a handler, return a HandlerID which you may use with keyboard.output.state().enable_handler / disable_handler / toggle_handler / is_handler_enabled

by default, most handlers start in the enabled state (with the notable exception of Layers).

pub fn future_handler_id(&self, offset: usize) -> HandlerID[src]

predict the next or further out hander_ids returned by add_handler Needed to add space cadets before the layers they toggle.

pub fn handle_keys(&mut self) -> Result<(), ()>[src]

handle an update to the event stream

This returns OK(()) if all keys are handled by the handlers and an Err(()) otherwise. that way the down stream can decide what to do (tests: panic. Firmare/MatrixToStream -> drop unhandled events)

pub fn clear_unhandled(&mut self)[src]

pub fn add_keypress<X: AcceptsKeycode>(
    &mut self,
    keycode: X,
    ms_since_last: u16
)
[src]

add a KeyPress event

pub fn add_keyrelease<X: AcceptsKeycode>(
    &mut self,
    keycode: X,
    ms_since_last: u16
)
[src]

add a KeyRelease event

pub fn add_timeout(&mut self, ms_since_last: u16)[src]

Auto Trait Implementations

impl<'a, T> Send for Keyboard<'a, T> where
    T: Send

impl<'a, T> !Sync for Keyboard<'a, T>

impl<'a, T> Unpin for Keyboard<'a, T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.