diff --git a/services/modals/Cargo.toml b/services/modals/Cargo.toml index c8e971e07..c11249435 100644 --- a/services/modals/Cargo.toml +++ b/services/modals/Cargo.toml @@ -36,13 +36,14 @@ ux-api = { path = "../../libs/ux-api", optional = true, features = ["std"] } utralib = { version = "0.1.25", optional = true, default-features = false } [features] +no-gam = [] precursor = ["utralib/precursor", "trng", "gam", "tts-frontend"] hosted = ["utralib/hosted", "trng", "gam", "tts-frontend"] renode = ["utralib/renode", "trng", "gam", "tts-frontend"] -cramium-soc = ["utralib/cramium-soc", "cram-hal-service"] -hosted-baosec = ["ux-api/hosted-baosec", "cramium-emu", "cramium-api"] -board-baosec = ["ux-api/board-baosec", "cramium-api"] +cramium-soc = ["utralib/cramium-soc", "cram-hal-service", "no-gam"] +hosted-baosec = ["ux-api/hosted-baosec", "cramium-emu", "cramium-api", "no-gam"] +board-baosec = ["ux-api/board-baosec", "cramium-api", "no-gam"] doc-deps = ["gam", "ux-api/doc-deps"] modal-testing = [] diff --git a/services/modals/src/api.rs b/services/modals/src/api.rs index 35e82a3b7..661ac75ab 100644 --- a/services/modals/src/api.rs +++ b/services/modals/src/api.rs @@ -170,4 +170,9 @@ pub(crate) enum Opcode { Gutter = 29, Quit = 30, + + #[cfg(feature = "no-gam")] + ReleaseFocus = 1024, + #[cfg(feature = "no-gam")] + AcquireFocus = 1025, } diff --git a/services/modals/src/lib.rs b/services/modals/src/lib.rs index 137012c06..17ad3a38b 100644 --- a/services/modals/src/lib.rs +++ b/services/modals/src/lib.rs @@ -915,6 +915,18 @@ impl Modals { /// - needed for use with `dynamic_notification_blocking_listener` /// - see `dynamic_notification_blocking_listener` for a code example. pub fn token(&self) -> [u32; 4] { self.token } + + #[cfg(feature = "no-gam")] + pub fn release_focus(&self) { + send_message(self.conn, Message::new_scalar(Opcode::ReleaseFocus.to_usize().unwrap(), 0, 0, 0, 0)) + .unwrap(); + } + + #[cfg(feature = "no-gam")] + pub fn acquire_focus(&self) { + send_message(self.conn, Message::new_scalar(Opcode::AcquireFocus.to_usize().unwrap(), 0, 0, 0, 0)) + .unwrap(); + } } use core::sync::atomic::{AtomicU32, Ordering}; diff --git a/services/modals/src/main.rs b/services/modals/src/main.rs index 8dd9619cb..8392eb131 100644 --- a/services/modals/src/main.rs +++ b/services/modals/src/main.rs @@ -176,6 +176,8 @@ fn wrapped_main() -> ! { let mut dynamic_notification_listener: Option = None; let mut dynamic_notification_active: bool = false; + #[cfg(feature = "no-gam")] + let mut has_focus = false; loop { let mut msg = xous::receive_message(modals_sid).unwrap(); @@ -1021,13 +1023,22 @@ fn wrapped_main() -> ! { core::char::from_u32(k3 as u32).unwrap_or('\u{0000}'), core::char::from_u32(k4 as u32).unwrap_or('\u{0000}'), ]; - renderer_modal.key_event(keys); + if has_focus { + renderer_modal.key_event(keys); + } }), Some(Opcode::ModalDrop) => { // this guy should never quit, it's a core OS service panic!("Password modal for PDDB quit unexpectedly"); } - + #[cfg(feature = "no-gam")] + Some(Opcode::AcquireFocus) => msg_scalar_unpack!(msg, _, _, _, _, { + has_focus = true; + }), + #[cfg(feature = "no-gam")] + Some(Opcode::ReleaseFocus) => msg_scalar_unpack!(msg, _, _, _, _, { + has_focus = false; + }), Some(Opcode::Quit) => { log::warn!("Shared modal UX handler exiting."); break;