Skip to content

Commit

Permalink
fix(input): windows: always use us layout
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 17, 2024
1 parent 6e59f8a commit 993171a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions input/driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,11 @@ func parseConInputEvent(event coninput.InputRecord, ps *coninput.ButtonState) Ev
return event
}

// Get active keyboard layout
fgWin := windows.GetForegroundWindow()
fgThread, err := windows.GetWindowThreadProcessId(fgWin, nil)
if err != nil {
return event
}

layout := termwindows.GetKeyboardLayout(fgThread)
if layout == windows.InvalidHandle {
return event
}
// Always use US layout for translation
// This is to follow the behavior of the Kitty Keyboard base layout
// feature :eye_roll:
// https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-language-pack-default-values?view=windows-11
const usLayout = 0x409

// Translate key to rune
var keyState [256]byte
Expand All @@ -154,7 +148,7 @@ func parseConInputEvent(event coninput.InputRecord, ps *coninput.ButtonState) Ev
&utf16Buf[0],
int32(len(utf16Buf)),
dontChangeKernelKeyboardLayout,
layout,
usLayout,
)

// -1 indicates a dead key
Expand Down

0 comments on commit 993171a

Please sign in to comment.