windows: change exported ToUnicodeEx signature + fix tests

This commit is contained in:
Ayman Bagabas
2024-05-17 15:35:16 -04:00
parent 3aa85da655
commit d4d009aecf
2 changed files with 5 additions and 3 deletions

View File

@@ -1925,10 +1925,9 @@ const (
// ToUnicodeEx Translates the specified virtual-key code and keyboard state to
// the corresponding Unicode character or characters.
func ToUnicodeEx(virtualKey, scanCode uint32, buf []uint16, flags uint32, layout Handle) int32 {
func ToUnicodeEx(virtualKey, scanCode uint32, keyState [256]byte, buf []uint16, flags uint32, layout Handle) int32 {
if len(buf) == 0 {
return 0
}
var keyState [256]byte
return toUnicodeEx(virtualKey, scanCode, &keyState[0], &buf[0], int32(len(buf)), flags, layout)
}

View File

@@ -1283,17 +1283,20 @@ func TestGetKeyboardLayout(t *testing.T) {
t.Fatalf("GetWindowThreadProcessId failed: %v", err)
}
// We don't care about the result, just that it doesn't crash.
_ = windows.GetKeyboardLayout(tid)
}
func TestToUnicodeEx(t *testing.T) {
var utf16Buf [16]uint16
const araLayout = windows.Handle(0x401)
var keyState [256]byte
ret := windows.ToUnicodeEx(
0x41, // 'A' vkCode
0x1e, // 'A' scanCode
keyState,
utf16Buf[:],
0,
0x4, // don't change keyboard state
araLayout,
)