diff --git a/crates/pf-ps5-app/src/runtime/connect.rs b/crates/pf-ps5-app/src/runtime/connect.rs index b949c75..b5f052c 100644 --- a/crates/pf-ps5-app/src/runtime/connect.rs +++ b/crates/pf-ps5-app/src/runtime/connect.rs @@ -67,19 +67,26 @@ pub(super) struct ConnectOutcome { pub exit_plan: Option, } -/// The mode to ask for, in whole hertz: the document's explicit pick, or the console's own -/// output where it says "Native" (`0`). The host refuses a 0×0 request. +/// The mode to ask for: the document's explicit pick, or the console's own output where it +/// says "Native" (`0`). A Native rate is the output's exact one, 119.88 Hz say; a picked rate +/// is whole hertz. The host refuses a 0×0 request. pub(super) fn stream_mode(settings: &store::Settings, native: Mode) -> Mode { let explicit = !settings.match_window && settings.width != 0 && settings.height != 0; - Mode { + let native_rate = settings.refresh_hz == 0; + let whole = Mode { width: if explicit { settings.width } else { native.width }, height: if explicit { settings.height } else { native.height }, - refresh_hz: if settings.refresh_hz == 0 { + refresh_hz: if native_rate { native.refresh_hz } else { settings.refresh_hz }, refresh_mhz: 0, + }; + if native_rate { + whole.stating(native.refresh_mhz) + } else { + whole } } @@ -252,4 +259,18 @@ mod tests { } ); } + + /// A 119.88 Hz output is asked for as that under Native, at any size; a picked rate is whole. + #[test] + fn a_native_rate_is_the_outputs_exact_one() { + let output = Mode::exact(3840, 2160, 119_880); + let mut s = store::Settings::default(); + assert_eq!(stream_mode(&s, output).millihz(), 119_880); + s.width = 1920; + s.height = 1080; + let sized = stream_mode(&s, output); + assert_eq!((sized.width, sized.refresh_hz, sized.millihz()), (1920, 120, 119_880)); + s.refresh_hz = 60; + assert_eq!(stream_mode(&s, output).millihz(), 60_000); + } } diff --git a/crates/pf-ps5-app/src/runtime/menu.rs b/crates/pf-ps5-app/src/runtime/menu.rs index 3affc80..0db6595 100644 --- a/crates/pf-ps5-app/src/runtime/menu.rs +++ b/crates/pf-ps5-app/src/runtime/menu.rs @@ -21,15 +21,10 @@ use crate::services::store::console::ConsoleStore; use crate::services::store::{self, StateWriter}; use crate::ui::Service; -/// The console's output as a stream mode at its whole rate, for a "Native" pick. +/// The console's output as a stream mode at its exact rate, for a "Native" pick. pub(super) fn native_mode(app: &App) -> Mode { let (width, height) = app.display.size(); - Mode { - width, - height, - refresh_hz: app.display.refresh().hz(), - refresh_mhz: 0, - } + Mode::exact(width, height, app.display.refresh().0) } /// Runs the console until it commits a launch or asks to leave.