Partial fix [#21395] Command key for keyboard mapping not functional
[blender-staging.git] / intern / ghost / intern / GHOST_SystemWin32.cpp
index 33c7a7f15a2b9dbf2ab7618e5692c5c91c71304a..dceecb53dd2e69aad02d7d53aabf3c3c007441bb 100644 (file)
@@ -287,17 +287,6 @@ GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
 
 GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) const
 {
 
 GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) const
 {
-       /*
-       GetKeyState and GetAsyncKeyState only work with Win95, Win98, NT4,
-       Terminal Server and Windows 2000.
-       But on WinME it always returns zero. These two functions are simply
-       skipped by Millenium Edition!
-
-       Official explanation from Microsoft:
-       Intentionally disabled.
-       It didn't work all that well on some newer hardware, and worked less 
-       well with the passage of time, so it was fully disabled in ME.
-       */
        if (m_separateLeftRight && m_separateLeftRightInitialized) {
                bool down = HIBYTE(::GetKeyState(VK_LSHIFT)) != 0;
                keys.set(GHOST_kModifierKeyLeftShift, down);
        if (m_separateLeftRight && m_separateLeftRightInitialized) {
                bool down = HIBYTE(::GetKeyState(VK_LSHIFT)) != 0;
                keys.set(GHOST_kModifierKeyLeftShift, down);
@@ -311,6 +300,12 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons
                keys.set(GHOST_kModifierKeyLeftControl, down);
                down = HIBYTE(::GetKeyState(VK_RCONTROL)) != 0;
                keys.set(GHOST_kModifierKeyRightControl, down);
                keys.set(GHOST_kModifierKeyLeftControl, down);
                down = HIBYTE(::GetKeyState(VK_RCONTROL)) != 0;
                keys.set(GHOST_kModifierKeyRightControl, down);
+               bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
+               bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
+               if(lwindown || rwindown)
+                       keys.set(GHOST_kModifierKeyCommand, true);
+               else
+                       keys.set(GHOST_kModifierKeyCommand, false);
        }
        else {
                bool down = HIBYTE(::GetKeyState(VK_SHIFT)) != 0;
        }
        else {
                bool down = HIBYTE(::GetKeyState(VK_SHIFT)) != 0;
@@ -322,6 +317,12 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons
                down = HIBYTE(::GetKeyState(VK_CONTROL)) != 0;
                keys.set(GHOST_kModifierKeyLeftControl, down);
                keys.set(GHOST_kModifierKeyRightControl, down);
                down = HIBYTE(::GetKeyState(VK_CONTROL)) != 0;
                keys.set(GHOST_kModifierKeyLeftControl, down);
                keys.set(GHOST_kModifierKeyRightControl, down);
+               bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0;
+               bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0;
+               if(lwindown || rwindown)
+                       keys.set(GHOST_kModifierKeyCommand, true);
+               else
+                       keys.set(GHOST_kModifierKeyCommand, false);
        }
        return GHOST_kSuccess;
 }
        }
        return GHOST_kSuccess;
 }
@@ -376,8 +377,8 @@ GHOST_TSuccess GHOST_SystemWin32::init()
                wc.cbClsExtra= 0;
                wc.cbWndExtra= 0;
                wc.hInstance= ::GetModuleHandle(0);
                wc.cbClsExtra= 0;
                wc.cbWndExtra= 0;
                wc.hInstance= ::GetModuleHandle(0);
-               wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON");
-               
+               wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON");
+               
                if (!wc.hIcon) {
                        ::LoadIcon(NULL, IDI_APPLICATION);
                }
                if (!wc.hIcon) {
                        ::LoadIcon(NULL, IDI_APPLICATION);
                }
@@ -670,6 +671,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
                                                case VK_SHIFT:
                                                case VK_CONTROL:
                                                case VK_MENU:
                                                case VK_SHIFT:
                                                case VK_CONTROL:
                                                case VK_MENU:
+                                               case VK_LWIN:
+                                               case VK_RWIN:
                                                        if (!system->m_separateLeftRightInitialized) {
                                                                // Check whether this system supports separate left and right keys
                                                                switch (wParam) {
                                                        if (!system->m_separateLeftRightInitialized) {
                                                                // Check whether this system supports separate left and right keys
                                                                switch (wParam) {
@@ -691,6 +694,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
                                                                                        (HIBYTE(::GetKeyState(VK_RMENU)) != 0) ?
                                                                                        true : false;
                                                                                break;
                                                                                        (HIBYTE(::GetKeyState(VK_RMENU)) != 0) ?
                                                                                        true : false;
                                                                                break;
+                                                                       case VK_LWIN:
+                                                                       case VK_RWIN:
+                                                                               system->m_separateLeftRight = true;
+                                                                               break;
                                                                }
                                                                system->m_separateLeftRightInitialized = true;
                                                        }
                                                                }
                                                                system->m_separateLeftRightInitialized = true;
                                                        }
@@ -714,6 +721,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
                                                case VK_SHIFT:
                                                case VK_CONTROL:
                                                case VK_MENU:
                                                case VK_SHIFT:
                                                case VK_CONTROL:
                                                case VK_MENU:
+                                               case VK_LWIN:
+                                               case VK_RWIN:
                                                        system->processModifierKeys(window);
                                                        // Bypass call to DefWindowProc
                                                        return 0;
                                                        system->processModifierKeys(window);
                                                        // Bypass call to DefWindowProc
                                                        return 0;