Browse Source

settings: option to disable ISO key swapping

Fixes #6976
osy 4 days ago
parent
commit
ed492177ec
2 changed files with 7 additions and 2 deletions
  1. 2 1
      Platform/macOS/Display/VMMetalView.swift
  2. 5 1
      Platform/macOS/SettingsView.swift

+ 2 - 1
Platform/macOS/Display/VMMetalView.swift

@@ -26,11 +26,12 @@ class VMMetalView: MTKView {
     private(set) var isMouseInWindow = false
     @Setting("HandleInitialClick") private var isHandleInitialClick: Bool = false
     @Setting("IsCtrlCmdSwapped") private var isCtrlCmdSwapped = false
+    @Setting("IsISOKeySwapped") private var isISOKeySwapped = false
 
     /// On ISO keyboards we have to switch `kVK_ISO_Section` and `kVK_ANSI_Grave`
     /// from: https://chromium.googlesource.com/chromium/src/+/lkgr/ui/events/keycodes/keyboard_code_conversion_mac.mm
     private func convertToCurrentLayout(for keycode: Int) -> Int {
-        guard KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardISO else {
+        guard !isISOKeySwapped && KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardISO else {
             return keycode
         }
         switch keycode {

+ 5 - 1
Platform/macOS/SettingsView.swift

@@ -272,7 +272,8 @@ struct InputSettingsView: View {
     @AppStorage("IsCtrlCmdSwapped") var isCtrlCmdSwapped = false
     @AppStorage("InvertScroll") var isInvertScroll = false
     @AppStorage("HandleInitialClick") var isHandleInitialClick = false
-    
+    @AppStorage("IsISOKeySwapped") var isISOKeySwapped = false
+
     @State private var isKeyboardShortcutsShown = false
     
     var body: some View {
@@ -320,6 +321,9 @@ struct InputSettingsView: View {
                 Toggle(isOn: $isCtrlCmdSwapped, label: {
                     Text("Swap Control (⌃) and Command (⌘) keys")
                 }).help("This does not apply to key binding outside the guest.")
+                Toggle(isOn: $isISOKeySwapped) {
+                    Text("Swap the leftmost key on the number row and the key next to left shift on ISO keyboards")
+                }.help("This only applies to ISO layout keyboards.")
             }
             .sheet(isPresented: $isKeyboardShortcutsShown) {
                 VMKeyboardShortcutsView().padding()