mirror of
https://github.com/golang/sys.git
synced 2026-02-09 04:06:04 +03:00
windows: change exported ToUnicodeEx signature + fix tests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user