[Bf-blender-cvs] [ecda118be40] master: Fix T101866: Incorrect buttons for space-mouse enterprise

Campbell Barton noreply at git.blender.org
Wed Oct 19 04:55:23 CEST 2022


Commit: ecda118be407163096641db36b6ee8bf1d88ee55
Author: Campbell Barton
Date:   Wed Oct 19 12:52:58 2022 +1100
Branches: master
https://developer.blender.org/rBecda118be407163096641db36b6ee8bf1d88ee55

Fix T101866: Incorrect buttons for space-mouse enterprise

Use key from spacenavd's wiki.

Also add keys: ENTER, DELETE, TAB, SPACE & Views 1-3.

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

M	intern/ghost/intern/GHOST_NDOFManager.cpp
M	intern/ghost/intern/GHOST_NDOFManager.h
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/wm_event_types.h

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

diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index f4c726c7450..2754b9c8a6f 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -53,11 +53,6 @@ static const char *ndof_button_names[] = {
     "NDOF_BUTTON_DOMINANT",
     "NDOF_BUTTON_PLUS",
     "NDOF_BUTTON_MINUS",
-    /* keyboard emulation */
-    "NDOF_BUTTON_ESC",
-    "NDOF_BUTTON_ALT",
-    "NDOF_BUTTON_SHIFT",
-    "NDOF_BUTTON_CTRL",
     /* general-purpose buttons */
     "NDOF_BUTTON_1",
     "NDOF_BUTTON_2",
@@ -73,6 +68,19 @@ static const char *ndof_button_names[] = {
     "NDOF_BUTTON_A",
     "NDOF_BUTTON_B",
     "NDOF_BUTTON_C",
+    /* Stored views. */
+    "NDOF_BUTTON_V1",
+    "NDOF_BUTTON_V2",
+    "NDOF_BUTTON_V3",
+    /* Keyboard emulation. */
+    "NDOF_BUTTON_ESC",
+    "NDOF_BUTTON_ENTER",
+    "NDOF_BUTTON_DELETE",
+    "NDOF_BUTTON_TAB",
+    "NDOF_BUTTON_SPACE",
+    "NDOF_BUTTON_ALT",
+    "NDOF_BUTTON_SHIFT",
+    "NDOF_BUTTON_CTRL",
     /* the end */
     "NDOF_BUTTON_LAST",
 };
@@ -134,6 +142,41 @@ static const NDOF_ButtonT Generic_HID_map[] = {
     NDOF_BUTTON_C,
 };
 
+/* Values taken from: https://github.com/FreeSpacenav/spacenavd/wiki/Device-button-names */
+static const NDOF_ButtonT SpaceMouseEnterprise_HID_map[] = {
+    NDOF_BUTTON_1,       /* (0) */
+    NDOF_BUTTON_2,       /* (1) */
+    NDOF_BUTTON_3,       /* (2) */
+    NDOF_BUTTON_4,       /* (3) */
+    NDOF_BUTTON_5,       /* (4) */
+    NDOF_BUTTON_6,       /* (5) */
+    NDOF_BUTTON_7,       /* (6) */
+    NDOF_BUTTON_8,       /* (7) */
+    NDOF_BUTTON_9,       /* (8) */
+    NDOF_BUTTON_A,       /* Labeled "10" (9). */
+    NDOF_BUTTON_B,       /* Labeled "11" (10). */
+    NDOF_BUTTON_C,       /* Labeled "12" (11). */
+    NDOF_BUTTON_MENU,    /* (12). */
+    NDOF_BUTTON_FIT,     /* (13). */
+    NDOF_BUTTON_TOP,     /* (14). */
+    NDOF_BUTTON_RIGHT,   /* (15). */
+    NDOF_BUTTON_FRONT,   /* (16). */
+    NDOF_BUTTON_ROLL_CW, /* (17). */
+    NDOF_BUTTON_ESC,     /* (18). */
+    NDOF_BUTTON_ALT,     /* (19). */
+    NDOF_BUTTON_SHIFT,   /* (20). */
+    NDOF_BUTTON_CTRL,    /* (21). */
+    NDOF_BUTTON_ROTATE,  /* Labeled "Lock Rotate" (22). */
+    NDOF_BUTTON_ENTER,   /* Labeled "Enter" (23). */
+    NDOF_BUTTON_DELETE,  /* (24). */
+    NDOF_BUTTON_TAB,     /* (25). */
+    NDOF_BUTTON_SPACE,   /* (26). */
+    NDOF_BUTTON_V1,      /* Labeled "V1" (27). */
+    NDOF_BUTTON_V2,      /* Labeled "V2" (28). */
+    NDOF_BUTTON_V3,      /* Labeled "V3" (29). */
+    NDOF_BUTTON_ISO1,    /* Labeled "ISO1" (30). */
+};
+
 static const int genericButtonCount = ARRAY_SIZE(Generic_HID_map);
 
 GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys)
@@ -257,7 +300,7 @@ bool GHOST_NDOFManager::setDevice(ushort vendor_id, ushort product_id)
           puts("ndof: using SpaceMouse Enterprise");
           m_deviceType = NDOF_SpaceMouseEnterprise;
           m_buttonCount = 31;
-          m_hidMap = Modern3Dx_HID_map;
+          m_hidMap = SpaceMouseEnterprise_HID_map;
           break;
 
         default:
@@ -314,6 +357,18 @@ static GHOST_TKey ghost_map_keyboard_from_ndof_buttom(const NDOF_ButtonT button)
     case NDOF_BUTTON_ESC: {
       return GHOST_kKeyEsc;
     }
+    case NDOF_BUTTON_ENTER: {
+      return GHOST_kKeyEnter;
+    }
+    case NDOF_BUTTON_DELETE: {
+      return GHOST_kKeyDelete;
+    }
+    case NDOF_BUTTON_TAB: {
+      return GHOST_kKeyTab;
+    }
+    case NDOF_BUTTON_SPACE: {
+      return GHOST_kKeySpace;
+    }
     case NDOF_BUTTON_ALT: {
       return GHOST_kKeyLeftAlt;
     }
diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h
index 73c1b17f891..58371826527 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.h
+++ b/intern/ghost/intern/GHOST_NDOFManager.h
@@ -58,11 +58,6 @@ typedef enum {
   NDOF_BUTTON_DOMINANT,
   NDOF_BUTTON_PLUS,
   NDOF_BUTTON_MINUS,
-  /* Keyboard emulation. */
-  NDOF_BUTTON_ESC,
-  NDOF_BUTTON_ALT,
-  NDOF_BUTTON_SHIFT,
-  NDOF_BUTTON_CTRL,
   /* General-purpose buttons.
    * Users can assign functions via keymap editor. */
   NDOF_BUTTON_1,
@@ -79,6 +74,19 @@ typedef enum {
   NDOF_BUTTON_A,
   NDOF_BUTTON_B,
   NDOF_BUTTON_C,
+  /* Store Views. */
+  NDOF_BUTTON_V1,
+  NDOF_BUTTON_V2,
+  NDOF_BUTTON_V3,
+  /* Keyboard emulation. */
+  NDOF_BUTTON_ESC,
+  NDOF_BUTTON_ENTER,
+  NDOF_BUTTON_DELETE,
+  NDOF_BUTTON_TAB,
+  NDOF_BUTTON_SPACE,
+  NDOF_BUTTON_ALT,
+  NDOF_BUTTON_SHIFT,
+  NDOF_BUTTON_CTRL,
   /* The end. */
   NDOF_BUTTON_LAST
 } NDOF_ButtonT;
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 5b5544120a1..eebe595820e 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -99,13 +99,6 @@ static const EnumPropertyItem event_ndof_type_items[] = {
     {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "Dominant", ""},
     {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "Plus", ""},
     {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "Minus", ""},
-#  if 0 /* Never used (converted to keyboard events by GHOST). */
-    /* keyboard emulation */
-    {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "Esc"},
-    {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "Alt"},
-    {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "Shift"},
-    {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "Ctrl"},
-#  endif
     /* general-purpose buttons */
     {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "Button 1", ""},
     {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "Button 2", ""},
@@ -120,6 +113,21 @@ static const EnumPropertyItem event_ndof_type_items[] = {
     {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "Button A", ""},
     {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "Button B", ""},
     {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "Button C", ""},
+    /* View buttons. */
+    {NDOF_BUTTON_V1, "NDOF_BUTTON_V1", 0, "View 1", ""},
+    {NDOF_BUTTON_V2, "NDOF_BUTTON_V2", 0, "View 2", ""},
+    {NDOF_BUTTON_V3, "NDOF_BUTTON_V3", 0, "View 3", ""},
+#  if 0 /* Never used (converted to keyboard events by GHOST). */
+    /* keyboard emulation */
+    {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "Esc"},
+    {NDOF_BUTTON_ENTER, "NDOF_BUTTON_ENTER", 0, "Enter"},
+    {NDOF_BUTTON_DELETE, "NDOF_BUTTON_DELETE", 0, "Delete"},
+    {NDOF_BUTTON_TAB, "NDOF_BUTTON_TAB", 0, "Tab"},
+    {NDOF_BUTTON_SPACE, "NDOF_BUTTON_SPACE", 0, "Space"},
+    {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "Alt"},
+    {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "Shift"},
+    {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "Ctrl"},
+#  endif
     {0, NULL, 0, NULL, NULL},
 };
 #endif /* RNA_RUNTIME */
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 405b7225bd5..10536a00501 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -281,35 +281,42 @@ enum {
   NDOF_BUTTON_DOMINANT = 0x01a3, /* 419 */
   NDOF_BUTTON_PLUS = 0x01a4,     /* 420 */
   NDOF_BUTTON_MINUS = 0x01a5,    /* 421 */
+  /* General-purpose buttons. */
+  NDOF_BUTTON_1 = 0x01a6,  /* 422 */
+  NDOF_BUTTON_2 = 0x01a7,  /* 423 */
+  NDOF_BUTTON_3 = 0x01a8,  /* 424 */
+  NDOF_BUTTON_4 = 0x01a9,  /* 425 */
+  NDOF_BUTTON_5 = 0x01aa,  /* 426 */
+  NDOF_BUTTON_6 = 0x01ab,  /* 427 */
+  NDOF_BUTTON_7 = 0x01ac,  /* 428 */
+  NDOF_BUTTON_8 = 0x01ad,  /* 429 */
+  NDOF_BUTTON_9 = 0x01ae,  /* 430 */
+  NDOF_BUTTON_10 = 0x01af, /* 431 */
+  /* more general-purpose buttons */
+  NDOF_BUTTON_A = 0x01b0, /* 432 */
+  NDOF_BUTTON_B = 0x01b1, /* 433 */
+  NDOF_BUTTON_C = 0x01b2, /* 434 */
+  /* Store/restore views. */
+  NDOF_BUTTON_V1 = 0x01b3, /* 435 */
+  NDOF_BUTTON_V2 = 0x01b4, /* 436 */
+  NDOF_BUTTON_V3 = 0x01b5, /* 437 */
 
 /* Disabled as GHOST converts these to keyboard events
  * which use regular keyboard event handling logic. */
 #if 0
   /* keyboard emulation */
-  NDOF_BUTTON_ESC = 0x01a6,   /* 422 */
-  NDOF_BUTTON_ALT = 0x01a7,   /* 423 */
-  NDOF_BUTTON_SHIFT = 0x01a8, /* 424 */
-  NDOF_BUTTON_CTRL = 0x01a9,  /* 425 */
+  NDOF_BUTTON_ESC = 0x01b6,    /* 438 */
+  NDOF_BUTTON_ENTER = 0x01b7,  /* 439 */
+  NDOF_BUTTON_DELETE = 0x01b8, /* 440 */
+  NDOF_BUTTON_TAB = 0x01b9,    /* 441 */
+  NDOF_BUTTON_SPACE = 0x01ba,  /* 442 */
+  NDOF_BUTTON_ALT = 0x01bb,    /* 443 */
+  NDOF_BUTTON_SHIFT = 0x01bc,  /* 444 */
+  NDOF_BUTTON_CTRL = 0x01bd,   /* 445 */
 #endif
 
-  /* general-purpose buttons */
-  NDOF_BUTTON_1 = 0x01aa,  /* 426 */
-  NDOF_BUTTON_2 = 0x01ab,  /* 427 */
-  NDOF_BUTTON_3 = 0x01ac,  /* 428 */
-  NDOF_BUTTON_4 = 0x01ad,  /* 429 */
-  NDOF_BUTTON_5 = 0x01ae,  /* 430 */
-  NDOF_BUTTON_6 = 0x01af,  /* 431 */
-  NDOF_BUTTON_7 = 0x01b0,  /* 432 */
-  NDOF_BUTTON_8 = 0x01b1,  /* 433 */
-  NDOF_BUTTON_9 = 0x01b2,  /* 434 */
-  NDOF_BUTTON_10 = 0x01b3, /* 435 */
-  /* more general-purpose buttons */
-  NDOF_BUTTON_A = 0x01b4, /* 436 */
-  NDOF_BUTTON_B = 0x01b5, /* 437 */
-  NDOF_BUTTON_C = 0x01b6, /* 438 */
-
-#define _NDOF_MAX NDOF_BUTTON_C
-#define _NDOF_BUTTON_MAX NDOF_BUTTON_C
+#define _NDOF_MAX NDOF_BUTTON_V3
+#define _NDOF_BUTTON_MAX NDOF_BUTTON_V3
 
   /* ********** End of Input devices. ********** */



More information about the Bf-blender-cvs mailing list