Commit 09c6bf41 authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

winex11: Fix MapVirtualKeyEx to properly map left-right modifier keys.

parent 56989b6e
......@@ -1111,6 +1111,27 @@ static void test_GetMouseMovePointsEx(void)
#undef MYERROR
}
static void test_key_map(void)
{
HKL kl = GetKeyboardLayout(0);
UINT kL, kR, s, sL;
s = MapVirtualKeyEx(VK_SHIFT, MAPVK_VK_TO_VSC, kl);
ok(s != 0, "MapVirtualKeyEx(VK_SHIFT) should return non-zero\n");
sL = MapVirtualKeyEx(VK_LSHIFT, MAPVK_VK_TO_VSC, kl);
ok(s == sL, "%x != %x\n", s, sL);
kL = MapVirtualKeyEx(0x2a, MAPVK_VSC_TO_VK, kl);
ok(kL == VK_SHIFT, "Scan code -> vKey = %x (not VK_SHIFT)\n", kL);
kR = MapVirtualKeyEx(0x36, MAPVK_VSC_TO_VK, kl);
ok(kR == VK_SHIFT, "Scan code -> vKey = %x (not VK_SHIFT)\n", kR);
kL = MapVirtualKeyEx(0x2a, MAPVK_VSC_TO_VK_EX, kl);
ok(kL == VK_LSHIFT, "Scan code -> vKey = %x (not VK_LSHIFT)\n", kL);
kR = MapVirtualKeyEx(0x36, MAPVK_VSC_TO_VK_EX, kl);
ok(kR == VK_RSHIFT, "Scan code -> vKey = %x (not VK_RSHIFT)\n", kR);
}
START_TEST(input)
{
init_function_pointers();
......@@ -1123,6 +1144,7 @@ START_TEST(input)
test_Input_blackbox();
test_keynames();
test_mouse_ll_hook();
test_key_map();
if(pGetMouseMovePointsEx)
test_GetMouseMovePointsEx();
......
......@@ -2053,31 +2053,64 @@ UINT X11DRV_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl)
if (hkl != X11DRV_GetKeyboardLayout(0))
FIXME("keyboard layout %p is not supported\n", hkl);
switch(wMapType) {
case MAPVK_VK_TO_VSC: /* vkey-code to scan-code */
case MAPVK_VK_TO_VSC_EX: /* FIXME: should differentiate between
left and right keys */
{
/* let's do vkey -> keycode -> scan */
int keyc;
for (keyc=min_keycode; keyc<=max_keycode; keyc++)
if ((keyc2vkey[keyc] & 0xFF) == wCode)
returnMVK (keyc2scan[keyc] & 0xFF);
TRACE("returning no scan-code.\n");
return 0;
}
case MAPVK_VSC_TO_VK: /* scan-code to vkey-code */
case MAPVK_VSC_TO_VK_EX: /* FIXME: should differentiate between
left and right keys */
{
/* let's do scan -> keycode -> vkey */
int keyc;
for (keyc=min_keycode; keyc<=max_keycode; keyc++)
if ((keyc2scan[keyc] & 0xFF) == (wCode & 0xFF))
returnMVK (keyc2vkey[keyc] & 0xFF);
TRACE("returning no vkey-code.\n");
return 0;
}
switch(wMapType)
{
case MAPVK_VK_TO_VSC: /* vkey-code to scan-code */
case MAPVK_VK_TO_VSC_EX:
{
int keyc;
switch (wCode)
{
case VK_SHIFT: wCode = VK_LSHIFT; break;
case VK_CONTROL: wCode = VK_LCONTROL; break;
case VK_MENU: wCode = VK_LMENU; break;
}
/* let's do vkey -> keycode -> scan */
for (keyc = min_keycode; keyc <= max_keycode; keyc++)
if ((keyc2vkey[keyc] & 0xFF) == wCode) break;
if (keyc > max_keycode)
{
TRACE("returning no scan-code.\n");
return 0;
}
returnMVK (keyc2scan[keyc] & 0xFF);
}
case MAPVK_VSC_TO_VK: /* scan-code to vkey-code */
case MAPVK_VSC_TO_VK_EX:
{
int keyc;
UINT vkey;
/* let's do scan -> keycode -> vkey */
for (keyc = min_keycode; keyc <= max_keycode; keyc++)
if ((keyc2scan[keyc] & 0xFF) == (wCode & 0xFF)) break;
if (keyc > max_keycode)
{
TRACE("returning no vkey-code.\n");
return 0;
}
vkey = keyc2vkey[keyc] & 0xFF;
if (wMapType == MAPVK_VSC_TO_VK)
switch (vkey)
{
case VK_LSHIFT:
case VK_RSHIFT:
vkey = VK_SHIFT; break;
case VK_LCONTROL:
case VK_RCONTROL:
vkey = VK_CONTROL; break;
case VK_LMENU:
case VK_RMENU:
vkey = VK_MENU; break;
}
returnMVK (vkey);
}
case MAPVK_VK_TO_CHAR: /* vkey-code to unshifted ANSI code */
{
/* we still don't know what "unshifted" means. in windows VK_W (0x57)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment