fix hub home launch input arming

This commit is contained in:
2026-05-16 08:31:50 +01:00
parent 8f74bd2b22
commit 2e214b544b
3 changed files with 44 additions and 30 deletions
@@ -25,7 +25,9 @@ const COLOR_BUTTON: Color = Color::rgb(45, 59, 82);
const COLOR_BUTTON_ACTIVE: Color = Color::rgb(72, 91, 122);
/// PrometeuHub: Launcher and system UI environment.
pub struct PrometeuHub;
pub struct PrometeuHub {
home_input_armed: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NativeShellApp {
@@ -87,11 +89,11 @@ impl Default for PrometeuHub {
impl PrometeuHub {
pub fn new() -> Self {
Self
Self { home_input_armed: false }
}
pub fn init(&mut self) {
// Initializes the Window System and lists apps
self.home_input_armed = false;
}
pub fn gui_update(
@@ -102,19 +104,23 @@ impl PrometeuHub {
hw.gfx_mut().clear(Color::BLACK);
let in_shell = os.windows().focused_window().is_some();
if !in_shell {
if !self.home_input_armed {
self.home_input_armed = !activation_input_down(hw);
return None;
}
} else {
self.home_input_armed = false;
}
if let Some(action) =
action_for_click(in_shell, hw.touch().x(), hw.touch().y(), hw.touch().f().pressed)
{
return Some(action);
}
if !in_shell && hw.pad().a().pressed {
Some(SystemProfileAction::LaunchNativeShell(NativeShellApp::ShellA))
} else if !in_shell && hw.pad().b().pressed {
Some(SystemProfileAction::LaunchNativeShell(NativeShellApp::ShellB))
} else {
None
}
None
}
pub fn render(&mut self, os: &mut SystemOS, hw: &mut dyn HardwareBridge) {
@@ -182,6 +188,10 @@ fn rect_contains(rect: Rect, x: i32, y: i32) -> bool {
x >= rect.x && x < rect.x + rect.w && y >= rect.y && y < rect.y + rect.h
}
fn activation_input_down(hw: &dyn HardwareBridge) -> bool {
hw.touch().f().down || hw.pad().a().down || hw.pad().b().down || hw.pad().start().down
}
fn render_home(gfx: &mut dyn GfxBridge, pointer_x: i32, pointer_y: i32) {
gfx.fill_rect(VIEWPORT.x, VIEWPORT.y, VIEWPORT.w, VIEWPORT.h, COLOR_BG);
draw_panel(gfx, TITLE_PANEL, COLOR_PANEL_DARK, COLOR_BORDER);
@@ -275,6 +285,12 @@ mod tests {
assert_eq!(action_for_click(false, SHELL_A_BUTTON.x, SHELL_A_BUTTON.y, false), None);
}
#[test]
fn hub_starts_with_home_input_disarmed() {
let hub = PrometeuHub::new();
assert!(!hub.home_input_armed);
}
#[test]
fn close_button_click_emits_close_only_in_shell() {
assert_eq!(