user32: Implement OemKeyScan().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-09-22 11:12:38 +01:00 committed by Alexandre Julliard
parent ddc1658501
commit b7c5ff05a7
2 changed files with 47 additions and 2 deletions

View File

@ -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;
}
/******************************************************************************

View File

@ -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();