From 71364c8336edaf45071e3775d07f291b6fecd41d Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Thu, 26 Sep 2019 08:57:05 -0400 Subject: Set the keyboard protocol to boot mode during enumeration. --- src/lib.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 43e3f12..11caafe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,6 +104,7 @@ enum DeviceState { WaitForSettle(usize), GetConfig, SetConfig(u8), + SetProtocol, SetIdle, SetReport, Running, @@ -262,7 +263,28 @@ impl Device { none, )?; - self.state = DeviceState::SetIdle + self.state = DeviceState::SetProtocol; + } + + DeviceState::SetProtocol => { + if let Some(ref ep) = self.endpoints[0] { + host.control_transfer( + &mut self.ep0, + RequestType::from(( + RequestDirection::HostToDevice, + RequestKind::Class, + RequestRecipient::Interface, + )), + RequestCode::SetInterface, + WValue::from((0, 0)), + u16::from(ep.interface_num), + None, + )?; + + self.state = DeviceState::SetIdle; + } else { + return Err(TransferError::Permanent("no boot keyboard")); + } } DeviceState::SetIdle => { @@ -278,7 +300,7 @@ impl Device { 0, none, )?; - self.state = DeviceState::SetReport + self.state = DeviceState::SetReport; } DeviceState::SetReport => { -- cgit v1.2.3