* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Keyboard functions
- * FILE: subsystems/win32/win32k/ntuser/keyboard.c
+ * FILE: win32ss/user/ntuser/keyboard.c
* PROGRAMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* Rafal Harabien (rafalh@reactos.org)
*/
static BYTE gafAsyncKeyStateRecentDown[256 / 8]; // 1 bit per key
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans = NULL;
static KEYBOARD_INDICATOR_PARAMETERS gIndicators = {0, 0};
+KEYBOARD_ATTRIBUTES gKeyboardInfo;
/* FUNCTIONS *****************************************************************/
{
RtlZeroMemory(&gafAsyncKeyState, sizeof(gafAsyncKeyState));
RtlZeroMemory(&gafAsyncKeyStateRecentDown, sizeof(gafAsyncKeyStateRecentDown));
+ // Clear and set default information.
+ RtlZeroMemory(&gKeyboardInfo, sizeof(gKeyboardInfo));
+ gKeyboardInfo.KeyboardIdentifier.Type = 4; /* AT-101 */
+ gKeyboardInfo.NumberOfFunctionKeys = 12; /* We're doing an 101 for now, so return 12 F-keys */
return STATUS_SUCCESS;
}
* Asks the keyboard driver to send a small table that shows which
* lights should connect with which scancodes
*/
-static
+//static
NTSTATUS APIENTRY
IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice,
PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans)
while (pRet)
{
- Status = NtDeviceIoControlFile(hKeyboardDevice,
+ Status = ZwDeviceIoControlFile(hKeyboardDevice,
NULL,
NULL,
NULL,
NTSTATUS APIENTRY
IntKeyboardUpdateLeds(HANDLE hKeyboardDevice,
WORD wVk,
- WORD wScanCode,
- BOOL bEnabled)
+ WORD wScanCode)
{
NTSTATUS Status;
UINT i;
if (LedFlag)
{
- if (bEnabled)
- gIndicators.LedFlags |= LedFlag;
- else
- gIndicators.LedFlags = ~LedFlag;
+ gIndicators.LedFlags ^= LedFlag;
/* Update the lights on the hardware */
- Status = NtDeviceIoControlFile(hKeyboardDevice,
+ Status = ZwDeviceIoControlFile(hKeyboardDevice,
NULL,
NULL,
NULL,
IntKeyboardGetIndicatorTrans(hKeyboardDevice, &gpKeyboardIndicatorTrans);
- Status = NtDeviceIoControlFile(hKeyboardDevice,
+ Status = ZwDeviceIoControlFile(hKeyboardDevice,
NULL,
NULL,
NULL,
{
WARN("NtDeviceIoControlFile() failed, ignored\n");
}
-
SET_KEY_LOCKED(gafAsyncKeyState, VK_CAPITAL,
gIndicators.LedFlags & KEYBOARD_CAPS_LOCK_ON);
SET_KEY_LOCKED(gafAsyncKeyState, VK_NUMLOCK,
gIndicators.LedFlags & KEYBOARD_NUM_LOCK_ON);
SET_KEY_LOCKED(gafAsyncKeyState, VK_SCROLL,
gIndicators.LedFlags & KEYBOARD_SCROLL_LOCK_ON);
+
+ // FIXME: Need device driver to work! HID support more than one!!!!
+ Status = ZwDeviceIoControlFile(hKeyboardDevice,
+ NULL,
+ NULL,
+ NULL,
+ &Block,
+ IOCTL_KEYBOARD_QUERY_ATTRIBUTES,
+ NULL, 0,
+ &gKeyboardInfo, sizeof(gKeyboardInfo));
+
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("NtDeviceIoControlFile() failed, ignored\n");
+ }
+ ERR("Keyboard type %d, subtype %d and number of func keys %d\n",
+ gKeyboardInfo.KeyboardIdentifier.Type,
+ gKeyboardInfo.KeyboardIdentifier.Subtype,
+ gKeyboardInfo.NumberOfFunctionKeys);
}
/*
*pbLigature = (wch == WCH_LGTR);
*pwcTranslatedChar = wch;
- TRACE("%d %04x: dwModNumber %08x Char %04x\n",
+ TRACE("%lu %04x: dwModNumber %08x Char %04x\n",
i, wVirtKey, dwModNumber, wch);
if (*pbDead)
UserLeave();
- TRACE("Leave NtUserGetAsyncKeyState, ret=%i\n", wRet);
+ TRACE("Leave NtUserGetAsyncKeyState, ret=%u\n", wRet);
return wRet;
}
{
WORD wSimpleVk = 0, wFixedVk, wVk2;
PUSER_MESSAGE_QUEUE pFocusQueue;
+ PTHREADINFO pti;
BOOL bExt = (dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
BOOL bIsDown = (dwFlags & KEYEVENTF_KEYUP) ? FALSE : TRUE;
BOOL bPacket = (dwFlags & KEYEVENTF_UNICODE) ? TRUE : FALSE;
/* Update keyboard LEDs */
IntKeyboardUpdateLeds(ghKeyboardDevice,
wSimpleVk,
- wScanCode,
- IS_KEY_LOCKED(gafAsyncKeyState, wSimpleVk));
+ wScanCode);
}
/* Call WH_KEYBOARD_LL hook */
/* Check if this is a hotkey */
if (co_UserProcessHotKeys(wSimpleVk, bIsDown))
+ {
+ TRACE("HotKey Processed\n");
bPostMsg = FALSE;
-
+ }
+
wFixedVk = IntFixVk(wSimpleVk, bExt); /* LSHIFT + EXT = RSHIFT */
if (wSimpleVk == VK_SHIFT) /* shift can't be extended */
bExt = FALSE;
}
else if (pFocusQueue && bPostMsg)
{
- PWND Wnd = pFocusQueue->spwndFocus;
- if (!Wnd)
+ PWND Wnd = pFocusQueue->spwndFocus; // SysInit.....
+
+ pti = pFocusQueue->ptiKeyboard;
+
+ if (!Wnd && pFocusQueue->spwndActive) // SysInit.....
{
- // Focus can be null so going with Active. WM_SYSKEYXXX last wine Win test_keyboard_input.
+ // Going with Active. WM_SYSKEYXXX last wine Win test_keyboard_input.
Wnd = pFocusQueue->spwndActive;
}
+ if (Wnd) pti = Wnd->head.pti;
/* Init message */
- Msg.hwnd = UserHMGetHandle(Wnd);
+ Msg.hwnd = Wnd ? UserHMGetHandle(Wnd) : NULL;
Msg.wParam = wFixedVk & 0xFF; /* Note: It's simplified by msg queue */
Msg.lParam = MAKELPARAM(1, wScanCode);
Msg.time = dwTime;
Msg.pt = gpsi->ptCursor;
+ if ( Msg.message == WM_KEYDOWN || Msg.message == WM_SYSKEYDOWN )
+ {
+ if ( (Msg.wParam == VK_SHIFT ||
+ Msg.wParam == VK_CONTROL ||
+ Msg.wParam == VK_MENU ) &&
+ !IS_KEY_DOWN(gafAsyncKeyState, Msg.wParam))
+ {
+ ERR("Set last input\n");
+ //ptiLastInput = pti;
+ }
+ }
+
/* If it is VK_PACKET, high word of wParam is used for wchar */
if (!bPacket)
{
/* Post a keyboard message */
TRACE("Posting keyboard msg %u wParam 0x%x lParam 0x%x\n", Msg.message, Msg.wParam, Msg.lParam);
- MsqPostMessage(pFocusQueue, &Msg, TRUE, QS_KEY, 0);
+ if (!Wnd) {ERR("Window is NULL\n");}
+ MsqPostMessage(pti, &Msg, TRUE, QS_KEY, 0);
}
return TRUE;
PKL pKl = NULL;
PKBDTABLES pKbdTbl;
PUSER_MESSAGE_QUEUE pFocusQueue;
- struct _ETHREAD *pFocusThread;
LARGE_INTEGER LargeTickCount;
DWORD dwTime;
BOOL bExt = (pKbdInput->dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
/* Find the target thread whose locale is in effect */
pFocusQueue = IntGetFocusMessageQueue();
- if (pFocusQueue)
+ if (pFocusQueue && pFocusQueue->ptiKeyboard)
{
- pFocusThread = pFocusQueue->Thread;
- if (pFocusThread && pFocusThread->Tcb.Win32Thread)
- pKl = ((PTHREADINFO)pFocusThread->Tcb.Win32Thread)->KeyboardLayout;
+ pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
}
if (!pKl)
PKL pKl = NULL;
PKBDTABLES pKbdTbl;
PUSER_MESSAGE_QUEUE pFocusQueue;
- struct _ETHREAD *pFocusThread;
/* Calculate scan code with prefix */
wScanCode = pKbdInputData->MakeCode & 0x7F;
/* Find the target thread whose locale is in effect */
pFocusQueue = IntGetFocusMessageQueue();
- if (pFocusQueue)
+ if (pFocusQueue && pFocusQueue->ptiKeyboard)
{
- pFocusThread = pFocusQueue->Thread;
- if (pFocusThread && pFocusThread->Tcb.Win32Thread)
- pKl = ((PTHREADINFO)pFocusThread->Tcb.Win32Thread)->KeyboardLayout;
+ pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
}
if (!pKl)
NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
NewMsg.wParam = HIWORD(lpMsg->lParam);
NewMsg.lParam = LOWORD(lpMsg->lParam);
- MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY, 0);
+ MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0);
return TRUE;
}
{
TRACE("Msg: %x '%lc' (%04x) %08x\n", NewMsg.message, wch[i], wch[i], NewMsg.lParam);
NewMsg.wParam = wch[i];
- MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY, 0);
+ MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0);
}
bResult = TRUE;
}
ret = IntMapVirtualKeyEx(uCode, uType, pKbdTbl);
UserLeave();
- TRACE("Leave NtUserMapVirtualKeyEx, ret=%i\n", ret);
+ TRACE("Leave NtUserMapVirtualKeyEx, ret=%u\n", ret);
return ret;
}
pwszBuff = ExAllocatePoolWithTag(NonPagedPool, sizeof(WCHAR) * cchBuff, TAG_STRING);
if (!pwszBuff)
{
- ERR("ExAllocatePoolWithTag(%d) failed\n", sizeof(WCHAR) * cchBuff);
+ ERR("ExAllocatePoolWithTag(%u) failed\n", sizeof(WCHAR) * cchBuff);
return 0;
}
RtlZeroMemory(pwszBuff, sizeof(WCHAR) * cchBuff);
cleanup:
UserLeave();
- TRACE("Leave NtUserGetKeyNameText, ret=%i\n", dwRet);
+ TRACE("Leave NtUserGetKeyNameText, ret=%lu\n", dwRet);
return dwRet;
}
switch (dwTypeFlag)
{
case 0: /* Keyboard type */
- return 4; /* AT-101 */
+ return (DWORD)gKeyboardInfo.KeyboardIdentifier.Type;
case 1: /* Keyboard Subtype */
- return 0; /* There are no defined subtypes */
+ return (DWORD)gKeyboardInfo.KeyboardIdentifier.Subtype;
case 2: /* Number of F-keys */
- return 12; /* We're doing an 101 for now, so return 12 F-keys */
+ return (DWORD)gKeyboardInfo.NumberOfFunctionKeys;
default:
ERR("Unknown type!\n");
return 0; /* Note: we don't have to set last error here */
PKL pKl = NULL;
DWORD i, dwModBits = 0, dwModNumber = 0, Ret = (DWORD)-1;
- TRACE("NtUserVkKeyScanEx() wch %d, KbdLayout 0x%p\n", wch, dwhkl);
+ TRACE("NtUserVkKeyScanEx() wch %u, KbdLayout 0x%p\n", wch, dwhkl);
UserEnterShared();
if (bUsehKL)
if (pVkToWch->wch[dwModNumber] == wch)
{
dwModBits = pKbdTbl->pCharModifiers->ModNumber[dwModNumber];
- TRACE("i %d wC %04x: dwModBits %08x dwModNumber %08x MaxModBits %08x\n",
+ TRACE("i %lu wC %04x: dwModBits %08x dwModNumber %08x MaxModBits %08x\n",
i, wch, dwModBits, dwModNumber, pKbdTbl->pCharModifiers->wMaxModBits);
Ret = (dwModBits << 8) | (pVkToWch->VirtualKey & 0xFF);
goto Exit;