Huw Davies : user32: Implement OemKeyScan().
Alexandre Julliard
julliard at winehq.org
Thu Sep 22 10:00:02 CDT 2016
Module: wine
Branch: master
Commit: b7c5ff05a72716d92dd2fa399f960d42b69fcb97
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b7c5ff05a72716d92dd2fa399f960d42b69fcb97
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Sep 22 11:12:38 2016 +0100
user32: Implement OemKeyScan().
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/input.c | 17 +++++++++++++++--
dlls/user32/tests/input.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 63fae67..44b7e70 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -884,9 +884,22 @@ WORD WINAPI VkKeyScanExW(WCHAR cChar, HKL dwhkl)
/**********************************************************************
* OemKeyScan (USER32.@)
*/
-DWORD WINAPI OemKeyScan(WORD wOemChar)
+DWORD WINAPI OemKeyScan( WORD oem )
{
- return wOemChar;
+ WCHAR wchr;
+ DWORD vkey, scan;
+ char oem_char = LOBYTE( oem );
+
+ if (!OemToCharBuffW( &oem_char, &wchr, 1 ))
+ return -1;
+
+ vkey = VkKeyScanW( wchr );
+ scan = MapVirtualKeyW( LOBYTE( vkey ), MAPVK_VK_TO_VSC );
+ if (!scan) return -1;
+
+ vkey &= 0xff00;
+ vkey <<= 8;
+ return vkey | scan;
}
/******************************************************************************
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 1813367..8e89481 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -53,6 +53,7 @@
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
+#include "winnls.h"
#include "wine/test.h"
@@ -2493,6 +2494,36 @@ static void test_GetKeyState(void)
CloseHandle(semaphores[1]);
}
+static void test_OemKeyScan(void)
+{
+ DWORD ret, expect, vkey, scan;
+ WCHAR oem, wchr;
+ char oem_char;
+
+ for (oem = 0; oem < 0x200; oem++)
+ {
+ ret = OemKeyScan( oem );
+
+ oem_char = LOBYTE( oem );
+ if (!OemToCharBuffW( &oem_char, &wchr, 1 ))
+ expect = -1;
+ else
+ {
+ vkey = VkKeyScanW( wchr );
+ scan = MapVirtualKeyW( LOBYTE( vkey ), MAPVK_VK_TO_VSC );
+ if (!scan)
+ expect = -1;
+ else
+ {
+ vkey &= 0xff00;
+ vkey <<= 8;
+ expect = vkey | scan;
+ }
+ }
+ ok( ret == expect, "%04x: got %08x expected %08x\n", oem, ret, expect );
+ }
+}
+
START_TEST(input)
{
init_function_pointers();
@@ -2516,6 +2547,7 @@ START_TEST(input)
test_key_names();
test_attach_input();
test_GetKeyState();
+ test_OemKeyScan();
if(pGetMouseMovePointsEx)
test_GetMouseMovePointsEx();
More information about the wine-cvs
mailing list