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
Merge main into ios-pad-mapping
v0lumehi808bf299cbed
diff --cc frontend-ios/Sources/ShellHost/ShellHostModel.swiftindex c69c6bfc,9197795d..62a6986e--- a/frontend-ios/Sources/ShellHost/ShellHostModel.swift+++ b/frontend-ios/Sources/ShellHost/ShellHostModel.swift@@@ -295,14 -285,7 +295,15 @@@ public struct ShellHostConfig: SendablonUseShellCloud: { [weak self] id in self?.useShellCloudSaves(id) },onClearShellData: { [weak self] in self?.clearShellData() },onClearShellCloud: { [weak self] in self?.clearShellCloud() },+ onGlobalPadMapChange: { [weak self] setting, value in+ guard let self else { return }+ if setting == "swapAB" { self.shellSettings.setPadSwapAB(value == "1") }+ else { self.shellSettings.setPadButton(setting, to: value) }+ self.refreshAll()+ },+ onGlobalPadMapReset: { [weak self] in self?.shellSettings.resetPadMap(); self?.refreshAll() },- onButtonTest: { [weak self] open in self?.buttonTest(open) })++ onButtonTest: { [weak self] open in self?.buttonTest(open) },+ onDeleteGame: { [weak self] id, saves in self?.deleteGame(id, saves: saves) })}public func change(_ id: String, setting: String, value: String) {diff --cc frontend-ios/Sources/ShellUI/LibraryView.swiftindex 7b1cc926,1e7b9359..62dcacea--- a/frontend-ios/Sources/ShellUI/LibraryView.swift+++ b/frontend-ios/Sources/ShellUI/LibraryView.swift@@@ -42,11 -39,11 +42,14 @@@ public struct LibraryView: View@State private var controllersOpen: Bool/// The game whose How to fix or How to update explanation is open.@State private var helpGameID: String?+ /// The game whose Delete question is open, and whether its saves go too.+ @State private var deleteGameID: String?+ @State private var deleteSaves = false/// The choice whose option list is open.@State private var choice: ChoiceRequest?+ /// The button-mapping card, while open.+ @State private var padMapping: PadMappingState?+ @State private var buttonTestOpen: Bool@State private var focus: FocusAppearance@State private var targets = FocusTargetBuffer()@State private var settingsPosition = ScrollPosition()@@@ -140,7 -131,7 +143,7 @@@.opacity(settingsOpen ? 1 : 0).frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing).allowsHitTesting(settingsOpen)- .accessibilityHidden(!settingsOpen || choice != nil || padMapping != nil)- .accessibilityHidden(!settingsOpen || choice != nil || deleteGameID != nil)++ .accessibilityHidden(!settingsOpen || choice != nil || padMapping != nil || deleteGameID != nil).accessibilityAddTraits(settingsOpen ? .isModal : []).transformPreference(FocusTargets.self) { if !settingsOpen { $0.removeAll() } }}@@@ -158,6 -149,29 +161,20 @@@.accessibilityAddTraits(.isModal).transition(.opacity.combined(with: .scale(scale: 0.96)))}+ if let id = deleteGameID, let game = games.first(where: { $0.id == id })?.game {+ Color.black.opacity(0.55).ignoresSafeArea().accessibilityHidden(true)+ .onTapGesture { closeDelete() }+ .transition(.opacity)+ DeleteGameView(game: game, saves: $deleteSaves, delete: { confirmDelete(id) }, cancel: closeDelete)+ .frame(maxWidth: 460)+ .background(Color(red: 0.075, green: 0.075, blue: 0.082), in: RoundedRectangle(cornerRadius: 26))+ .overlay(RoundedRectangle(cornerRadius: 26).strokeBorder(.white.opacity(0.10)))+ .shadow(color: .black.opacity(0.5), radius: 40)+ .padding(16)+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ .accessibilityAddTraits(.isModal)+ .transition(.opacity.combined(with: .scale(scale: 0.96)))+ }- if let choice {- Color.black.opacity(0.55).ignoresSafeArea().accessibilityHidden(true)- .onTapGesture { closeChoice() }- .transition(.opacity)- ChoicePickerView(request: choice, pick: pickChoice, close: closeChoice)- .padding(.horizontal, 16).padding(.vertical, 12)- .frame(maxWidth: .infinity, maxHeight: .infinity)- .transition(.opacity.combined(with: .scale(scale: 0.96)))- }if controllersOpen {Color.black.opacity(0.55 * (1 - min(1, edgeDrag / min(width, 520)))).ignoresSafeArea().accessibilityHidden(true).onTapGesture { back() }@@@ -222,14 -204,14 +239,14 @@@if controllersOpen { return target.id.hasPrefix("ctl.") }if shellSettingsOpen { return target.id.hasPrefix("shs.") }if helpGameID != nil { return target.id.hasPrefix("help.") }- return !target.id.hasPrefix("ctl.") && !target.id.hasPrefix("help.") && !target.id.hasPrefix("pick.") && !target.id.hasPrefix("shs.")- && !target.id.hasPrefix("map.") && !target.id.hasPrefix("test.")+ if deleteGameID != nil { return target.id.hasPrefix("del.") }- if choice != nil { return target.id.hasPrefix("pick.") }- return !["ctl.", "help.", "pick.", "shs.", "del."].contains { target.id.hasPrefix($0) }++ return !["ctl.", "help.", "pick.", "shs.", "del.", "map.", "test."].contains { target.id.hasPrefix($0) }}}.coordinateSpace(name: "shell").background {- EdgeSwipeBack(enabled: (settingsOpen || controllersOpen || shellSettingsOpen) && choice == nil && helpGameID == nil- EdgeSwipeBack(enabled: (settingsOpen || controllersOpen || shellSettingsOpen) && choice == nil && helpGameID == nil && deleteGameID == nil,++ EdgeSwipeBack(enabled: (settingsOpen || controllersOpen || shellSettingsOpen) && choice == nil && helpGameID == nil && deleteGameID == nil+ && padMapping == nil && !buttonTestOpen,changed: { edgeDrag = $0 },ended: { finishEdgeSwipe(travel: $0, velocity: $1, span: controllersOpen || shellSettingsOpen ? min(width, 520) : pane) },cancelled: cancelEdgeSwipe)@@@ -243,13 -225,11 +260,15 @@@.animation(reduceMotion ? nil : .smooth(duration: 0.3), value: controllersOpen).animation(reduceMotion ? nil : .smooth(duration: 0.3), value: shellSettingsOpen).animation(reduceMotion ? nil : .smooth(duration: 0.25), value: helpGameID)+ .animation(reduceMotion ? nil : .smooth(duration: 0.25), value: deleteGameID).animation(reduceMotion ? nil : .smooth(duration: 0.25), value: choice)+ .animation(reduceMotion ? nil : .smooth(duration: 0.25), value: padMapping)+ .animation(reduceMotion ? nil : .smooth(duration: 0.25), value: buttonTestOpen).environment(\.shellPickChoice, { request in openChoice(request) })+ .environment(\.shellOpenPadMapping, { id in openPadMapping(id) })+ .environment(\.shellOpenButtonTest, { openButtonTest() }).environment(\.shellShowHelp, { game in openHelp(game.id) })+ .environment(\.shellAskDelete, { game in openDelete(game.id) }).environment(\.shellFocus, focus).environment(\.shellInputDevice, device).foregroundStyle(.white)@@@ -413,57 -403,10 +442,58 @@@}closeChoice()}+ // The mapping card: the shell's map or a game's, a row's options in place of the rows once one is picked.+ private func padMappingRows(_ id: String) -> [SettingRow] {+ if id == ControllersView.mappingID { return PadMappingRows.global(globalPadMap) }+ return games.first { $0.id == id }.map(PadMappingRows.game) ?? []+ }+ private func padMappingTitle(_ id: String) -> String {+ if id == ControllersView.mappingID { return ShellStrings.text("For every game") }+ return games.first { $0.id == id }?.game.title ?? ""+ }+ private func openPadMapping(_ id: String) {+ noteTouch()+ returnFocus = focus.id+ padMapping = PadMappingState(gameID: id)+ focus.id = "map.row." + (padMappingRows(id).first?.id ?? "")+ }+ private func closePadMapping() { padMapping = nil; focus.id = returnFocus }+ private func openPadRow(_ row: String) {+ noteTouch()+ padMapping?.row = row+ focus.id = "map.opt." + (padMappingRows(padMapping?.gameID ?? "").first { $0.id == row }?.value ?? "")+ }+ private func closePadRow() {+ guard let row = padMapping?.row else { return }+ padMapping?.row = nil+ focus.id = "map.row." + row+ }+ private func pickPadValue(_ row: String, _ value: String) {+ noteTouch()+ guard let id = padMapping?.gameID else { return }+ if id == ControllersView.mappingID { actions.onGlobalPadMapChange(row, value) } else { actions.onChange(id, row, value) }+ closePadRow()+ }+ private func resetPadMapping() {+ noteTouch()+ guard let id = padMapping?.gameID else { return }+ if id == ControllersView.mappingID { actions.onGlobalPadMapReset() } else { actions.onChange(id, PadMappingRows.resetID, "") }+ focus.id = "map.row." + (padMappingRows(id).first?.id ?? "")+ }+ private func openButtonTest() { noteTouch(); buttonTestOpen = true; focus.id = "test.close"; actions.onButtonTest(true) }+ private func closeButtonTest() {+ guard buttonTestOpen else { return }+ buttonTestOpen = false+ actions.onButtonTest(false)+ focus.id = "ctl.test"+ }private func back() {- if choice != nil { closeChoice() }+ if buttonTestOpen { closeButtonTest() }+ else if padMapping?.row != nil { closePadRow() }+ else if padMapping != nil { closePadMapping() }+ else if choice != nil { closeChoice() }else if helpGameID != nil { closeHelp() }+ else if deleteGameID != nil { closeDelete() }else if controllersOpen { controllersOpen = false; focus.id = "lib.controllers" }else if shellSettingsOpen { closeShellSettings() }else if settingsOpen { closeSettings() }@@@ -506,10 -447,9 +536,11 @@@if let id = focus.id, id.hasPrefix("lib.tile.") { select(String(id.dropFirst("lib.tile.".count))) }}private var defaultFocus: String? {- if let choice { return "pick.\(choice.row.value)" }+ if buttonTestOpen { return "test.close" }+ if let padMapping { return padMapping.row == nil ? "map.close" : "map.back" }+ if let choice { return "pick." + choice.row.value }if helpGameID != nil { return "help.done" }+ if deleteGameID != nil { return "del.cancel" }if controllersOpen { return "ctl.close" }if shellSettingsOpen { return "shs.close" }if settingsOpen { return "set.back" }diff --cc frontend-ios/Sources/ShellUI/ShellInputs.swiftindex d99bcea3,40f68980..4533d0ef--- a/frontend-ios/Sources/ShellUI/ShellInputs.swift+++ b/frontend-ios/Sources/ShellUI/ShellInputs.swift@@@ -200,10 -186,8 +212,12 @@@ public struct ShellActionspublic var onUseShellCloud: (String) -> Voidpublic var onClearShellData: () -> Voidpublic var onClearShellCloud: () -> Void+ public var onGlobalPadMapChange: (String, String) -> Void+ public var onGlobalPadMapReset: () -> Void+ /// The button test opened (true) or closed: the host sends `PadSnapshot`s only in between.+ public var onButtonTest: (Bool) -> Void+ /// Deletes the game's data on this device and takes it off the list. `saves`: its saves go too.+ public var onDeleteGame: (_ gameID: String, _ saves: Bool) -> Voidpublic init(onSelect: @escaping (String) -> Void = { _ in }, onPlay: @escaping (String) -> Void = { _ in },onChange: @escaping (String, String, String) -> Void = { _, _, _ in },onPickGameData: @escaping (String) -> Void = { _ in }, onUseAppData: @escaping (String) -> Void = { _ in },@@@ -212,9 -196,7 +226,10 @@@onAppUpdate: @escaping () -> Void = {}, onBack: @escaping () -> Void = {},onPickShellData: @escaping () -> Void = {}, onPickShellCloud: @escaping () -> Void = {},onUseShellCloud: @escaping (String) -> Void = { _ in }, onClearShellData: @escaping () -> Void = {},- onClearShellCloud: @escaping () -> Void = {}, onDeleteGame: @escaping (String, Bool) -> Void = { _, _ in }) {+ onClearShellCloud: @escaping () -> Void = {},+ onGlobalPadMapChange: @escaping (String, String) -> Void = { _, _ in },- onGlobalPadMapReset: @escaping () -> Void = {}, onButtonTest: @escaping (Bool) -> Void = { _ in }) {++ onGlobalPadMapReset: @escaping () -> Void = {}, onButtonTest: @escaping (Bool) -> Void = { _ in },++ onDeleteGame: @escaping (String, Bool) -> Void = { _, _ in }) {self.onSelect = onSelectself.onPlay = onPlayself.onChange = onChange@@@ -231,8 -213,6 +246,9 @@@self.onUseShellCloud = onUseShellCloudself.onClearShellData = onClearShellDataself.onClearShellCloud = onClearShellCloud+ self.onGlobalPadMapChange = onGlobalPadMapChange+ self.onGlobalPadMapReset = onGlobalPadMapReset+ self.onButtonTest = onButtonTest+ self.onDeleteGame = onDeleteGame}}diff --cc patches/0061-ios-apply-controller-button-mappings-to-physical.patchindex b330923b,00000000..b330923bmode 100644,000000..100644--- a/patches/0061-ios-apply-controller-button-mappings-to-physical.patch+++ b/patches/0061-ios-apply-controller-button-mappings-to-physical.patchdiff --cc patches/seriesindex 040316d2,113e7925..ca1ddb3d--- a/patches/series+++ b/patches/series@@@ -33,4 -31,8 +31,9 @@@0053-runtime-profile-every-site.patch0054-front-mac-start-with-the-pointer-hidden-when-the.patch0055-ios-shell-declare-en-and-zh-hans-in-cfbundleloca.patch- 0056-ios-apply-controller-button-mappings-to-physical.patch+ 0056-ios-shell-declare-every-language-of-frontend-l10.patch+ 0057-mac-app-keep-the-finder-files-of-an-exfat-volume.patch+ 0058-read-pfs0-packages-missing-the-final-filename-te.patch+ 0059-recognize-unframed-pointer-tail-calls-before-zer.patch+ 0060-ios-shell-declare-italian-in-cfbundlelocalizatio.patch++0061-ios-apply-controller-button-mappings-to-physical.patch