Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
iOS shell: Picture row, Fit or Fill for screens that are not 16:9 (#545)
v0lumehi286a2f3111e3
diff --git a/frontend-ios/Sources/ShellUI/GameDetailView.swift b/frontend-ios/Sources/ShellUI/GameDetailView.swiftindex 0bb006f6..90d844b0 100644--- a/frontend-ios/Sources/ShellUI/GameDetailView.swift+++ b/frontend-ios/Sources/ShellUI/GameDetailView.swift@@ -196,9 +196,13 @@ struct SettingControl: View, Equatable {let scale = ChoicePresentation.textScale(typeSize)switch ChoicePresentation.resolve(labels: labels, width: width, textScale: scale) {case .segmented:- // Equal segments across the card. If the real layout still cannot hold them, the compact row.+ // Equal segments across the card. If the real layout still cannot hold them, the compact row. Only the segments+ // decide: the label wraps to the card, so a long note (Picture, #545) does not push the row into the list.ViewThatFits(in: .horizontal) {- VStack(alignment: .leading, spacing: 12) { label; segmented([options]) }+ VStack(alignment: .leading, spacing: 12) {+ label.frame(minWidth: 0, idealWidth: 0, maxWidth: .infinity, alignment: .leading)+ segmented([options])+ }valueRow(options)}case .list:diff --git a/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstrings b/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstringsindex ebecb56c..2a2db877 100644--- a/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstrings+++ b/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstrings@@ -2051,6 +2051,126 @@}}},+ "Fill": {+ "localizations": {+ "de": {+ "stringUnit": {+ "state": "translated",+ "value": "Füllen"+ }+ },+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Fill"+ }+ },+ "fr": {+ "stringUnit": {+ "state": "translated",+ "value": "Remplir"+ }+ },+ "it": {+ "stringUnit": {+ "state": "translated",+ "value": "Riempi"+ }+ },+ "sv": {+ "stringUnit": {+ "state": "translated",+ "value": "Fyll"+ }+ },+ "zh-Hans": {+ "stringUnit": {+ "state": "translated",+ "value": "填充"+ }+ }+ }+ },+ "Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game.": {+ "localizations": {+ "de": {+ "stringUnit": {+ "state": "translated",+ "value": "Füllen schneidet das 16:9-Bild des Spiels zu, damit es den Bildschirm ausfüllt. Lebensleisten, Untertitel oder Karten am Rand können abgeschnitten werden. Ein Vollbild ohne Zuschnitt braucht einen Patch für jedes Spiel."+ }+ },+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game."+ }+ },+ "fr": {+ "stringUnit": {+ "state": "translated",+ "value": "Remplir recadre l’image 16:9 du jeu pour couvrir l’écran. Les barres de vie, sous-titres ou cartes près des bords peuvent être coupés. Une image plein écran sans recadrage demande un patch pour chaque jeu."+ }+ },+ "it": {+ "stringUnit": {+ "state": "translated",+ "value": "Riempi ritaglia l’immagine 16:9 del gioco per coprire lo schermo. Barre della salute, sottotitoli o mappe vicino ai bordi possono venire tagliati. Un’immagine a schermo intero senza ritaglio richiede una patch per ogni gioco."+ }+ },+ "sv": {+ "stringUnit": {+ "state": "translated",+ "value": "Fyll beskär spelets 16:9-bild så att den täcker skärmen. Hälsomätare, undertexter eller kartor nära kanterna kan skäras bort. En helskärmsbild utan beskärning kräver en patch för varje spel."+ }+ },+ "zh-Hans": {+ "stringUnit": {+ "state": "translated",+ "value": "填充会裁切游戏的 16:9 画面以铺满屏幕。边缘附近的血条、字幕或地图可能被裁掉。不裁切的全屏画面需要为每个游戏单独打补丁。"+ }+ }+ }+ },+ "Fit": {+ "localizations": {+ "de": {+ "stringUnit": {+ "state": "translated",+ "value": "Einpassen"+ }+ },+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Fit"+ }+ },+ "fr": {+ "stringUnit": {+ "state": "translated",+ "value": "Ajuster"+ }+ },+ "it": {+ "stringUnit": {+ "state": "translated",+ "value": "Adatta"+ }+ },+ "sv": {+ "stringUnit": {+ "state": "translated",+ "value": "Anpassa"+ }+ },+ "zh-Hans": {+ "stringUnit": {+ "state": "translated",+ "value": "适应"+ }+ }+ }+ },"For a bug report": {"localizations": {"en": {@@ -3941,6 +4061,46 @@}}},+ "Picture": {+ "localizations": {+ "de": {+ "stringUnit": {+ "state": "translated",+ "value": "Bild"+ }+ },+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Picture"+ }+ },+ "fr": {+ "stringUnit": {+ "state": "translated",+ "value": "Image"+ }+ },+ "it": {+ "stringUnit": {+ "state": "translated",+ "value": "Immagine"+ }+ },+ "sv": {+ "stringUnit": {+ "state": "translated",+ "value": "Bild"+ }+ },+ "zh-Hans": {+ "stringUnit": {+ "state": "translated",+ "value": "画面"+ }+ }+ }+ },"Pipeline prebuild": {"localizations": {"de": {diff --git a/frontend-ios/Tests/ShellHostTests/PictureFitTests.swift b/frontend-ios/Tests/ShellHostTests/PictureFitTests.swiftnew file mode 100644index 00000000..9ad47bd6--- /dev/null+++ b/frontend-ios/Tests/ShellHostTests/PictureFitTests.swift@@ -0,0 +1,72 @@+import Foundation+import Testing+import ShellUI+@testable import ShellHost++/// The Picture row of a game's settings (#545): Fit or Fill, per game, passed to the engine as DM_PICTURE_FIT.+/// The row is the one dm/games/settings.py writes into launcher.json for an iOS game (platform:ios).+@MainActor @Suite struct PictureFitTests {+ static let note = "Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game."+ static let row: [String: Any] = ["env": "DM_PICTURE_FIT", "kind": "choice", "section": "Game", "label": "Picture", "note": note,+ "default": "fit", "options": [["fit", "Fit"], ["fill", "Fill"]]]++ /// The orbit fixture with the Picture row after its Game rows, as the engine's list puts it.+ private func box() throws -> Sandbox {+ let box = try Sandbox()+ try box.giveAppData()+ let url = box.games.appendingPathComponent(Fixtures.orbit).appendingPathComponent("launcher.json")+ var json = try #require(JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any])+ var settings = try #require(json["settings"] as? [[String: Any]])+ settings.insert(Self.row, at: 1)+ json["settings"] = settings+ try JSONSerialization.data(withJSONObject: json).write(to: url)+ return box+ }++ private func pictureRow(_ model: ShellHostModel) throws -> SettingRow {+ let detail = try #require(model.details.first { $0.id == Fixtures.orbit })+ return try #require(detail.sections.first { $0.id == "Game" }?.rows.first { $0.id == "DM_PICTURE_FIT" })+ }++ @Test func theRowIsATwoWayChoiceWithItsNoteAndFitByDefault() throws {+ let box = try box() // kept for the test: the sandbox removes its folder when it goes+ let model = ShellHostModel(config: box.config())+ let row = try pictureRow(model)+ #expect(row.value == "fit", "Fit is today's picture and stays the default")+ #expect(row.label == "Picture" && row.note == Self.note)+ guard case .choice(let options) = row.kind else { Issue.record("not a choice"); return }+ #expect(options.map(\.id) == ["fit", "fill"] && options.map(\.label) == ["Fit", "Fill"])+ #expect(!row.note.contains(";"))+ }++ @Test func fillIsKeptPerGameAndPassedToTheEngine() async throws {+ let box = try box()+ let launcher = RecordingLauncher()+ let model = ShellHostModel(config: box.config(), launcher: launcher)+ await model.playNow(Fixtures.orbit)+ #expect(launcher.launched.last?.environment["DM_PICTURE_FIT"] == "fit")++ model.change(Fixtures.orbit, setting: "DM_PICTURE_FIT", value: "fill")+ #expect(box.defaults(Fixtures.orbit).string(forKey: "launcher.DM_PICTURE_FIT") == "fill", "in the game's own suite")+ #expect(try pictureRow(model).value == "fill")+ await model.playNow(Fixtures.orbit)+ let game = try #require(launcher.launched.last)+ #expect(game.environment["DM_PICTURE_FIT"] == "fill")+ let plan = EngineLaunchPlan.make(game: game, appResources: box.root, documents: box.root, envFileText: nil)+ #expect(plan.environment["DM_PICTURE_FIT"] == "fill", "setenv gets it before the engine reads it")++ // A new model over the same suite, as after a relaunch, still has Fill. Fit again stores nothing.+ let again = ShellHostModel(config: box.config(), launcher: launcher)+ #expect(try pictureRow(again).value == "fill")+ again.change(Fixtures.orbit, setting: "DM_PICTURE_FIT", value: "fit")+ #expect(box.defaults(Fixtures.orbit).object(forKey: "launcher.DM_PICTURE_FIT") == nil)+ }++ @Test func aValueTheEngineDoesNotReadIsRefused() throws {+ let box = try box()+ let profile = try LauncherProfile.parse(Data(contentsOf: box.games.appendingPathComponent(Fixtures.orbit).appendingPathComponent("launcher.json")))+ let store = GameSettingsStore(profile: profile, defaults: box.defaults(Fixtures.orbit))+ #expect(!store.set("DM_PICTURE_FIT", to: "stretch"), "only the two values the engine reads")+ #expect(store.values()["DM_PICTURE_FIT"] == "fit")+ }+}diff --git a/frontend-ios/Tests/ShellUITests/PictureFitRowTests.swift b/frontend-ios/Tests/ShellUITests/PictureFitRowTests.swiftnew file mode 100644index 00000000..532003ed--- /dev/null+++ b/frontend-ios/Tests/ShellUITests/PictureFitRowTests.swift@@ -0,0 +1,92 @@+import Foundation+import Testing+@testable import ShellUI++/// The Picture row of a game's settings (#545): its texts come from launcher.json in English and are shown in the player's language.+@Suite struct PictureFitRowTests {+ static let note = "Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game."++ private func bundle(_ language: String) throws -> Bundle {+ try #require(ShellStrings.bundle.path(forResource: language, ofType: "lproj").flatMap(Bundle.init(path:)), "\(language).lproj")+ }++ @Test(arguments: ["zh-Hans", "de", "fr", "sv", "it"]) func everyShellLanguageHasTheRow(language: String) throws {+ let b = try bundle(language)+ let row = SettingRow(id: "DM_PICTURE_FIT", label: "Picture", note: Self.note,+ kind: .choice([SettingOption("fit", "Fit", in: b), SettingOption("fill", "Fill", in: b)]), value: "fit", in: b)+ #expect(row.label != "Picture" && row.note != Self.note, "\(language)")+ #expect(!row.note.contains(";") && !row.note.contains(";") && !row.note.contains("—"), "the text rules: no semicolons, no em-dashes")+ guard case .choice(let options) = row.kind else { Issue.record("not a choice"); return }+ #expect(options.map(\.id) == ["fit", "fill"], "the values the engine reads are not translated")+ #expect(!options.contains { $0.label == "Fit" || $0.label == "Fill" }, "\(language)")+ }++ /// Two short labels: a segmented choice like Console mode and Frame rate around it, also in German at the iPhone's width.+ @Test(arguments: ["en", "de", "fr", "zh-Hans"]) func theChoiceIsSegmented(language: String) throws {+ let b = try bundle(language)+ let labels = [ShellStrings.setting("Fit", bundle: b), ShellStrings.setting("Fill", bundle: b)]+ #expect(ChoicePresentation.resolve(labels: labels, width: 320) == .segmented)+ }+}++#if os(macOS)+import AppKit+import SwiftUI+import XCTest++/// Visual QA of the Picture row (#545), rendered on the Mac: the Game section of a game's settings before (no row) and after (Fit,+/// and Fill chosen). Set NX_SHELL_CAPTURE_DIR to write the PNGs, NX_SHELL_CAPTURE_LANG for the language.+@MainActor+final class PictureFitCaptureTests: XCTestCase {+ private func capture<V: View>(_ name: String, width: CGFloat, _ view: () -> V) throws {+ guard let dir = ProcessInfo.processInfo.environment["NX_SHELL_CAPTURE_DIR"] else { throw XCTSkip("Set NX_SHELL_CAPTURE_DIR to capture the shell") }+ let lang = ProcessInfo.processInfo.environment["NX_SHELL_CAPTURE_LANG"] ?? "en"+ if let path = ShellStrings.bundle.path(forResource: lang == "zh" ? "zh-Hans" : lang, ofType: "lproj") {+ ShellStrings.captureBundle = Bundle(path: path)+ }+ defer { ShellStrings.captureBundle = nil }+ NSApplication.shared.setActivationPolicy(.accessory)+ let host = NSHostingView(rootView: view().frame(width: width).background(ShellPalette.background).environment(\.colorScheme, .dark))+ host.frame = NSRect(origin: .zero, size: host.fittingSize)+ let window = NSWindow(contentRect: NSRect(origin: NSPoint(x: -100_000, y: -100_000), size: host.frame.size),+ styleMask: [.borderless], backing: .buffered, defer: false)+ window.isReleasedWhenClosed = false+ window.contentView = host+ window.orderFront(nil)+ defer { window.orderOut(nil); window.contentView = nil }+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))+ host.layoutSubtreeIfNeeded()+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))+ host.cacheDisplay(in: host.bounds, to: rep)+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: URL(fileURLWithPath: dir).appendingPathComponent("\(name)-\(lang).png"))+ }++ private let game = GameTile(id: "0100F2C0115B6000", title: "The Legend of Zelda: Tears of the Kingdom")++ /// The Game section of an iOS game as launcher.json lists it, in the engine's order. Built inside the capture, so the texts+ /// come in the capture's language.+ private func section(picture: String?) -> SettingSection {+ var rows = [+ SettingRow(id: "DM_FPS_TARGET", label: "Frame rate", kind: .choice([SettingOption("30", "30 fps"), SettingOption("60", "60 fps")]), value: "60"),+ SettingRow(id: "DM_OPMODE", label: "Console mode", kind: .choice([SettingOption("1", "Docked"), SettingOption("0", "Handheld")]), value: "0"),+ SettingRow(id: "DM_PRESENT_UPSCALE", label: "Upscaling", note: "Uses more GPU time and can increase heat.",+ kind: .choice([SettingOption("off", "Standard"), SettingOption("metalfx", "MetalFX")]), value: "off")+ ]+ if let picture {+ rows.append(SettingRow(id: "DM_PICTURE_FIT", label: "Picture", note: PictureFitRowTests.note,+ kind: .choice([SettingOption("fit", "Fit"), SettingOption("fill", "Fill")]), value: picture))+ }+ rows.append(SettingRow(id: "DM_SHOW_FPS", label: "Frame-rate counter", kind: .toggle(on: "1", off: "0"), value: "0"))+ return SettingSection(id: "Game", title: "Game", rows: rows)+ }++ func testCaptureTheGameSection() throws {+ for (name, picture) in [("shell-picture-before", nil), ("shell-picture-fit", "fit"), ("shell-picture-fill", "fill")] as [(String, String?)] {+ try capture(name, width: 402) {+ GameDetailView(detail: GameDetail(game: game, sections: [section(picture: picture)]), showsPrimaryAction: false, showsHeader: false)+ .padding(24)+ }+ }+ }+}+#endifdiff --git a/frontend/l10n/de.json b/frontend/l10n/de.jsonindex 42b02c39..5e7d7a0a 100644--- a/frontend/l10n/de.json+++ b/frontend/l10n/de.json@@ -729,6 +729,8 @@"launch.opt.DM_LANG.zh-Hant": "Traditionelles Chinesisch","launch.opt.DM_OPMODE.0": "Handheld","launch.opt.DM_OPMODE.1": "Angedockt",+ "launch.opt.DM_PICTURE_FIT.fill": "Füllen",+ "launch.opt.DM_PICTURE_FIT.fit": "Einpassen","launch.opt.DM_PRESENT_UPSCALE.metalfx": "MetalFX","launch.opt.DM_PRESENT_UPSCALE.off": "Standard","launch.reset": "Getestete Werte laden",@@ -748,6 +750,8 @@"launch.set.DM_METAL_HUD": "Leistungsanzeige","launch.set.DM_NVN_ENC_THREAD": "Encode-Thread","launch.set.DM_OPMODE": "Konsolenmodus",+ "launch.set.DM_PICTURE_FIT": "Bild",+ "launch.set.DM_PICTURE_FIT.note": "Füllen schneidet das 16:9-Bild des Spiels zu, damit es den Bildschirm ausfüllt. Lebensleisten, Untertitel oder Karten am Rand können abgeschnitten werden. Ein Vollbild ohne Zuschnitt braucht einen Patch für jedes Spiel.","launch.set.DM_PRESENT_SNAP": "Bildpufferung","launch.set.DM_PRESENT_SNAP.note": "Bis zu ein Bild mehr Anzeigeverzögerung.","launch.set.DM_PRESENT_UPSCALE": "Hochskalierung",diff --git a/frontend/l10n/en.json b/frontend/l10n/en.jsonindex 32e52638..c2da38e0 100644--- a/frontend/l10n/en.json+++ b/frontend/l10n/en.json@@ -855,6 +855,8 @@"launch.opt.DM_LANG.zh-Hant": "Traditional Chinese","launch.opt.DM_OPMODE.0": "Handheld","launch.opt.DM_OPMODE.1": "Docked",+ "launch.opt.DM_PICTURE_FIT.fill": "Fill",+ "launch.opt.DM_PICTURE_FIT.fit": "Fit","launch.opt.DM_PRESENT_UPSCALE.metalfx": "MetalFX","launch.opt.DM_PRESENT_UPSCALE.off": "Standard","launch.reset": "Reset to tested defaults",@@ -874,6 +876,8 @@"launch.set.DM_METAL_HUD": "Performance HUD","launch.set.DM_NVN_ENC_THREAD": "Encode thread","launch.set.DM_OPMODE": "Console mode",+ "launch.set.DM_PICTURE_FIT": "Picture",+ "launch.set.DM_PICTURE_FIT.note": "Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game.","launch.set.DM_PRESENT_SNAP": "Frame buffering","launch.set.DM_PRESENT_SNAP.note": "Up to one frame more display latency.","launch.set.DM_PRESENT_UPSCALE": "Upscaling",diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.jsonindex 7509a532..d0377032 100644--- a/frontend/l10n/fr.json+++ b/frontend/l10n/fr.json@@ -731,6 +731,8 @@"launch.opt.DM_LANG.zh-Hant": "Chinois traditionnel","launch.opt.DM_OPMODE.0": "Portable","launch.opt.DM_OPMODE.1": "TV",+ "launch.opt.DM_PICTURE_FIT.fill": "Remplir",+ "launch.opt.DM_PICTURE_FIT.fit": "Ajuster","launch.opt.DM_PRESENT_UPSCALE.metalfx": "MetalFX","launch.opt.DM_PRESENT_UPSCALE.off": "Standard","launch.reset": "Rétablir valeurs testées",@@ -750,6 +752,8 @@"launch.set.DM_METAL_HUD": "HUD de performances","launch.set.DM_NVN_ENC_THREAD": "Thread d’encodage","launch.set.DM_OPMODE": "Mode de la console",+ "launch.set.DM_PICTURE_FIT": "Image",+ "launch.set.DM_PICTURE_FIT.note": "Remplir recadre l’image 16:9 du jeu pour couvrir l’écran. Les barres de vie, sous-titres ou cartes près des bords peuvent être coupés. Une image plein écran sans recadrage demande un patch pour chaque jeu.","launch.set.DM_PRESENT_SNAP": "Mise en mémoire tampon","launch.set.DM_PRESENT_SNAP.note": "Jusqu’à une image de latence d’affichage en plus.","launch.set.DM_PRESENT_UPSCALE": "Mise à l’échelle",diff --git a/frontend/l10n/it.json b/frontend/l10n/it.jsonindex b8907b36..3eccea36 100644--- a/frontend/l10n/it.json+++ b/frontend/l10n/it.json@@ -732,6 +732,8 @@"launch.opt.DM_LANG.zh-Hant": "Cinese tradizionale","launch.opt.DM_OPMODE.0": "Portatile","launch.opt.DM_OPMODE.1": "TV",+ "launch.opt.DM_PICTURE_FIT.fill": "Riempi",+ "launch.opt.DM_PICTURE_FIT.fit": "Adatta","launch.opt.DM_PRESENT_UPSCALE.metalfx": "MetalFX","launch.opt.DM_PRESENT_UPSCALE.off": "Standard","launch.reset": "Carica valori testati",@@ -751,6 +753,8 @@"launch.set.DM_METAL_HUD": "HUD prestazioni","launch.set.DM_NVN_ENC_THREAD": "Thread di codifica","launch.set.DM_OPMODE": "Modalità console",+ "launch.set.DM_PICTURE_FIT": "Immagine",+ "launch.set.DM_PICTURE_FIT.note": "Riempi ritaglia l’immagine 16:9 del gioco per coprire lo schermo. Barre della salute, sottotitoli o mappe vicino ai bordi possono venire tagliati. Un’immagine a schermo intero senza ritaglio richiede una patch per ogni gioco.","launch.set.DM_PRESENT_SNAP": "Buffer dei fotogrammi","launch.set.DM_PRESENT_SNAP.note": "Fino a un fotogramma in più di latenza dello schermo.","launch.set.DM_PRESENT_UPSCALE": "Upscaling",diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.jsonindex 1312a647..babb4dd5 100644--- a/frontend/l10n/sv.json+++ b/frontend/l10n/sv.json@@ -574,6 +574,8 @@"launch.opt.DM_LANG.zh-Hant": "Traditionell kinesiska","launch.opt.DM_OPMODE.0": "Handhållen","launch.opt.DM_OPMODE.1": "Dockad",+ "launch.opt.DM_PICTURE_FIT.fill": "Fyll",+ "launch.opt.DM_PICTURE_FIT.fit": "Anpassa","launch.opt.DM_PRESENT_UPSCALE.metalfx": "MetalFX","launch.opt.DM_PRESENT_UPSCALE.off": "Standard","launch.reset": "Återställ testade värden",@@ -593,6 +595,8 @@"launch.set.DM_METAL_HUD": "Prestandaöversikt","launch.set.DM_NVN_ENC_THREAD": "Kodningstråd","launch.set.DM_OPMODE": "Konsolläge",+ "launch.set.DM_PICTURE_FIT": "Bild",+ "launch.set.DM_PICTURE_FIT.note": "Fyll beskär spelets 16:9-bild så att den täcker skärmen. Hälsomätare, undertexter eller kartor nära kanterna kan skäras bort. En helskärmsbild utan beskärning kräver en patch för varje spel.","launch.set.DM_PRESENT_SNAP": "Bildbuffring","launch.set.DM_PRESENT_SNAP.note": "Upp till en bildruta mer fördröjning på skärmen.","launch.set.DM_PRESENT_UPSCALE": "Uppskalning",diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.jsonindex 4884f1c1..5cf10975 100644--- a/frontend/l10n/zh.json+++ b/frontend/l10n/zh.json@@ -856,6 +856,8 @@"launch.opt.DM_LANG.zh-Hant": "繁体中文","launch.opt.DM_OPMODE.0": "掌机模式","launch.opt.DM_OPMODE.1": "底座模式",+ "launch.opt.DM_PICTURE_FIT.fill": "填充",+ "launch.opt.DM_PICTURE_FIT.fit": "适应","launch.opt.DM_PRESENT_UPSCALE.metalfx": "MetalFX","launch.opt.DM_PRESENT_UPSCALE.off": "标准","launch.reset": "恢复测试默认值",@@ -875,6 +877,8 @@"launch.set.DM_METAL_HUD": "性能 HUD","launch.set.DM_NVN_ENC_THREAD": "编码线程","launch.set.DM_OPMODE": "主机模式",+ "launch.set.DM_PICTURE_FIT": "画面",+ "launch.set.DM_PICTURE_FIT.note": "填充会裁切游戏的 16:9 画面以铺满屏幕。边缘附近的血条、字幕或地图可能被裁掉。不裁切的全屏画面需要为每个游戏单独打补丁。","launch.set.DM_PRESENT_SNAP": "帧缓冲","launch.set.DM_PRESENT_SNAP.note": "显示延迟最多增加一帧。","launch.set.DM_PRESENT_UPSCALE": "超分",diff --git a/patches/0063-ios-picture-fit-or-fill-for-screens-that-are-not.patch b/patches/0063-ios-picture-fit-or-fill-for-screens-that-are-not.patchnew file mode 100644index 00000000..8f522dad--- /dev/null+++ b/patches/0063-ios-picture-fit-or-fill-for-screens-that-are-not.patch@@ -0,0 +1,271 @@+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001+From: v0lumehi <[email protected]>+Date: Tue, 3 Nov 2026 15:07:02 +0100+Subject: [PATCH] iOS: picture Fit or Fill for screens that are not 16:9++A per-game launcher setting, DM_PICTURE_FIT (fit, the default, or fill).+Fit is today's picture: the largest centered 16:9 rectangle with black bars.+Fill scales the 16:9 picture until it covers the view and crops the overflow,+with no stretching. It applies to the overlay layout (landscape) only. A+portrait or tabletop split keeps the picture fitted in its area above the+controls, where cropping a small picture costs more than the bars.++The touch controls keep the full view. The game's own touch screen is+normalized on the scaled picture, so a touch on the visible part lands+where that part of the picture is (dm_game_touch_point). A TV keeps Fit.++The Duo harness stubs gain front_ios_device_check, which front_ios.m calls+since the device check, so the harness links again.++Upstream-Status: forwarded seedds/nxnative#1083+Reason: Players with screens that are not 16:9 can fill the screen, a per-game choice in the iOS shell.+Issue: LNPANDY/NX2Apple#545++---+ dm/games/settings.tsv | 1 ++ dm/ios/Sources/DmGamepad.m | 11 ++--+ dm/ios/Sources/DmLayout.h | 26 ++++++++++ dm/ios/Sources/front_ios.m | 6 +-+ dm/ios/tests/duo/Sources/DuoRuntimeStubs.m | 1 ++ dm/ios/tests/duo/Tests/DuoHarnessTests.m | 64 +++++++++++++++++++++++ dm/tools/tests/test_launcher_settings.py | 2 +-+ docs/env_switches.tsv | 1 ++ docs/settings.md | 1 ++ 9 files changed, 105 insertions(+), 8 deletions(-)++diff --git a/dm/games/settings.tsv b/dm/games/settings.tsv+index 00e1ddd1..abc665b0 100644+--- a/dm/games/settings.tsv++++ b/dm/games/settings.tsv+@@ -21,6 +21,7 @@ DM_OPMODE choice 1=Docked,0=Handheld DM_GAME_OPMODE always Game Console mode le+ DM_PRESENT_UPSCALE choice off=Standard,metalfx=MetalFX off always Game Upscaling Uses more GPU time and can increase heat.+ DM_LANG choice languages build:DM_LANG languages>1 Game Game language level=basic+ DM_FULLSCREEN choice 0=Window,1=Fullscreen 0 platform:mac Game Display mode level=basic++DM_PICTURE_FIT choice fit=Fit,fill=Fill fit platform:ios Game Picture Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game.+ DM_SHOW_FPS toggle - build:DM_SHOW_FPS platform:ios Game Frame-rate counter+ DM_TOUCH_HAPTICS toggle - 1 platform:ios Controls Touch feedback+ DM_RUMBLE toggle - 1 always Controls Game rumble level=basic+diff --git a/dm/ios/Sources/DmGamepad.m b/dm/ios/Sources/DmGamepad.m+index 39ad3f28..9f517490 100644+--- a/dm/ios/Sources/DmGamepad.m++++ b/dm/ios/Sources/DmGamepad.m+@@ -368,15 +368,14 @@ - (void)recompute {+ if (changed || stick || _stickShown) [self refresh]; // also refresh on the stick release so the knob returns to the centre+ _stickShown = stick;+ }+-// Touches no control takes go to the game's touch screen, normalized on front_ios.m's actual 16:9 viewport (including portrait and tabletop splits): Super Mario Galaxy's pointer in handheld mode (profile op_mode). The host reports them only in handheld mode, as on the Switch (hle_hid.c touch_read)++// Touches no control takes go to the game's touch screen, normalized on front_ios.m's actual 16:9 viewport (including portrait and tabletop splits, and the cropped Fill picture): Super Mario Galaxy's pointer in handheld mode (profile op_mode). The host reports them only in handheld mode, as on the Switch (hle_hid.c touch_read)+ - (void)pushGame {+- CGRect b = _layout.game; CGFloat w = b.size.width, h = b.size.height;+- if (w <= 0 || h <= 0) { dm_touch_set(NULL, 0); return; }+- CGFloat x0 = CGRectGetMinX(b), y0 = CGRectGetMinY(b);++ CGRect b = _layout.game;++ if (b.size.width <= 0 || b.size.height <= 0) { dm_touch_set(NULL, 0); return; }+ dm_touch t[16]; int n = 0;+ for (int i = 0; i < 16; i++) if (_game[i]) {+- CGPoint p = [_game[i] locationInView:self];+- t[n++] = (dm_touch){(uint32_t)i, (float)fmin(fmax((p.x - x0) / w, 0), 0.999), (float)fmin(fmax((p.y - y0) / h, 0), 0.999)};++ CGPoint p = dm_game_touch_point(b, [_game[i] locationInView:self]); // with Fill the game rectangle is larger than the view (DmLayout.h)++ t[n++] = (dm_touch){(uint32_t)i, (float)p.x, (float)p.y};+ }+ dm_touch_set(t, n);+ }+diff --git a/dm/ios/Sources/DmLayout.h b/dm/ios/Sources/DmLayout.h+index 4b118d80..ad4498f5 100644+--- a/dm/ios/Sources/DmLayout.h++++ b/dm/ios/Sources/DmLayout.h+@@ -17,6 +17,17 @@ static inline CGRect dm_aspect_fit(CGRect b) {+ return CGRectMake(floor(CGRectGetMidX(b) - w / 2), floor(CGRectGetMidY(b) - h / 2), w, h);+ }+++// Picture "Fill" (DM_PICTURE_FIT=fill, a launcher setting): the smallest centered 16:9 rectangle that covers b. The game still renders 16:9,++// so what lies outside b is cropped, never stretched. Not rounded, so it covers b exactly.++static inline CGRect dm_aspect_fill(CGRect b) {++ CGFloat w = b.size.width, h = b.size.height;++ if (w <= 0 || h <= 0) return CGRectZero;++ if (w / h > 16.0 / 9.0) h = w * 9.0 / 16.0; else w = h * 16.0 / 9.0;++ return CGRectMake(CGRectGetMidX(b) - w / 2, CGRectGetMidY(b) - h / 2, w, h);++}++++static inline BOOL dm_picture_fill(const char *_Nullable value) { return value && !strcmp(value, "fill"); } // DM_PICTURE_FIT: fit (default) or fill+++ static inline CGRect dm_horizontal_division(CGRect b, CGRect division) {+ if (CGRectIsNull(division) || division.size.width <= division.size.height) return CGRectNull;+ // Preserve zero-height inactive folds and clip regions during display handoff.+@@ -46,6 +57,21 @@ static inline DmLayout dm_layout(CGRect b, UIEdgeInsets insets, BOOL partiallyOp+ return l;+ }+++// Fill covers the full view only in the overlay layout (landscape). A portrait or tabletop split keeps the picture fitted in its++// area above the controls, where cropping a small picture would cost more than the bars.++static inline DmLayout dm_layout_picture(DmLayout l, CGRect b, BOOL fill) {++ if (fill && !l.separated && !CGRectIsEmpty(b)) l.game = dm_aspect_fill(b);++ return l;++}++++// A point in the view as the game's touch screen sees it: normalized on the game rectangle, which with Fill is larger than the view,++// so a touch on the visible part lands where that part of the picture is. Clamped to [0, 0.999].++static inline CGPoint dm_game_touch_point(CGRect game, CGPoint p) {++ CGFloat w = game.size.width, h = game.size.height;++ if (w <= 0 || h <= 0) return CGPointZero;++ return CGPointMake(fmin(fmax((p.x - CGRectGetMinX(game)) / w, 0), 0.999), fmin(fmax((p.y - CGRectGetMinY(game)) / h, 0), 0.999));++}+++ UIView *dm_gamepad_view(CGRect frame);+ void dm_gamepad_arrange(UIView *view, DmLayout layout);+ void dm_gamepad_reset(void);+diff --git a/dm/ios/Sources/front_ios.m b/dm/ios/Sources/front_ios.m+index a50696ad..fa2e9066 100644+--- a/dm/ios/Sources/front_ios.m++++ b/dm/ios/Sources/front_ios.m+@@ -89,6 +89,7 @@ @interface DmRootVC : UIViewController+ @property (nonatomic, strong) id tv; // the TV scene accessory's registration (iOS 27)+ @property (nonatomic) BOOL hasLauncher; // the app has a settings screen: a failed Play goes back to it (its Game data section is the way out)+ @property (nonatomic) BOOL partiallyOpen;++@property (nonatomic) BOOL fill; // DM_PICTURE_FIT=fill: the 16:9 picture covers the screen in landscape, cropped (DmLayout.h dm_layout_picture)+ @property (nonatomic) NSInteger hingeStatus;+ @property (nonatomic) BOOL separated;+ @property (nonatomic, copy) NSString *layoutLog;+@@ -161,6 +162,9 @@ - (void)startGame {+ front_hud_env(); // before the process's first Metal device, which reads MTL_HUD_ENABLED (an env file's DM_METAL_HUD sets it in main.m already; GitHub issue #840)+ const char *dev = front_ios_device_check(); // that first device: a GPU without BC textures is refused here, not at launch, so the launcher's HUD switch counts+ if (dev) { [self showHint:[NSString stringWithFormat:@"This device is not supported.\n%s", dev]]; return; } // the host does not start++ self.fill = dm_picture_fill(getenv("DM_PICTURE_FIT"));++ if (self.fill) LOG("front end: picture Fill (DM_PICTURE_FIT=fill), the 16:9 picture covers the screen in landscape and its edges are cropped");++ self.view.clipsToBounds = YES; // with Fill the game view is larger than the screen+ self.game =[[DmGameView alloc] initWithFrame:self.view.bounds];+ [self.view addSubview:self.game];+ g_layer = (CAMetalLayer *)self.game.layer;+@@ -193,7 +197,7 @@ - (void)viewDidLayoutSubviews {+ #endif+ BOOL duoPortrait = b.size.height > b.size.width && (self.hingeStatus != 0 || !CGRectIsNull(division));+ UIEdgeInsets gameInsets = dm_game_safe_insets(b, self.view.safeAreaInsets, duoPortrait);+- DmLayout layout = dm_layout(b, gameInsets, self.partiallyOpen, division);++ DmLayout layout = dm_layout_picture(dm_layout(b, gameInsets, self.partiallyOpen, division), b, self.fill);+ if (self.game.superview == self.view) self.game.frame = layout.game; // on a TV the TV's view lays it out+ layout.topSafeOnly = duoPortrait;+ UIInterfaceOrientationMask appMask = [UIApplication.sharedApplication supportedInterfaceOrientationsForWindow:self.view.window];+diff --git a/dm/ios/tests/duo/Sources/DuoRuntimeStubs.m b/dm/ios/tests/duo/Sources/DuoRuntimeStubs.m+index f2d20722..1ce9255d 100644+--- a/dm/ios/tests/duo/Sources/DuoRuntimeStubs.m++++ b/dm/ios/tests/duo/Sources/DuoRuntimeStubs.m+@@ -121,6 +121,7 @@ void dm_audio_reset(void) {}+ void dm_focus_set(int state) { (void)state; }+ void guest_clock_freeze_for(int reason, int on) { (void)reason; (void)on; }+ const char *front_ios_boot_message(void) { return NULL; }++const char *front_ios_device_check(void) { return NULL; }+ const char *front_ios_device_message(void) { return NULL; }+ int dm_locate_game_data(void) { return 1; }+ void dm_cloud_saves_env(void) {}+diff --git a/dm/ios/tests/duo/Tests/DuoHarnessTests.m b/dm/ios/tests/duo/Tests/DuoHarnessTests.m+index 271d44cc..f263ec86 100644+--- a/dm/ios/tests/duo/Tests/DuoHarnessTests.m++++ b/dm/ios/tests/duo/Tests/DuoHarnessTests.m+@@ -393,6 +393,70 @@ - (void)testLandscapeControlAnchorsAndMultitouchKeepTheirExistingLayout {+ XCTAssertEqual(input.touch_count, 0);+ }+++- (void)testPictureFillCoversTheLandscapeViewWithoutStretching {++ XCTAssertTrue(dm_picture_fill("fill"));++ XCTAssertFalse(dm_picture_fill("fit"));++ XCTAssertFalse(dm_picture_fill(NULL), @"Unset keeps Fit, today's picture");++ XCTAssertFalse(dm_picture_fill(""));++ const CGRect sizes[] = {CGRectMake(0, 0, 844, 390), CGRectMake(0, 0, 932, 430), CGRectMake(0, 0, 1024, 768), CGRectMake(0, 0, 1280, 720)};++ for (NSUInteger i = 0; i < 4; i++) {++ CGRect bounds = sizes[i];++ DmLayout fit = dm_layout(bounds, UIEdgeInsetsZero, NO, CGRectNull);++ DmLayout fill = dm_layout_picture(fit, bounds, YES);++ XCTAssertTrue(CGRectEqualToRect(dm_layout_picture(fit, bounds, NO).game, fit.game), @"Fit leaves the layout as it was");++ XCTAssertFalse(fill.separated);++ XCTAssertTrue(CGRectEqualToRect(fill.controls, bounds), @"The touch controls keep the full view");++ XCTAssertEqualWithAccuracy(fill.game.size.width / fill.game.size.height, 16.0 / 9.0, 0.0001, @"Fill scales, never stretches");++ XCTAssertTrue(CGRectContainsRect(CGRectInset(fill.game, -0.001, -0.001), bounds), @"Fill covers the whole view");++ XCTAssertEqualWithAccuracy(CGRectGetMidX(fill.game), CGRectGetMidX(bounds), 0.001);++ XCTAssertEqualWithAccuracy(CGRectGetMidY(fill.game), CGRectGetMidY(bounds), 0.001);++ XCTAssertTrue(fill.game.size.width == bounds.size.width || fill.game.size.height == bounds.size.height,++ @"The smallest cover: one side matches the view");++ }++ CGRect wide = dm_aspect_fill(CGRectMake(0, 0, 844, 390));++ XCTAssertEqualWithAccuracy(wide.size.height, 474.75, 0.001);++ XCTAssertEqualWithAccuracy(CGRectGetMinY(wide), -42.375, 0.001, @"A wide iPhone crops the top and the bottom");++ CGRect pad = dm_aspect_fill(CGRectMake(0, 0, 1024, 768));++ XCTAssertEqualWithAccuracy(CGRectGetMinX(pad), -170.667, 0.001, @"A 4:3 iPad crops the sides");++ XCTAssertTrue(CGRectIsEmpty(dm_aspect_fill(CGRectZero)));++}++++- (void)testPictureFillKeepsPortraitAndTabletopSplitsFitted {++ CGRect portrait = CGRectMake(0, 0, 390, 844);++ DmLayout split = dm_layout(portrait, UIEdgeInsetsMake(59, 0, 34, 0), NO, CGRectNull);++ DmLayout filled = dm_layout_picture(split, portrait, YES);++ XCTAssertTrue(filled.separated);++ XCTAssertTrue(CGRectEqualToRect(filled.game, split.game), @"Portrait keeps the picture fitted above the controls");++ CGRect landscape = CGRectMake(0, 0, 844, 390);++ DmLayout tabletop = dm_layout(landscape, UIEdgeInsetsZero, YES, CGRectMake(0, 180, 844, 24));++ XCTAssertTrue(tabletop.separated);++ XCTAssertTrue(CGRectEqualToRect(dm_layout_picture(tabletop, landscape, YES).game, tabletop.game), @"Tabletop keeps the picture fitted in its half");++}++++- (void)testPictureFillTouchesFollowTheCroppedPicture {++ CGRect bounds = CGRectMake(0, 0, 844, 390);++ DmLayout layout = dm_layout_picture(dm_layout(bounds, UIEdgeInsetsZero, NO, CGRectNull), bounds, YES);++ CGPoint top = dm_game_touch_point(layout.game, CGPointMake(422, 0));++ XCTAssertEqualWithAccuracy(top.x, 0.5, 0.001);++ XCTAssertEqualWithAccuracy(top.y, 42.375 / 474.75, 0.001, @"The view's top edge is below the cropped top of the picture");++ CGPoint bottom = dm_game_touch_point(layout.game, CGPointMake(0, 390));++ XCTAssertEqualWithAccuracy(bottom.x, 0, 0.001);++ XCTAssertEqualWithAccuracy(bottom.y, (390 + 42.375) / 474.75, 0.001);++ CGPoint outside = dm_game_touch_point(layout.game, CGPointMake(-50, 900));++ XCTAssertEqualWithAccuracy(outside.x, 0, 0.0001);++ XCTAssertEqualWithAccuracy(outside.y, 0.999, 0.0001);++++ UIView *pad = [self padForLayout:layout bounds:bounds];++ DuoFakeTouch *game = [self touchAt:CGPointMake(300, 150) time:1];++ [self beginTouches:@[game] onPad:pad];++ DuoHarnessInput input = duo_harness_input();++ XCTAssertEqual(input.touch_count, 1, @"A touch on no control goes to the game");++ XCTAssertEqualWithAccuracy(input.touches[0].x, 300 / 844.0, 0.001);++ XCTAssertEqualWithAccuracy(input.touches[0].y, (150 + 42.375) / 474.75, 0.001, @"Normalized on the scaled picture, not the view");++ [self endTouches:@[game] onPad:pad cancelled:NO];++ XCTAssertEqual(duo_harness_input().touch_count, 0);++}+++ - (void)testSmallSeparatedHitTargetsMeetMinimumsWithoutGrowingArtwork {+ CGRect bounds = CGRectMake(0, 0, 390, 844);+ DmLayout layout = [self separatedLayout:bounds];+diff --git a/dm/tools/tests/test_launcher_settings.py b/dm/tools/tests/test_launcher_settings.py+index cd43d2d7..12ec7221 100644+--- a/dm/tools/tests/test_launcher_settings.py++++ b/dm/tools/tests/test_launcher_settings.py+@@ -62,7 +62,7 @@ class LauncherSettingsTests(unittest.TestCase):+ def test_iphone_switches_only_on_the_iphone(self): # the frame-rate counter and touch feedback are the iOS front end's (front_ios.m, DmGamepad.m)+ ios, mac = build(BOTW, 'nvn'), build(BOTW, 'nvn', 'mac')+ self.assertEqual(build(BOTW, 'nvn', 'ios').keys(), ios.keys()) # ios when unset+- self.assertEqual(set(ios) - set(mac), {'DM_SHOW_FPS', 'DM_TOUCH_HAPTICS'})++ self.assertEqual(set(ios) - set(mac), {'DM_SHOW_FPS', 'DM_TOUCH_HAPTICS', 'DM_PICTURE_FIT'})+ self.assertIn('DM_RUMBLE', mac); self.assertIn('DM_METAL_HUD', mac)+ self.assertEqual(set(mac) - set(ios), {'DM_FULLSCREEN'}) # the Mac window's Display mode (front_mac.m reads 1 or 0)+ s = mac['DM_FULLSCREEN']+diff --git a/docs/env_switches.tsv b/docs/env_switches.tsv+index e594a57a..db980663 100644+--- a/docs/env_switches.tsv++++ b/docs/env_switches.tsv+@@ -212,6 +212,7 @@ DM_PAD_MAP player Mac controllers: `<name>=<name>,…` makes the button that sen+ DM_PAD_MERGE switch `=1` merges every controller into player 1, as before, instead of giving each controller a player of its own (Mac and iOS)+ DM_PATCH_FRONT switch `=<bytes>`: the size of the patch area right before the module base for a long text (`BIG_TEXT`); set only by the rewriter's own rerun with the size it needs+ DM_PHONE_MOTION switch On iOS, whether the phone's own device motion drives player 1's six-axis sensor: `auto` (default) while no controller supplies fresh motion, `1` phone only, `0` never; each source keeps its own orientation++DM_PICTURE_FIT player `fill` scales the 16:9 picture on the iPhone and iPad until it covers the screen in landscape and crops the edges (a portrait or tabletop split stays fitted); `fit` or unset, the largest 16:9 rectangle with black bars. Launcher setting+ DM_PREEMPT switch `0` / `1` overrides the profile's `core_preempt`: also check already-runnable higher-priority peers on the caller's core after every thread SVC+ DM_PRELOAD diagnostic Set: on the Mac, runs the host's early background loading (`dm_host_preload_start`) as the iOS app does, to exercise that path+ DM_PRESENT_FIFO switch `0` makes the display link take the newest queued frame each tick, as before; by default it shows frames in order, at most one tick behind+diff --git a/docs/settings.md b/docs/settings.md+index 0f992d4c..d9a79493 100644+--- a/docs/settings.md++++ b/docs/settings.md+@@ -223,6 +223,7 @@ A line like `DM_PRESENT_SNAP=0` in `Documents/env.txt` (in the Files app, under+ | Game language | `DM_LANG` | a language code, such as `ja` |+ | Display mode (Mac) | `DM_FULLSCREEN` | `1` fullscreen, `0` a window |+ | Cloud saves folder (Mac) | `DM_SAVE_SYNC` | a folder; `icloud`: iCloud Drive › nxnative Saves; `0`: off |++| Picture (iPhone and iPad) | `DM_PICTURE_FIT` | `fit` 16:9 with black bars, `fill` covers the screen, cropped |+ | Frame-rate counter | `DM_SHOW_FPS` | `1`, `0` |+ | Touch feedback | `DM_TOUCH_HAPTICS` | `1`, `0` |+ | Game rumble | `DM_RUMBLE` | `1`, `0` |diff --git a/patches/series b/patches/seriesindex b87ebcc4..505005f1 100644--- a/patches/series+++ b/patches/series@@ -38,3 +38,4 @@0060-ios-shell-declare-italian-in-cfbundlelocalizatio.patch0061-ios-adapt-gameplay-to-duo-portrait-and-tabletop.patch0062-ios-apply-controller-button-mappings-to-physical.patch+0063-ios-picture-fit-or-fill-for-screens-that-are-not.patchdiff --git a/tools/tests/launcher_texts.txt b/tools/tests/launcher_texts.txtindex eb821919..376fcfc1 100644--- a/tools/tests/launcher_texts.txt+++ b/tools/tests/launcher_texts.txt@@ -12,6 +12,9 @@ DockedDutchDynamic resolutionEncode thread+Fill+Fill crops the game's 16:9 picture to cover the screen. Health bars, subtitles or maps near the edges can be cut off. A full-screen picture without cropping needs a patch for each game.+FitFrame bufferingFrame rateFrame-rate counter@@ -32,6 +35,7 @@ Metal 4 pipelinesMetalFXPerformancePerformance HUD+PicturePipeline prebuildPortugueseRender scale