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) {}
@@ -1,15 +1,21 @@
use crate::VirtualMachineRuntime;
use crate::programs::prometeu_hub::window_manager::WindowManager;
use prometeu_hal::HardwareBridge;
use crate::{CrashReport, VirtualMachineRuntime};
use prometeu_hal::color::Color;
use prometeu_hal::log::{LogLevel, LogSource};
use prometeu_hal::window::Rect;
use prometeu_hal::{HardwareBridge, InputSignals};
use prometeu_vm::VirtualMachine;
/// PrometeuHub: Launcher and system UI environment.
pub struct PrometeuHub {
pub window_manager: WindowManager,
}
pub struct SystemProfileUpdate {
pub crash: Option<CrashReport>,
pub focused_window_active: bool,
}
impl Default for PrometeuHub {
fn default() -> Self {
Self::new()
@@ -75,4 +81,29 @@ impl PrometeuHub {
);
}
}
pub fn update_system_profile(
&mut self,
os: &mut VirtualMachineRuntime,
vm: &mut VirtualMachine,
signals: &InputSignals,
hw: &mut dyn HardwareBridge,
) -> SystemProfileUpdate {
let mut crash = None;
self.gui_update(os, hw);
if let Some(focused_id) = self.window_manager.focused {
if hw.pad().start().down {
self.window_manager.remove_window(focused_id);
} else {
crash = os.tick(vm, signals, hw);
}
}
self.render(os, hw);
hw.gfx_mut().present();
SystemProfileUpdate { crash, focused_window_active: self.window_manager.focused.is_some() }
}
}