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
Write the Mac Driver keys as REG_SZ, not DWORD
Michael Liendo4d3737a0ebae
diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swiftindex a3d91b6..4743c44 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -281,7 +281,9 @@ public struct WineRunner: Sendable {////// Pure so the mapping is unit-tested without touching a prefix.public static func keyboardRegistry(commandIsControl: Bool) -> [(name: String, data: String)] {- let on = commandIsControl ? "1" : "0"+ // Mac Driver settings are REG_SZ "y"/"n", not DWORD — a DWORD 1 is read as absent and the+ // mapping silently stays off, which is exactly how this was first shipped and had to be fixed.+ let on = commandIsControl ? "y" : "n"return [("LeftCommandIsCtrl", on), ("RightCommandIsCtrl", on),("LeftOptionIsAlt", on), ("RightOptionIsAlt", on),@@ -291,7 +293,7 @@ public struct WineRunner: Sendable {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,- type: "REG_DWORD", data: v.data)+ type: "REG_SZ", data: v.data)}}diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 096c42a..3114ab0 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -83,15 +83,17 @@ final class RegressionTests: XCTestCase {// Cmd+V beeped instead of pasting in Steam: Wine's Mac driver leaves Command acting as Alt.// Mapping Command to Ctrl without also mapping Option to Alt leaves no way to send Alt at all// (winemac.drv warns about exactly that), so the four values must move together.+ // Mac Driver values are REG_SZ "y"/"n". Writing DWORD 1 reads as absent and the mapping+ // silently stays off — the first cut of this shipped that way.func testCommandKeyMappingMovesAsASet() throws {let on = WineRunner.keyboardRegistry(commandIsControl: true)XCTAssertEqual(on.count, 4)XCTAssertEqual(Set(on.map(\.name)),["LeftCommandIsCtrl", "RightCommandIsCtrl", "LeftOptionIsAlt", "RightOptionIsAlt"])- XCTAssertTrue(on.allSatisfy { $0.data == "1" }, "Command→Ctrl is useless without Option→Alt")+ XCTAssertTrue(on.allSatisfy { $0.data == "y" }, "Command→Ctrl is useless without Option→Alt")let off = WineRunner.keyboardRegistry(commandIsControl: false)- XCTAssertTrue(off.allSatisfy { $0.data == "0" }, "off restores Wine's default mapping")+ XCTAssertTrue(off.allSatisfy { $0.data == "n" }, "off restores Wine's default mapping")XCTAssertEqual(Set(off.map(\.name)), Set(on.map(\.name)),"turning it off must clear the same keys it set, not leave half behind")}