Skip to main content

Keyboard

Struct Keyboard 

Source
pub struct Keyboard { /* private fields */ }
Expand description

Boot-compatible keyboard.

Pressing a key means sending a report with that key set, then sending KeyboardReport::default (or the next set of keys) to release it. Wrap it in a HidClass to talk to the host:

ⓘ
let mut kbd = HidClass::new(&alloc, Keyboard::new());
kbd.send_input(&KeyboardReport { keys: [0x04, 0, 0, 0, 0, 0], ..Default::default() }.to_bytes());

Implementations§

Source§

impl Keyboard

Source

pub const fn new() -> Self

Create a keyboard with all LEDs off.

Source

pub fn leds(&self) -> u8

LED state the host last asked for, see led.

Trait Implementations§

Source§

impl Default for Keyboard

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<B: UsbBus> HidDevice<B> for Keyboard

Source§

fn spec(&self) -> HidSpec

Report descriptor, endpoint sizes and interface class/protocol.
Source§

fn output_report(&mut self, _report_id: u8, data: &[u8])

Output report received on the interrupt OUT endpoint. Read more
Source§

fn reset(&mut self)

Called after a USB bus reset.
Source§

fn get_report( &mut self, _report_type: ReportType, _report_id: u8, _buf: &mut [u8], ) -> Option<usize>

Get Report — copy the report selected by report_type and report_id into buf and return its length, including the report ID byte when the spec declares report IDs. Read more
Source§

fn set_report( &mut self, _report_type: ReportType, _report_id: u8, _data: &[u8], ) -> bool

Set Report — handle a report written by the host. Read more
Source§

fn configure(&mut self)

Called when the host configures the device. Read more
Source§

fn deconfigure(&mut self)

Called when the host de-configures the device.
Source§

fn poll(&mut self, _input: &EndpointIn<'_, B>)

Called on every device poll while configured. Read more

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.