Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

iOS shell: pass the quit prompt's texts to the engine (#421)

v0lumehia0920ff2da55
diff --git a/frontend-ios/README.md b/frontend-ios/README.md
index dca6ff89..30742801 100644
--- a/frontend-ios/README.md
+++ b/frontend-ios/README.md
@@ -63,7 +63,7 @@ The caller returns changed values through `games`. The views keep no second copy
| `FolderPicker` | `DocumentFolderPicker` is a `UIDocumentPickerViewController` for a folder, opened in place. Tests use a fake. | `DocumentPicker` in `dm/ios/Sources/Launcher.swift` |
| Log | Show log reads the tail (256 KB) of `log.txt` in the game's data folder, else the app's folder, into a read-only sheet. | |
| Update | `ShellHostConfig.updateURL` is opened by Update app. | |
-| Touch controls | The shell settings' Touch controls group, for every game: a preview of the controls on a phone held sideways (`TouchControlsPreview`, which mirrors the engine's `DmPadGeometry.h` for that screen) the Size row (small, medium, large) and the Left stick row (corner, higher, inward, the preview marks the default place with a dashed ring). `ShellSettingsStore.touchSize` and `touchStick` store them, and `gameDefaults` passes them to the engine as `DM_TOUCH_SIZE` and `DM_TOUCH_STICK` (medium and the corner are the engine's own and are not passed). The engine keeps a choice off a screen too small for it. Every game also gets `DM_TOUCH_HINT`, the words the engine shows once per launch where the 3D layout's undrawn right stick is (`ios.host.touchHint`). `TouchControlsCaptureTests` renders the group on the Mac. | `dm/ios/Sources/DmPadGeometry.h` (patches 0065 to 0067) |
+| Touch controls | The shell settings' Touch controls group, for every game: a preview of the controls on a phone held sideways (`TouchControlsPreview`, which mirrors the engine's `DmPadGeometry.h` for that screen) the Size row (small, medium, large) and the Left stick row (corner, higher, inward, the preview marks the default place with a dashed ring). `ShellSettingsStore.touchSize` and `touchStick` store them, and `gameDefaults` passes them to the engine as `DM_TOUCH_SIZE` and `DM_TOUCH_STICK` (medium and the corner are the engine's own and are not passed). The engine keeps a choice off a screen too small for it. Every game also gets `DM_TOUCH_HINT`, the words the engine shows once per launch where the 3D layout's undrawn right stick is (`ios.host.touchHint`). Every game gets the quit prompt's words as `DM_HOME_QUIT_TEXT` (`ios.host.quit*`, five lines in `home_quit.h`'s order, as the Mac launcher passes them): the engine shows the prompt when the player picks Quit in the in-game menu (the gear) or holds a controller's Home button. `TouchControlsCaptureTests` renders the group on the Mac. | `dm/ios/Sources/DmPadGeometry.h`, `quit_prompt.h` (patches 0065 to 0068) |
| Controllers | `ShellHostModel.startControllers()` runs `GamepadAdapter` and fills `controllers` (`ControllerInfo`) and `input` (`ShellInput`). Global mappings are stored in `ShellSettingsStore.padMap`, individual overrides in the game's suite under `GameDefaults.padMapKey`. At launch, each button resolves game > global > default and is passed to the engine as `DM_PAD_MAP`. A profile's own `DM_PAD_MAP` row takes precedence. Touch controls and shell navigation keep their original mapping. | |
```swift
diff --git a/frontend-ios/Sources/ShellHost/Resources/Localizable.xcstrings b/frontend-ios/Sources/ShellHost/Resources/Localizable.xcstrings
index 0afc902c..4727d00c 100644
--- a/frontend-ios/Sources/ShellHost/Resources/Localizable.xcstrings
+++ b/frontend-ios/Sources/ShellHost/Resources/Localizable.xcstrings
@@ -209,6 +209,46 @@
}
}
},
+ "Cancel": {
+ "localizations": {
+ "de": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Abbrechen"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Cancel"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Annuler"
+ }
+ },
+ "it": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Annulla"
+ }
+ },
+ "sv": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Avbryt"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "取消"
+ }
+ }
+ }
+ },
"Choose a RomFS folder or romfs.img on this device, an external drive, or iCloud Drive.": {
"localizations": {
"en": {
@@ -323,6 +363,46 @@
}
}
},
+ "Keep holding to quit": {
+ "localizations": {
+ "de": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Zum Beenden gedrückt halten"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Keep holding to quit"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Maintenez pour quitter"
+ }
+ },
+ "it": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Tieni premuto per uscire"
+ }
+ },
+ "sv": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Fortsätt hålla in för att avsluta"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "继续按住即可退出"
+ }
+ }
+ }
+ },
"Launching is not available yet.": {
"localizations": {
"en": {
@@ -531,6 +611,86 @@
}
}
},
+ "Quit": {
+ "localizations": {
+ "de": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Beenden"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Quit"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Quitter"
+ }
+ },
+ "it": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Esci"
+ }
+ },
+ "sv": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Avsluta"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "退出"
+ }
+ }
+ }
+ },
+ "Quit %@?": {
+ "localizations": {
+ "de": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ beenden?"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Quit %@?"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Quitter %@ ?"
+ }
+ },
+ "it": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Uscire da %@?"
+ }
+ },
+ "sv": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Avsluta %@?"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "退出%@?"
+ }
+ }
+ }
+ },
"Right stick: drag here": {
"localizations": {
"de": {
@@ -1091,6 +1251,46 @@
}
}
},
+ "Unsaved progress will be lost. The app closes and opens on your games next time.": {
+ "localizations": {
+ "de": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nicht gesicherter Fortschritt geht verloren. Die App wird geschlossen und zeigt beim nächsten Öffnen deine Spiele."
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Unsaved progress will be lost. The app closes and opens on your games next time."
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "La progression non sauvegardée sera perdue. L’app se ferme et s’ouvre sur vos jeux la prochaine fois."
+ }
+ },
+ "it": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "I progressi non salvati andranno persi. L’app si chiude e la prossima volta si apre sui tuoi giochi."
+ }
+ },
+ "sv": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Osparade framsteg går förlorade. Appen stängs och öppnas med dina spel nästa gång."
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "未保存的进度将会丢失。App 会关闭,下次打开时显示你的游戏。"
+ }
+ }
+ }
+ },
"chain \"%@\" is not of the form b-<hex>.": {
"localizations": {
"en": {
diff --git a/frontend-ios/Sources/ShellHost/ShellHostModel.swift b/frontend-ios/Sources/ShellHost/ShellHostModel.swift
index 6429003d..788b39c7 100644
--- a/frontend-ios/Sources/ShellHost/ShellHostModel.swift
+++ b/frontend-ios/Sources/ShellHost/ShellHostModel.swift
@@ -466,7 +466,8 @@ public struct ShellHostConfig: Sendable {
static var touchHint: String { hostText("Right stick: drag here") }
/// DM_HOME_QUIT_TEXT: the game's quit prompt in the player's language, one text per line in the engine's order (home_quit.h): the hold
- /// indicator, the title with the game's name, the note, Quit and Cancel. The engine draws it when the quit control is tapped or Home is held.
+ /// indicator, the title with the game's name, the note, Quit and Cancel. The engine draws it when Quit is picked in the in-game menu (the gear)
+ /// or Home is held. The menu item reads the title without its question mark.
static func quitPromptText(gameName: String) -> String {
[hostText("Keep holding to quit"), hostText("Quit \(gameName)?"),
hostText("Unsaved progress will be lost. The app closes and opens on your games next time."), hostText("Quit"), hostText("Cancel")]
diff --git a/frontend-ios/Tests/ShellHostTests/ShellHostModelTests.swift b/frontend-ios/Tests/ShellHostTests/ShellHostModelTests.swift
index 98fbeef7..edeed052 100644
--- a/frontend-ios/Tests/ShellHostTests/ShellHostModelTests.swift
+++ b/frontend-ios/Tests/ShellHostTests/ShellHostModelTests.swift
@@ -61,30 +61,25 @@ final class Clock: @unchecked Sendable { var date: Date; init(_ d: Date) { date
#expect(hint == ShellHostModel.touchHint && !hint.isEmpty)
}
- /// The quit prompt's words reach the engine with the game's name in the title, five lines in home_quit.h's order (patch 0068), and the
- /// quit control's choice from the shell's settings.
+ /// The quit prompt's words reach the engine with the game's name in the title, five lines in home_quit.h's order (patch 0068): the
+ /// engine draws the prompt when Quit is picked in the in-game menu or Home is held.
@Test func everyGameGetsTheQuitPromptInThePlayersLanguage() async throws {
let box = try Sandbox()
try box.giveAppData()
- let shell = shellSettings()
let launcher = RecordingLauncher()
- let model = ShellHostModel(config: box.config(), launcher: launcher, shellSettings: shell)
+ let model = ShellHostModel(config: box.config(), launcher: launcher, shellSettings: shellSettings())
await model.playNow(Fixtures.orbit)
let text = try #require(launcher.launched.last?.environment["DM_HOME_QUIT_TEXT"])
let lines = text.components(separatedBy: "\n")
let name = try #require(launcher.launched.last?.name)
#expect(lines.count == 5 && lines.allSatisfy { !$0.isEmpty } && lines[1].contains(name))
- #expect(launcher.launched.last?.environment["DM_TOUCH_EXIT"] == nil, "the quit control is on by default")
- shell.storeTouchQuit(false)
- await model.playNow(Fixtures.orbit)
- #expect(launcher.launched.last?.environment["DM_TOUCH_EXIT"] == "0")
}
/// The prompt's texts in every language: no semicolon, no line break (one text per line in DM_HOME_QUIT_TEXT), the title keeps the game's name.
@Test func theQuitPromptTextsFollowTheTextRules() throws {
let l10n = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
.deletingLastPathComponent().appendingPathComponent("frontend/l10n")
- let keys = ["ios.host.quitHold", "ios.host.quitTitle", "ios.host.quitNote", "ios.host.quitButton", "ios.host.quitCancel", "ios.ui.touchQuit", "ios.ui.touchQuitNote"]
+ let keys = ["ios.host.quitHold", "ios.host.quitTitle", "ios.host.quitNote", "ios.host.quitButton", "ios.host.quitCancel"]
for file in try FileManager.default.contentsOfDirectory(at: l10n, includingPropertiesForKeys: nil) where file.pathExtension == "json" {
let strings = try #require(JSONSerialization.jsonObject(with: Data(contentsOf: file)) as? [String: Any])
for key in keys {
diff --git a/frontend/l10n/de.json b/frontend/l10n/de.json
index 501d3ecc..223c1c49 100644
--- a/frontend/l10n/de.json
+++ b/frontend/l10n/de.json
@@ -608,6 +608,11 @@
"ios.host.padOn": "An",
"ios.host.padSameAsAllGames": "Wie alle Spiele",
"ios.host.padSwapAB": "A und B tauschen",
+ "ios.host.quitButton": "Beenden",
+ "ios.host.quitCancel": "Abbrechen",
+ "ios.host.quitHold": "Zum Beenden gedrückt halten",
+ "ios.host.quitNote": "Nicht gesicherter Fortschritt geht verloren. Die App wird geschlossen und zeigt beim nächsten Öffnen deine Spiele.",
+ "ios.host.quitTitle": "%@ beenden?",
"ios.host.touchHint": "Rechter Stick: hier ziehen",
"ios.setting.DM_PSO_MTL4.note": "Behält ein Pipeline-Archiv und braucht mehr Speicher.",
"ios.ui.cancel": "Abbrechen",
diff --git a/frontend/l10n/en.json b/frontend/l10n/en.json
index a3ff5dd4..4be34bf3 100644
--- a/frontend/l10n/en.json
+++ b/frontend/l10n/en.json
@@ -653,6 +653,11 @@
"ios.host.padSameAsAllGames": "Same as all games",
"ios.host.padSwapAB": "Swap A and B",
"ios.host.player": "Player %@",
+ "ios.host.quitButton": "Quit",
+ "ios.host.quitCancel": "Cancel",
+ "ios.host.quitHold": "Keep holding to quit",
+ "ios.host.quitNote": "Unsaved progress will be lost. The app closes and opens on your games next time.",
+ "ios.host.quitTitle": "Quit %@?",
"ios.host.rangeWithoutLimits": "%@ is a range without min, max and step.",
"ios.host.settingsDamaged": "Settings list damaged",
"ios.host.settingsDamagedNote": "This game's settings list is damaged. Rebuild the game in the launcher on your Mac.",
diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.json
index bdde17e6..0eff6529 100644
--- a/frontend/l10n/fr.json
+++ b/frontend/l10n/fr.json
@@ -608,6 +608,11 @@
"ios.host.padOn": "Activé",
"ios.host.padSameAsAllGames": "Comme tous les jeux",
"ios.host.padSwapAB": "Inverser A et B",
+ "ios.host.quitButton": "Quitter",
+ "ios.host.quitCancel": "Annuler",
+ "ios.host.quitHold": "Maintenez pour quitter",
+ "ios.host.quitNote": "La progression non sauvegardée sera perdue. L’app se ferme et s’ouvre sur vos jeux la prochaine fois.",
+ "ios.host.quitTitle": "Quitter %@ ?",
"ios.host.touchHint": "Stick droit : glissez ici",
"ios.setting.DM_PSO_MTL4.note": "Conserve une archive de pipelines et utilise plus de mémoire.",
"ios.ui.cancel": "Annuler",
diff --git a/frontend/l10n/it.json b/frontend/l10n/it.json
index 7ae8a0b0..a0da9e10 100644
--- a/frontend/l10n/it.json
+++ b/frontend/l10n/it.json
@@ -608,6 +608,11 @@
"ios.host.padOn": "Attivato",
"ios.host.padSameAsAllGames": "Come tutti i giochi",
"ios.host.padSwapAB": "Scambia A e B",
+ "ios.host.quitButton": "Esci",
+ "ios.host.quitCancel": "Annulla",
+ "ios.host.quitHold": "Tieni premuto per uscire",
+ "ios.host.quitNote": "I progressi non salvati andranno persi. L’app si chiude e la prossima volta si apre sui tuoi giochi.",
+ "ios.host.quitTitle": "Uscire da %@?",
"ios.host.touchHint": "Levetta destra: trascina qui",
"ios.setting.DM_PSO_MTL4.note": "Conserva un archivio delle pipeline e usa più memoria.",
"ios.ui.cancel": "Annulla",
diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.json
index 6e419f0f..c98bb355 100644
--- a/frontend/l10n/sv.json
+++ b/frontend/l10n/sv.json
@@ -450,6 +450,11 @@
"ios.host.padOn": "På",
"ios.host.padSameAsAllGames": "Som alla spel",
"ios.host.padSwapAB": "Byt A och B",
+ "ios.host.quitButton": "Avsluta",
+ "ios.host.quitCancel": "Avbryt",
+ "ios.host.quitHold": "Fortsätt hålla in för att avsluta",
+ "ios.host.quitNote": "Osparade framsteg går förlorade. Appen stängs och öppnas med dina spel nästa gång.",
+ "ios.host.quitTitle": "Avsluta %@?",
"ios.host.touchHint": "Höger spak: dra här",
"ios.setting.DM_PSO_MTL4.note": "Behåller ett pipelinearkiv och använder mer minne.",
"ios.ui.cancel": "Avbryt",
diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.json
index 5540c892..432e3a13 100644
--- a/frontend/l10n/zh.json
+++ b/frontend/l10n/zh.json
@@ -654,6 +654,11 @@
"ios.host.padSameAsAllGames": "与所有游戏相同",
"ios.host.padSwapAB": "交换 A 和 B",
"ios.host.player": "玩家 %@",
+ "ios.host.quitButton": "退出",
+ "ios.host.quitCancel": "取消",
+ "ios.host.quitHold": "继续按住即可退出",
+ "ios.host.quitNote": "未保存的进度将会丢失。App 会关闭,下次打开时显示你的游戏。",
+ "ios.host.quitTitle": "退出%@?",
"ios.host.rangeWithoutLimits": "%@ 是缺少 min、max、step 的范围项。",
"ios.host.settingsDamaged": "设置列表已损坏",
"ios.host.settingsDamagedNote": "此游戏的设置列表已损坏。请在 Mac 上的启动器中重新构建。",