[Bf-blender-cvs] [4ee4b61dd8d] blender-v3.1-release: Ghost/Event System: Support mapping more keys

Germano Cavalcante noreply at git.blender.org
Sat Feb 26 21:56:57 CET 2022


Commit: 4ee4b61dd8d372358606441f450df02a6e27d563
Author: Germano Cavalcante
Date:   Sat Feb 26 17:42:19 2022 -0300
Branches: blender-v3.1-release
https://developer.blender.org/rB4ee4b61dd8d372358606441f450df02a6e27d563

Ghost/Event System: Support mapping more keys

This fixes T93051, T76405 and maybe others.

Characters like '²', '<' are not recognized in Blender's shortcut keys.
And sometimes simple buttons like {key .} and {key /} on the Windows
keyboard, although the symbol is "known", Blender also doesn't
detect for shortcuts.

For Windows, some of the symbols represented by `VK_OEM_[1-8]` values,
depending on the language, are not mapped by Blender.

On Mac there is a fallback reading the "actual character value of the
'remappable' keys". But sometimes the character is not mapped either.

On Windows, the solution now mimics the Mac and tries to read the button's
character as a fallback.

For unmapped characters ('²', '<', '\''), now another value is chosen as a
substitute.

More "substitutes" may be added over time.

Differential Revision: https://developer.blender.org/D14149

===================================================================

M	intern/ghost/intern/GHOST_SystemCocoa.mm
M	intern/ghost/intern/GHOST_SystemWin32.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index b92c3e73a88..a53c3d8f2ab 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -323,6 +323,7 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
           case ']':
             return GHOST_kKeyRightBracket;
           case '`':
+          case '<': /* The position of '`' is equivalent to this symbol in the French layout. */
             return GHOST_kKeyAccentGrave;
           default:
             return GHOST_kKeyUnknown;
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 5251dd01b29..9b5994ae5e7 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -69,9 +69,6 @@
 #ifndef VK_COMMA
 #  define VK_COMMA 0xBC
 #endif  // VK_COMMA
-#ifndef VK_QUOTE
-#  define VK_QUOTE 0xDE
-#endif  // VK_QUOTE
 #ifndef VK_BACK_QUOTE
 #  define VK_BACK_QUOTE 0xC0
 #endif  // VK_BACK_QUOTE
@@ -646,14 +643,32 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw,
 GHOST_TKey GHOST_SystemWin32::processSpecialKey(short vKey, short scanCode) const
 {
   GHOST_TKey key = GHOST_kKeyUnknown;
-  switch (PRIMARYLANGID(m_langId)) {
-    case LANG_FRENCH:
-      if (vKey == VK_OEM_8)
-        key = GHOST_kKeyF13;  // oem key; used purely for shortcuts .
+  char ch = (char)MapVirtualKeyA(vKey, MAPVK_VK_TO_CHAR);
+  switch (ch) {
+    case u'\"':
+    case u'\'':
+      key = GHOST_kKeyQuote;
       break;
-    case LANG_ENGLISH:
-      if (SUBLANGID(m_langId) == SUBLANG_ENGLISH_UK && vKey == VK_OEM_8)  // "`¬"
-        key = GHOST_kKeyAccentGrave;
+    case u'.':
+      key = GHOST_kKeyNumpadPeriod;
+      break;
+    case u'/':
+      key = GHOST_kKeySlash;
+      break;
+    case u'`':
+    case u'²':
+      key = GHOST_kKeyAccentGrave;
+      break;
+    default:
+      if (vKey == VK_OEM_7) {
+        key = GHOST_kKeyQuote;
+      }
+      else if (vKey == VK_OEM_8) {
+        if (PRIMARYLANGID(m_langId) == LANG_FRENCH) {
+          /* oem key; used purely for shortcuts. */
+          key = GHOST_kKeyF13;
+        }
+      }
       break;
   }
 
@@ -788,9 +803,6 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
       case VK_CLOSE_BRACKET:
         key = GHOST_kKeyRightBracket;
         break;
-      case VK_QUOTE:
-        key = GHOST_kKeyQuote;
-        break;
       case VK_GR_LESS:
         key = GHOST_kKeyGrLess;
         break;
@@ -832,9 +844,6 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
       case VK_CAPITAL:
         key = GHOST_kKeyCapsLock;
         break;
-      case VK_OEM_8:
-        key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode);
-        break;
       case VK_MEDIA_PLAY_PAUSE:
         key = GHOST_kKeyMediaPlay;
         break;
@@ -847,8 +856,10 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
       case VK_MEDIA_NEXT_TRACK:
         key = GHOST_kKeyMediaLast;
         break;
+      case VK_OEM_7:
+      case VK_OEM_8:
       default:
-        key = GHOST_kKeyUnknown;
+        key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode);
         break;
     }
   }



More information about the Bf-blender-cvs mailing list