Fixed skipped events from keyboard:
[reactos.git] / reactos / subsys / win32k / ntuser / input.c
index db69e28..f9e77ff 100644 (file)
@@ -151,7 +151,7 @@ ProcessMouseInputData(PMOUSE_INPUT_DATA Data, ULONG InputCount)
 VOID STDCALL
 MouseThreadMain(PVOID StartContext)
 {
-   UNICODE_STRING MouseDeviceName = RTL_CONSTANT_STRING(L"\\Device\\PointerClassPnp0");
+   UNICODE_STRING MouseDeviceName = RTL_CONSTANT_STRING(L"\\Device\\PointerClass0");
    OBJECT_ATTRIBUTES MouseObjectAttributes;
    IO_STATUS_BLOCK Iosb;
    NTSTATUS Status;
@@ -404,7 +404,7 @@ co_IntKeyboardSendAltKeyMsg()
 STATIC VOID STDCALL
 KeyboardThreadMain(PVOID StartContext)
 {
-   UNICODE_STRING KeyboardDeviceName = RTL_CONSTANT_STRING(L"\\??\\Keyboard");
+   UNICODE_STRING KeyboardDeviceName = RTL_CONSTANT_STRING(L"\\Device\\KeyboardClass0");
    OBJECT_ATTRIBUTES KeyboardObjectAttributes;
    IO_STATUS_BLOCK Iosb;
    NTSTATUS Status;
@@ -413,7 +413,6 @@ KeyboardThreadMain(PVOID StartContext)
    struct _ETHREAD *FocusThread;
    extern NTSTATUS Win32kInitWin32Thread(PETHREAD Thread);
 
-
    PKEYBOARD_INDICATOR_TRANSLATION IndicatorTrans = NULL;
    UINT ModifierState = 0;
    USHORT LastMakeCode = 0;
@@ -486,8 +485,10 @@ KeyboardThreadMain(PVOID StartContext)
          HWND hWnd;
          int id;
 
+        DPRINT("KeyInput @ %08x\n", &KeyInput);
+
          Status = NtReadFile (KeyboardDeviceHandle,
-                              NULL,
+                             NULL,
                               NULL,
                               NULL,
                               &Iosb,
@@ -495,6 +496,22 @@ KeyboardThreadMain(PVOID StartContext)
                               sizeof(KEYBOARD_INPUT_DATA),
                               NULL,
                               NULL);
+
+         if(Status == STATUS_ALERTED && !InputThreadsRunning)
+         {
+            break;
+         }
+         if(Status == STATUS_PENDING)
+         {
+            NtWaitForSingleObject(KeyboardDeviceHandle, FALSE, NULL);
+            Status = Iosb.Status;
+         }
+         if(!NT_SUCCESS(Status))
+         {
+            DPRINT1("Win32K: Failed to read from mouse.\n");
+            return; //(Status);
+         }
+
          DPRINT("KeyRaw: %s %04x\n",
                 (KeyInput.Flags & KEY_BREAK) ? "up" : "down",
                 KeyInput.MakeCode );
@@ -670,14 +687,14 @@ KeyboardThreadMain(PVOID StartContext)
             FocusThread = FocusQueue->Thread;
 
             if (!(FocusThread && FocusThread->Tcb.Win32Thread &&
-                  FocusThread->Tcb.Win32Thread->KeyboardLayout))
+                  ((PW32THREAD)FocusThread->Tcb.Win32Thread)->KeyboardLayout))
                continue;
 
             /* This function uses lParam to fill wParam according to the
              * keyboard layout in use.
              */
             W32kKeyProcessMessage(&msg,
-                                  FocusThread->Tcb.Win32Thread->KeyboardLayout,
+                                  ((PW32THREAD)FocusThread->Tcb.Win32Thread)->KeyboardLayout,
                                   KeyInput.Flags & KEY_E0 ? 0xE0 :
                                   (KeyInput.Flags & KEY_E1 ? 0xE1 : 0));