diff --git a/Cargo.lock b/Cargo.lock index 37db3c5..adec220 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -593,7 +593,7 @@ dependencies = [ [[package]] name = "fec-rs" version = "0.1.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" [[package]] name = "fiat-crypto" @@ -1116,7 +1116,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pf-client-core" version = "0.46.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" dependencies = [ "anyhow", "cfg_aliases", @@ -1132,7 +1132,7 @@ dependencies = [ [[package]] name = "pf-client-video" version = "0.46.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" dependencies = [ "anyhow", "ash", @@ -1146,7 +1146,7 @@ dependencies = [ [[package]] name = "pf-console-ui" version = "0.46.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" dependencies = [ "anyhow", "pf-client-core", @@ -1162,7 +1162,7 @@ dependencies = [ [[package]] name = "pf-l10n" version = "0.46.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" [[package]] name = "pf-ps5" @@ -1234,6 +1234,7 @@ dependencies = [ "libc", "pf-client-core", "pf-ps5-app", + "pf-ps5-platform", "pf-ps5-sys", "punktfunk-core", "quinn-udp", @@ -1355,7 +1356,7 @@ dependencies = [ [[package]] name = "punktfunk-core" version = "0.46.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" dependencies = [ "aes-gcm", "aws-lc-rs", @@ -1393,7 +1394,7 @@ checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" [[package]] name = "pyrowave-sys" version = "0.46.0" -source = "git+https://git.unom.io/unom/punktfunk?rev=9eb2eb64113b6848e921a7153edd2248b8f61d7a#9eb2eb64113b6848e921a7153edd2248b8f61d7a" +source = "git+https://git.unom.io/unom/punktfunk?rev=6e1381e3e976ece0362c734b2b3cf39ffd5537d1#6e1381e3e976ece0362c734b2b3cf39ffd5537d1" dependencies = [ "bindgen 0.73.2", "cmake", diff --git a/Cargo.toml b/Cargo.toml index b9b5d6e..92bffe2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,12 +63,12 @@ ash = { version = "0.38", default-features = false, features = ["debug", "std"] # Same Skia as the shared console; only the PS5 build adds the Vulkan backend (pf-ps5-vk). skia-safe = { version = "0.153", features = ["textlayout"] } # One REV for all three shared crates: a tag and a rev build two copies whose types don't unify. -punktfunk-core = { git = "https://git.unom.io/unom/punktfunk", rev = "9eb2eb64113b6848e921a7153edd2248b8f61d7a", features = ["quic"] } -pf-client-core = { git = "https://git.unom.io/unom/punktfunk", rev = "9eb2eb64113b6848e921a7153edd2248b8f61d7a", default-features = false } -pf-console-ui = { git = "https://git.unom.io/unom/punktfunk", rev = "9eb2eb64113b6848e921a7153edd2248b8f61d7a", default-features = false } -pf-client-video = { git = "https://git.unom.io/unom/punktfunk", rev = "9eb2eb64113b6848e921a7153edd2248b8f61d7a", default-features = false, features = ["pyrowave"] } +punktfunk-core = { git = "https://git.unom.io/unom/punktfunk", rev = "6e1381e3e976ece0362c734b2b3cf39ffd5537d1", features = ["quic"] } +pf-client-core = { git = "https://git.unom.io/unom/punktfunk", rev = "6e1381e3e976ece0362c734b2b3cf39ffd5537d1", default-features = false } +pf-console-ui = { git = "https://git.unom.io/unom/punktfunk", rev = "6e1381e3e976ece0362c734b2b3cf39ffd5537d1", default-features = false } +pf-client-video = { git = "https://git.unom.io/unom/punktfunk", rev = "6e1381e3e976ece0362c734b2b3cf39ffd5537d1", default-features = false, features = ["pyrowave"] } # The messages the console UI and this title word their text from; the kit reads the same rev. -pf-l10n = { git = "https://git.unom.io/unom/punktfunk", rev = "9eb2eb64113b6848e921a7153edd2248b8f61d7a", default-features = false, features = ["client", "console", "host"] } +pf-l10n = { git = "https://git.unom.io/unom/punktfunk", rev = "6e1381e3e976ece0362c734b2b3cf39ffd5537d1", default-features = false, features = ["client", "console", "host"] } [workspace.lints.rust] unsafe_op_in_unsafe_fn = "deny" diff --git a/crates/pf-ps5-app/src/platform/mod.rs b/crates/pf-ps5-app/src/platform/mod.rs index 3d48b75..57a183d 100644 --- a/crates/pf-ps5-app/src/platform/mod.rs +++ b/crates/pf-ps5-app/src/platform/mod.rs @@ -3,7 +3,8 @@ //! Three implementations exist: the console (`pf-ps5-platform`), a developer box //! (`pf-ps5-host`) and [`fake`] for tests. The binary builds one [`Platform`] and hands it to //! [`crate::run`]; nothing in this crate names a console API, a Vulkan handle or a file path -//! outside [`Storage::data_dir`]. The contract tests in `tests/seams.rs` are the spec. +//! outside [`Storage::data_dir`] and [`DeviceInfo::fonts`]. The contract tests in +//! `tests/seams.rs` are the spec. pub mod fake; @@ -43,6 +44,9 @@ pub struct DeviceInfo { pub ui: String, /// The system's languages as BCP-47 tags, most preferred first. Empty reads English. pub languages: Vec, + /// The system's font files for what Geist lacks (Han, kana, Hangul), most fitting first. + /// Empty where Skia has a font manager to ask instead. + pub fonts: Vec, } /// Refresh rate of the scan-out, in millihertz (59 940, 119 880). diff --git a/crates/pf-ps5-app/src/runtime/menu.rs b/crates/pf-ps5-app/src/runtime/menu.rs index a6c0994..b646623 100644 --- a/crates/pf-ps5-app/src/runtime/menu.rs +++ b/crates/pf-ps5-app/src/runtime/menu.rs @@ -41,6 +41,7 @@ pub(super) fn run(app: &mut App, notice: Option) -> Result { let caps = crate::core::caps::video_caps(); let opts = ConsoleOptions { device_name: "PlayStation 5".into(), + device_code: pf_client_core::trust::device_code(&app.identity), version: Some(crate::core::build_id()), system_keyboard: false, tv: true, @@ -70,7 +71,11 @@ pub(super) fn run(app: &mut App, notice: Option) -> Result { .selected_row() .map_or(ConsoleEntry::Home, |row| ConsoleEntry::Library(Box::new(row))), }; - let mut console = Console::new(opts, entry, &handles).context("console shell")?; + let faces = super::system_faces(&app.device.fonts); + let faces: Vec<&[u8]> = faces.iter().map(Vec::as_slice).collect(); + let mut console = Console::new(opts, entry, &handles) + .and_then(|console| console.with_fallback_fonts(&faces)) + .context("console shell")?; let viewport = { let (w, h) = app.display.ui_size(); Viewport::plain(w, h) diff --git a/crates/pf-ps5-app/src/runtime/mod.rs b/crates/pf-ps5-app/src/runtime/mod.rs index 07c889c..fcfeff5 100644 --- a/crates/pf-ps5-app/src/runtime/mod.rs +++ b/crates/pf-ps5-app/src/runtime/mod.rs @@ -157,6 +157,38 @@ fn alternate(app: &mut App) -> Option { } } +/// The system's font files ([`crate::platform::DeviceInfo::fonts`]) as faces for the kit's +/// fallback. A file that is missing or not a face is logged and left out: the kit refuses all +/// faces for one bad one. +fn system_faces(paths: &[std::path::PathBuf]) -> Vec> { + let started = std::time::Instant::now(); + let mgr = skia_safe::FontMgr::new(); + let faces: Vec> = paths + .iter() + .filter_map(|path| match std::fs::read(path) { + Ok(bytes) if mgr.new_from_data(skia_safe::Data::new_copy(&bytes), None).is_some() => Some(bytes), + Ok(_) => { + tracing::warn!(path = %path.display(), "system font is not a face"); + None + } + Err(e) => { + tracing::warn!(path = %path.display(), error = %e, "system font unreadable"); + None + } + }) + .collect(); + if !paths.is_empty() { + tracing::info!( + "fonts: {} of {} system faces, {} KiB, in {} ms", + faces.len(), + paths.len(), + faces.iter().map(Vec::len).sum::() / 1024, + started.elapsed().as_millis() + ); + } + faces +} + /// A panic on any thread goes to the log with its frames, then the process aborts. fn install_panic_hook() { std::panic::set_hook(Box::new(|info| { @@ -174,3 +206,16 @@ fn teardown(connected: session::Connected) { connected.disconnect_quit(); connected.shutdown_and_quit(); } + +#[cfg(test)] +mod tests { + #[test] + fn a_missing_or_foreign_file_is_no_face() { + let dir = std::env::temp_dir().join(format!("pf-faces-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let text = dir.join("not-a-font.otf"); + std::fs::write(&text, b"not a font").unwrap(); + assert!(super::system_faces(&[text, dir.join("missing.ttf")]).is_empty()); + let _ = std::fs::remove_dir_all(dir); + } +} diff --git a/crates/pf-ps5-app/src/runtime/stream.rs b/crates/pf-ps5-app/src/runtime/stream.rs index 6fbe357..e672ad6 100644 --- a/crates/pf-ps5-app/src/runtime/stream.rs +++ b/crates/pf-ps5-app/src/runtime/stream.rs @@ -249,7 +249,9 @@ fn stream( }; let router = PadRouter::new(&settings.shortcuts, &settings.overlay_actions); let input = InputThread::start(pads, connected.input(), settings.gamepad_type(), router); - let fonts = match pf_console_ui::theme::build_fonts() { + let faces = super::system_faces(&app.device.fonts); + let faces: Vec<&[u8]> = faces.iter().map(Vec::as_slice).collect(); + let fonts = match pf_console_ui::theme::build_fonts_with(&faces) { Ok(f) => Some(f), Err(e) => { tracing::warn!("overlay fonts: {e:#}"); diff --git a/crates/pf-ps5-app/src/ui/service.rs b/crates/pf-ps5-app/src/ui/service.rs index c1a74f0..c6ca377 100644 --- a/crates/pf-ps5-app/src/ui/service.rs +++ b/crates/pf-ps5-app/src/ui/service.rs @@ -21,6 +21,7 @@ use pf_console_ui::{ SpeedPhase, Stale, WakeStatus, }; use punktfunk_core::client::NativeClient; +use punktfunk_core::PunktfunkError; use crate::core::model::{GameEntry, KnownHost}; use crate::services::discovery::{DiscoveredHost, Discovery}; @@ -318,6 +319,8 @@ impl Service { game_presets: h.game_presets.clone(), profile: h.profile.clone(), running: String::new(), + // Never fetched: this client offers no screen pick. + screens: None, key, } } @@ -345,7 +348,7 @@ impl Service { .map_err(|e| crate::core::errors::pair_message(&e)) }), // The host parks this console until its operator approves it, held to the advertised - // fingerprint. Never streams. + // fingerprint. Never streams. The console offers a request only for a row with one. ConsoleCmd::RequestAccess { addr, port, @@ -355,6 +358,10 @@ impl Service { } => { let pin = shared::parse_fp(&fp_hex); self.start_pair(addr, port, req, move |addr, port, id| { + let Some(pin) = pin else { + let e = PunktfunkError::InvalidArg("fingerprint"); + return Err(crate::core::errors::access_message(&e)); + }; NativeClient::request_access(addr, port, (&id.0, &id.1), pin, &device_name, budget::HOST_WAIT, None) .map_err(|e| crate::core::errors::access_message(&e)) }); @@ -427,8 +434,8 @@ impl Service { ConsoleCmd::SetPin { key, preset_id, pin } => self.set_pin(&key, preset_id, pin), ConsoleCmd::PadTest { on } => self.pad_test = on, // Nothing to do: no status client (Resume badges stay off), no clipboard, no prompt - // here, no title is endable or installable (`to_model`), and the profile picker is - // off (`ConsoleOptions::profiles`). + // here, no title is endable or installable (`to_model`), the profile picker is off + // (`ConsoleOptions::profiles`), and no row carries `screens`. ConsoleCmd::RefreshRunning { .. } | ConsoleCmd::SetClipboard { .. } | ConsoleCmd::PromptAnswer { .. } @@ -437,7 +444,8 @@ impl Service { | ConsoleCmd::FetchProfiles { .. } | ConsoleCmd::FetchAvatar { .. } | ConsoleCmd::WakeProfile { .. } - | ConsoleCmd::SetProfile { .. } => {} + | ConsoleCmd::SetProfile { .. } + | ConsoleCmd::SetScreen { .. } => {} } } @@ -1203,6 +1211,7 @@ fn discovered_row(d: &DiscoveredHost) -> HostRow { // Needs `/api/v1/status`, which this client does not ask — the same reason // `LibraryGame::running` is false here. Empty renders as no line. running: String::new(), + screens: None, } } diff --git a/crates/pf-ps5-host/src/lib.rs b/crates/pf-ps5-host/src/lib.rs index cf72bf9..5517e5b 100644 --- a/crates/pf-ps5-host/src/lib.rs +++ b/crates/pf-ps5-host/src/lib.rs @@ -304,6 +304,7 @@ pub fn platform(opts: &Options) -> Result { gpu, ui, languages: Vec::new(), + fonts: Vec::new(), }, }) } diff --git a/crates/pf-ps5-platform/src/console/mod.rs b/crates/pf-ps5-platform/src/console/mod.rs index 6f4f6f4..db207ec 100644 --- a/crates/pf-ps5-platform/src/console/mod.rs +++ b/crates/pf-ps5-platform/src/console/mod.rs @@ -157,6 +157,17 @@ fn system_languages() -> Vec { tags } +/// The console's CJK font files for the kit, by the system language, from the first font +/// directory that exists. Reports to the kernel log, since logging does not exist yet. +fn system_fonts(language: Option<&str>) -> Vec { + use std::io::Write as _; + let dirs = crate::fonts::dirs(pf_ps5_sys::kernel::sandbox_word().as_deref()); + let found = dirs.iter().find(|d| d.is_dir()); + let line = found.map_or_else(|| format!("none of {dirs:?}"), |d| d.display().to_string()); + let _ = writeln!(klog::Klog::default(), "punktfunk-ps5: fonts: {line}"); + found.map(|d| crate::fonts::faces(d, language)).unwrap_or_default() +} + /// The data directory and the kernel log, for the probe, which needs nothing else. pub fn probe_parts() -> (PathBuf, Box) { (storage().0, Box::new(klog::Klog::default())) @@ -176,6 +187,7 @@ pub fn platform() -> Result { let dev = Arc::new(GpuDevice::new(entry(), Target::Display).context("bring up the GPU")?); let slot = Arc::new(VideoSlot::default()); let presenter = Presenter::new(dev.clone(), slot.clone()).context("bring up the display")?; + let languages = system_languages(); let device = DeviceInfo { platform: "ps5", model: "PlayStation 5".into(), @@ -183,7 +195,8 @@ pub fn platform() -> Result { .map_or_else(String::new, |v| format!("{:x}.{:02x}", v >> 24, (v >> 16) & 0xff)), gpu: format!("{} (mesa {MESA_PIN})", dev.name), ui: presenter.ui(), - languages: system_languages(), + fonts: system_fonts(languages.first().map(String::as_str)), + languages, }; Ok(Platform { display: Box::new(presenter), diff --git a/crates/pf-ps5-platform/src/fonts.rs b/crates/pf-ps5-platform/src/fonts.rs new file mode 100644 index 0000000..c312836 --- /dev/null +++ b/crates/pf-ps5-platform/src/fonts.rs @@ -0,0 +1,72 @@ +//! The console's own fonts for what Geist lacks: Han, kana and Hangul. Pure, so it tests anywhere. + +use std::path::{Path, PathBuf}; + +/// Kana and JIS kanji (`SST-JPPRO-R`). +const JAPANESE: &str = "SSTJpPro-Regular.otf"; +/// Simplified Chinese Hei (`SST-CNGB-HEI-R`). +const CHINESE: &str = "DFHEI5-SONY.ttf"; +/// Hangul only (`SCE-EXT-HANGUL-R`). +const KOREAN: &str = "SCEPS4Yoongd-Medium.otf"; + +/// The system font directory under the sandbox's word, else where it lives outside a sandbox. +pub fn dirs(word: Option<&str>) -> Vec { + let mut dirs: Vec = word + .map(|w| Path::new("/").join(w).join("common/font")) + .into_iter() + .collect(); + dirs.push(PathBuf::from("/preinst/common/font")); + dirs +} + +/// The CJK faces in `dir`, the system language's own first. The kit draws a character from the +/// first face that has it, so a Han character takes that region's shape; Japanese leads otherwise. +pub fn faces(dir: &Path, language: Option<&str>) -> Vec { + let lang = language.unwrap_or_default(); + let order = if lang.starts_with("zh") { + [CHINESE, JAPANESE, KOREAN] + } else if lang.starts_with("ko") { + [KOREAN, JAPANESE, CHINESE] + } else { + [JAPANESE, CHINESE, KOREAN] + }; + order.iter().map(|name| dir.join(name)).collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + fn names(language: Option<&str>) -> Vec { + faces(Path::new("/f"), language) + .iter() + .map(|p| p.file_name().unwrap().to_string_lossy().into_owned()) + .collect() + } + + #[test] + fn the_system_language_leads() { + assert_eq!(names(Some("ja")), [JAPANESE, CHINESE, KOREAN]); + assert_eq!(names(Some("zh-Hans")), [CHINESE, JAPANESE, KOREAN]); + assert_eq!(names(Some("zh-Hant")), [CHINESE, JAPANESE, KOREAN]); + assert_eq!(names(Some("ko")), [KOREAN, JAPANESE, CHINESE]); + } + + #[test] + fn any_other_language_reads_japanese_first() { + assert_eq!(names(Some("en-US")), [JAPANESE, CHINESE, KOREAN]); + assert_eq!(names(None), [JAPANESE, CHINESE, KOREAN]); + } + + #[test] + fn the_sandbox_directory_comes_first() { + assert_eq!( + dirs(Some("abcdefghij")), + [ + PathBuf::from("/abcdefghij/common/font"), + PathBuf::from("/preinst/common/font") + ] + ); + assert_eq!(dirs(None), [PathBuf::from("/preinst/common/font")]); + } +} diff --git a/crates/pf-ps5-platform/src/language.rs b/crates/pf-ps5-platform/src/language.rs index 24211c1..d4a9b94 100644 --- a/crates/pf-ps5-platform/src/language.rs +++ b/crates/pf-ps5-platform/src/language.rs @@ -51,6 +51,14 @@ mod tests { assert_eq!(tag(29), Some("id")); } + #[test] + fn chinese_japanese_and_korean_carry_their_script() { + assert_eq!(tag(0), Some("ja")); + assert_eq!(tag(9), Some("ko")); + assert_eq!(tag(10), Some("zh-Hant")); + assert_eq!(tag(11), Some("zh-Hans")); + } + #[test] fn an_unknown_value_is_no_language() { assert_eq!(tag(-1), None); diff --git a/crates/pf-ps5-platform/src/lib.rs b/crates/pf-ps5-platform/src/lib.rs index 189a2ce..7ddc38a 100644 --- a/crates/pf-ps5-platform/src/lib.rs +++ b/crates/pf-ps5-platform/src/lib.rs @@ -4,6 +4,7 @@ //! calls the console is `cfg(target_vendor = "sie")`. The binary calls [`platform`] once and //! hands the result to `pf_ps5_app::run`. +pub mod fonts; pub mod language; pub mod pad_map; pub mod triggers; diff --git a/crates/pf-ps5-probe/Cargo.toml b/crates/pf-ps5-probe/Cargo.toml index 66b7c7b..78538c0 100644 --- a/crates/pf-ps5-probe/Cargo.toml +++ b/crates/pf-ps5-probe/Cargo.toml @@ -16,6 +16,7 @@ punktfunk-core.workspace = true pf-client-core.workspace = true pf-ps5-app = { path = "../pf-ps5-app" } pf-ps5-sys = { path = "../pf-ps5-sys" } +pf-ps5-platform = { path = "../pf-ps5-platform" } quinn-udp = "0.5" tokio = { version = "1", features = ["rt-multi-thread", "time", "net"] } libc = "0.2" diff --git a/crates/pf-ps5-probe/src/lib.rs b/crates/pf-ps5-probe/src/lib.rs index a6910e3..04e8aa4 100644 --- a/crates/pf-ps5-probe/src/lib.rs +++ b/crates/pf-ps5-probe/src/lib.rs @@ -98,6 +98,7 @@ const CHECKS: &[(&str, Check)] = &[ ("session", session), ("display-hdr", display_hdr), ("hdr-scanout", hdr_scanout), + ("fonts", fonts), ]; /// Runs every check in order. Returns how many failed. @@ -285,6 +286,37 @@ fn display_hdr(_: &Ctx) -> Result { Ok(Outcome::Skip("VideoOut is the console's".into())) } +/// The system font directories the title reads its CJK faces from, each with its files and +/// sizes. Fails when none can be listed: Han, kana and Hangul then draw as boxes. +#[cfg(target_vendor = "sie")] +fn fonts(_: &Ctx) -> Result { + let dirs = pf_ps5_platform::fonts::dirs(pf_ps5_sys::kernel::sandbox_word().as_deref()); + let listed: Vec = dirs + .iter() + .filter_map(|dir| { + let mut files: Vec = std::fs::read_dir(dir) + .ok()? + .flatten() + .map(|e| { + let kib = e.metadata().map_or(0, |m| m.len() / 1024); + format!("{} {kib} KiB", e.file_name().to_string_lossy()) + }) + .collect(); + files.sort(); + Some(format!("{}: {}", dir.display(), files.join(", "))) + }) + .collect(); + if listed.is_empty() { + bail!("none of {dirs:?} lists"); + } + ok(listed.join("; ")) +} + +#[cfg(not(target_vendor = "sie"))] +fn fonts(_: &Ctx) -> Result { + Ok(Outcome::Skip("the system fonts are the console's".into())) +} + /// `VideoOut` takes buffers in the HDR10 pixel format and flips them: four solid PQ fills, 8 s each, /// on the display (the TV's HDR indicator and the picture are the other half of the result). #[cfg(target_vendor = "sie")] diff --git a/crates/pf-ps5-sys/src/kernel.rs b/crates/pf-ps5-sys/src/kernel.rs index d0267f2..1a20edb 100644 --- a/crates/pf-ps5-sys/src/kernel.rs +++ b/crates/pf-ps5-sys/src/kernel.rs @@ -1,4 +1,4 @@ -//! libkernel: direct memory (Videodec2's buffers), flexible memory, the kernel log. +//! libkernel: direct memory (Videodec2's buffers), flexible memory, the kernel log, the sandbox. use core::ffi::{c_char, c_void}; @@ -87,6 +87,21 @@ pub fn set_thread_affinity(mask: u64) -> Result<(), i32> { } } +/// The directory a title's sandbox mounts the system's shared files under (`//common`), +/// or `None` where the call names none. +#[cfg(target_vendor = "sie")] +pub fn sandbox_word() -> Option { + // SAFETY: takes nothing; returns null or a NUL-terminated string libkernel owns for the + // process's life. + let word = unsafe { sceKernelGetFsSandboxRandomWord() }; + if word.is_null() { + return None; + } + // SAFETY: non-null, and NUL-terminated by the contract above. + let word = unsafe { core::ffi::CStr::from_ptr(word) }; + Some(word.to_string_lossy().into_owned()) +} + /// Rounds `len` up to [`PAGE`]. pub const fn page_align(len: usize) -> usize { (len + PAGE - 1) & !(PAGE - 1) @@ -123,4 +138,6 @@ extern "C" { /// One line to the kernel log (klog, TCP 3232). Append the newline yourself. pub fn sceKernelDebugOutText(channel: i32, text: *const c_char) -> i32; pub fn sceKernelUsleep(micros: u32) -> i32; + /// The sandbox's ten-character directory name; see [`sandbox_word`]. + pub fn sceKernelGetFsSandboxRandomWord() -> *const c_char; } diff --git a/docs/NOTES.md b/docs/NOTES.md index 693f7a4..577889f 100644 --- a/docs/NOTES.md +++ b/docs/NOTES.md @@ -176,6 +176,11 @@ OpenNOW-PS5 (ONW). Section numbers refer to the extraction kept with the plan's - **AudioOut:** user 0xFF, MAIN port, 48 kHz, grains of 256..2048 frames in steps of 256, `sceAudioOutOutput` blocks one grain; S16 stereo and 8-channel are hardware-verified. - **klog:** `sceKernelDebugOutText(0, line)`; a title's stderr does not reach it. +- **System fonts:** the SDK has no font library. A sandbox mounts `/preinst/common/font` at + `//common/font`, the word from `sceKernelGetFsSandboxRandomWord`. It holds + `SSTJpPro-Regular.otf` (kana, JIS kanji), `DFHEI5-SONY.ttf` (Chinese, GB Hei) and + `SCEPS4Yoongd-Medium.otf` (Hangul), which the title hands the kit for what Geist lacks + (a 4.03 sandbox listing; shadPS4's PS4 font table). Probe `fonts` lists the directory. - **libc traps for std:** `arc4random*` resolve to nothing in a title (bound to the SDK fork's `ps5_` versions by the link recipe); `pthread_set_name_np` from inside the new thread hangs it (bound to a no-op here); malloc is wrapped onto the platform heap; TLS is emulated diff --git a/docs/pins.md b/docs/pins.md index b557864..2337a33 100644 --- a/docs/pins.md +++ b/docs/pins.md @@ -5,7 +5,7 @@ | Pin | Value | What it fixes | Moves when | | --- | --- | --- | --- | | Rust nightly | `nightly-2026-08-11` | `-Z build-std` for the custom target | a std change is needed; re-run the probe | -| punktfunk | `9eb2eb641` | `punktfunk-core`, `pf-client-core`, `pf-console-ui`, `pf-client-video`, one rev for all | the shared crates change; one bump, all four | +| punktfunk | `6e1381e3e` | `punktfunk-core`, `pf-client-core`, `pf-console-ui`, `pf-client-video`, one rev for all | the shared crates change; one bump, all four | | PS5_Vulkan | `f410e67a0` | link recipe, title CRT, `ps5-native-tool`, `libc.prx` | RADV or the recipe changes upstream | | PS5_Mesa | `c90ea0aab` | RADV with the PS5 winsys: PS5_Vulkan's `1ba9874f4` plus HDR10 swapchains and 119.88 Hz under VRR | with PS5_Vulkan; re-run WP1's bundle (R11) | | PS5_PayloadSDK | `b83202be7` | payload SDK + platform layer (`libps5platform.a`) | with PS5_Vulkan | diff --git a/scripts/pins.env b/scripts/pins.env index aee8952..ef0f233 100644 --- a/scripts/pins.env +++ b/scripts/pins.env @@ -2,7 +2,7 @@ # The Rust toolchain (rust-toolchain.toml carries the same value). RUST_NIGHTLY=nightly-2026-08-11 # The three shared crates (Cargo.toml carries the same rev). -PUNKTFUNK_REV=9eb2eb64113b6848e921a7153edd2248b8f61d7a +PUNKTFUNK_REV=6e1381e3e976ece0362c734b2b3cf39ffd5537d1 # PS5_Vulkan: the RADV link recipe, the title CRT, ps5-native-tool, libc.prx. PS5_VULKAN_REPO=https://github.com/mihawk-99/PS5_Vulkan.git PS5_VULKAN_REV=f410e67a0241b3e8edcdbcd2a9b285dfc4a412ed