aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-09-26 08:57:05 -0400
committerBrian Cully <bjc@kublai.com>2019-09-26 08:57:05 -0400
commit71364c8336edaf45071e3775d07f291b6fecd41d (patch)
treee8f3d8d044de751f34de08f50824fd2e1ce42e7f /src
parentdac87373a4193d17d288edd38224e73fbc2c517e (diff)
downloadbootkbd-71364c8336edaf45071e3775d07f291b6fecd41d.tar.gz
bootkbd-71364c8336edaf45071e3775d07f291b6fecd41d.zip
Set the keyboard protocol to boot mode during enumeration.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs26
1 files 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 => {