Skip to content

Commit b22df7f

Browse files
committed
windows: add GetKeyboardLayout & ToUnicodeEx
These are used along with GetForegroundWindow and GetWindowThreadProcessId to determine the current user layout and translate the base key the user has pressed.
1 parent 95f07ec commit b22df7f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

windows/syscall_windows.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import (
1717
"unsafe"
1818
)
1919

20-
type Handle uintptr
21-
type HWND uintptr
20+
type (
21+
Handle uintptr
22+
HWND uintptr
23+
)
2224

2325
const (
2426
InvalidHandle = ^Handle(0)
@@ -211,6 +213,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
211213
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
212214
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
213215
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
216+
//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout
217+
//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx
214218
//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow
215219
//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
216220
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
@@ -1357,9 +1361,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) {
13571361
func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) {
13581362
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4)
13591363
}
1364+
13601365
func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) {
13611366
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
13621367
}
1368+
13631369
func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) {
13641370
return syscall.EWINDOWS
13651371
}

windows/zsyscall_windows.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)