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
Console mode: Return and Escape key caps as symbols, equal caps, tighter version column
v0lumehi9fccdd0392b4
diff --git a/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swift b/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swiftindex abf2f2c0..aeef1b89 100644--- a/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swift+++ b/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swift@@ -43,13 +43,17 @@ struct ConsoleGlyphs: Equatable {}}var keyCap: String {- switch self { case .activate: return "Return"; case .back: return "Esc"; case .options: return "O"; case .controllers: return "Y" }+ switch self { case .activate: return "return"; case .back: return "escape"; case .options: return "O"; case .controllers: return "Y" }+ }+ /// Keys drawn as an SF Symbol in their cap (Return, Escape) instead of a word.+ var keySymbol: Bool {+ switch self { case .activate, .back: return true; case .options, .controllers: return false }}var letter: String {switch self { case .activate: return "A"; case .back: return "B"; case .options: return "+"; case .controllers: return "Y" }}}- enum Glyph: Equatable { case symbol(String), key(String), letter(String) }+ enum Glyph: Equatable { case symbol(String), key(String), keySymbol(String), letter(String) }var family: Family/// SF Symbols names the controller itself reports for its elements.@@ -59,7 +63,7 @@ struct ConsoleGlyphs: Equatable {static let neutral = ConsoleGlyphs(family: .neutral)func glyph(for role: Role) -> Glyph {- if family == .keyboard { return .key(role.keyCap) }+ if family == .keyboard { return role.keySymbol ? .keySymbol(role.keyCap) : .key(role.keyCap) }if let name = reported[role.element] ?? Self.table(family)[role.element] { return .symbol(name) }return .letter(role.letter)}@@ -100,11 +104,20 @@ struct ConsoleGlyphView: View {case .symbol(let name):Image(systemName: name).font(.system(size: size, weight: .medium)).accessibilityHidden(true)case .key(let cap):- Text(cap).font(.manrope(size * 0.62, .bold)).padding(.horizontal, size * 0.3).frame(minWidth: size, minHeight: size)- .overlay(RoundedRectangle(cornerRadius: size * 0.28).strokeBorder(.white.opacity(0.5), lineWidth: 1.5)).accessibilityHidden(true)+ keyCap { Text(cap).font(.manrope(size * 0.62, .bold)) }+ case .keySymbol(let name):+ keyCap { Image(systemName: name).font(.system(size: size * 0.6, weight: .bold)) }case .letter(let letter):Text(letter).font(.manrope(size * 0.62, .bold)).frame(width: size, height: size).overlay(Circle().strokeBorder(.white.opacity(0.5), lineWidth: 1.5)).accessibilityHidden(true)}}}++extension ConsoleGlyphView {+ /// Every keyboard cap has the same height, weight and outline, whatever it holds.+ private func keyCap<Content: View>(@ViewBuilder _ content: () -> Content) -> some View {+ content().frame(minWidth: size * 0.75).padding(.horizontal, size * 0.22).frame(height: size * 1.15)+ .overlay(RoundedRectangle(cornerRadius: size * 0.28).strokeBorder(.white.opacity(0.5), lineWidth: 1.5)).accessibilityHidden(true)+ }+}diff --git a/frontend/Sources/NSPortBuilder/ConsoleView.swift b/frontend/Sources/NSPortBuilder/ConsoleView.swiftindex 820b9d13..0a2d1bd0 100644--- a/frontend/Sources/NSPortBuilder/ConsoleView.swift+++ b/frontend/Sources/NSPortBuilder/ConsoleView.swift@@ -136,7 +136,7 @@ enum ConsoleInput {.accessibilityAddTraits(.isHeader)HStack(spacing: 12) {Text(String(format: t("console.version"), game.version)).monospacedDigit().lineLimit(1)- .foregroundStyle(.white.opacity(0.6)).frame(width: compact ? 118 : 176, alignment: .leading) // fixed, so the badges stay put+ .foregroundStyle(.white.opacity(0.6)).frame(width: compact ? 116 : 150, alignment: .leading) // fixed, so the badges stay putForEach(game.platforms, id: \.self) { platform inText(t(platform.labelKey)).font(.manrope(compact ? 13 : 17, .semibold)).padding(.horizontal, 12).padding(.vertical, 5)diff --git a/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swift b/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swiftindex 6c6a9818..ee9a5894 100644--- a/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swift+++ b/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swift@@ -94,7 +94,7 @@ final class ConsolePadTests: XCTestCase {NSApplication.shared.setActivationPolicy(.accessory)let repo = BuildModel.findRepo()for (sizeName, width, height) in [("1920", CGFloat(1920), CGFloat(1080)), ("compact", 390, 844)] {- for (name, scenario, family) in [("home", MockConsoleDriver.Scenario.full, ConsoleGlyphs.Family.xbox), ("home-dualsense", .full, .playStation),+ for (name, scenario, family) in [("home", MockConsoleDriver.Scenario.full, ConsoleGlyphs.Family.xbox), ("home-dualsense", .full, .playStation), ("home-keyboard", .full, .keyboard),("controllers", .controllersMixed, .xbox), ("options", .full, .xbox), ("empty", .empty, .xbox), ("starting", .starting, .xbox)] {let driver = MockConsoleDriver(scenario: scenario, lang: .en, animated: false, artworkRepo: repo.isEmpty ? nil : repo)if name == "options" { driver.openOptions("demo.0") }@@ -148,9 +148,11 @@ final class ConsolePadTests: XCTestCase {XCTAssertEqual(reported.glyph(for: .back), .symbol("b.circle"), "an element it does not report uses the family table")XCTAssertEqual(ConsoleGlyphs.neutral.glyph(for: .activate), .letter("A"))XCTAssertEqual(ConsoleGlyphs.neutral.glyph(for: .options), .letter("+"))- XCTAssertEqual(ConsoleGlyphs.keyboard.glyph(for: .activate), .key("Return"))- XCTAssertEqual(ConsoleGlyphs.keyboard.glyph(for: .back), .key("Esc"))- XCTAssertEqual(ConsoleGlyphs(family: .keyboard, reported: [.a: "x"]).glyph(for: .activate), .key("Return"))+ XCTAssertEqual(ConsoleGlyphs.keyboard.glyph(for: .activate), .keySymbol("return"))+ XCTAssertEqual(ConsoleGlyphs.keyboard.glyph(for: .back), .keySymbol("escape"))+ XCTAssertEqual(ConsoleGlyphs.keyboard.glyph(for: .options), .key("O"))+ XCTAssertEqual(ConsoleGlyphs.keyboard.glyph(for: .controllers), .key("Y"))+ XCTAssertEqual(ConsoleGlyphs(family: .keyboard, reported: [.a: "x"]).glyph(for: .activate), .keySymbol("return"))}/// One mapping serves every family: GameController reports Xbox and PlayStation buttons by position (A is the bottom button,