implements PLN-0136
This commit is contained in:
parent
126bffa37d
commit
d54dadf2a5
@ -2,6 +2,7 @@ use crate::firmware::boot_target::BootTarget;
|
||||
use crate::firmware::firmware_state::{FirmwareState, LoadCartridgeStep, ResetStep};
|
||||
use crate::firmware::prometeu_context::PrometeuContext;
|
||||
use prometeu_hal::cartridge::Cartridge;
|
||||
use prometeu_hal::log::LogSource;
|
||||
use prometeu_hal::telemetry::CertificationConfig;
|
||||
use prometeu_hal::{InputSignals, RuntimePlatform};
|
||||
use prometeu_system::{PrometeuHub, SystemOS};
|
||||
@ -166,6 +167,10 @@ impl Firmware {
|
||||
self.state = FirmwareState::LoadCartridge(LoadCartridgeStep::new(cartridge));
|
||||
self.state_initialized = false;
|
||||
}
|
||||
|
||||
pub fn request_home_from_host(&mut self) {
|
||||
self.os.info(LogSource::Pos, "Host requested Home/SystemOS".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -43,9 +43,27 @@ impl FbViewport {
|
||||
|
||||
pub struct HostInputHandler {
|
||||
pub signals: InputSignals,
|
||||
system_controls: HostSystemControls,
|
||||
display_size: (usize, usize),
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct HostSystemControls {
|
||||
home_requested: bool,
|
||||
}
|
||||
|
||||
impl HostSystemControls {
|
||||
pub fn request_home(&mut self) {
|
||||
self.home_requested = true;
|
||||
}
|
||||
|
||||
pub fn take_home_requested(&mut self) -> bool {
|
||||
let requested = self.home_requested;
|
||||
self.home_requested = false;
|
||||
requested
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for HostInputHandler {
|
||||
fn default() -> Self {
|
||||
Self::new((480, 270))
|
||||
@ -54,35 +72,47 @@ impl Default for HostInputHandler {
|
||||
|
||||
impl HostInputHandler {
|
||||
pub fn new(display_size: (usize, usize)) -> Self {
|
||||
Self { signals: InputSignals::default(), display_size }
|
||||
Self {
|
||||
signals: InputSignals::default(),
|
||||
system_controls: HostSystemControls::default(),
|
||||
display_size,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_home_requested(&mut self) -> bool {
|
||||
self.system_controls.take_home_requested()
|
||||
}
|
||||
|
||||
pub fn handle_key_code(&mut self, code: KeyCode, state: ElementState) {
|
||||
let is_down = state == ElementState::Pressed;
|
||||
|
||||
match code {
|
||||
KeyCode::Escape | KeyCode::Home if is_down => self.system_controls.request_home(),
|
||||
|
||||
KeyCode::ArrowUp => self.signals.up_signal = is_down,
|
||||
KeyCode::ArrowDown => self.signals.down_signal = is_down,
|
||||
KeyCode::ArrowLeft => self.signals.left_signal = is_down,
|
||||
KeyCode::ArrowRight => self.signals.right_signal = is_down,
|
||||
|
||||
KeyCode::KeyA => self.signals.a_signal = is_down,
|
||||
KeyCode::KeyD => self.signals.b_signal = is_down,
|
||||
KeyCode::KeyW => self.signals.x_signal = is_down,
|
||||
KeyCode::KeyS => self.signals.y_signal = is_down,
|
||||
KeyCode::KeyQ => self.signals.l_signal = is_down,
|
||||
KeyCode::KeyE => self.signals.r_signal = is_down,
|
||||
|
||||
KeyCode::KeyZ => self.signals.start_signal = is_down,
|
||||
KeyCode::ShiftLeft | KeyCode::ShiftRight => self.signals.select_signal = is_down,
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_event(&mut self, event: &WindowEvent, window: &Window) {
|
||||
match event {
|
||||
WindowEvent::KeyboardInput { event, .. } => {
|
||||
if let PhysicalKey::Code(code) = event.physical_key {
|
||||
let is_down = event.state == ElementState::Pressed;
|
||||
|
||||
match code {
|
||||
KeyCode::ArrowUp => self.signals.up_signal = is_down,
|
||||
KeyCode::ArrowDown => self.signals.down_signal = is_down,
|
||||
KeyCode::ArrowLeft => self.signals.left_signal = is_down,
|
||||
KeyCode::ArrowRight => self.signals.right_signal = is_down,
|
||||
|
||||
KeyCode::KeyA => self.signals.a_signal = is_down,
|
||||
KeyCode::KeyD => self.signals.b_signal = is_down,
|
||||
KeyCode::KeyW => self.signals.x_signal = is_down,
|
||||
KeyCode::KeyS => self.signals.y_signal = is_down,
|
||||
KeyCode::KeyQ => self.signals.l_signal = is_down,
|
||||
KeyCode::KeyE => self.signals.r_signal = is_down,
|
||||
|
||||
KeyCode::KeyZ => self.signals.start_signal = is_down,
|
||||
KeyCode::ShiftLeft | KeyCode::ShiftRight => {
|
||||
self.signals.select_signal = is_down
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
self.handle_key_code(code, event.state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,3 +164,69 @@ impl HostInputHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn assert_no_pad_signal(signals: InputSignals) {
|
||||
assert!(!signals.up_signal);
|
||||
assert!(!signals.down_signal);
|
||||
assert!(!signals.left_signal);
|
||||
assert!(!signals.right_signal);
|
||||
assert!(!signals.a_signal);
|
||||
assert!(!signals.b_signal);
|
||||
assert!(!signals.x_signal);
|
||||
assert!(!signals.y_signal);
|
||||
assert!(!signals.l_signal);
|
||||
assert!(!signals.r_signal);
|
||||
assert!(!signals.start_signal);
|
||||
assert!(!signals.select_signal);
|
||||
assert!(!signals.f_signal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_requests_home_without_mutating_guest_pad() {
|
||||
let mut input = HostInputHandler::default();
|
||||
|
||||
input.handle_key_code(KeyCode::Escape, ElementState::Pressed);
|
||||
|
||||
assert!(input.take_home_requested());
|
||||
assert!(!input.take_home_requested());
|
||||
assert_no_pad_signal(input.signals);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn physical_home_requests_home_without_mutating_guest_pad() {
|
||||
let mut input = HostInputHandler::default();
|
||||
|
||||
input.handle_key_code(KeyCode::Home, ElementState::Pressed);
|
||||
|
||||
assert!(input.take_home_requested());
|
||||
assert_no_pad_signal(input.signals);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn home_release_does_not_emit_a_new_home_request() {
|
||||
let mut input = HostInputHandler::default();
|
||||
|
||||
input.handle_key_code(KeyCode::Home, ElementState::Released);
|
||||
|
||||
assert!(!input.take_home_requested());
|
||||
assert_no_pad_signal(input.signals);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_keyboard_pad_mapping_is_preserved() {
|
||||
let mut input = HostInputHandler::default();
|
||||
|
||||
input.handle_key_code(KeyCode::KeyZ, ElementState::Pressed);
|
||||
input.handle_key_code(KeyCode::ShiftLeft, ElementState::Pressed);
|
||||
input.handle_key_code(KeyCode::ArrowUp, ElementState::Pressed);
|
||||
|
||||
assert!(input.signals.start_signal);
|
||||
assert!(input.signals.select_signal);
|
||||
assert!(input.signals.up_signal);
|
||||
assert!(!input.take_home_requested());
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,6 +372,12 @@ impl ApplicationHandler for HostRunner {
|
||||
self.firmware.os.fs().mount(Box::new(backend));
|
||||
}
|
||||
|
||||
if self.input.take_home_requested() {
|
||||
self.firmware.request_home_from_host();
|
||||
self.invalidate_host_surface();
|
||||
self.request_redraw_if_needed();
|
||||
}
|
||||
|
||||
// 3. Timing Management (The heart of determinism).
|
||||
// We measure the elapsed time since the last iteration and add it to an
|
||||
// accumulator. We then execute exactly as many 60Hz slices as the
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
{"type":"discussion","id":"DSC-0043","status":"open","ticket":"system-os-cartridge-switch-orchestrator","title":"SystemOS Cartridge Switch Orchestrator","created_at":"2026-07-03","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","game","cartridge","architecture"],"agendas":[{"id":"AGD-0044","file":"AGD-0044-systemos-cartridge-switch-orchestrator.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03"}],"decisions":[],"plans":[],"lessons":[]}
|
||||
{"type":"discussion","id":"DSC-0039","status":"abandoned","ticket":"render-pipeline-family-and-future-3d","title":"Render Pipeline Family and Future 3D","created_at":"2026-06-04","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","architecture","pipeline"],"agendas":[{"id":"AGD-0039","file":"AGD-0039-render-pipeline-family-and-future-3d.md","status":"abandoned","created_at":"2026-06-04","updated_at":"2026-06-04","_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}],"decisions":[],"plans":[],"lessons":[],"_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}
|
||||
{"type":"discussion","id":"DSC-0040","status":"done","ticket":"vm-render-parallel-execution-boundary","title":"VM and Render Parallel Execution Boundary","created_at":"2026-06-04","updated_at":"2026-06-06","tags":["runtime","renderer","vm","concurrency","architecture","perf"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0048","file":"discussion/lessons/DSC-0040-vm-render-parallel-execution-boundary/LSN-0048-render-workers-need-a-closed-packet-contract.md","status":"done","created_at":"2026-06-06","updated_at":"2026-06-06"}]}
|
||||
{"type":"discussion","id":"DSC-0041","status":"in_progress","ticket":"foreground-stack-game-pause-shell-vm-backed","title":"Foreground Stack, Game Pause, and VM-Backed Shell Coexistence","created_at":"2026-06-05","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","shell","game","vm","foreground","architecture"],"agendas":[{"id":"AGD-0041","file":"AGD-0041-foreground-stack-game-pause-shell-vm-backed.md","status":"accepted","created_at":"2026-06-05","updated_at":"2026-07-03"}],"decisions":[{"id":"DEC-0037","file":"DEC-0037-foreground-stack-and-game-pause-contract.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0041"}],"plans":[{"id":"PLN-0136","file":"PLN-0136-route-desktop-home-key-outside-guest-input.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0137","file":"PLN-0137-implement-systemos-foreground-stack-state.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0138","file":"PLN-0138-specify-foreground-pause-and-home-contract.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0139","file":"PLN-0139-validate-game-home-shell-game-end-to-end.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0140","file":"PLN-0140-deliver-game-pause-resume-and-suspension.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0141","file":"PLN-0141-integrate-render-audio-and-input-pause-boundaries.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]}],"lessons":[]}
|
||||
{"type":"discussion","id":"DSC-0041","status":"in_progress","ticket":"foreground-stack-game-pause-shell-vm-backed","title":"Foreground Stack, Game Pause, and VM-Backed Shell Coexistence","created_at":"2026-06-05","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","shell","game","vm","foreground","architecture"],"agendas":[{"id":"AGD-0041","file":"AGD-0041-foreground-stack-game-pause-shell-vm-backed.md","status":"accepted","created_at":"2026-06-05","updated_at":"2026-07-03"}],"decisions":[{"id":"DEC-0037","file":"DEC-0037-foreground-stack-and-game-pause-contract.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0041"}],"plans":[{"id":"PLN-0136","file":"PLN-0136-route-desktop-home-key-outside-guest-input.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0137","file":"PLN-0137-implement-systemos-foreground-stack-state.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0138","file":"PLN-0138-specify-foreground-pause-and-home-contract.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0139","file":"PLN-0139-validate-game-home-shell-game-end-to-end.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0140","file":"PLN-0140-deliver-game-pause-resume-and-suspension.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0141","file":"PLN-0141-integrate-render-audio-and-input-pause-boundaries.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]}],"lessons":[]}
|
||||
{"type":"discussion","id":"DSC-0042","status":"done","ticket":"real-render-worker-establishment","title":"Real Render Worker Establishment","created_at":"2026-06-06","updated_at":"2026-06-20","tags":["runtime","renderer","worker","concurrency","host","hal","architecture"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0049","file":"discussion/lessons/DSC-0042-real-render-worker-establishment/LSN-0049-render-worker-publication-boundary.md","status":"done","created_at":"2026-06-20","updated_at":"2026-06-20"}]}
|
||||
{"type":"discussion","id":"DSC-0038","status":"done","ticket":"render-frame-packet-boundary","title":"Logical Render Pipelines and Command Packets","created_at":"2026-05-25","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","frame-composer","architecture","ui","pipeline"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0047","file":"discussion/lessons/DSC-0038-render-frame-packet-boundary/LSN-0047-typed-render-submissions-preserve-domain-boundaries.md","status":"done","created_at":"2026-06-04","updated_at":"2026-06-04"}]}
|
||||
{"type":"discussion","id":"DSC-0035","status":"done","ticket":"task-owned-shell-windows","title":"Agenda - Task-Owned Shell Windows","created_at":"2026-05-15","updated_at":"2026-05-15","tags":["runtime","os","task","window-manager","shell","lifecycle"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0044","file":"discussion/lessons/DSC-0035-task-owned-shell-windows/LSN-0044-task-window-liveness-belongs-to-the-task.md","status":"done","created_at":"2026-05-15","updated_at":"2026-05-15"}]}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
id: PLN-0136
|
||||
ticket: foreground-stack-game-pause-shell-vm-backed
|
||||
title: Route Desktop Home Key Outside Guest Input
|
||||
status: open
|
||||
status: done
|
||||
created: 2026-07-03
|
||||
ref_decisions: [DEC-0037]
|
||||
tags: [host, input, systemos, keyboard, lifecycle]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user