[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31955] trunk/blender/intern/ghost: Partial fix [#21395] Command key for keyboard mapping not functional

Nathan Letwory nathan at letworyinteractive.com
Thu Sep 16 01:19:21 CEST 2010


Revision: 31955
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31955
Author:   jesterking
Date:     2010-09-16 01:19:21 +0200 (Thu, 16 Sep 2010)

Log Message:
-----------
Partial fix [#21395] Command key for keyboard mapping not functional
Reported by Andy Braham.

Handle VK_LWIN and VK_RWIN (The infamous Windows keys). Note, these are not separate, so handled as one command key.

Modified Paths:
--------------
    trunk/blender/intern/ghost/GHOST_Types.h
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp

Modified: trunk/blender/intern/ghost/GHOST_Types.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_Types.h	2010-09-15 19:03:52 UTC (rev 31954)
+++ trunk/blender/intern/ghost/GHOST_Types.h	2010-09-15 23:19:21 UTC (rev 31955)
@@ -283,8 +283,8 @@
 	GHOST_kKeyRightControl,
 	GHOST_kKeyLeftAlt,
 	GHOST_kKeyRightAlt,
-    GHOST_kKeyCommand,				// APPLE only!
-    GHOST_kKeyGrLess ,		// German PC only!
+	GHOST_kKeyCommand,		// Command key on Apple, Windows key(s) on Windows
+	GHOST_kKeyGrLess ,		// German PC only!
 
 	GHOST_kKeyCapsLock,
 	GHOST_kKeyNumLock,

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2010-09-15 19:03:52 UTC (rev 31954)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2010-09-15 23:19:21 UTC (rev 31955)
@@ -287,17 +287,6 @@
 
 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);
@@ -311,6 +300,12 @@
 		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;
@@ -322,6 +317,12 @@
 		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;
 }
@@ -376,8 +377,8 @@
 		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);
 		}
@@ -670,6 +671,8 @@
 						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) {
@@ -691,6 +694,10 @@
 											(HIBYTE(::GetKeyState(VK_RMENU)) != 0) ?
 											true : false;
 										break;
+									case VK_LWIN:
+									case VK_RWIN:
+										system->m_separateLeftRight = true;
+										break;
 								}
 								system->m_separateLeftRightInitialized = true;
 							}
@@ -714,6 +721,8 @@
 						case VK_SHIFT:
 						case VK_CONTROL:
 						case VK_MENU:
+						case VK_LWIN:
+						case VK_RWIN:
 							system->processModifierKeys(window);
 							// Bypass call to DefWindowProc
 							return 0;





More information about the Bf-blender-cvs mailing list