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: fix split Joy-Con P1/P2 ping-pong freeze and rotate sideways menu input (#740)
LNPANDY9b47bd8de621
diff --git a/frontend/Sources/NX2Apple/Gamepad.swift b/frontend/Sources/NX2Apple/Gamepad.swiftindex 34fff32f..878e9b29 100644--- a/frontend/Sources/NX2Apple/Gamepad.swift+++ b/frontend/Sources/NX2Apple/Gamepad.swift@@ -20,6 +20,54 @@ final class LauncherGamepad: ObservableObject {/// Sees every press with the controller it came from before it navigates. Returning true consumes it (the Controllers sheet uses/// this to give the next press to the player being assigned).var capture: ((String, Action) -> Bool)?+ /// Whether "Split Joy-Con pair into two controllers" is enabled (#740).+ var joyconSplit: () -> Bool = { UserDefaults.standard.bool(forKey: ControlLayout.joyconSplitKey) }++ struct RawPadInput {+ var dpadX: Float = 0, dpadY: Float = 0+ var leftStickX: Float = 0, leftStickY: Float = 0+ var rightStickX: Float = 0, rightStickY: Float = 0+ var a = false, b = false, x = false, y = false+ var l = false, r = false, plus = false, select = false+ }++ static func isJoyCon(category: String?, vendorName: String? = nil) -> Bool {+ let s = ((category ?? "") + " " + (vendorName ?? "")).lowercased().replacingOccurrences(of: "-", with: "")+ return s.contains("joycon")+ }++ /// Per-controller button and direction states. When `splitJoyCon` is true on a Joy-Con, Left Joy-Con (`.L`) is rotated 90°+ /// counter-clockwise and Right Joy-Con (`.R`) is rotated 90° clockwise so launcher and console mode match sideways play (#740).+ static func states(controller: String, input: RawPadInput, splitJoyCon: Bool) -> [(controller: String, state: [(String, Bool, Action)])] {+ guard splitJoyCon else {+ let x = input.dpadX != 0 ? input.dpadX : input.leftStickX+ let y = input.dpadY != 0 ? input.dpadY : input.leftStickY+ return [(controller, [+ ("left", x < -0.5, .left), ("right", x > 0.5, .right), ("up", y > 0.5, .up), ("down", y < -0.5, .down),+ ("a", input.a, .a), ("b", input.b, .b), // by label, see `face`+ ("x", input.x, .x), ("y", input.y, .y),+ ("l", input.l, .l), ("r", input.r, .r),+ ("plus", input.plus, .plus), ("select", input.select, .select),+ ])]+ }+ // Left Joy-Con held sideways (90° CCW, rail on top): left stick rotated 90° CCW, D-pad rotated 90° CCW as face buttons (Down->A, Left->B, Right->X, Up->Y)+ let lx = -input.leftStickY, ly = input.leftStickX+ let leftState: [(String, Bool, Action)] = [+ ("left", lx < -0.5, .left), ("right", lx > 0.5, .right), ("up", ly > 0.5, .up), ("down", ly < -0.5, .down),+ ("a", input.dpadY < -0.5, .a), ("b", input.dpadX < -0.5, .b),+ ("x", input.dpadX > 0.5, .x), ("y", input.dpadY > 0.5, .y),+ ("l", input.l, .l), ("select", input.select, .select),+ ]+ // Right Joy-Con held sideways (90° CW, rail on top): right stick rotated 90° CW, ABXY rotated 90° CW (X->A, A->B, Y->X, B->Y)+ let rx = input.rightStickY, ry = -input.rightStickX+ let rightState: [(String, Bool, Action)] = [+ ("left", rx < -0.5, .left), ("right", rx > 0.5, .right), ("up", ry > 0.5, .up), ("down", ry < -0.5, .down),+ ("a", input.x, .a), ("b", input.a, .b),+ ("x", input.y, .x), ("y", input.b, .y),+ ("r", input.r, .r), ("plus", input.plus, .plus),+ ]+ return [(controller + ".L", leftState), (controller + ".R", rightState)]+ }/// The GameController button an action reads, in one place (the glyphs of the console mode follow it). GameController names/// the face buttons by label: buttonA is the bottom of Apple's diamond (GCExtendedGamepad.h), which is A on an Xbox/// controller and the cross on a DualSense, and a Nintendo-layout controller reports the button printed A (on the right) as@@ -37,7 +85,23 @@ final class LauncherGamepad: ObservableObject {/// One press, one action, per controller: a button held on one controller never hides the same button on another.struct Edges {private var held: Set<String> = []- mutating func reset(controller: String) { held = held.filter { !$0.hasPrefix(controller + "/") } }+ private var splitMode: [String: Bool] = [:]+ mutating func reset(controller: String) {+ held = held.filter { !$0.hasPrefix(controller + "/") && !$0.hasPrefix(controller + ".L/") && !$0.hasPrefix(controller + ".R/") }+ splitMode.removeValue(forKey: controller)+ }+ /// Synchronizes held state without firing actions when `split` mode changes for `baseController` so a button held across the toggle does not re-fire under its new mapping.+ mutating func syncSplitMode(baseController: String, split: Bool, groups: [(controller: String, state: [(String, Bool, Action)])]) -> Bool {+ defer { splitMode[baseController] = split }+ guard let previous = splitMode[baseController], previous != split else { return false }+ held = held.filter { !$0.hasPrefix(baseController + "/") && !$0.hasPrefix(baseController + ".L/") && !$0.hasPrefix(baseController + ".R/") }+ for group in groups {+ for (key, down, _) in group.state where down {+ held.insert(group.controller + "/" + key)+ }+ }+ return true+ }/// What changed for `controller` given the state of its buttons: pressed and released actions.mutating func changes(controller: String, state: [(String, Bool, Action)]) -> (pressed: [Action], released: [Action]) {var pressed: [Action] = [], released: [Action] = []@@ -81,31 +145,41 @@ final class LauncherGamepad: ObservableObject {connected = !pads.isEmptyfor pad in pads {let id = String(UInt(bitPattern: ObjectIdentifier(pad).hashValue), radix: 16)- pad.physicalInputProfile.valueDidChangeHandler = { [weak self] profile, _ in self?.read(profile, controller: id) }+ let isJC = Self.isJoyCon(category: pad.productCategory, vendorName: pad.vendorName)+ pad.physicalInputProfile.valueDidChangeHandler = { [weak self] profile, _ in self?.read(profile, controller: id, isJoyCon: isJC) }}}- private func read(_ pad: GCPhysicalInputProfile, controller: String) {+ private func read(_ pad: GCPhysicalInputProfile, controller: String, isJoyCon: Bool) {func button(_ name: String) -> Bool { pad.buttons[name]?.isPressed ?? false }- let dpad = pad.dpads[GCInputDirectionPad], stick = pad.dpads[GCInputLeftThumbstick]- let x = (dpad?.xAxis.value ?? 0) != 0 ? dpad!.xAxis.value : (stick?.xAxis.value ?? 0)- let y = (dpad?.yAxis.value ?? 0) != 0 ? dpad!.yAxis.value : (stick?.yAxis.value ?? 0)- let state: [(String, Bool, Action)] = [- ("left", x < -0.5, .left), ("right", x > 0.5, .right), ("up", y > 0.5, .up), ("down", y < -0.5, .down),- ("a", button(GCInputButtonA), .a), ("b", button(GCInputButtonB), .b), // by label, see `face`- ("x", button(GCInputButtonX), .x), ("y", button(GCInputButtonY), .y),- ("l", button(GCInputLeftShoulder), .l), ("r", button(GCInputRightShoulder), .r),- ("plus", button(GCInputButtonMenu), .plus), ("select", button(GCInputButtonOptions), .select),- ]- let (pressed, released) = edges.changes(controller: controller, state: state)- for action in pressed {- DispatchQueue.main.async {- if NSApp.isActive, let capture = self.capture, capture(controller, action) { return }- self.fire(action)- if [.left, .right, .up, .down].contains(action) { self.startRepeat(action) }+ let dpad = pad.dpads[GCInputDirectionPad], lStick = pad.dpads[GCInputLeftThumbstick], rStick = pad.dpads[GCInputRightThumbstick]+ let raw = RawPadInput(+ dpadX: dpad?.xAxis.value ?? 0, dpadY: dpad?.yAxis.value ?? 0,+ leftStickX: lStick?.xAxis.value ?? 0, leftStickY: lStick?.yAxis.value ?? 0,+ rightStickX: rStick?.xAxis.value ?? 0, rightStickY: rStick?.yAxis.value ?? 0,+ a: button(GCInputButtonA), b: button(GCInputButtonB),+ x: button(GCInputButtonX), y: button(GCInputButtonY),+ l: button(GCInputLeftShoulder), r: button(GCInputRightShoulder),+ plus: button(GCInputButtonMenu), select: button(GCInputButtonOptions)+ )+ let split = isJoyCon && joyconSplit()+ let groups = Self.states(controller: controller, input: raw, splitJoyCon: split)+ if edges.syncSplitMode(baseController: controller, split: split, groups: groups) {+ DispatchQueue.main.async { self.stopRepeat() }+ return+ }+ for group in groups {+ let (pressed, released) = edges.changes(controller: group.controller, state: group.state)+ for action in pressed {+ let subID = group.controller+ DispatchQueue.main.async {+ if NSApp.isActive, let capture = self.capture, capture(subID, action) { return }+ self.fire(action)+ if [.left, .right, .up, .down].contains(action) { self.startRepeat(action) }+ }}+ for action in released { DispatchQueue.main.async { if self.repeating == action { self.stopRepeat() } } }}- for action in released { DispatchQueue.main.async { if self.repeating == action { self.stopRepeat() } } }}private func fire(_ action: Action) { if NSApp.isActive { perform(action) } }diff --git a/frontend/Sources/NX2Apple/LiveConsoleDriver.swift b/frontend/Sources/NX2Apple/LiveConsoleDriver.swiftindex 7a8d0c60..2edd57dd 100644--- a/frontend/Sources/NX2Apple/LiveConsoleDriver.swift+++ b/frontend/Sources/NX2Apple/LiveConsoleDriver.swift@@ -99,6 +99,7 @@ struct ConsolePadSnapshot: Equatable {controls.$joyconSplit.dropFirst().sink { [weak self] split inguard let self, self.state.joyconSplit != split else { return }self.state.joyconSplit = split+ self.resetPairedDevicePlayerIndices()self.refreshControllers(announce: false)}.store(in: &cancellables)refresh()@@ -131,6 +132,8 @@ struct ConsolePadSnapshot: Equatable {deinit {observers.forEach { NotificationCenter.default.removeObserver($0); NSWorkspace.shared.notificationCenter.removeObserver($0) }clock?.invalidate()+ primeTask?.cancel()+ batteryRereadTask?.cancel()}// MARK: Games@@ -389,9 +392,19 @@ struct ConsolePadSnapshot: Equatable {/// hand are taken and ignored.func consumePress(controllerID: String, isBack: Bool) -> Bool {guard let player = state.assigningPlayer, state.presentedSheet == .controllers else { return false }- if let target = state.assigningControllerID, target != controllerID { return true }+ let resolvedID: String+ if let target = state.assigningControllerID {+ guard target == controllerID || Self.baseControllerID(target) == controllerID else { return true }+ resolvedID = target+ } else if state.controllers.contains(where: { $0.id == controllerID }) {+ resolvedID = controllerID+ } else if let split = state.controllers.first(where: { Self.baseControllerID($0.id) == controllerID }) {+ resolvedID = split.id+ } else {+ resolvedID = controllerID+ }if isBack { cancelCapture(); showToast(t("console.assignCancelled")); return true }- assignPlayer(controllerID: controllerID, player: player)+ assignPlayer(controllerID: resolvedID, player: player)return true}@@ -404,7 +417,7 @@ struct ConsolePadSnapshot: Equatable {overrides[controllerID] = playerstate.assigningPlayer = nil; state.assigningControllerID = nilassignTimeout?.cancel()- for (id, value) in overrides {+ for (id, value) in overrides where !id.hasSuffix(".R") {devices[id]?.playerIndex = value == 0 ? .indexUnset : (GCControllerPlayerIndex(rawValue: value - 1) ?? .indexUnset)}refreshControllers(announce: false)@@ -414,9 +427,23 @@ struct ConsolePadSnapshot: Equatable {func setJoyconSplit(_ enabled: Bool) {controls.joyconSplit = enabledstate.joyconSplit = enabled+ resetPairedDevicePlayerIndices()refreshControllers(announce: false)}+ /// Clears hardware playerIndex on paired Joy-Con `GCController` instances when toggling split mode so auto-assignment starts cleanly from P1/P2.+ private func resetPairedDevicePlayerIndices() {+ guard devicePads else { return }+ for c in GCController.controllers() {+ let cat = c.productCategory.lowercased().replacingOccurrences(of: "-", with: "")+ if cat.contains("joycon") { c.playerIndex = .indexUnset }+ }+ }++ static func baseControllerID(_ id: String) -> String {+ (id.hasSuffix(".L") || id.hasSuffix(".R")) ? String(id.dropLast(2)) : id+ }+/// Expands each paired Joy-Con snapshot into separate `Joy-Con (L)` and `Joy-Con (R)` sideways controller snapshots when `enabled` is true (#740).static func splitJoyConSnapshots(_ pads: [ConsolePadSnapshot], enabled: Bool) -> [ConsolePadSnapshot] {guard enabled else { return pads }@@ -470,7 +497,14 @@ struct ConsolePadSnapshot: Equatable {private func rumble(_ pad: GCController, id: String) {guard let haptics = pad.haptics else { Self.log.debug("identify: no haptics on this controller"); return }- let localities: [GCHapticsLocality] = [.default, .all, .handles, .leftHandle, .rightHandle]+ let localities: [GCHapticsLocality]+ if id.hasSuffix(".L") {+ localities = [.leftHandle, .default, .all, .handles]+ } else if id.hasSuffix(".R") {+ localities = [.rightHandle, .default, .all, .handles]+ } else {+ localities = [.default, .all, .handles, .leftHandle, .rightHandle]+ }guard let engine = localities.lazy.compactMap({ haptics.createEngine(withLocality: $0) }).first else {Self.log.debug("identify: haptics exist but no engine could be created (supported localities: \(haptics.supportedLocalities.map(\.rawValue).joined(separator: ","), privacy: .public))")return@@ -507,6 +541,8 @@ struct ConsolePadSnapshot: Equatable {private var remembered: [String: Int] = [:]/// The player each controller was last told about (player lights and light bar), so the output is sent once per assignment.private var primedPlayer: [String: Int] = [:]+ private var primeTask: Task<Void, Never>?+ private var batteryRereadTask: Task<Void, Never>?/// Writes the player to a controller: its player lights and, when it has one, its light bar. Tests replace it.var sendPlayerOutput: ((String, Int) -> Void)?@@ -529,9 +565,14 @@ struct ConsolePadSnapshot: Equatable {for pad in pads {guard let player = pad.playerIndex, primedPlayer[pad.id] != player else { continue }primedPlayer[pad.id] = player+ if let sendPlayerOutput {+ if !pad.id.hasSuffix(".R") { sent = true; sendPlayerOutput(pad.id, player) }+ continue+ }+ // A split Joy-Con pair shares one underlying GCController instance between `.L` and `.R`. Writing `.R`'s playerIndex back to+ // that shared instance overwrites `.L`'s hardware playerIndex and causes P1/P2 to ping-pong on every reread (#740).+ guard let device = devices[pad.id], !pad.id.hasSuffix(".R") else { continue }sent = true- if let sendPlayerOutput { sendPlayerOutput(pad.id, player); continue }- guard let device = devices[pad.id] else { continue }device.playerIndex = GCControllerPlayerIndex(rawValue: player - 1) ?? .indexUnsetif let light = device.light {let c = Self.playerLightColor(player)@@ -540,9 +581,11 @@ struct ConsolePadSnapshot: Equatable {Self.hidLog.debug("player output to \(pad.name, privacy: .public): player \(player), light bar \(device.light != nil)")}if sent {- Task { [weak self] in+ primeTask?.cancel()+ primeTask = Task { [weak self] infor seconds in [0.5, 1.5] {try? await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))+ guard !Task.isCancelled else { return }self?.refreshControllers(announce: false)}}@@ -603,20 +646,24 @@ struct ConsolePadSnapshot: Equatable {private func tearDown(_ pad: GCController) {let id = String(UInt(bitPattern: ObjectIdentifier(pad).hashValue), radix: 16)pad.physicalInputProfile.valueDidChangeHandler = nil- identifyEngines.removeValue(forKey: id)?.stop(completionHandler: nil)- if state.identifyingControllerID == id { identifyTask?.cancel(); state.identifyingControllerID = nil }- devices[id] = nil- overrides[id] = nil+ for key in [id, id + ".L", id + ".R"] {+ identifyEngines.removeValue(forKey: key)?.stop(completionHandler: nil)+ if state.identifyingControllerID == key { identifyTask?.cancel(); state.identifyingControllerID = nil }+ devices[key] = nil+ overrides[key] = nil+ primedPlayer[key] = nil+ }batteryWatchers[id] = nil- primedPlayer[id] = nilSelf.hidLog.debug("torn down \(id, privacy: .public)")}/// Right after a connect GameController may still report 0 or an unknown battery (a Bluetooth reconnect): read it again soon.private func scheduleBatteryRereads() {- Task { [weak self] in+ batteryRereadTask?.cancel()+ batteryRereadTask = Task { [weak self] infor seconds in [2.0, 3.0] { // reads at 2 and 5 seconds after a connect, then the 20 second ticktry? await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))+ guard !Task.isCancelled else { return }self?.refreshControllers(announce: false)}}@@ -646,12 +693,13 @@ struct ConsolePadSnapshot: Equatable {snapshots = Self.splitJoyConSnapshots(snapshots, enabled: controls.joyconSplit)if devicePads, controls.joyconSplit {for snap in snapshots where snap.id.hasSuffix(".L") || snap.id.hasSuffix(".R") {- let base = String(snap.id.dropLast(2))+ let base = Self.baseControllerID(snap.id)if let dev = devices[base] { devices[snap.id] = dev }}}let live = Set(snapshots.map(\.id))- batteryWatchers = batteryWatchers.filter { live.contains($0.key) || !devicePads }+ let liveBase = Set(snapshots.map { Self.baseControllerID($0.id) })+ batteryWatchers = batteryWatchers.filter { liveBase.contains($0.key) || !devicePads }overrides = overrides.filter { live.contains($0.key) }snapshots = snapshots.map { snap inguard let chosen = overrides[snap.id] else { return snap }@@ -659,7 +707,7 @@ struct ConsolePadSnapshot: Equatable {return s}let assigned = Self.autoAssigned(snapshots, remembered: remembered)- for (old, new) in zip(snapshots, assigned) where old.playerIndex != new.playerIndex {+ for (old, new) in zip(snapshots, assigned) where old.playerIndex != new.playerIndex && !new.id.hasSuffix(".R") {devices[new.id]?.playerIndex = GCControllerPlayerIndex(rawValue: (new.playerIndex ?? 1) - 1) ?? .indexUnset}for pad in assigned { if let p = pad.playerIndex { remembered[Self.memoryKey(pad)] = p } }diff --git a/frontend/Tests/NX2AppleTests/ConsoleLiveTests.swift b/frontend/Tests/NX2AppleTests/ConsoleLiveTests.swiftindex 972a3dec..625534f0 100644--- a/frontend/Tests/NX2AppleTests/ConsoleLiveTests.swift+++ b/frontend/Tests/NX2AppleTests/ConsoleLiveTests.swift@@ -741,4 +741,38 @@ import SwiftUIXCTAssertEqual(driver.state.toast, gone, "no second disconnect toast")XCTAssertTrue(driver.state.controllers.isEmpty)}++ /// Regression test (#740): a paired Joy-Con is a single GCController instance with one shared `playerIndex` property.+ /// Writing `.R`'s assigned player back to that shared hardware slot used to overwrite `.L`'s playerIndex, causing P1 and P2+ /// to ping-pong on every reread and spawning an exponential storm of reread Tasks.+ func testSplitJoyConPairDoesNotPingPongSharedHardwarePlayerIndex() {+ var hardwarePlayerIndex: Int? = 1+ var writes: [(String, Int)] = []+ let layout = ControlLayout(defaults: UserDefaults(suiteName: "ConsoleLiveTests-" + UUID().uuidString)!)+ let driver = LiveConsoleDriver(+ library: GameLibrary(file: temporary.appendingPathComponent("library.json")),+ controls: layout, repo: { "" }, lang: { .en }, labels: { $0 },+ pads: {+ [ConsolePadSnapshot(id: "jc", name: "Joy-Con (L/R)", category: "Nintendo Switch Joy-Con (L/R)", playerIndex: hardwarePlayerIndex)]+ },+ artwork: { _, _ in nil }, observeSystem: false,+ playerOutput: { id, player in+ writes.append((id, player))+ hardwarePlayerIndex = player // shared GCController.playerIndex+ })+ XCTAssertEqual(driver.state.controllers.map(\.id), ["jc"])+ XCTAssertEqual(driver.state.controllers.map(\.player), [1])++ driver.setJoyconSplit(true)+ XCTAssertEqual(driver.state.controllers.map(\.id), ["jc.L", "jc.R"])+ XCTAssertEqual(driver.state.controllers.map(\.player), [1, 2])+ let countAfterSplit = writes.count++ // Subsequent rereads (e.g. from primeOutputs or battery KVO) must keep L=1, R=2 stable and emit no new hardware writes.+ for _ in 0..<5 {+ driver.refreshControllers(announce: false)+ XCTAssertEqual(driver.state.controllers.map(\.player), [1, 2], "P1 and P2 must not ping-pong across rereads")+ XCTAssertEqual(writes.count, countAfterSplit, "no new player output writes when nothing changed")+ }+ }}diff --git a/frontend/Tests/NX2AppleTests/ConsolePadTests.swift b/frontend/Tests/NX2AppleTests/ConsolePadTests.swiftindex 9eac3d36..b2c76687 100644--- a/frontend/Tests/NX2AppleTests/ConsolePadTests.swift+++ b/frontend/Tests/NX2AppleTests/ConsolePadTests.swift@@ -185,6 +185,49 @@ import NXModelXCTAssertEqual(ConsoleGlyphs(family: .nintendo).glyph(for: .back), .symbol("b.circle"))}+ func testSplitJoyConSidewaysMenuMappingAndToggleSuppression() {+ XCTAssertTrue(LauncherGamepad.isJoyCon(category: "Switch Joy-Con (L/R)"))+ XCTAssertTrue(LauncherGamepad.isJoyCon(category: "Gamepad", vendorName: "Joy-Con (L)"))+ XCTAssertFalse(LauncherGamepad.isJoyCon(category: "Nintendo Switch Pro Controller"))++ var edges = LauncherGamepad.Edges()+ func fire(_ raw: LauncherGamepad.RawPadInput, split: Bool) -> [(String, [LauncherGamepad.Action])] {+ let groups = LauncherGamepad.states(controller: "jc", input: raw, splitJoyCon: split)+ if edges.syncSplitMode(baseController: "jc", split: split, groups: groups) { return [] }+ return groups.compactMap { g in+ let (p, _) = edges.changes(controller: g.controller, state: g.state)+ return p.isEmpty ? nil : (g.controller, p)+ }+ }++ // Left Joy-Con sideways (90° CCW): physical right (+X) -> .up, physical down (-Y) -> .right; D-pad Down -> .a, Left -> .b+ XCTAssertEqual(fire(.init(leftStickX: 0.9), split: true).first?.1, [.up])+ _ = fire(.init(), split: true)+ XCTAssertEqual(fire(.init(leftStickY: -0.9), split: true).first?.1, [.right])+ _ = fire(.init(), split: true)+ let leftFace = fire(.init(dpadX: -0.9, dpadY: -0.9), split: true)+ XCTAssertEqual(leftFace.first?.0, "jc.L")+ XCTAssertEqual(leftFace.first?.1, [.a, .b])+ _ = fire(.init(), split: true)++ // Right Joy-Con sideways (90° CW): physical left (-X) -> .up, physical up (+Y) -> .right; X -> .a, A -> .b+ XCTAssertEqual(fire(.init(rightStickX: -0.9), split: true).first?.1, [.up])+ _ = fire(.init(), split: true)+ XCTAssertEqual(fire(.init(rightStickY: 0.9), split: true).first?.1, [.right])+ _ = fire(.init(), split: true)+ let rightFace = fire(.init(a: true, x: true), split: true)+ XCTAssertEqual(rightFace.first?.0, "jc.R")+ XCTAssertEqual(rightFace.first?.1, [.a, .b])+ _ = fire(.init(), split: true)++ // Holding A while toggling split off->on must not re-fire as .b on the next frame before release+ _ = fire(.init(), split: false)+ XCTAssertEqual(fire(.init(a: true), split: false).first?.1, [.a])+ XCTAssertTrue(fire(.init(a: true), split: true).isEmpty, "button held across split toggle must not re-fire under its rotated role")+ _ = fire(.init(), split: true)+ XCTAssertEqual(fire(.init(a: true), split: true).first?.1, [.b], "fires normally once released and pressed again")+ }+/// Opt-in: the desktop top bar with the entry button and the controller strip, and the connect prompt.@MainActor func testCaptureDesktopEntry() throws {guard let directory = ProcessInfo.processInfo.environment["NX_CONSOLE_SHOTS_DIR"] else { throw XCTSkip("Set NX_CONSOLE_SHOTS_DIR") }