tweak delays for more consistent key down reporting

This commit is contained in:
bunnie 2022-05-16 21:43:24 +08:00
parent 71f5183766
commit 3f779d5def
2 changed files with 1 additions and 4 deletions

View file

@ -543,10 +543,6 @@ impl UsbBus for SpinalUsbDevice {
core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst);
log::debug!("ep{} write: {:x?}", ep_addr.index(), &buf);
if ep_addr.index() == 0 {
// TODO: why is this delay necessary? there is a race condition, but I don't know where.
//self.tt.sleep_ms(1).unwrap();
}
Ok(buf.len())
}
} else {

View file

@ -206,6 +206,7 @@ fn xmain() -> ! {
let code = hid_convert(key);
keyboard.interface().write_report(&code).ok();
keyboard.interface().tick().unwrap();
tt.sleep_ms(20).unwrap();
keyboard.interface().write_report(&[]).ok(); // this is the key-up
keyboard.interface().tick().unwrap();