- Fix NtUserVkKeyScanEx to support current thread keyboard layout or use the one provided by handle. See bug report 4269 and the related bug report 4272.

svn path=/trunk/; revision=41040
This commit is contained in:
James Tabor 2009-05-22 01:35:48 +00:00
parent 13d610f832
commit 9897a55a56
3 changed files with 25 additions and 13 deletions

View file

@ -492,7 +492,7 @@ SHORT WINAPI
VkKeyScanExW(WCHAR ch,
HKL dwhkl)
{
return (SHORT) NtUserVkKeyScanEx(ch, dwhkl, 0);
return (SHORT) NtUserVkKeyScanEx(ch, dwhkl, TRUE);
}
@ -502,7 +502,7 @@ VkKeyScanExW(WCHAR ch,
SHORT WINAPI
VkKeyScanW(WCHAR ch)
{
return VkKeyScanExW(ch, GetKeyboardLayout(0));
return (SHORT) NtUserVkKeyScanEx(ch, 0, FALSE);
}

View file

@ -2697,7 +2697,7 @@ NTAPI
NtUserVkKeyScanEx(
WCHAR wChar,
HKL KeyboardLayout,
DWORD Unknown2);
BOOL bUsehHK);
DWORD
NTAPI

View file

@ -1000,22 +1000,31 @@ DWORD
APIENTRY
NtUserVkKeyScanEx(
WCHAR wChar,
HKL KeyboardLayout,
DWORD Unknown2)
HKL hKeyboardLayout,
BOOL UsehKL ) // TRUE from KeyboardLayout, FALSE from pkbl = (THREADINFO)->KeyboardLayout
{
/* FIXME: currently, this routine doesnt seem to need any locking */
PKBDTABLES KeyLayout;
PVK_TO_WCHAR_TABLE vtwTbl;
PVK_TO_WCHARS10 vkPtr;
size_t size_this_entry;
int nMod;
DWORD CapsMod = 0, CapsState = 0;
PKBL pkbl = NULL;
DWORD CapsMod = 0, CapsState = 0, Ret = -1;
DPRINT("NtUserVkKeyScanEx() wChar %d, KbdLayout 0x%p\n", wChar, KeyboardLayout);
DPRINT("NtUserVkKeyScanEx() wChar %d, KbdLayout 0x%p\n", wChar, hKeyboardLayout);
UserEnterShared();
if(!KeyboardLayout)
return -1;
KeyLayout = UserHklToKbl(KeyboardLayout)->KBTables;
if (UsehKL)
{
if ( !hKeyboardLayout || !(pkbl = UserHklToKbl(hKeyboardLayout)))
goto Exit;
}
else // From VkKeyScanAW it is FALSE so KeyboardLayout is white noise.
{
pkbl = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->KeyboardLayout;
}
KeyLayout = pkbl->KBTables;
for (nMod = 0; KeyLayout->pVkToWcharTable[nMod].nModifications; nMod++)
{
@ -1038,13 +1047,16 @@ NtUserVkKeyScanEx(
CapsMod = KeyLayout->pCharModifiers->ModNumber[CapsState];
DPRINT("nMod %d wC %04x: CapsMod %08x CapsState %08x MaxModBits %08x\n",
nMod, wChar, CapsMod, CapsState, KeyLayout->pCharModifiers->wMaxModBits);
return ((CapsMod << 8)|(vkPtr->VirtualKey & 0xff));
Ret = ((CapsMod << 8)|(vkPtr->VirtualKey & 0xff));
goto Exit;
}
}
vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
}
}
return -1;
Exit:
UserLeave();
return Ret;
}