make keyboard tick() blocks non-fatal

at the moment if for some reason the USB stack can't send a tick
there's a panic. it's not actually a life-ending event if that happens.
This commit is contained in:
bunnie 2022-06-27 02:18:55 +08:00
parent 0e5fb14894
commit a7ce3e6204

View file

@ -180,7 +180,7 @@ fn main() -> ! {
{ {
let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>(); let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>();
keyboard.write_report(&Vec::<Keyboard>::new()).ok(); keyboard.write_report(&Vec::<Keyboard>::new()).ok();
keyboard.tick().unwrap(); keyboard.tick().ok();
} }
#[cfg(any(target_os = "none", target_os = "xous"))] #[cfg(any(target_os = "none", target_os = "xous"))]
@ -414,11 +414,11 @@ fn main() -> ! {
{ {
let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>(); let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>();
keyboard.write_report(&codes).ok(); keyboard.write_report(&codes).ok();
keyboard.tick().unwrap(); keyboard.tick().ok();
tt.sleep_ms(30).ok(); tt.sleep_ms(30).ok();
if auto_up { if auto_up {
keyboard.write_report(&[]).ok(); // this is the key-up keyboard.write_report(&[]).ok(); // this is the key-up
keyboard.tick().unwrap(); keyboard.tick().ok();
tt.sleep_ms(30).ok(); tt.sleep_ms(30).ok();
} }
} }
@ -450,10 +450,10 @@ fn main() -> ! {
{ {
let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>(); let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>();
keyboard.write_report(&codes).ok(); keyboard.write_report(&codes).ok();
keyboard.tick().unwrap(); keyboard.tick().ok();
tt.sleep_ms(30).ok(); tt.sleep_ms(30).ok();
keyboard.write_report(&[]).ok(); // this is the key-up keyboard.write_report(&[]).ok(); // this is the key-up
keyboard.tick().unwrap(); keyboard.tick().ok();
tt.sleep_ms(30).ok(); tt.sleep_ms(30).ok();
} }
sent += 1; sent += 1;