[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43518] trunk/blender/intern/ghost/intern: added support for the 3Dconnexion SpaceMouse Pro -- tested on Linux w/ spacenavd, Macs need latest driver (Intel only (grumble)), Windows should be good as well but have not tested

Mike Erwin significant.bit at gmail.com
Thu Jan 19 07:14:57 CET 2012


Revision: 43518
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43518
Author:   merwin
Date:     2012-01-19 06:14:50 +0000 (Thu, 19 Jan 2012)
Log Message:
-----------
added support for the 3Dconnexion SpaceMouse Pro -- tested on Linux w/ spacenavd, Macs need latest driver (Intel only (grumble)), Windows should be good as well but have not tested

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

Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp	2012-01-19 04:13:58 UTC (rev 43517)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp	2012-01-19 06:14:50 UTC (rev 43518)
@@ -137,6 +137,37 @@
 	NDOF_BUTTON_MINUS
 };
 
+// latest HW: button-compatible with SpacePilotPro, just fewer of them
+static const NDOF_ButtonT SpaceMousePro_HID_map[] = {
+	NDOF_BUTTON_MENU,
+	NDOF_BUTTON_FIT,
+	NDOF_BUTTON_TOP,
+	NDOF_BUTTON_NONE, // left
+	NDOF_BUTTON_RIGHT,
+	NDOF_BUTTON_FRONT,
+	NDOF_BUTTON_NONE, // bottom
+	NDOF_BUTTON_NONE, // back
+	NDOF_BUTTON_ROLL_CW,
+	NDOF_BUTTON_NONE, // roll ccw
+	NDOF_BUTTON_NONE, // iso 1
+	NDOF_BUTTON_NONE, // iso 2
+	NDOF_BUTTON_1,
+	NDOF_BUTTON_2,
+	NDOF_BUTTON_3,
+	NDOF_BUTTON_4,
+	NDOF_BUTTON_NONE, // 5
+	NDOF_BUTTON_NONE, // 6
+	NDOF_BUTTON_NONE, // 7
+	NDOF_BUTTON_NONE, // 8
+	NDOF_BUTTON_NONE, // 9
+	NDOF_BUTTON_NONE, // 10
+	NDOF_BUTTON_NONE, // esc key
+	NDOF_BUTTON_NONE, // alt key
+	NDOF_BUTTON_NONE, // shift key
+	NDOF_BUTTON_NONE, // ctrl key
+	NDOF_BUTTON_ROTATE,
+};
+
 /* this is the older SpacePilot (sans Pro)
  * thanks to polosson for the info in this table */
 static const NDOF_ButtonT SpacePilot_HID_map[] = {
@@ -210,6 +241,12 @@
 					m_deviceType = NDOF_SpacePilotPro;
 					m_buttonCount = 31;
 					break;
+				case 0xC62B:
+					puts("ndof: using SpaceMousePro");
+					m_deviceType = NDOF_SpaceMousePro;
+					m_buttonCount = 27;
+					// ^^ actually has 15 buttons, but their HID codes range from 0 to 26
+					break;
 
 				// -- older devices --
 				case 0xC625:
@@ -237,6 +274,8 @@
 	else {
 		m_buttonMask = ~(-1 << m_buttonCount);
 
+		// special case for SpaceMousePro? maybe...
+
 #ifdef DEBUG_NDOF_BUTTONS
 		printf("ndof: %d buttons -> hex:%X\n", m_buttonCount, m_buttonMask);
 #endif
@@ -261,6 +300,16 @@
 
 void GHOST_NDOFManager::sendButtonEvent(NDOF_ButtonT button, bool press, GHOST_TUns64 time, GHOST_IWindow* window)
 {
+	if (button == NDOF_BUTTON_NONE) {
+		// just being exceptionally cautious...
+		// air-tight button masking and proper function key emulation
+		// should guarantee we never get to this point
+#ifdef DEBUG_NDOF_BUTTONS
+		printf("discarding NDOF_BUTTON_NONE (should not escape the NDOF manager)\n");
+#endif
+		return;
+	}
+
 	GHOST_EventNDOFButton* event = new GHOST_EventNDOFButton(time, window);
 	GHOST_TEventNDOFButtonData* data = (GHOST_TEventNDOFButtonData*) event->getData();
 
@@ -317,6 +366,15 @@
 				default: sendButtonEvent(SpacePilotPro_HID_map[button_number], press, time, window);
 			}
 			break;
+		case NDOF_SpaceMousePro:
+			switch (button_number) {
+				case 22: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break;
+				case 23: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break;
+				case 24: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break;
+				case 25: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break;
+				default: sendButtonEvent(SpaceMousePro_HID_map[button_number], press, time, window);
+			}
+			break;
 		case NDOF_SpacePilot:
 			switch (button_number) {
 				case 10: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break;

Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManager.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManager.h	2012-01-19 04:13:58 UTC (rev 43517)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.h	2012-01-19 06:14:50 UTC (rev 43518)
@@ -37,6 +37,7 @@
 	NDOF_SpaceNavigator,
 	NDOF_SpaceExplorer,
 	NDOF_SpacePilotPro,
+	NDOF_SpaceMousePro,
 
 	// older devices
 	NDOF_SpacePilot



More information about the Bf-blender-cvs mailing list