Skip to content

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

Console mode review fixes: no bundled artwork, own glyphs, controller input, player-mode setting

v0lumehi80329b681e24
diff --git a/frontend/Console.md b/frontend/Console.md
index 8c5f4ff8..943b7865 100644
--- a/frontend/Console.md
+++ b/frontend/Console.md
@@ -1,6 +1,6 @@
# Console mode UI
-This is a native SwiftUI presentation preview for macOS 13+, built off `main`. It never launches a game, reads the real library, discovers controllers or writes settings. The existing desktop launcher remains the default. The onboarding pattern was read from `onboarding-ui`; that branch is not a dependency.
+This is a native SwiftUI presentation preview for macOS 13+, built off `main`. It never launches a game, reads the real library, discovers controllers or writes settings. The existing desktop launcher remains the default. The onboarding pattern was read from `onboarding-ui`. That branch is not a dependency.
## Run the demos
@@ -16,7 +16,7 @@ NSPB_CONSOLE_DEMO=starting swift run
`full` contains 12 games with ready, needs-build, missing-data and broken states. `few` contains two games. `controllers` opens three controllers with player 3 awaiting assignment. `controllersMixed` adds a Pro-style pad, an Xbox-style pad with 12% battery, a keyboard and charging paired controllers. `starting` animates simulated shader compilation, then waits at Opening game window until the driver reports a return. No real shader compilation runs, and the mock never fabricates a completed game launch. Unknown or absent demo values open the desktop launcher as before.
-Arrow keys navigate. Return or Space activates the focused item. O or + opens game options; Y opens Controllers. Escape acts as B: close the top sheet, then exit from Home. Home's Play action explains incomplete setup instead of launching. In options, left/right changes the selected row; Return advances its value. Choose a player, use Assign player on a controller, then Simulate a button press to exercise assignment. Identify and Disconnect update the mock only. The exit preview offers Return to console. The mode fills its window and works in macOS full screen; the view does not change system window state.
+Arrow keys navigate. Return or Space activates the focused item. O or + opens game options, and Y opens Controllers. Escape acts as B and closes the top sheet, then exits from Home. Home's Play action explains incomplete setup instead of launching. In options, left/right changes the selected row, and Return advances its value. Choose a player, use Assign player on a controller, then Simulate a button press to exercise assignment. Identify and Disconnect update the mock only. The exit preview offers Return to console. The mode fills its window and works in macOS full screen. The view does not change system window state.
## Driver API
@@ -40,9 +40,9 @@ exitToDesktop()
returnFromGame()
```
-The state includes games, decoded SwiftUI artwork images, versions, platforms, ready/build/data/broken status, focused game ID, controllers with kind, player, optional battery fraction (0–1) and charging state, an assignment target, player merge mode, a toast, a sheet stack, Starting, exit status and a clock value. Broken messages and `LaunchSetting` labels/choices/notes are localized by the driver. Option values are in-memory overrides keyed by the existing setting's environment variable; the console uses `LaunchSetting.accepts`, defaults and `needs` dependencies. It renders every supported choice, range and toggle supplied to it, including advanced options, without loading a launcher JSON or a settings store. `ConsoleOption` implements controller stepping. The real driver decides how to persist and apply those values. `setPadMerge` is a presentation intent for the future `DM_PAD_MERGE` bridge. Merged display assigns every controller to player 1 while preserving its separate-player mapping for switching back.
+The state includes games, decoded SwiftUI artwork images, versions, platforms, ready/build/data/broken status, focused game ID, controllers with kind, player, optional battery fraction (0–1) and charging state, an assignment target, player merge mode, a toast, a sheet stack, Starting, exit status and a clock value. Broken messages and `LaunchSetting` labels/choices/notes are localized by the driver. Option values are in-memory overrides keyed by the existing setting's environment variable. The console uses `LaunchSetting.accepts`, defaults and `needs` dependencies. It renders every supported choice, range and toggle supplied to it, including advanced options, without loading a launcher JSON or a settings store. `ConsoleOption` implements controller stepping. The real driver decides how to persist and apply those values. `setPadMerge` is a presentation intent for the future `DM_PAD_MERGE` bridge. Merged display assigns every controller to player 1 while preserving its separate-player mapping for switching back.
-`ConsoleState` provides pure guarded navigation/mutation methods used by the mock and available to the eventual real driver. Sheet nesting preserves the preceding options sheet; player reassignment releases that player's former controller. Focus does not wrap at the collection ends. Starting ignores further Play/Back actions until the driver completes the transition. Call `returnFromGame` for the future controller Home-button route; it preserves the selected game and clears Starting and sheets.
+`ConsoleState` provides pure guarded navigation/mutation methods used by the mock and available to the eventual real driver. Sheet nesting preserves the preceding options sheet. Player reassignment releases that player's former controller. Focus does not wrap at the collection ends. Starting ignores further Play/Back actions until the driver completes the transition. Call `returnFromGame` for the future controller guide-button route. It preserves the selected game and clears Starting and sheets.
Pass a publisher of `ConsoleInput` to the view for future controller events: left/right/up/down, activate, back, options and controllers. This adapter is intentionally absent. Every interactive element registers with `padTarget` in `console`, `console.options`, `console.controllers`, `console.explanation` or `console.entry`. The future controller adapter must intercept an assigning controller's button and call `assignPlayer(controllerID:player:)`, rather than treating it as generic activation. The real driver supplies controller connect/disconnect snapshots, short localized toasts and clock ticks. The mock exposes `connect` and `disconnect` events with a three-second toast lifetime. It never flashes, rumbles or disconnects real hardware.
@@ -52,9 +52,9 @@ The desktop's `ContentView(enterConsole:controllerDriver:)` button and controlle
The visual target is the existing launcher code: `LauncherPalette`, embedded Manrope, cream capsule actions and its 1.8:1 artwork crop. Console mode places the selected game's name and platform badges above large landscape cards, with a soft artwork backdrop and a fixed text-and-glyph hint strip. It has no round system-action row, system avatars, Nintendo fonts, Nintendo sounds or copied home-menu arrangement. The typography and generous spacing carry the console feel. Standard SF Symbols identify controls.
-The reusable `ConsoleArtwork` and `ConsoleGameTile` accept presentation values. At compact widths the cards become a touch-friendly horizontal collection, hints form two columns, and the side sheet fills the width. Vertically short windows scroll the library and sheet contents; the primary option action stays visible. Focus/background transitions last 0.18–0.22 seconds, without springs. Reduced Motion removes focus scaling and scroll animation, retaining only fades. No UI sounds are included. Controller kinds use neutral SF Symbols, including a split rectangle for paired controllers, with no Nintendo artwork. Chips have fixed strip height, horizontal overflow, player numbers, battery percentage when reported and charging status. Connect/disconnect toasts overlay the screen without moving it. All controller copy is localized and contains no semicolons.
+The reusable `ConsoleArtwork` and `ConsoleGameTile` accept presentation values. At compact widths the cards become a touch-friendly horizontal collection, hints form two columns, and the side sheet fills the width. Vertically short windows scroll the library and sheet contents, and the primary option action stays visible. Focus/background transitions last 0.18–0.22 seconds, without springs. Reduced Motion removes focus scaling and scroll animation, retaining only fades. No UI sounds are included. Controller kinds use neutral SF Symbols, including a split rectangle for paired controllers, with no Nintendo artwork. Chips have fixed strip height, horizontal overflow, player numbers, battery percentage when reported and charging status. Connect/disconnect toasts overlay the screen without moving it. All controller copy is localized and contains no semicolons.
-The mock bundles reduced previews copied from the repository's existing game gallery, matched to each title. These are demonstration screenshots, not a new title-art lookup or game assets. All interface copy and mock controller labels live in the shared English/Chinese localization table.
+Nothing is bundled. The demo takes covers from the repository's `docs/images` through `GameLibrary.artwork(for:repo:)`, the lookup the desktop launcher uses, with the repository found by `BuildModel.findRepo()`. A title without an image gets a generated placeholder (a gradient in the launcher's palette and the name). All interface copy and mock controller labels live in the shared English/Chinese localization table.
Starting takes a `ConsoleStarting` snapshot: preparing, compiling shaders (completed/total), or opening. Shader progress uses the existing cream launcher progress bar, animating for 0.3 seconds per update, and Reduced Motion removes interpolation. A preview label explicitly identifies simulated shader progress. The live driver must publish actual shader stages and counts, then end Starting when the game window appears.
@@ -69,6 +69,12 @@ NX_CONSOLE_CAPTURE_DIR=/Volumes/NX/console-captures swift test --filter ConsoleT
The optional offscreen capture test hosts every screen, setup explanation, exit preview and entry prompt in English and Chinese at 1920×1080, 1280×800 and 390×844. Ordinary tests skip captures. State tests cover focus bounds, each status's Play behavior, sheet nesting, B/exit/return, launch-setting validation/dependencies and unique controller assignment. Localization tests check both languages for the console keys.
-Files added: `ConsoleState.swift`, `MockConsoleDriver.swift`, `ConsoleView.swift`, `ConsoleKeyboardInput.swift`, `ConsoleEntryView.swift`, `ConsoleControllersView.swift`, `Resources/ConsoleCover0.jpg` through `ConsoleCover11.jpg`, `ConsoleTests.swift`, and this note. Files changed: `Package.swift` (resources), `NSPortBuilderApp.swift` (isolated demo hook), `LauncherView.swift` (entry intent and connection prompt), and `Localization.swift` (English/Chinese).
+Files added: `ConsoleState.swift`, `MockConsoleDriver.swift`, `ConsoleView.swift`, `ConsoleKeyboardInput.swift`, `ConsoleEntryView.swift`, `ConsoleControllersView.swift`, `ConsoleGlyphs.swift`, `ConsoleLauncherDriver.swift`, `ConsolePadTests.swift`, `ConsoleTests.swift`, and this note. Files changed: `Gamepad.swift` (a + action), `NSPortBuilderApp.swift` (isolated demo hook), `LauncherView.swift` (entry intent and connection prompt), and `Localization.swift` (English/Chinese).
-Validation on 2026-10-28: release build passed. The complete frontend suite passed with 188 tests, zero failures and six unrelated opt-in capture tests skipped. The console's two capture tests ran and produced 94 images, including desktop integration at 900 and 1280 points. Native UI checks exercised keyboard focus, option changes after mouse clicks, setup explanations, Identify feedback, assignment, merged player display, Disconnect, chip updates, Escape and return from the exit preview. Visual review corrected missing bundled artwork, duplicate tile focus borders, the Starting crop, minimum-height card clipping, and crowded desktop navigation. This is a new console composition derived from the existing design system, not a pixel-matching recreation of a supplied console mockup.
+Validation on 2026-10-28: release build passed. The complete frontend suite passed with 188 tests, zero failures and six unrelated opt-in capture tests skipped. The console's two capture tests ran and produced 94 images, including desktop integration at 900 and 1280 points. Native UI checks exercised keyboard focus, option changes after mouse clicks, setup explanations, Identify feedback, assignment, merged player display, Disconnect, chip updates, Escape and return from the exit preview. Visual review corrected duplicate tile focus borders, the Starting crop, minimum-height card clipping, and crowded desktop navigation. This is a new console composition derived from the existing design system, not a pixel-matching recreation of a supplied console mockup.
+
+## Controller, glyphs and the player-mode setting
+
+`ConsoleView` takes the launcher's `LauncherGamepad` (Gamepad.swift), like the onboarding, and maps its actions with `ConsoleInput(_:)`: the D-pad and left stick move, A activates, B backs out, + and X open game options, Y opens Controllers. L and R are unused. `ConsoleGlyphs` resolves each action to the physical button Gamepad.swift reads and shows what the controller last used prints there (Apple's `sfSymbolsName`, a per-family table as fallback, key caps after the keyboard, a neutral letter otherwise). The Controls page layout (By label) only changes what a game receives, so it does not move these glyphs.
+
+"All controllers are player 1" is a launcher setting (off by default, `ControlLayout.padMerge` in UserDefaults). Play passes `DM_PAD_MERGE=1` with the Controls environment. It is in Settings and in the Controllers sheet. The console entry button and the controller strip stay hidden until the coordinator supplies `enterConsole` and a real driver.
diff --git a/frontend/Package.swift b/frontend/Package.swift
index d5c9fd97..2eed0a5b 100644
--- a/frontend/Package.swift
+++ b/frontend/Package.swift
@@ -5,7 +5,7 @@ let package = Package(
name: "NSPortBuilder",
platforms: [.macOS(.v13)],
targets: [
- .executableTarget(name: "NSPortBuilder", path: "Sources/NSPortBuilder", resources: [.process("Resources")]),
+ .executableTarget(name: "NSPortBuilder", path: "Sources/NSPortBuilder"),
.testTarget(name: "NSPortBuilderTests", dependencies: ["NSPortBuilder"])
]
)
diff --git a/frontend/Sources/NSPortBuilder/ConsoleControllersView.swift b/frontend/Sources/NSPortBuilder/ConsoleControllersView.swift
index 875b9dee..434a10be 100644
--- a/frontend/Sources/NSPortBuilder/ConsoleControllersView.swift
+++ b/frontend/Sources/NSPortBuilder/ConsoleControllersView.swift
@@ -175,7 +175,7 @@ struct ConsoleToastView: View {
action(id: controller.id + ".disconnect", label: t("console.disconnect"), symbol: "xmark.circle") { driver.disconnect(controllerID: controller.id) }
}
if state.isPreview, state.assigningPlayer != nil, state.assigningControllerID == nil || state.assigningControllerID == controller.id {
- action(id: controller.id + ".press", label: t("console.mockPress"), symbol: "a.circle") {
+ action(id: controller.id + ".press", label: t("console.mockPress"), symbol: "hand.tap") {
driver.assignPlayer(controllerID: controller.id, player: state.assigningPlayer ?? 1)
}
}
diff --git a/frontend/Sources/NSPortBuilder/ConsoleEntryView.swift b/frontend/Sources/NSPortBuilder/ConsoleEntryView.swift
index 07ee492d..f3eceee0 100644
--- a/frontend/Sources/NSPortBuilder/ConsoleEntryView.swift
+++ b/frontend/Sources/NSPortBuilder/ConsoleEntryView.swift
@@ -65,9 +65,9 @@ struct ConsoleConnectionPrompt: View {
}
}
-/// The demo is isolated from ContentView: no BuildModel, library discovery, controller adapter or process is made.
+/// The demo reads covers from the repository's docs/images (BuildModel.findRepo, as the launcher does) and is otherwise isolated from ContentView: no BuildModel, library discovery, controller adapter or process is made.
@MainActor struct ConsoleDemoView: View {
@StateObject private var driver: MockConsoleDriver
- init(scenario: MockConsoleDriver.Scenario) { _driver = StateObject(wrappedValue: MockConsoleDriver(scenario: scenario)) }
+ init(scenario: MockConsoleDriver.Scenario) { _driver = StateObject(wrappedValue: MockConsoleDriver(scenario: scenario, artworkRepo: Optional(BuildModel.findRepo()).flatMap { $0.isEmpty ? nil : $0 })) }
var body: some View { ConsoleView(driver: driver).frame(minWidth: 360, minHeight: 600) }
}
diff --git a/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swift b/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swift
new file mode 100644
index 00000000..06817e85
--- /dev/null
+++ b/frontend/Sources/NSPortBuilder/ConsoleGlyphs.swift
@@ -0,0 +1,100 @@
+import GameController
+import SwiftUI
+
+/// The button glyphs the console mode shows, for the input used last. The launcher's controller navigation is by position
+/// (Gamepad.swift: Action.a is GameController's buttonB, the east face button, Action.b is buttonA at the south, Y is buttonX at
+/// the west, and + is buttonMenu), so each action resolves to a physical element and the glyph is whatever that element is
+/// printed with on the controller: Apple's per-element `sfSymbolsName`, a per-family table when the controller reports none, a
+/// key cap for the keyboard, and our own neutral letter when nothing is known. The Controls page's layout (By label, #70) only
+/// changes what a game receives (DM_PAD_MAP), never what the launcher's menus do, so it does not move these glyphs. No logos.
+struct ConsoleGlyphs: Equatable {
+ enum Family: Equatable {
+ case xbox, playStation, nintendo, keyboard, neutral
+
+ /// From GCController.productCategory ("DualSense", "DualShock 4", "Xbox One", "Switch Pro Controller", "Nintendo Switch JoyCon (L/R)", ...).
+ init(category: String?) {
+ let c = (category ?? "").lowercased().replacingOccurrences(of: "-", with: "")
+ if c.contains("dual") || c.contains("playstation") { self = .playStation }
+ else if c.contains("xbox") { self = .xbox }
+ else if c.contains("nintendo") || c.contains("switch") || c.contains("joycon") { self = .nintendo }
+ else { self = .neutral }
+ }
+ }
+ /// A physical button, by position.
+ enum Element: Hashable { case east, south, west, north, menu }
+ enum Role {
+ case activate, back, options, controllers
+ var element: Element {
+ switch self {
+ case .activate: return .east
+ case .back: return .south
+ case .options: return .menu
+ case .controllers: return .west
+ }
+ }
+ var keyCap: String {
+ switch self { case .activate: return "Return"; case .back: return "Esc"; case .options: return "O"; case .controllers: return "Y" }
+ }
+ 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) }
+
+ var family: Family
+ /// SF Symbols names the controller itself reports for its elements.
+ var reported: [Element: String] = [:]
+
+ static let keyboard = ConsoleGlyphs(family: .keyboard)
+ static let neutral = ConsoleGlyphs(family: .neutral)
+
+ func glyph(for role: Role) -> Glyph {
+ if family == .keyboard { return .key(role.keyCap) }
+ if let name = reported[role.element] ?? Self.table(family)[role.element] { return .symbol(name) }
+ return .letter(role.letter)
+ }
+
+ /// What a family's elements are printed with, for a controller that reports no symbol of its own.
+ static func table(_ family: Family) -> [Element: String] {
+ switch family {
+ case .xbox: return [.east: "b.circle", .south: "a.circle", .west: "x.circle", .north: "y.circle", .menu: "line.3.horizontal.circle"]
+ case .playStation: return [.east: "circle.circle", .south: "xmark.circle", .west: "square.circle", .north: "triangle.circle", .menu: "line.3.horizontal.circle"]
+ case .nintendo: return [.east: "a.circle", .south: "b.circle", .west: "y.circle", .north: "x.circle", .menu: "plus.circle"]
+ case .keyboard, .neutral: return [:]
+ }
+ }
+
+ init(family: Family, reported: [Element: String] = [:]) { self.family = family; self.reported = reported }
+
+ init(controller: GCController) {
+ family = Family(category: controller.productCategory)
+ if let pad = controller.extendedGamepad {
+ let elements: [(Element, GCControllerButtonInput)] = [(.east, pad.buttonB), (.south, pad.buttonA), (.west, pad.buttonX), (.north, pad.buttonY), (.menu, pad.buttonMenu)]
+ for (element, button) in elements { if let name = button.sfSymbolsName { reported[element] = name } }
+ }
+ }
+
+ /// The controller used last, else the first one connected, else the keyboard.
+ static func current() -> ConsoleGlyphs {
+ let pads = GCController.controllers().filter { $0.extendedGamepad != nil }
+ if let pad = GCController.current.flatMap({ c in pads.contains(c) ? c : nil }) ?? pads.first { return ConsoleGlyphs(controller: pad) }
+ return .keyboard
+ }
+}
+
+struct ConsoleGlyphView: View {
+ let glyph: ConsoleGlyphs.Glyph
+ var size: CGFloat = 22
+ var body: some View {
+ switch glyph {
+ 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)
+ 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)
+ }
+ }
+}
diff --git a/frontend/Sources/NSPortBuilder/ConsoleLauncherDriver.swift b/frontend/Sources/NSPortBuilder/ConsoleLauncherDriver.swift
new file mode 100644
index 00000000..d02687d7
--- /dev/null
+++ b/frontend/Sources/NSPortBuilder/ConsoleLauncherDriver.swift
@@ -0,0 +1,32 @@
+import SwiftUI
+import Combine
+
+/// The desktop launcher's side of the Controllers sheet. Only the player-mode setting is real: it reads and writes
+/// `ControlLayout.padMerge`, which Play passes to games as DM_PAD_MERGE. Controller discovery, Identify, assignment and
+/// Disconnect arrive with the console coordinator, so the list stays empty and those intents do nothing here.
+@MainActor final class LauncherControllerDriver: ConsoleDriver {
+ @Published var state = ConsoleState()
+ private let layout: ControlLayout
+ private var subscription: AnyCancellable?
+
+ init(layout: ControlLayout) {
+ self.layout = layout
+ state.padMerge = layout.padMerge
+ subscription = layout.$padMerge.sink { [weak self] merged in self?.state.padMerge = merged }
+ }
+ func setPadMerge(_ enabled: Bool) { layout.padMerge = enabled }
+ func openControllers() { state.openControllers() }
+ func back() { state.back() }
+ func dismissToast() { state.toast = nil }
+ func focus(_ gameID: String) {}
+ func play(_ gameID: String) {}
+ func openOptions(_ gameID: String) {}
+ func setOption(gameID: String, setting: String, value: String) {}
+ func identify(controllerID: String) {}
+ func disconnect(controllerID: String) {}
+ func requestAssignment(controllerID: String) {}
+ func requestPlayer(_ player: Int) {}
+ func assignPlayer(controllerID: String, player: Int) {}
+ func exitToDesktop() {}
+ func returnFromGame() {}
+}
diff --git a/frontend/Sources/NSPortBuilder/ConsoleState.swift b/frontend/Sources/NSPortBuilder/ConsoleState.swift
index 8a86ec2b..5e9ff270 100644
--- a/frontend/Sources/NSPortBuilder/ConsoleState.swift
+++ b/frontend/Sources/NSPortBuilder/ConsoleState.swift
@@ -50,13 +50,13 @@ struct ConsoleController: Identifiable, Equatable {
var id: String
var name: String
var player: Int?
- enum Kind: String, CaseIterable { case gamepad, pro, joyCon, xbox, keyboard
+ enum Kind: String, CaseIterable { case gamepad, fullSize, paired, xbox, keyboard
var labelKey: String { "console.kind." + rawValue }
var symbol: String {
switch self {
case .gamepad: return "gamecontroller"
- case .pro: return "gamecontroller.fill"
- case .joyCon: return "rectangle.split.2x1"
+ case .fullSize: return "gamecontroller.fill"
+ case .paired: return "rectangle.split.2x1"
case .xbox: return "circle.grid.cross"
case .keyboard: return "keyboard"
}
@@ -161,7 +161,7 @@ struct ConsoleState {
}
/// Main-actor intents form the entire I/O seam. A real driver owns launching, persistence, hardware
-/// and returning to the desktop. B/Escape is `back`; the future Home-button adapter calls `returnFromGame`.
+/// and returning to the desktop. B/Escape is `back`; the future controller-guide-button adapter calls `returnFromGame`.
@MainActor protocol ConsoleDriver: ObservableObject {
var state: ConsoleState { get }
func focus(_ gameID: String)
diff --git a/frontend/Sources/NSPortBuilder/ConsoleView.swift b/frontend/Sources/NSPortBuilder/ConsoleView.swift
index f8eaaa32..a49fb970 100644
--- a/frontend/Sources/NSPortBuilder/ConsoleView.swift
+++ b/frontend/Sources/NSPortBuilder/ConsoleView.swift
@@ -2,13 +2,43 @@ import SwiftUI
import Combine
/// Semantic inputs from a future controller adapter; the view does not discover hardware.
-enum ConsoleInput { case left, right, up, down, activate, back, options, controllers }
+enum ConsoleInput {
+ case left, right, up, down, activate, back, options, controllers
+
+ /// The launcher's controller path (Gamepad.swift) in console terms: the D-pad and left stick move, A activates, B backs out,
+ /// + and X open game options, Y opens Controllers. L and R are not used.
+ init?(_ action: LauncherGamepad.Action) {
+ switch action {
+ case .left: self = .left
+ case .right: self = .right
+ case .up: self = .up
+ case .down: self = .down
+ case .a: self = .activate
+ case .b: self = .back
+ case .plus, .x: self = .options
+ case .y: self = .controllers
+ case .l, .r: return nil
+ }
+ }
+}
@MainActor struct ConsoleView<Driver: ConsoleDriver>: View {
@ObservedObject var driver: Driver
var lang: Lang = .initial()
var inputs: AnyPublisher<ConsoleInput, Never> = Empty().eraseToAnyPublisher()
@StateObject private var pad = PadFocus()
+ @StateObject private var gamepad: LauncherGamepad
+ /// The glyph set follows the input used last: a controller's own buttons, or key caps after the keyboard.
+ @State private var glyphs: ConsoleGlyphs
+
+ /// `gamepad` is the one the root view owns (the controller has a single handler, so two would fight); without one the view makes its own.
+ init(driver: Driver, lang: Lang = .initial(), inputs: AnyPublisher<ConsoleInput, Never> = Empty().eraseToAnyPublisher(), gamepad: LauncherGamepad? = nil, glyphs: ConsoleGlyphs? = nil) {
+ _glyphs = State(initialValue: glyphs ?? .current())
+ self.driver = driver
+ self.lang = lang
+ self.inputs = inputs
+ _gamepad = StateObject(wrappedValue: gamepad ?? LauncherGamepad())
+ }
@Environment(\.accessibilityReduceMotion) private var reduceMotion
private var state: ConsoleState { driver.state }
@@ -51,11 +81,12 @@ enum ConsoleInput { case left, right, up, down, activate, back, options, control
.tint(LauncherPalette.cream)
.preferredColorScheme(.dark)
.environmentObject(pad)
- .background(ConsoleKeyboardInput(perform: handle).frame(width: 0, height: 0))
+ .background(ConsoleKeyboardInput(perform: { input in glyphs = .keyboard; handle(input) }).frame(width: 0, height: 0))
.onReceive(inputs, perform: handle)
.onChange(of: scope) { _ in resetFocus() }
.onChange(of: state.exited) { _ in resetFocus() }
- .onAppear { resetFocus() }
+ .onAppear { gamepad.perform = { [self] action in if let input = ConsoleInput(action) { glyphs = .current(); handle(input) } }; resetFocus() }
+ .onDisappear { gamepad.perform = { _ in } }
.onChange(of: pad.focused) { id in
if let id, id.hasPrefix("console.game.") { driver.focus(String(id.dropFirst("console.game.".count))) }
}
@@ -68,9 +99,13 @@ enum ConsoleInput { case left, right, up, down, activate, back, options, control
private func backdrop(size: CGSize) -> some View {
ZStack {
LauncherPalette.background
- if let game = state.startingGame ?? state.focusedGame, let image = game.artwork {
- image.resizable().scaledToFill().frame(width: size.width, height: size.height)
- .blur(radius: 70).drawingGroup().opacity(0.30).id(game.id).transition(.opacity)
+ if let game = state.startingGame ?? state.focusedGame {
+ Group {
+ if let image = game.artwork { image.resizable().scaledToFill() }
+ else { LinearGradient(colors: ConsolePlaceholder.colors(for: game.title), startPoint: .topLeading, endPoint: .bottomTrailing) }
+ }
+ .frame(width: size.width, height: size.height)
+ .blur(radius: 70).drawingGroup().opacity(0.30).id(game.id).transition(.opacity)
}
LinearGradient(colors: [.black.opacity(0.10), LauncherPalette.background.opacity(0.95)], startPoint: .top, endPoint: .bottom)
}
@@ -117,18 +152,18 @@ enum ConsoleInput { case left, right, up, down, activate, back, options, control
.padScope("console", pad)
}
+ /// One fixed-height status row: the controller chips (scrolling sideways inside their own group) to the left of the clock.
+ /// Its height never changes, so a controller arriving or leaving moves nothing below it.
private func topBar(compact: Bool) -> some View {
- VStack(alignment: .leading, spacing: 20) {
- HStack(alignment: .firstTextBaseline) {
- Text(t("console.brand")).font(.manrope(compact ? 24 : 30, .bold)).tracking(-1)
- .foregroundStyle(LauncherPalette.cream)
- Spacer()
- Text(state.time, style: .time).font(.manrope(compact ? 17 : 22, .medium)).monospacedDigit()
- .foregroundStyle(.white.opacity(0.65))
- }
+ HStack(spacing: compact ? 12 : 20) {
+ Spacer(minLength: 0)
ConsoleControllerChips(controllers: state.controllers, merged: state.padMerge, lang: lang, compact: compact) { driver.openControllers() }
-
+ .frame(maxWidth: CGFloat(max(1, state.controllers.count)) * (compact ? 120 : 150))
+ ConsoleGlyphView(glyph: glyphs.glyph(for: .controllers), size: compact ? 18 : 22).foregroundStyle(.white.opacity(0.6)) // the button that opens the Controllers sheet
+ Text(state.time, style: .time).font(.manrope(compact ? 17 : 22, .medium)).monospacedDigit()
+ .foregroundStyle(.white.opacity(0.65)).fixedSize()
}
+ .frame(height: compact ? 40 : 52)
}
private func gameRow(size: CGSize, compact: Bool, inset: CGFloat) -> some View {
@@ -165,17 +200,18 @@ enum ConsoleInput { case left, right, up, down, activate, back, options, control
return VStack(spacing: 20) {
Rectangle().fill(.white.opacity(0.10)).frame(height: 1)
LazyVGrid(columns: columns, alignment: .leading, spacing: 16) {
- hint("a.circle", "console.play", "console.play", primary: true, compact: compact) { if let id = state.focusedGame?.id { driver.play(id) } }
- hint("plus.circle", "console.options", "console.options", compact: compact) { if let id = state.focusedGame?.id { driver.openOptions(id) } }
- hint("y.circle", "console.controllers", "console.controllers", compact: compact) { driver.openControllers() }
- hint("b.circle", "console.desktop", "console.desktop", compact: compact) { driver.exitToDesktop() }
+ hint(.activate, "console.play", "console.play", primary: true, compact: compact) { if let id = state.focusedGame?.id { driver.play(id) } }
+ hint(.options, "console.options", "console.options", compact: compact) { if let id = state.focusedGame?.id { driver.openOptions(id) } }
+ hint(.controllers, "console.controllers", "console.controllers", compact: compact) { driver.openControllers() }
+ hint(.back, "console.desktop", "console.desktop", compact: compact) { driver.exitToDesktop() }
}
}
}
- private func hint(_ symbol: String, _ key: String, _ id: String, primary: Bool = false, compact: Bool, action: @escaping () -> Void) -> some View {
+ private func hint(_ role: ConsoleGlyphs.Role, _ key: String, _ id: String, primary: Bool = false, compact: Bool, action: @escaping () -> Void) -> some View {
Button(action: action) {
- Label(t(key), systemImage: symbol).font(.manrope(compact ? 15 : 20, .semibold))
+ HStack(spacing: 10) { ConsoleGlyphView(glyph: glyphs.glyph(for: role), size: compact ? 20 : 24); Text(t(key)) }
+ .font(.manrope(compact ? 15 : 20, .semibold))
.padding(.horizontal, primary ? 20 : 4).frame(minHeight: 48)
.foregroundStyle(primary ? LauncherPalette.background : .white.opacity(0.8))
.background(primary ? LauncherPalette.cream : .clear, in: Capsule())
@@ -287,7 +323,7 @@ enum ConsoleInput { case left, right, up, down, activate, back, options, control
private func starting(_ game: ConsoleGame, compact: Bool) -> some View {
VStack(spacing: 30) {
- ConsoleArtwork(image: game.artwork).aspectRatio(1.8, contentMode: .fit).frame(maxWidth: compact ? 320 : 680)
+ ConsoleArtwork(image: game.artwork, title: game.title).aspectRatio(1.8, contentMode: .fit).frame(maxWidth: compact ? 320 : 680)
.clipShape(RoundedRectangle(cornerRadius: 22)).accessibilityHidden(true)
Text(String(format: t("console.starting"), game.title)).font(.manrope(compact ? 30 : 48, .bold))
.multilineTextAlignment(.center).accessibilityAddTraits(.isHeader)
@@ -370,12 +406,33 @@ enum ConsoleInput { case left, right, up, down, activate, back, options, control
}
/// Reusable 1.8:1 presentation; nil artwork uses the same quiet surface as the desktop library.
+/// A cover drawn from the title alone, in the launcher's palette: a dark gradient tinted by one of its accents, and the name.
+/// Nothing is loaded or bundled. The same title always gets the same colors.
+enum ConsolePlaceholder {
+ static func colors(for title: String) -> [Color] {
+ let accents = [LauncherPalette.cream, LauncherPalette.ready, LauncherPalette.building, LauncherPalette.unbuilt]
+ let seed = title.unicodeScalars.reduce(5381) { ($0 &* 33) &+ Int($1.value) }
+ let accent = accents[abs(seed) % accents.count]
+ return [accent.opacity(0.42), LauncherPalette.surface, LauncherPalette.background]
+ }
+}
+
struct ConsoleArtwork: View {
let image: Image?
+ var title = ""
var body: some View {
GeometryReader { geometry in
if let image { image.resizable().scaledToFill().frame(width: geometry.size.width, height: geometry.size.height).clipped() }
- else { LauncherPalette.surface.overlay { Image(systemName: "gamecontroller").font(.system(size: 50)).foregroundStyle(.secondary) } }
+ else {
+ ZStack(alignment: .bottomLeading) {
+ LinearGradient(colors: ConsolePlaceholder.colors(for: title), startPoint: .topLeading, endPoint: .bottomTrailing)
+ if title.isEmpty { Image(systemName: "gamecontroller").font(.system(size: 50)).foregroundStyle(.secondary) }
+ else {
+ Text(title).font(.manrope(max(14, geometry.size.width / 11), .bold)).foregroundStyle(LauncherPalette.cream.opacity(0.9))
+ .lineLimit(3).minimumScaleFactor(0.6).padding(geometry.size.width / 18)
+ }
+ }
+ }
}
}
}
@@ -386,8 +443,8 @@ struct ConsoleGameTile: View {
let compact: Bool
let lang: Lang
var body: some View {
- VStack(alignment: .leading, spacing: 16) {
- ConsoleArtwork(image: game.artwork).aspectRatio(1.8, contentMode: .fit)
+ VStack(alignment: .leading, spacing: 12) {
+ ConsoleArtwork(image: game.artwork, title: game.title).aspectRatio(1.8, contentMode: .fit)
.overlay(alignment: .bottomLeading) {
if game.status != .ready {
Text(L10n.string(game.status.labelKey, lang)).font(.manrope(compact ? 14 : 18, .semibold))
@@ -397,9 +454,12 @@ struct ConsoleGameTile: View {
}
.clipShape(RoundedRectangle(cornerRadius: 16))
.overlay(RoundedRectangle(cornerRadius: 16).strokeBorder(.white.opacity(0.12), lineWidth: 1))
- Text(game.title).font(.manrope(compact ? 18 : 23, .semibold)).lineLimit(2)
- .foregroundStyle(selected ? .white : .white.opacity(0.6)).padding(.horizontal, 16).padding(.bottom, 16)
+ // The focused game's name is the big title above, so its tile shows the image alone (the row is top-aligned, so
+ // nothing else moves). The others keep a small, muted caption.
+ if !selected {
+ Text(game.title).font(.manrope(compact ? 14 : 17, .medium)).lineLimit(1)
+ .foregroundStyle(.white.opacity(0.5)).padding(.horizontal, 4).accessibilityHidden(true)
+ }
}
- .background(LauncherPalette.surface.opacity(0.65), in: RoundedRectangle(cornerRadius: 18))
}
}
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swift
index e41360fc..c0356a35 100644
--- a/frontend/Sources/NSPortBuilder/ContentView.swift
+++ b/frontend/Sources/NSPortBuilder/ContentView.swift
@@ -2419,6 +2419,7 @@ struct BuilderView: View {
var onOpenControls: () -> Void = {}
var onRunSetup: (() -> Void)? // the guided first-run setup, again (nil where there is none)
var controlChanges = 0
+ var padMerge: Binding<Bool> = .constant(false) // "All controllers are player 1" (ControlLayout.padMerge)
@AppStorage(BuildNotice.defaultsKey) private var notifyBuilds = true // BuildNotifications.swift
@State private var extrasOpen = false
@State private var logOpen = false
@@ -2857,6 +2858,11 @@ struct BuilderView: View {
Button(m.t("controls.customize"), action: onOpenControls)
.padTarget("set.controls", scope: "main") { onOpenControls() }
}
+ divider
+ row(m.t("console.mergeAll"), detail: m.t("console.mergeNote")) {
+ Toggle("", isOn: padMerge).labelsHidden().toggleStyle(LauncherSwitchStyle())
+ .padTarget("set.padMerge", scope: "main") { padMerge.wrappedValue.toggle() }
+ }
}
tools
group(m.t("section.app"), footnote: m.appStatus) {
diff --git a/frontend/Sources/NSPortBuilder/Controls.swift b/frontend/Sources/NSPortBuilder/Controls.swift
index 4942ad40..aecac273 100644
--- a/frontend/Sources/NSPortBuilder/Controls.swift
+++ b/frontend/Sources/NSPortBuilder/Controls.swift
@@ -35,12 +35,17 @@ final class ControlLayout: ObservableObject {
@Published private(set) var padMode: PadMode = .standard
/// The connected controller's GCController.productCategory, which Auto goes by; tests stand in for it.
var controllerCategory: () -> String? = ControlLayout.connectedCategory
+ /// "All controllers are player 1" (launcher setting, off by default): passed at Play as DM_PAD_MERGE=1. It is not a layout
+ /// change, so it stays out of `isDefault`, `changeCount` and the Controls sheet's reset.
+ @Published var padMerge: Bool { didSet { defaults.set(padMerge, forKey: Self.padMergeKey) } }
+ static let padMergeKey = "padMerge"
private let defaults: UserDefaults
/// A key code, -1 for no key. `mode` is nil in settings saved before the layouts, which had only the custom buttons.
private struct Saved: Codable { var keys: [String: Int]; var pad: [String: String]; var mode: String? }
init(defaults: UserDefaults = .standard) {
self.defaults = defaults
+ padMerge = defaults.bool(forKey: Self.padMergeKey)
if let data = defaults.data(forKey: "controlLayout"), let saved = try? JSONDecoder().decode(Saved.self, from: data) {
keys = saved.keys.filter { k, code in Self.functions.contains { $0.id == k } && code < 128 }.mapValues { $0 < 0 ? nil : $0 }
pad = saved.pad.filter { b, to in Self.buttons.contains(b) && (to == "none" || Self.buttons.contains(to)) }
@@ -90,9 +95,10 @@ final class ControlLayout: ObservableObject {
func resetKeyboard() { keys = [:]; save() }
func resetController() { pad = [:]; padMode = .standard; save() }
- /// DM_KEYMAP and DM_PAD_MAP for the changes, in the sheet's order; empty when nothing changed.
+ /// DM_KEYMAP and DM_PAD_MAP for the changes, in the sheet's order, and DM_PAD_MERGE=1 when merging is on; empty when nothing changed.
var environment: [String: String] {
var env: [String: String] = [:]
+ if padMerge { env["DM_PAD_MERGE"] = "1" }
let k = Self.functions.compactMap { f in keys[f.id].map { "\(f.id)=\($0.map(String.init) ?? "none")" } }
if !k.isEmpty { env["DM_KEYMAP"] = k.joined(separator: ",") }
let active = activePad
diff --git a/frontend/Sources/NSPortBuilder/Gamepad.swift b/frontend/Sources/NSPortBuilder/Gamepad.swift
index 66839266..4de3dbf7 100644
--- a/frontend/Sources/NSPortBuilder/Gamepad.swift
+++ b/frontend/Sources/NSPortBuilder/Gamepad.swift
@@ -8,7 +8,7 @@ import GameController
/// started is in front then, and GameController gives a controller's input to the app in front, so the launcher never
/// acts behind a running game.
final class LauncherGamepad: ObservableObject {
- enum Action: Equatable { case left, right, up, down, a, b, x, y, l, r }
+ enum Action: Equatable { case left, right, up, down, a, b, x, y, l, r, plus }
@Published private(set) var connected = false
var perform: (Action) -> Void = { _ in }
@@ -41,6 +41,7 @@ final class LauncherGamepad: ObservableObject {
("a", pad.buttonB.isPressed, .a), ("b", pad.buttonA.isPressed, .b), // by position: right A, bottom B, top X, left Y
("x", pad.buttonY.isPressed, .x), ("y", pad.buttonX.isPressed, .y),
("l", pad.leftShoulder.isPressed, .l), ("r", pad.rightShoulder.isPressed, .r),
+ ("plus", pad.buttonMenu.isPressed, .plus), // the console mode's options; the desktop ignores it
]
for (key, down, action) in state {
if down, !held.contains(key) {
diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swift
index aa413fb4..34c2e702 100644
--- a/frontend/Sources/NSPortBuilder/LauncherView.swift
+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift
@@ -28,7 +28,8 @@ struct ContentView: View {
@State private var search = ""
@State private var searching = false
@State private var consolePrompt = false
- private let enterConsole: () -> Void
+ private let enterConsole: (() -> Void)? // nil until the console mode is wired: no entry button, no prompt
+ private let injectedDriver: Bool
@StateObject private var consoleDriver: AnyConsoleDriver
@State private var controllerSheet = false
@FocusState private var searchFocused: Bool
@@ -42,7 +43,7 @@ struct ContentView: View {
@State private var controlsOpen = false
@State private var savesFor: UUID? // the game whose Saves sheet is open (SaveTransfer.swift)
@State private var manageOpenFor: UUID? // the game whose Manage menu is open (ManageMenu.swift)
- @StateObject private var controls = ControlLayout()
+ @StateObject private var controls: ControlLayout
@StateObject private var gamepad = LauncherGamepad()
@StateObject private var padFocus = PadFocus()
@StateObject private var row = RowScroller()
@@ -56,9 +57,12 @@ struct ContentView: View {
init(model: BuildModel? = nil, library: GameLibrary? = nil, initialPage: LauncherPage = .library,
activeBuildID: UUID? = nil, performStartupChecks: Bool = true, search: String? = nil, olderTools: Set<UUID> = [],
manageOpen: Bool = false, padRing: Bool = false, onRunSetup: (() -> Void)? = nil,
- enterConsole: @escaping () -> Void = {}, controllerDriver: AnyConsoleDriver? = nil) {
+ enterConsole: (() -> Void)? = nil, controllerDriver: AnyConsoleDriver? = nil) {
self.onRunSetup = onRunSetup
- _consoleDriver = StateObject(wrappedValue: controllerDriver ?? AnyConsoleDriver(MockConsoleDriver(state: ConsoleState())))
+ let layout = ControlLayout()
+ _controls = StateObject(wrappedValue: layout)
+ _consoleDriver = StateObject(wrappedValue: controllerDriver ?? AnyConsoleDriver(LauncherControllerDriver(layout: layout)))
+ injectedDriver = controllerDriver != nil
self.enterConsole = enterConsole
qaManage = (manageOpen, padRing)
if let search { _search = State(initialValue: search); _searching = State(initialValue: true) } // visual QA: the bar with its field open
@@ -70,6 +74,12 @@ struct ContentView: View {
self.performStartupChecks = performStartupChecks
}
+ /// "All controllers are player 1": saved here, passed to games as DM_PAD_MERGE, shown in the Controllers sheet too.
+ private func setPadMerge(_ on: Bool) {
+ controls.padMerge = on
+ if injectedDriver { consoleDriver.setPadMerge(on) }
+ }
+
private var filteredGames: [LibraryGame] {
library.games.filter { search.isEmpty || $0.name.localizedCaseInsensitiveContains(search) }
}
@@ -89,11 +99,12 @@ struct ContentView: View {
else if consoleDriver.state.presentedSheet == .controllers { consoleDriver.back() }
}
.overlay {
- if consolePrompt {
+ if consolePrompt, let enterConsole {
ConsoleConnectionPrompt(lang: m.lang, enterConsole: { consolePrompt = false; enterConsole() }, dismissPrompt: { consolePrompt = false })
}
}
- .onChange(of: gamepad.connected) { connected in if connected { consolePrompt = true } }
+ .onChange(of: gamepad.connected) { connected in if connected, enterConsole != nil { consolePrompt = true } }
+ .onChange(of: consoleDriver.state.padMerge) { merged in if injectedDriver { controls.padMerge = merged } }
.onChange(of: consolePrompt) { open in
padFocus.scope = open ? "console.entry" : currentPadScope
if open { padFocus.focused = "console.entry.enter" }
@@ -110,7 +121,8 @@ struct ContentView: View {
} else {
BuilderView(m: m, library: library, settings: page == .settings, onViewGame: { page = .library },
onOpenSettings: { page = .settings }, onChooseLibraryFolder: chooseLibraryFolder,
- onOpenControls: { controlsOpen = true }, onRunSetup: onRunSetup, controlChanges: controls.changeCount)
+ onOpenControls: { controlsOpen = true }, onRunSetup: onRunSetup, controlChanges: controls.changeCount,
+ padMerge: Binding(get: { controls.padMerge }, set: { setPadMerge($0) }))
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
if m.running || page == .library { activityBar }
@@ -219,9 +231,12 @@ struct ContentView: View {
}
}
+ /// The controller strip appears with the first controller the driver reports (none yet outside the preview).
+ private var showsControllers: Bool { !consoleDriver.state.controllers.isEmpty }
+
private var topBar: some View {
GeometryReader { geometry in
- let compact = geometry.size.width < 1100 || (searching && geometry.size.width < 1400)
+ let compact = (enterConsole != nil || showsControllers) && (geometry.size.width < 1100 || (searching && geometry.size.width < 1400))
VStack(spacing: 0) {
HStack(spacing: 6) {
// The project is NX2Apple (the user's call: what this fork produces is NX2Apple);
@@ -250,7 +265,7 @@ struct ContentView: View {
.padTarget("tab." + destination.rawValue, scope: "main") { page = destination }
}
Spacer(minLength: 8)
- ConsoleEntryButton(lang: m.lang, compact: compact, enterConsole: enterConsole)
+ if let enterConsole { ConsoleEntryButton(lang: m.lang, compact: compact, enterConsole: enterConsole) }
searchField
Button { newBuild() } label: {
Group {
@@ -269,16 +284,16 @@ struct ContentView: View {
.padding(.leading, 90).padding(.trailing, 24)
.frame(height: 64)
.background(TitlebarDoubleClick()) // an empty part of the bar acts as the title bar does
- HStack {
+ if showsControllers { HStack {
Spacer(minLength: 0)
ConsoleControllerChips(controllers: consoleDriver.state.controllers, merged: consoleDriver.state.padMerge, lang: m.lang,
compact: true, scope: "main") { controllerSheet = true }
.frame(width: min(geometry.size.width - 114, max(120, CGFloat(consoleDriver.state.controllers.count) * 116)))
}
- .padding(.leading, 90).padding(.trailing, 24)
+ .padding(.leading, 90).padding(.trailing, 24) }
}
}
- .frame(height: 104)
+ .frame(height: showsControllers ? 104 : 64)
}
@@ -694,7 +709,7 @@ struct ContentView: View {
guard !sheetOpen, let at = LauncherPage.allCases.firstIndex(of: page) else { return }
let pages = LauncherPage.allCases
page = pages[(at + (action == .l ? pages.count - 1 : 1)) % pages.count]
- case .y: // the Manage menu: ManagePad.route opened it above
+ case .y, .plus: // Y is the Manage menu: ManagePad.route opened it above
return
case .b:
return
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index 27dff608..1ba698f4 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -132,8 +132,8 @@ enum L10n {
"onboarding.demo.note": ("\u{8fd9}\u{662f}\u{9884}\u{89c8}\u{3002}\u{672a}\u{8bfb}\u{53d6}\u{4efb}\u{4f55}\u{6587}\u{4ef6}\u{ff0c}\u{4e5f}\u{672a}\u{5b89}\u{88c5}\u{4efb}\u{4f55}\u{5de5}\u{5177}\u{3002}", "This is a preview. No files were read and no tools were installed."),
"onboarding.demo.resume": ("\u{7ee7}\u{7eed}\u{8bbe}\u{7f6e}", "Resume setup"),
"console.kind.gamepad": ("\u{6e38}\u{620f}\u{624b}\u{67c4}", "Gamepad"),
- "console.kind.pro": ("\u{4e13}\u{4e1a}\u{578b}\u{624b}\u{67c4}", "Pro-style pad"),
- "console.kind.joyCon": ("\u{53cc}\u{4f53}\u{624b}\u{67c4}", "Paired controllers"),
+ "console.kind.fullSize": ("\u{5168}\u{5c3a}\u{5bf8}\u{624b}\u{67c4}", "Full-size pad"),
+ "console.kind.paired": ("\u{53cc}\u{4f53}\u{624b}\u{67c4}", "Paired controllers"),
"console.kind.xbox": ("Xbox \u{578b}\u{624b}\u{67c4}", "Xbox-style pad"),
"console.kind.keyboard": ("\u{952e}\u{76d8}", "Keyboard"),
"console.batteryPercent": ("%d%%", "%d%%"),
@@ -148,6 +148,7 @@ enum L10n {
"console.disconnect": ("\u{65ad}\u{5f00}\u{8fde}\u{63a5}", "Disconnect"),
"console.playerMode": ("\u{73a9}\u{5bb6}\u{6a21}\u{5f0f}", "Player mode"),
"console.mergeAll": ("\u{6240}\u{6709}\u{624b}\u{67c4}\u{5747}\u{4e3a}\u{73a9}\u{5bb6} 1", "All controllers are player 1"),
+ "console.mergeNote": ("\u{6253}\u{5f00}\u{540e}\u{ff0c}\u{6bcf}\u{4e2a}\u{624b}\u{67c4}\u{90fd}\u{6309}\u{73a9}\u{5bb6} 1 \u{8f93}\u{5165}\u{3002}\u{5173}\u{95ed}\u{65f6}\u{ff0c}\u{6bcf}\u{4e2a}\u{624b}\u{67c4}\u{5404}\u{6709}\u{81ea}\u{5df1}\u{7684}\u{73a9}\u{5bb6}\u{3002}\u{4ec5}\u{5bf9}\u{5728} Mac \u{4e0a}\u{8fd0}\u{884c}\u{7684}\u{6e38}\u{620f}\u{751f}\u{6548}\u{3002}", "Every controller sends player 1\u{2019}s input. When off, each controller is its own player. Applies to games running on this Mac."),
"console.mergeEach": ("\u{6bcf}\u{4e2a}\u{624b}\u{67c4}\u{5bf9}\u{5e94}\u{4e00}\u{4f4d}\u{73a9}\u{5bb6}", "Each controller is its own player"),
"console.mockPress": ("\u{6a21}\u{62df}\u{6309}\u{4e0b}\u{6309}\u{94ae}", "Simulate a button press"),
"console.connectedUnassigned": ("%@ \u{5df2}\u{8fde}\u{63a5}", "%@ connected"),
@@ -211,7 +212,7 @@ enum L10n {
"console.rumble": ("\u{624b}\u{67c4}\u{632f}\u{52a8}", "Controller vibration"),
"console.demoBroken": ("\u{4e0a}\u{6b21}\u{6784}\u{5efa}\u{672a}\u{5b8c}\u{6210}\u{3002}\u{8bf7}\u{5728} Mac \u{4e0a}\u{91cd}\u{65b0}\u{6784}\u{5efa}\u{3002}", "The last build did not finish. Rebuild it on your Mac."),
"console.demoController": ("\u{65e0}\u{7ebf}\u{624b}\u{67c4}", "Wireless controller"),
- "console.demoController2": ("\u{4e13}\u{4e1a}\u{624b}\u{67c4}", "Pro controller"),
+ "console.demoController2": ("\u{5168}\u{5c3a}\u{5bf8}\u{624b}\u{67c4}", "Full-size controller"),
"console.demoController3": ("USB \u{624b}\u{67c4}", "USB controller"),
"library.readyIOS": ("\u{53ef}\u{7528}\u{4e8e} iPhone", "Ready for iPhone"),
diff --git a/frontend/Sources/NSPortBuilder/ManageMenu.swift b/frontend/Sources/NSPortBuilder/ManageMenu.swift
index 3f676407..724cb087 100644
--- a/frontend/Sources/NSPortBuilder/ManageMenu.swift
+++ b/frontend/Sources/NSPortBuilder/ManageMenu.swift
@@ -57,7 +57,7 @@ enum ManagePad {
if menuOpen {
switch action {
case .b: return .close
- case .x, .y, .l, .r: return .swallow
+ case .x, .y, .l, .r, .plus: return .swallow
case .up, .down, .left, .right, .a: return .pass
}
}
diff --git a/frontend/Sources/NSPortBuilder/MockConsoleDriver.swift b/frontend/Sources/NSPortBuilder/MockConsoleDriver.swift
index 3dfd6151..32a80abc 100644
--- a/frontend/Sources/NSPortBuilder/MockConsoleDriver.swift
+++ b/frontend/Sources/NSPortBuilder/MockConsoleDriver.swift
@@ -9,7 +9,9 @@ import SwiftUI
private var animated = true
init(state: ConsoleState, lang: Lang = .initial(), animated: Bool = true) { self.state = state; self.lang = lang; self.animated = animated }
- convenience init(scenario: Scenario = .full, lang: Lang = .initial(), animated: Bool = true) {
+ /// `artworkRepo`: a repository checkout whose docs/images supply covers, found the way the desktop launcher finds a game's
+ /// artwork (`GameLibrary.artwork`). Nil (tests) or a title without an image gets the generated placeholder.
+ convenience init(scenario: Scenario = .full, lang: Lang = .initial(), animated: Bool = true, artworkRepo: String? = nil) {
func t(_ key: String) -> String { L10n.string(key, lang) }
let settings = [
LaunchSetting(env: "DM_RENDER_SCALE", kind: "range", label: t("console.resolution"), note: "", def: "1", section: nil,
@@ -23,11 +25,14 @@ import SwiftUI
LaunchSetting(env: "DM_RUMBLE", kind: "toggle", label: t("console.rumble"), note: "", def: "1", section: nil,
options: nil, min: nil, max: nil, step: nil, on: nil, off: nil)
]
- // Packaged preview artwork; no title database, library, file path or network access.
+ // Library-style titles. Covers come from the launcher's own artwork lookup in the repo copy (nothing is bundled or downloaded).
let titles = ["Hollow Knight: Silksong", "Celeste", "Hades", "Sea of Stars", "Portal", "Balatro", "Animal Well", "Cuphead", "Stardew Valley", "Return of the Obra Dinn", "Blasphemous", "Hades II"]
+ let noBanners = FileManager.default.temporaryDirectory.appendingPathComponent("console-demo-no-banners") // the demo ids are invented: no eShop banner to find
let games = titles.enumerated().map { index, title in
ConsoleGame(id: "demo.\(index)", title: title, version: "1.0.\(index % 3)", platforms: index % 3 == 1 ? [.mac] : [.mac, .iphone],
- artwork: Bundle.module.image(forResource: "ConsoleCover\(index).jpg").map { Image(nsImage: $0) },
+ artwork: artworkRepo.flatMap { repo in
+ GameLibrary.artwork(for: LibraryGame(titleID: String(format: "%016X", index), name: title), repo: repo, banners: noBanners)
+ }.map { Image(nsImage: $0) }, // nil: the view draws a placeholder cover from the title
status: index == 3 ? .needsBuild : index == 5 ? .needsData : index == 7 ? .broken(t("console.demoBroken")) : .ready,
settings: settings)
}
@@ -43,10 +48,10 @@ import SwiftUI
}
if scenario == .controllersMixed {
snapshot.controllers = [
- .init(id: "pad.1", name: t("console.demoController2"), player: 1, kind: .pro, battery: 0.76),
+ .init(id: "pad.1", name: t("console.demoController2"), player: 1, kind: .fullSize, battery: 0.76),
.init(id: "pad.2", name: t("console.demoXbox"), player: 2, kind: .xbox, battery: 0.12),
.init(id: "keyboard", name: t("console.demoKeyboard"), player: 3, kind: .keyboard),
- .init(id: "pad.4", name: t("console.demoPaired"), player: 4, kind: .joyCon, battery: 0.48, charging: true)
+ .init(id: "pad.4", name: t("console.demoPaired"), player: 4, kind: .paired, battery: 0.48, charging: true)
]
snapshot.openControllers()
}
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover0.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover0.jpg
deleted file mode 100644
index 4acb9a33..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover0.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover1.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover1.jpg
deleted file mode 100644
index cabb6531..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover1.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover10.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover10.jpg
deleted file mode 100644
index 28ac4f26..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover10.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover11.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover11.jpg
deleted file mode 100644
index 397c9c3d..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover11.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover2.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover2.jpg
deleted file mode 100644
index 4f90f5c8..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover2.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover3.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover3.jpg
deleted file mode 100644
index e4ec0463..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover3.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover4.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover4.jpg
deleted file mode 100644
index 1d0ee393..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover4.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover5.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover5.jpg
deleted file mode 100644
index 58b49bb8..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover5.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover6.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover6.jpg
deleted file mode 100644
index 27125b95..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover6.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover7.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover7.jpg
deleted file mode 100644
index 82f0fa67..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover7.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover8.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover8.jpg
deleted file mode 100644
index da9154f1..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover8.jpg and /dev/null differ
diff --git a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover9.jpg b/frontend/Sources/NSPortBuilder/Resources/ConsoleCover9.jpg
deleted file mode 100644
index 600e969d..00000000
Binary files a/frontend/Sources/NSPortBuilder/Resources/ConsoleCover9.jpg and /dev/null differ
diff --git a/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swift b/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swift
new file mode 100644
index 00000000..f6cbf6ed
--- /dev/null
+++ b/frontend/Tests/NSPortBuilderTests/ConsolePadTests.swift
@@ -0,0 +1,153 @@
+import XCTest
+import SwiftUI
+import Combine
+@testable import NSPortBuilder
+
+/// The player-mode setting's plumbing and the controller path into console mode (the same LauncherGamepad.perform
+/// closure the desktop launcher and the onboarding use). A real controller still needs a manual check.
+final class ConsolePadTests: XCTestCase {
+ private func freshDefaults() -> UserDefaults {
+ let name = "ConsolePadTests.\(UUID().uuidString)"
+ let defaults = UserDefaults(suiteName: name)!
+ defaults.removePersistentDomain(forName: name)
+ return defaults
+ }
+
+ func testPadMergeIsOffByDefaultAndPassesNothing() {
+ let layout = ControlLayout(defaults: freshDefaults())
+ XCTAssertFalse(layout.padMerge)
+ XCTAssertNil(layout.environment["DM_PAD_MERGE"])
+ XCTAssertTrue(layout.environment.isEmpty)
+ }
+
+ func testPadMergeReachesTheGameEnvironmentAndIsSaved() {
+ let defaults = freshDefaults()
+ let layout = ControlLayout(defaults: defaults)
+ layout.padMerge = true
+ XCTAssertEqual(layout.environment["DM_PAD_MERGE"], "1")
+ // not a layout change: the Controls row, its reset and isDefault ignore it
+ XCTAssertTrue(layout.isDefault)
+ XCTAssertEqual(layout.changeCount, 0)
+ let game = LibraryGame(titleID: "0100000000000000", name: "Demo")
+ let env = game.startEnvironment(controls: layout.environment, settings: [], mods: [])
+ XCTAssertEqual(env["DM_PAD_MERGE"], "1")
+ XCTAssertEqual(env["DM_LAUNCHER"], "0")
+ XCTAssertTrue(ControlLayout(defaults: defaults).padMerge, "saved in UserDefaults")
+ layout.padMerge = false
+ XCTAssertNil(game.startEnvironment(controls: layout.environment, settings: [], mods: [])["DM_PAD_MERGE"])
+ }
+
+ @MainActor func testLauncherDriverMirrorsAndWritesTheSetting() {
+ let layout = ControlLayout(defaults: freshDefaults())
+ let driver = AnyConsoleDriver(LauncherControllerDriver(layout: layout))
+ XCTAssertFalse(driver.state.padMerge)
+ driver.setPadMerge(true)
+ XCTAssertTrue(layout.padMerge)
+ XCTAssertEqual(layout.environment["DM_PAD_MERGE"], "1")
+ layout.padMerge = false
+ XCTAssertFalse(driver.state.padMerge)
+ }
+
+ func testGamepadActionsMapToConsoleInputs() {
+ let expected: [(LauncherGamepad.Action, ConsoleInput?)] = [
+ (.left, .left), (.right, .right), (.up, .up), (.down, .down), (.a, .activate), (.b, .back),
+ (.plus, .options), (.x, .options), (.y, .controllers), (.l, nil), (.r, nil)]
+ for (action, input) in expected { XCTAssertEqual(ConsoleInput(action), input, "\(action)") }
+ }
+
+ /// Hosts the console view and drives it only through `gamepad.perform`, as Gamepad.swift does on a button edge.
+ @MainActor func testControllerDrivesConsoleView() {
+ let driver = MockConsoleDriver(scenario: .full, animated: false)
+ let gamepad = LauncherGamepad()
+ let host = NSHostingView(rootView: ConsoleView(driver: driver, gamepad: gamepad).frame(width: 1280, height: 800))
+ let window = NSWindow(contentRect: NSRect(x: -10000, y: 0, width: 1280, height: 800), styleMask: [.borderless], backing: .buffered, defer: false)
+ window.isReleasedWhenClosed = false
+ window.contentView = host
+ window.orderBack(nil)
+ defer { window.orderOut(nil); window.contentView = nil; window.close() }
+ func settle() { RunLoop.main.run(until: Date().addingTimeInterval(0.15)); host.layoutSubtreeIfNeeded() }
+ settle()
+ XCTAssertEqual(driver.state.focusedGameID, "demo.0")
+ gamepad.perform(.right); settle()
+ XCTAssertEqual(driver.state.focusedGameID, "demo.1", "D-pad right moves focus")
+ gamepad.perform(.left); settle()
+ XCTAssertEqual(driver.state.focusedGameID, "demo.0")
+ gamepad.perform(.plus); settle()
+ XCTAssertEqual(driver.state.presentedSheet, .options("demo.0"), "+ opens options")
+ gamepad.perform(.b); settle()
+ XCTAssertNil(driver.state.presentedSheet, "B closes the sheet")
+ gamepad.perform(.y); settle()
+ XCTAssertEqual(driver.state.presentedSheet, .controllers, "Y opens Controllers")
+ gamepad.perform(.b); settle()
+ XCTAssertNil(driver.state.presentedSheet)
+ gamepad.perform(.l); gamepad.perform(.r); settle()
+ XCTAssertNil(driver.state.presentedSheet, "L and R do nothing")
+ gamepad.perform(.b); settle()
+ XCTAssertTrue(driver.state.exited, "B from Home exits to the desktop")
+ }
+
+ /// Opt-in: the four screens of the PR description, offscreen, with covers from this checkout's docs/images.
+ @MainActor func testCapturePRScreens() throws {
+ guard let directory = ProcessInfo.processInfo.environment["NX_CONSOLE_SHOTS_DIR"] else { throw XCTSkip("Set NX_CONSOLE_SHOTS_DIR") }
+ let output = URL(fileURLWithPath: directory)
+ try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)
+ 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),
+ ("controllers", .controllersMixed, .xbox), ("options", .full, .xbox), ("empty", .empty, .xbox)] {
+ let driver = MockConsoleDriver(scenario: scenario, lang: .en, animated: false, artworkRepo: repo.isEmpty ? nil : repo)
+ if name == "options" { driver.openOptions("demo.0") }
+ let host = NSHostingView(rootView: ConsoleView(driver: driver, lang: .en, glyphs: .init(family: family)).transaction { $0.disablesAnimations = true }.frame(width: width, height: height))
+ let window = NSWindow(contentRect: NSRect(x: -10000, y: 0, width: width, height: height), styleMask: [.borderless], backing: .buffered, defer: false)
+ window.isReleasedWhenClosed = false
+ window.contentView = host
+ window.orderBack(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.25))
+ 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: output.appendingPathComponent("\(name)-\(sizeName).png"))
+ window.orderOut(nil); window.contentView = nil; window.close()
+ }
+ }
+ }
+
+ func testGlyphFamiliesFromCategory() {
+ let cases: [(String?, ConsoleGlyphs.Family)] = [
+ ("DualSense", .playStation), ("DualShock 4", .playStation), ("Xbox One", .xbox), ("Xbox Series X", .xbox),
+ ("Switch Pro Controller", .nintendo), ("Nintendo Switch JoyCon (L/R)", .nintendo), ("Nintendo Switch Joy-Con (L/R)", .nintendo),
+ ("Generic", .neutral), (nil, .neutral)]
+ for (category, family) in cases { XCTAssertEqual(ConsoleGlyphs.Family(category: category), family, category ?? "nil") }
+ }
+
+ /// Actions resolve to the physical buttons Gamepad.swift reads (east confirms, south backs out, menu opens options, west opens
+ /// Controllers), then to what the controller prints there.
+ func testGlyphsFollowTheControllerInUse() {
+ XCTAssertEqual(ConsoleGlyphs.Role.activate.element, .east)
+ XCTAssertEqual(ConsoleGlyphs.Role.back.element, .south)
+ XCTAssertEqual(ConsoleGlyphs.Role.options.element, .menu)
+ XCTAssertEqual(ConsoleGlyphs.Role.controllers.element, .west)
+ let xbox = ConsoleGlyphs(family: .xbox)
+ XCTAssertEqual(xbox.glyph(for: .activate), .symbol("b.circle"), "Xbox: the east button reads B")
+ XCTAssertEqual(xbox.glyph(for: .back), .symbol("a.circle"))
+ let ps = ConsoleGlyphs(family: .playStation)
+ XCTAssertEqual(ps.glyph(for: .activate), .symbol("circle.circle"))
+ XCTAssertEqual(ps.glyph(for: .back), .symbol("xmark.circle"))
+ XCTAssertEqual(ps.glyph(for: .controllers), .symbol("square.circle"))
+ let nintendo = ConsoleGlyphs(family: .nintendo)
+ XCTAssertEqual(nintendo.glyph(for: .activate), .symbol("a.circle"))
+ XCTAssertEqual(nintendo.glyph(for: .options), .symbol("plus.circle"))
+ }
+
+ func testReportedSymbolWinsAndFallbacksAreNeutral() {
+ let reported = ConsoleGlyphs(family: .xbox, reported: [.east: "custom.symbol"])
+ XCTAssertEqual(reported.glyph(for: .activate), .symbol("custom.symbol"))
+ XCTAssertEqual(reported.glyph(for: .back), .symbol("a.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: [.east: "x"]).glyph(for: .activate), .key("Return"))
+ }
+}
diff --git a/frontend/Tests/NSPortBuilderTests/ConsoleTests.swift b/frontend/Tests/NSPortBuilderTests/ConsoleTests.swift
index 5e88c774..708dc59b 100644
--- a/frontend/Tests/NSPortBuilderTests/ConsoleTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/ConsoleTests.swift
@@ -7,7 +7,7 @@ final class ConsoleTests: XCTestCase {
@MainActor func testScenariosAndBoundedFocus() {
let driver = MockConsoleDriver(animated: false)
XCTAssertEqual(driver.state.games.count, 12)
- XCTAssertTrue(driver.state.games.allSatisfy { $0.artwork != nil }, "Every preview game must have bundled artwork")
+ XCTAssertTrue(driver.state.games.allSatisfy { $0.artwork == nil }, "Without a repository the covers are generated placeholders, never bundled artwork")
driver.focus("demo.2")
XCTAssertEqual(driver.state.focusedGameID, "demo.2")
driver.focus("missing")
@@ -131,7 +131,7 @@ final class ConsoleTests: XCTestCase {
@MainActor func testMixedControllersActionsMergeAndToasts() {
let driver = MockConsoleDriver(scenario: .controllersMixed, lang: .en, animated: false)
XCTAssertFalse(driver.state.padMerge)
- XCTAssertEqual(driver.state.controllers.map(\.kind), [.pro, .xbox, .keyboard, .joyCon])
+ XCTAssertEqual(driver.state.controllers.map(\.kind), [.fullSize, .xbox, .keyboard, .paired])
XCTAssertEqual(driver.state.controllers[1].batteryPercent, 12)
XCTAssertNil(driver.state.controllers[2].batteryPercent)
XCTAssertTrue(driver.state.controllers[3].charging)