add no-gam coordination of keyboard hits based on focus of keys

modals has to be able to acquire/release focus without the
assistance of the GAM in a no-gam model.
This commit is contained in:
bunnie 2025-05-06 01:46:56 +08:00
parent 8d896b4dba
commit 8a2651e9cb
4 changed files with 34 additions and 5 deletions

View file

@ -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 = []

View file

@ -170,4 +170,9 @@ pub(crate) enum Opcode {
Gutter = 29,
Quit = 30,
#[cfg(feature = "no-gam")]
ReleaseFocus = 1024,
#[cfg(feature = "no-gam")]
AcquireFocus = 1025,
}

View file

@ -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};

View file

@ -176,6 +176,8 @@ fn wrapped_main() -> ! {
let mut dynamic_notification_listener: Option<xous::MessageSender> = 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;