Struct pc_keyboard::Keyboard
source · pub struct Keyboard<T, S>where
T: KeyboardLayout<S>,
S: ScancodeSet,{ /* private fields */ }
Implementations
sourceimpl<T, S> Keyboard<T, S>where
T: KeyboardLayout<S>,
S: ScancodeSet,
impl<T, S> Keyboard<T, S>where
T: KeyboardLayout<S>,
S: ScancodeSet,
sourcepub fn new(_layout: T, _set: S) -> Keyboard<T, S>
pub fn new(_layout: T, _set: S) -> Keyboard<T, S>
Make a new Keyboard object with the given layout.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the bit register.
Call this when there is a timeout reading data from the keyboard.
sourcepub fn add_word(&mut self, word: u16) -> Result<Option<KeyEvent>, Error>
pub fn add_word(&mut self, word: u16) -> Result<Option<KeyEvent>, Error>
Processes a 16-bit word from the keyboard.
- The start bit (0) must be in bit 0.
- The data octet must be in bits 1..8, with the LSB in bit 1 and the MSB in bit 8.
- The parity bit must be in bit 9.
- The stop bit (1) must be in bit 10.
sourcepub fn add_byte(&mut self, byte: u8) -> Result<Option<KeyEvent>, Error>
pub fn add_byte(&mut self, byte: u8) -> Result<Option<KeyEvent>, Error>
Processes an 8-bit byte from the keyboard.
We assume the start, stop and parity bits have been processed and verified.
sourcepub fn add_bit(&mut self, bit: bool) -> Result<Option<KeyEvent>, Error>
pub fn add_bit(&mut self, bit: bool) -> Result<Option<KeyEvent>, Error>
Shift a bit into the register.
Call this /or/ call add_word
- don’t call both.
Until the last bit is added you get Ok(None) returned.
sourcepub fn process_keyevent(&mut self, ev: KeyEvent) -> Option<DecodedKey>
pub fn process_keyevent(&mut self, ev: KeyEvent) -> Option<DecodedKey>
Processes a KeyEvent
returned from add_bit
, add_byte
or add_word
and produces a decoded key.
For example, the KeyEvent for pressing the ‘5’ key on your keyboard gives a DecodedKey of unicode character ‘5’, unless the shift key is held in which case you get the unicode character ‘%’.
Trait Implementations
Auto Trait Implementations
impl<T, S> RefUnwindSafe for Keyboard<T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for Keyboard<T, S>where
S: Send,
T: Send,
impl<T, S> Sync for Keyboard<T, S>where
S: Sync,
T: Sync,
impl<T, S> Unpin for Keyboard<T, S>where
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for Keyboard<T, S>where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more