implements PLN-0105
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::os::SystemOS;
|
||||
use prometeu_hal::app_mode::AppMode;
|
||||
use prometeu_hal::cartridge::Cartridge;
|
||||
use prometeu_hal::telemetry::{CertificationConfig, TelemetryFrame};
|
||||
use prometeu_hal::{HardwareBridge, InputSignals};
|
||||
use prometeu_hal::{HardwareBridge, InputSignals, RuntimePlatform};
|
||||
use prometeu_vm::VirtualMachine;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -25,7 +25,7 @@ impl<'a> VmFacade<'a> {
|
||||
&mut self,
|
||||
vm: &mut VirtualMachine,
|
||||
signals: &InputSignals,
|
||||
hw: &mut dyn HardwareBridge,
|
||||
platform: &mut dyn RuntimePlatform,
|
||||
) -> Option<CrashReport> {
|
||||
self.os.vm_runtime.tick(
|
||||
&mut self.os.log_service,
|
||||
@@ -36,7 +36,7 @@ impl<'a> VmFacade<'a> {
|
||||
&mut self.os.next_handle,
|
||||
vm,
|
||||
signals,
|
||||
hw,
|
||||
platform,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ use crate::{CrashReport, SystemOS};
|
||||
use prometeu_hal::color::Color;
|
||||
use prometeu_hal::primitives::Rect;
|
||||
use prometeu_hal::{
|
||||
FrameId, GfxUiCommand, HardwareBridge, InputSignals, LegacyHardwareRenderSubmissionSink,
|
||||
RenderSubmission, RenderSubmissionSink, ShellUiFramePacket,
|
||||
FrameId, GfxUiCommand, InputPlatform, InputSignals, RenderSubmission, RuntimePlatform,
|
||||
ShellUiFramePacket,
|
||||
};
|
||||
use prometeu_vm::VirtualMachine;
|
||||
|
||||
@@ -101,31 +101,35 @@ impl PrometeuHub {
|
||||
pub fn gui_update(
|
||||
&mut self,
|
||||
os: &mut SystemOS,
|
||||
hw: &mut dyn HardwareBridge,
|
||||
platform: &mut dyn RuntimePlatform,
|
||||
) -> Option<SystemProfileAction> {
|
||||
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);
|
||||
self.home_input_armed = !activation_input_down(platform.input());
|
||||
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)
|
||||
{
|
||||
let input = platform.input();
|
||||
if let Some(action) = action_for_click(
|
||||
in_shell,
|
||||
input.touch().x(),
|
||||
input.touch().y(),
|
||||
input.touch().f().pressed,
|
||||
) {
|
||||
return Some(action);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn render(&mut self, os: &mut SystemOS, hw: &mut dyn HardwareBridge) {
|
||||
let pointer_x = hw.touch().x();
|
||||
let pointer_y = hw.touch().y();
|
||||
pub fn render(&mut self, os: &mut SystemOS, platform: &mut dyn RuntimePlatform) {
|
||||
let pointer_x = platform.input().touch().x();
|
||||
let pointer_y = platform.input().touch().y();
|
||||
|
||||
let packet = if os.windows().window_count() == 0 {
|
||||
render_home_packet(pointer_x, pointer_y)
|
||||
@@ -143,7 +147,8 @@ impl PrometeuHub {
|
||||
}
|
||||
ShellUiFramePacket::new(commands)
|
||||
};
|
||||
LegacyHardwareRenderSubmissionSink::new(hw)
|
||||
platform
|
||||
.render_submission_sink()
|
||||
.submit_render_submission(RenderSubmission::shell_ui(FrameId::ZERO, packet))
|
||||
.expect("hub render submission should publish");
|
||||
}
|
||||
@@ -153,20 +158,20 @@ impl PrometeuHub {
|
||||
os: &mut SystemOS,
|
||||
vm: &mut VirtualMachine,
|
||||
signals: &InputSignals,
|
||||
hw: &mut dyn HardwareBridge,
|
||||
platform: &mut dyn RuntimePlatform,
|
||||
) -> SystemProfileUpdate {
|
||||
let mut crash = None;
|
||||
let mut action = self.gui_update(os, hw);
|
||||
let mut action = self.gui_update(os, platform);
|
||||
|
||||
if os.windows().focused_window().is_some() {
|
||||
if hw.pad().start().down {
|
||||
if platform.input().pad().start().down {
|
||||
action = Some(SystemProfileAction::CloseShell);
|
||||
} else if action != Some(SystemProfileAction::CloseShell) {
|
||||
crash = os.vm().tick(vm, signals, hw);
|
||||
crash = os.vm().tick(vm, signals, platform);
|
||||
}
|
||||
}
|
||||
|
||||
self.render(os, hw);
|
||||
self.render(os, platform);
|
||||
|
||||
SystemProfileUpdate { crash, action }
|
||||
}
|
||||
@@ -191,8 +196,11 @@ 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 activation_input_down(input: &dyn InputPlatform) -> bool {
|
||||
input.touch().f().down
|
||||
|| input.pad().a().down
|
||||
|| input.pad().b().down
|
||||
|| input.pad().start().down
|
||||
}
|
||||
|
||||
fn render_home_packet(pointer_x: i32, pointer_y: i32) -> ShellUiFramePacket {
|
||||
|
||||
@@ -135,7 +135,7 @@ impl VirtualMachineRuntime {
|
||||
next_handle: &mut u32,
|
||||
vm: &mut VirtualMachine,
|
||||
signals: &InputSignals,
|
||||
hw: &mut dyn HardwareBridge,
|
||||
platform: &mut dyn RuntimePlatform,
|
||||
) -> Option<CrashReport> {
|
||||
let start = Instant::now();
|
||||
self.tick_index += 1;
|
||||
@@ -145,8 +145,6 @@ impl VirtualMachineRuntime {
|
||||
}
|
||||
|
||||
self.update_fs(log_service, fs, fs_state);
|
||||
let mut platform = LegacyHardwareRuntimePlatform::new(hw);
|
||||
|
||||
if !self.logical_frame_active {
|
||||
if RenderManager::policy_for_app_mode(self.current_cartridge_app_mode)
|
||||
.uses_frame_scheduler()
|
||||
@@ -157,7 +155,7 @@ impl VirtualMachineRuntime {
|
||||
}
|
||||
self.logical_frame_active = true;
|
||||
self.logical_frame_remaining_cycles = Self::CYCLES_PER_LOGICAL_FRAME;
|
||||
self.begin_logical_frame(signals, &mut platform);
|
||||
self.begin_logical_frame(signals, platform);
|
||||
|
||||
if self.needs_prepare_entry_call || vm.call_stack_is_empty() {
|
||||
vm.prepare_boot_call();
|
||||
@@ -185,7 +183,7 @@ impl VirtualMachineRuntime {
|
||||
|
||||
if budget > 0 {
|
||||
let run_result = {
|
||||
let mut ctx = HostContext::new_platform(Some(&mut platform));
|
||||
let mut ctx = HostContext::new_platform(Some(platform));
|
||||
let mut host = VmRuntimeHost {
|
||||
runtime: self,
|
||||
log_service,
|
||||
@@ -311,7 +309,7 @@ impl VirtualMachineRuntime {
|
||||
|
||||
// 1. Snapshot full telemetry at logical frame end
|
||||
let (glyph_bank, sound_bank, scene_bank) =
|
||||
Self::bank_telemetry_summary(&platform);
|
||||
Self::bank_telemetry_summary(platform);
|
||||
self.atomic_telemetry
|
||||
.glyph_slots_used
|
||||
.store(glyph_bank.used_slots as u32, Ordering::Relaxed);
|
||||
@@ -402,7 +400,7 @@ impl VirtualMachineRuntime {
|
||||
|
||||
// 2. High-frequency telemetry update (only if inspection is active)
|
||||
if self.inspection_active {
|
||||
let (glyph_bank, sound_bank, scene_bank) = Self::bank_telemetry_summary(&platform);
|
||||
let (glyph_bank, sound_bank, scene_bank) = Self::bank_telemetry_summary(platform);
|
||||
self.atomic_telemetry
|
||||
.glyph_slots_used
|
||||
.store(glyph_bank.used_slots as u32, Ordering::Relaxed);
|
||||
|
||||
Reference in New Issue
Block a user