Skip to content

Commit d4d009a

Browse files
committed
windows: change exported ToUnicodeEx signature + fix tests
1 parent 3aa85da commit d4d009a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

windows/syscall_windows.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,10 +1925,9 @@ const (
19251925

19261926
// ToUnicodeEx Translates the specified virtual-key code and keyboard state to
19271927
// the corresponding Unicode character or characters.
1928-
func ToUnicodeEx(virtualKey, scanCode uint32, buf []uint16, flags uint32, layout Handle) int32 {
1928+
func ToUnicodeEx(virtualKey, scanCode uint32, keyState [256]byte, buf []uint16, flags uint32, layout Handle) int32 {
19291929
if len(buf) == 0 {
19301930
return 0
19311931
}
1932-
var keyState [256]byte
19331932
return toUnicodeEx(virtualKey, scanCode, &keyState[0], &buf[0], int32(len(buf)), flags, layout)
19341933
}

windows/syscall_windows_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,17 +1283,20 @@ func TestGetKeyboardLayout(t *testing.T) {
12831283
t.Fatalf("GetWindowThreadProcessId failed: %v", err)
12841284
}
12851285

1286+
// We don't care about the result, just that it doesn't crash.
12861287
_ = windows.GetKeyboardLayout(tid)
12871288
}
12881289

12891290
func TestToUnicodeEx(t *testing.T) {
12901291
var utf16Buf [16]uint16
12911292
const araLayout = windows.Handle(0x401)
1293+
var keyState [256]byte
12921294
ret := windows.ToUnicodeEx(
12931295
0x41, // 'A' vkCode
12941296
0x1e, // 'A' scanCode
1297+
keyState,
12951298
utf16Buf[:],
1296-
0,
1299+
0x4, // don't change keyboard state
12971300
araLayout,
12981301
)
12991302

0 commit comments

Comments
 (0)