Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions crates/pf-ps5-app/src/runtime/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,26 @@ pub(super) struct ConnectOutcome {
pub exit_plan: Option<ExitPlan>,
}

/// 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
}
}

Expand Down Expand Up @@ -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);
}
}
9 changes: 2 additions & 7 deletions crates/pf-ps5-app/src/runtime/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading