[ros-diffs] [rharabien] 53655: [WIN32K] - Rename gQueueKeyStateTable to gKeyStateTable as it has nothing to do with msg queues. They have their own table - Use KS_*_BIT defines instead of magic values

rharabien at svn.reactos.org rharabien at svn.reactos.org
Fri Sep 9 13:11:45 UTC 2011


Author: rharabien
Date: Fri Sep  9 13:11:44 2011
New Revision: 53655

URL: http://svn.reactos.org/svn/reactos?rev=53655&view=rev
Log:
[WIN32K]
- Rename gQueueKeyStateTable to gKeyStateTable as it has nothing to do with msg queues. They have their own table
- Use KS_*_BIT defines instead of magic values

Modified:
    trunk/reactos/subsystems/win32/win32k/include/input.h
    trunk/reactos/subsystems/win32/win32k/ntuser/input.c
    trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c

Modified: trunk/reactos/subsystems/win32/win32k/include/input.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/input.h?rev=53655&r1=53654&r2=53655&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/input.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/input.h [iso-8859-1] Fri Sep  9 13:11:44 2011
@@ -28,7 +28,6 @@
 #define KBL_RESET 4
 
 /* Key States */
-#define KS_DOWN_MASK     0xc0
 #define KS_DOWN_BIT      0x80
 #define KS_LOCK_BIT      0x01
 /* Lock modifiers */

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/input.c?rev=53655&r1=53654&r2=53655&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Fri Sep  9 13:11:44 2011
@@ -15,7 +15,7 @@
 
 DBG_DEFAULT_CHANNEL(UserInput);
 
-extern BYTE gQueueKeyStateTable[];
+extern BYTE gKeyStateTable[];
 extern NTSTATUS Win32kInitWin32Thread(PETHREAD Thread);
 extern PPROCESSINFO ppiScrnSaver;
 
@@ -634,16 +634,16 @@
                {
                    if(KeyInput.Flags & KEY_E0)
                    {
-                      gQueueKeyStateTable[VK_RMENU] = 0;
+                      gKeyStateTable[VK_RMENU] = 0;
                    }
                    else
                    {
-                      gQueueKeyStateTable[VK_LMENU] = 0;
+                      gKeyStateTable[VK_LMENU] = 0;
                    }
-                   if (gQueueKeyStateTable[VK_RMENU] == 0 &&
-                       gQueueKeyStateTable[VK_LMENU] == 0)
+                   if (gKeyStateTable[VK_RMENU] == 0 &&
+                       gKeyStateTable[VK_LMENU] == 0)
                    {
-                      gQueueKeyStateTable[VK_MENU] = 0;
+                      gKeyStateTable[VK_MENU] = 0;
                    }
                }
             }
@@ -663,15 +663,15 @@
                    {
                       if(KeyInput.Flags & KEY_E0)
                       {
-                         gQueueKeyStateTable[VK_RMENU] = 0x80;
+                         gKeyStateTable[VK_RMENU] = KS_DOWN_BIT;
                       }
                       else
                       {
-                         gQueueKeyStateTable[VK_LMENU] = 0x80;
+                         gKeyStateTable[VK_LMENU] = KS_DOWN_BIT;
                          bLeftAlt = TRUE;
                       }
 
-                      gQueueKeyStateTable[VK_MENU] = 0x80;
+                      gKeyStateTable[VK_MENU] = KS_DOWN_BIT;
                    }
 
                   /* Read the next key before sending this one */
@@ -717,14 +717,14 @@
                         IntKeyboardSendWinKeyMsg();
                      else if (fsModifiers == MOD_ALT)
                      {
-                        gQueueKeyStateTable[VK_MENU] = 0;
+                        gKeyStateTable[VK_MENU] = 0;
                         if(bLeftAlt)
                         {
-                           gQueueKeyStateTable[VK_LMENU] = 0;
+                           gKeyStateTable[VK_LMENU] = 0;
                         }
                         else
                         {
-                           gQueueKeyStateTable[VK_RMENU] = 0;
+                           gKeyStateTable[VK_RMENU] = 0;
                         }
                         co_IntKeyboardSendAltKeyMsg();
                      }
@@ -1138,12 +1138,12 @@
    Msg.lParam = MAKELPARAM(MousePos.x, MousePos.y);
    Msg.pt = MousePos;
 
-   if (gQueueKeyStateTable[VK_SHIFT] & 0xc0)
+   if (gKeyStateTable[VK_SHIFT] & KS_DOWN_BIT)
    {
       Msg.wParam |= MK_SHIFT;
    }
 
-   if (gQueueKeyStateTable[VK_CONTROL] & 0xc0)
+   if (gKeyStateTable[VK_CONTROL] & KS_DOWN_BIT)
    {
       Msg.wParam |= MK_CONTROL;
    }
@@ -1154,7 +1154,7 @@
    }
    if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
    {
-      gQueueKeyStateTable[VK_LBUTTON] |= 0xc0;
+      gKeyStateTable[VK_LBUTTON] |= KS_DOWN_BIT;
       Msg.message = SwapBtnMsg[0][SwapButtons];
       CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
       Msg.wParam |= CurInfo->ButtonsDown;
@@ -1162,7 +1162,7 @@
    }
    else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
    {
-      gQueueKeyStateTable[VK_LBUTTON] &= ~0x80;
+      gKeyStateTable[VK_LBUTTON] &= ~KS_DOWN_BIT;
       Msg.message = SwapBtnMsg[1][SwapButtons];
       CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
       Msg.wParam |= CurInfo->ButtonsDown;
@@ -1170,7 +1170,7 @@
    }
    if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
    {
-      gQueueKeyStateTable[VK_MBUTTON] |= 0xc0;
+      gKeyStateTable[VK_MBUTTON] |= KS_DOWN_BIT;
       Msg.message = WM_MBUTTONDOWN;
       CurInfo->ButtonsDown |= MK_MBUTTON;
       Msg.wParam |= CurInfo->ButtonsDown;
@@ -1178,7 +1178,7 @@
    }
    else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
    {
-      gQueueKeyStateTable[VK_MBUTTON] &= ~0x80;
+      gKeyStateTable[VK_MBUTTON] &= ~KS_DOWN_BIT;
       Msg.message = WM_MBUTTONUP;
       CurInfo->ButtonsDown &= ~MK_MBUTTON;
       Msg.wParam |= CurInfo->ButtonsDown;
@@ -1186,7 +1186,7 @@
    }
    if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
    {
-      gQueueKeyStateTable[VK_RBUTTON] |= 0xc0;
+      gKeyStateTable[VK_RBUTTON] |= KS_DOWN_BIT;
       Msg.message = SwapBtnMsg[0][!SwapButtons];
       CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
       Msg.wParam |= CurInfo->ButtonsDown;
@@ -1194,7 +1194,7 @@
    }
    else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
    {
-      gQueueKeyStateTable[VK_RBUTTON] &= ~0x80;
+      gKeyStateTable[VK_RBUTTON] &= ~KS_DOWN_BIT;
       Msg.message = SwapBtnMsg[1][!SwapButtons];
       CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
       Msg.wParam |= CurInfo->ButtonsDown;
@@ -1213,14 +1213,14 @@
       Msg.message = WM_XBUTTONDOWN;
       if(mi->mouseData & XBUTTON1)
       {
-         gQueueKeyStateTable[VK_XBUTTON1] |= 0xc0;
+         gKeyStateTable[VK_XBUTTON1] |= KS_DOWN_BIT;
          CurInfo->ButtonsDown |= MK_XBUTTON1;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
          co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
       }
       if(mi->mouseData & XBUTTON2)
       {
-         gQueueKeyStateTable[VK_XBUTTON2] |= 0xc0;
+         gKeyStateTable[VK_XBUTTON2] |= KS_DOWN_BIT;
          CurInfo->ButtonsDown |= MK_XBUTTON2;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
          co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
@@ -1231,14 +1231,14 @@
       Msg.message = WM_XBUTTONUP;
       if(mi->mouseData & XBUTTON1)
       {
-         gQueueKeyStateTable[VK_XBUTTON1] &= ~0x80;
+         gKeyStateTable[VK_XBUTTON1] &= ~KS_DOWN_BIT;
          CurInfo->ButtonsDown &= ~MK_XBUTTON1;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
          co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
       }
       if(mi->mouseData & XBUTTON2)
       {
-         gQueueKeyStateTable[VK_XBUTTON2] &= ~0x80;
+         gKeyStateTable[VK_XBUTTON2] &= ~KS_DOWN_BIT;
          CurInfo->ButtonsDown &= ~MK_XBUTTON2;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
          co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
@@ -1315,9 +1315,9 @@
    if (ki->dwFlags & KEYEVENTF_KEYUP)
    {
       Msg.message = WM_KEYUP;
-      if (((gQueueKeyStateTable[VK_MENU] & 0x80) &&
+      if (((gKeyStateTable[VK_MENU] & KS_DOWN_BIT) &&
           ((wVkStripped == VK_MENU) || (wVkStripped == VK_CONTROL)
-           || !(gQueueKeyStateTable[VK_CONTROL] & 0x80)))
+           || !(gKeyStateTable[VK_CONTROL] & KS_DOWN_BIT)))
           || (wVkStripped == VK_F10))
       {
          if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
@@ -1330,14 +1330,14 @@
    else
    {
       Msg.message = WM_KEYDOWN;
-      if (((gQueueKeyStateTable[VK_MENU] & 0x80 || wVkStripped == VK_MENU) &&
-          !(gQueueKeyStateTable[VK_CONTROL] & 0x80 || wVkStripped == VK_CONTROL))
+      if (((gKeyStateTable[VK_MENU] & KS_DOWN_BIT || wVkStripped == VK_MENU) &&
+          !(gKeyStateTable[VK_CONTROL] & KS_DOWN_BIT || wVkStripped == VK_CONTROL))
           || (wVkStripped == VK_F10))
       {
          Msg.message = WM_SYSKEYDOWN;
          TrackSysKey = wVkStripped;
       }
-      if (!(ki->dwFlags & KEYEVENTF_UNICODE) && gQueueKeyStateTable[wVk] & 0x80) flags |= KF_REPEAT;
+      if (!(ki->dwFlags & KEYEVENTF_UNICODE) && gKeyStateTable[wVk] & KS_DOWN_BIT) flags |= KF_REPEAT;
    }
 
    if (ki->dwFlags & KEYEVENTF_UNICODE)
@@ -1350,17 +1350,17 @@
    {
       if (ki->dwFlags & KEYEVENTF_KEYUP)
       {
-         gQueueKeyStateTable[wVk] &= ~0x80;
-         gQueueKeyStateTable[wVkStripped] = gQueueKeyStateTable[wVkL] | gQueueKeyStateTable[wVkR];
+         gKeyStateTable[wVk] &= ~KS_DOWN_BIT;
+         gKeyStateTable[wVkStripped] = gKeyStateTable[wVkL] | gKeyStateTable[wVkR];
       }
       else
       {
-         if (!(gQueueKeyStateTable[wVk] & 0x80)) gQueueKeyStateTable[wVk] ^= 0x01;
-         gQueueKeyStateTable[wVk] |= 0xc0;
-         gQueueKeyStateTable[wVkStripped] = gQueueKeyStateTable[wVkL] | gQueueKeyStateTable[wVkR];
-      }
-
-      if (gQueueKeyStateTable[VK_MENU] & 0x80) flags |= KF_ALTDOWN;
+         if (!(gKeyStateTable[wVk] & KS_DOWN_BIT)) gKeyStateTable[wVk] ^= KS_LOCK_BIT;
+         gKeyStateTable[wVk] |= KS_DOWN_BIT;
+         gKeyStateTable[wVkStripped] = gKeyStateTable[wVkL] | gKeyStateTable[wVkR];
+      }
+
+      if (gKeyStateTable[VK_MENU] & KS_DOWN_BIT) flags |= KF_ALTDOWN;
 
       if (wVkStripped == VK_SHIFT) flags &= ~KF_EXTENDED;
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c?rev=53655&r1=53654&r2=53655&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] Fri Sep  9 13:11:44 2011
@@ -32,7 +32,7 @@
 
 DBG_DEFAULT_CHANNEL(UserKbd);
 
-BYTE gQueueKeyStateTable[256];
+BYTE gKeyStateTable[0x100];
 
 /* FUNCTIONS *****************************************************************/
 
@@ -42,7 +42,7 @@
 NTAPI
 InitKeyboardImpl(VOID)
 {
-   RtlZeroMemory(&gQueueKeyStateTable,0x100);
+   RtlZeroMemory(&gKeyStateTable, 0x100);
    return STATUS_SUCCESS;
 }
 
@@ -69,7 +69,7 @@
    if (vk == VK_CAPITAL || vk == VK_NUMLOCK)
    {
       if (down)
-         gQueueKeyStateTable[vk] ^= KS_LOCK_BIT;
+         gKeyStateTable[vk] ^= KS_LOCK_BIT;
    }
 
    if (vk == VK_SHIFT)
@@ -80,46 +80,46 @@
       vk = ext ? VK_RMENU : VK_LMENU;
 
    if (down)
-      gQueueKeyStateTable[vk] |= KS_DOWN_BIT;
+      gKeyStateTable[vk] |= KS_DOWN_BIT;
    else
-      gQueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
+      gKeyStateTable[vk] &= ~KS_DOWN_BIT;
 
    if (vk == VK_LSHIFT || vk == VK_RSHIFT)
    {
-      if ((gQueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
-            (gQueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
-      {
-         gQueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
+      if ((gKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
+            (gKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
+      {
+         gKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
       }
       else
       {
-         gQueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
+         gKeyStateTable[VK_SHIFT] &= ~KS_DOWN_BIT;
       }
    }
 
    if (vk == VK_LCONTROL || vk == VK_RCONTROL)
    {
-      if ((gQueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
-            (gQueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
-      {
-         gQueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
+      if ((gKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
+            (gKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
+      {
+         gKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
       }
       else
       {
-         gQueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
+         gKeyStateTable[VK_CONTROL] &= ~KS_DOWN_BIT;
       }
    }
 
    if (vk == VK_LMENU || vk == VK_RMENU)
    {
-      if ((gQueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
-            (gQueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
-      {
-         gQueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
+      if ((gKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
+            (gKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
+      {
+         gKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
       }
       else
       {
-         gQueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK;
+         gKeyStateTable[VK_MENU] &= ~KS_DOWN_BIT;
       }
    }
 }
@@ -338,8 +338,8 @@
 
    if( key < 0x100 )
    {
-      ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
-            (gQueueKeyStateTable[key] & KS_LOCK_BIT);
+      ret = ((DWORD)(gKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
+            (gKeyStateTable[key] & KS_LOCK_BIT);
       if ( ret & 0x8000 )
          ret |= 0xFFFF0000; // If down, windows returns 0xFFFF8000.
    }
@@ -359,19 +359,19 @@
 
     if (gpsi->aiSysMet[SM_SWAPBUTTON])
     {
-        if (gQueueKeyStateTable[VK_RBUTTON] & 0x80) ret |= MK_LBUTTON;
-        if (gQueueKeyStateTable[VK_LBUTTON] & 0x80) ret |= MK_RBUTTON;
+        if (gKeyStateTable[VK_RBUTTON] & KS_DOWN_BIT) ret |= MK_LBUTTON;
+        if (gKeyStateTable[VK_LBUTTON] & KS_DOWN_BIT) ret |= MK_RBUTTON;
     }
     else
     {
-        if (gQueueKeyStateTable[VK_LBUTTON] & 0x80) ret |= MK_LBUTTON;
-        if (gQueueKeyStateTable[VK_RBUTTON] & 0x80) ret |= MK_RBUTTON;
+        if (gKeyStateTable[VK_LBUTTON] & KS_DOWN_BIT) ret |= MK_LBUTTON;
+        if (gKeyStateTable[VK_RBUTTON] & KS_DOWN_BIT) ret |= MK_RBUTTON;
     }
-    if (gQueueKeyStateTable[VK_MBUTTON]  & 0x80) ret |= MK_MBUTTON;
-    if (gQueueKeyStateTable[VK_SHIFT]    & 0x80) ret |= MK_SHIFT;
-    if (gQueueKeyStateTable[VK_CONTROL]  & 0x80) ret |= MK_CONTROL;
-    if (gQueueKeyStateTable[VK_XBUTTON1] & 0x80) ret |= MK_XBUTTON1;
-    if (gQueueKeyStateTable[VK_XBUTTON2] & 0x80) ret |= MK_XBUTTON2;
+    if (gKeyStateTable[VK_MBUTTON]  & KS_DOWN_BIT) ret |= MK_MBUTTON;
+    if (gKeyStateTable[VK_SHIFT]    & KS_DOWN_BIT) ret |= MK_SHIFT;
+    if (gKeyStateTable[VK_CONTROL]  & KS_DOWN_BIT) ret |= MK_CONTROL;
+    if (gKeyStateTable[VK_XBUTTON1] & KS_DOWN_BIT) ret |= MK_XBUTTON1;
+    if (gKeyStateTable[VK_XBUTTON2] & KS_DOWN_BIT) ret |= MK_XBUTTON2;
     return ret;
 }
 
@@ -443,7 +443,7 @@
 
    UState = ToUnicodeInner( lpMsg->wParam,
                             HIWORD(lpMsg->lParam) & 0xff,
-                            gQueueKeyStateTable,
+                            gKeyStateTable,
                             wp,
                             2,
                             0,
@@ -850,7 +850,7 @@
 
    /* arty -- handle numpad -- On real windows, the actual key produced
     * by the messaging layer is different based on the state of numlock. */
-   ModifierBits = ModBits(KeyboardLayout,gQueueKeyStateTable);
+   ModifierBits = ModBits(KeyboardLayout,gKeyStateTable);
 
    /* Get the raw scan code, so we can look up whether the key is a numpad
     * key
@@ -934,7 +934,7 @@
    }
 
    /* We need to unset SYSKEYDOWN if the ALT key is an ALT+Gr */
-   if( gQueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT )
+   if( gKeyStateTable[VK_RMENU] & KS_DOWN_BIT )
    {
       if( Msg->message == WM_SYSKEYDOWN )
          Msg->message = WM_KEYDOWN;




More information about the Ros-diffs mailing list