From f162555ac309a9ceb8e94b8cfad2762a4207d8ec Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 29 Jan 2024 23:15:34 +0800 Subject: [PATCH] register a listener for U2F events plugged into autobacklight this should cause the backlight to turn on anytime there is an incoming U2F packet, allowing a user to read the screen and see what they are trying to allow for authentication even in a dark room. --- services/status/src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/status/src/main.rs b/services/status/src/main.rs index dd76f03f9..2f8f32eb7 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -223,8 +223,10 @@ fn wrapped_main() -> ! { // ------------------ lay out our public API infrastructure // ok, now that we have a GID, we can continue on with our merry way let status_gid: Gid = Gid::new(canvas_gid); - // allow only one connection, from keyboard to us. - let status_sid = xns.register_name(SERVER_NAME_STATUS, Some(1)).unwrap(); + // Expected connections: + // - from keyboard + // - from USB HID + let status_sid = xns.register_name(SERVER_NAME_STATUS, Some(2)).unwrap(); // create a connection for callback hooks let cb_cid = xous::connect(status_sid).unwrap(); unsafe { CB_TO_MAIN_CONN = Some(cb_cid) }; @@ -395,6 +397,9 @@ fn wrapped_main() -> ! { kbd.lock() .unwrap() .register_observer(SERVER_NAME_STATUS, StatusOpcode::Keypress.to_u32().unwrap() as usize); + // register the USB U2F event listener - point to the same handler as key press since our intention is to + // just toggle the backlight + usb_hid.register_u2f_observer(SERVER_NAME_STATUS, StatusOpcode::Keypress.to_u32().unwrap() as usize); let autobacklight_enabled = Arc::new(Mutex::new(true)); let (tx, rx): (Sender, Receiver) = unbounded();