Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Apply the mapping on launch, not only at creation and Repair
Michael Liendo2431d11e83b7
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex bb70a6c..939d478 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -165,6 +165,11 @@ public struct BottleSettings: Codable, Sendable {/// beeps instead of pasting. Option is mapped to Alt alongside it — without that, mapping both/// Command keys leaves no way to send Alt at all (winemac.drv warns about exactly this).public var commandIsControl: Bool = true+ /// The commandIsControl value last mirrored into the prefix registry. Bottles created before+ /// this setting existed carry nil, so the first launch after updating applies it — otherwise a+ /// user would have to know to press Repair, which is exactly the discoverability problem this+ /// setting exists to fix.+ public var commandIsControlSynced: Bool?/// Windows UI scale as a DPI value (LogPixels): 96 = 100% (1x), up to 240 = 250%. Above 96 the/// Mac driver switches to native Retina pixels so the scaled UI stays crisp. Applied to the prefix/// registry on change. Supersedes the old on/off retinaMode (which was just 96 / 192).diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swiftindex 4743c44..56f03f1 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -117,6 +117,7 @@ public struct WineRunner: Sendable {@discardableResultpublic func start(_ executable: URL, arguments: [String] = [], renderer: Renderer? = nil, extraEnvironment: [String: String] = [:], workingDirectory: URL? = nil, onOutput: (@Sendable (String) -> Void)? = nil) async throws -> LaunchResult {await syncDllOverridesRegistry()+ await syncKeyboardRegistry()return try await run([executable.path] + arguments, renderer: renderer, extraEnvironment: extraEnvironment, label: executable.lastPathComponent, workingDirectory: workingDirectory, onOutput: onOutput)}@@ -290,6 +291,18 @@ public struct WineRunner: Sendable {]}+ /// Applies the Command→Ctrl mapping when it differs from what the prefix already has, so an+ /// existing bottle picks it up on its next launch and the settings toggle takes effect without+ /// a Repair. Same shape as syncDllOverridesRegistry.+ public func syncKeyboardRegistry() async {+ let current = bottle.settings.commandIsControl+ guard current != bottle.settings.commandIsControlSynced else { return }+ guard (try? await setKeyboardMapping(commandIsControl: current)) != nil else { return }+ var copy = bottle+ copy.settings.commandIsControlSynced = current+ try? copy.save()+ }+public func setKeyboardMapping(commandIsControl: Bool) async throws {for v in Self.keyboardRegistry(commandIsControl: commandIsControl) {try await regAdd(key: #"HKCU\Software\Wine\Mac Driver"#, name: v.name,diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 3114ab0..fcd4024 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -98,6 +98,17 @@ final class RegressionTests: XCTestCase {"turning it off must clear the same keys it set, not leave half behind")}+ // A bottle made before this setting existed decodes with commandIsControlSynced == nil, which+ // is what makes the first launch after updating apply the mapping instead of waiting for Repair.+ func testPreExistingBottleIsUnsyncedSoLaunchApplies() throws {+ let json = #"{"formatVersion":1,"name":"old","engineID":"e"}"#+ let s = try JSONDecoder().decode(BottleSettings.self, from: Data(json.utf8))+ XCTAssertTrue(s.commandIsControl, "the default carries into bottles that predate it")+ XCTAssertNil(s.commandIsControlSynced, "never mirrored → next launch applies it")+ XCTAssertNotEqual(s.commandIsControl, s.commandIsControlSynced,+ "differing is the trigger syncKeyboardRegistry checks")+ }+// New bottles get Mac-native copy/paste; the setting is what the registry write follows.func testCommandIsControlDefaultsOn() throws {let s = BottleSettings(name: "t", engineID: "e")