diff options
author | Brian Cully <bjc@kublai.com> | 2019-09-26 08:57:05 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-09-26 08:57:05 -0400 |
commit | 71364c8336edaf45071e3775d07f291b6fecd41d (patch) | |
tree | e8f3d8d044de751f34de08f50824fd2e1ce42e7f /src/lib.rs | |
parent | dac87373a4193d17d288edd38224e73fbc2c517e (diff) | |
download | bootkbd-71364c8336edaf45071e3775d07f291b6fecd41d.tar.gz bootkbd-71364c8336edaf45071e3775d07f291b6fecd41d.zip |
Set the keyboard protocol to boot mode during enumeration.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -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 => { |