implements PLN-0048 minimal system hub pipeline

This commit is contained in:
2026-05-14 13:27:05 +01:00
parent bea3f76aa7
commit 20e8439416
6 changed files with 60 additions and 38 deletions
@@ -343,6 +343,22 @@ mod tests {
assert_eq!(firmware.hub.window_manager.windows.len(), 1);
}
#[test]
fn system_running_ticks_focused_system_app_through_hub_pipeline() {
let mut firmware = Firmware::new(None);
let mut hardware = Hardware::new();
let signals = InputSignals::default();
firmware.load_cartridge(valid_cartridge(AppMode::System));
firmware.tick(&signals, &mut hardware);
let tick_index_before_system_update = firmware.os.tick_index;
firmware.tick(&signals, &mut hardware);
assert!(matches!(firmware.state, FirmwareState::SystemRunning(_)));
assert_eq!(firmware.os.tick_index, tick_index_before_system_update + 1);
}
#[test]
fn load_cartridge_routes_game_apps_to_game_running() {
let mut firmware = Firmware::new(None);
@@ -11,26 +11,8 @@ impl HubHomeStep {
}
pub fn on_update(&mut self, ctx: &mut PrometeuContext) -> Option<FirmwareState> {
let mut error = None;
// Always updates the Hub GUI (clears screen and processes input if no focus)
ctx.hub.gui_update(ctx.os, ctx.hw);
if let Some(focused_id) = ctx.hub.window_manager.focused {
if ctx.hw.pad().start().down {
ctx.hub.window_manager.remove_window(focused_id);
} else {
// System App runs here, drawing over the Hub background
error = ctx.os.tick(ctx.vm, ctx.signals, ctx.hw);
}
}
// Renders the System App window borders
ctx.hub.render(ctx.os, ctx.hw);
ctx.hw.gfx_mut().present();
if let Some(report) = error {
let outcome = ctx.hub.update_system_profile(ctx.os, ctx.vm, ctx.signals, ctx.hw);
if let Some(report) = outcome.crash {
return Some(FirmwareState::AppCrashes(AppCrashesStep { report }));
}
@@ -11,23 +11,16 @@ impl SystemRunningStep {
}
pub fn on_update(&mut self, ctx: &mut PrometeuContext) -> Option<FirmwareState> {
let mut error = None;
ctx.hub.gui_update(ctx.os, ctx.hw);
if let Some(focused_id) = ctx.hub.window_manager.focused {
if ctx.hw.pad().start().down {
ctx.hub.window_manager.remove_window(focused_id);
return Some(FirmwareState::HubHome(HubHomeStep));
}
error = ctx.os.tick(ctx.vm, ctx.signals, ctx.hw);
let outcome = ctx.hub.update_system_profile(ctx.os, ctx.vm, ctx.signals, ctx.hw);
if let Some(report) = outcome.crash {
return Some(FirmwareState::AppCrashes(AppCrashesStep { report }));
}
ctx.hub.render(ctx.os, ctx.hw);
ctx.hw.gfx_mut().present();
if !outcome.focused_window_active {
return Some(FirmwareState::HubHome(HubHomeStep));
}
error.map(|report| FirmwareState::AppCrashes(AppCrashesStep { report }))
None
}
pub fn on_exit(&mut self, _ctx: &mut PrometeuContext) {}