[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43706] trunk/blender/intern/ghost/intern: added support for USB Spaceball5000, also a partial attempt to accept button presses from unidentified 3D mice (for ancient serial devices)

Mike Erwin significant.bit at gmail.com
Thu Jan 26 04:27:22 CET 2012


Revision: 43706
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43706
Author:   merwin
Date:     2012-01-26 03:27:10 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
added support for USB Spaceball5000, also a partial attempt to accept button presses from unidentified 3D mice (for ancient serial devices)

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-26 01:46:16 UTC (rev 43705)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp	2012-01-26 03:27:10 UTC (rev 43706)
@@ -77,6 +77,12 @@
 	"NDOF_BUTTON_8",
 	"NDOF_BUTTON_9",
 	"NDOF_BUTTON_10",
+	// more general-purpose buttons
+	"NDOF_BUTTON_A",
+	"NDOF_BUTTON_B",
+	"NDOF_BUTTON_C",
+	// the end
+	"NDOF_BUTTON_LAST"
 };
 #endif
 
@@ -169,7 +175,7 @@
 };
 
 /* this is the older SpacePilot (sans Pro)
- * thanks to polosson for the info in this table */
+ * thanks to polosson for info about this device */
 static const NDOF_ButtonT SpacePilot_HID_map[] = {
 	NDOF_BUTTON_1,
 	NDOF_BUTTON_2,
@@ -194,6 +200,23 @@
 	NDOF_BUTTON_NONE // the CONFIG button -- what does it do?
 };
 
+/* this is the older Spaceball 5000 USB
+ * thanks to Tehrasha Darkon for info about this device */
+static const NDOF_ButtonT Spaceball5000_HID_map[] = {
+	NDOF_BUTTON_1,
+	NDOF_BUTTON_2,
+	NDOF_BUTTON_3,
+	NDOF_BUTTON_4,
+	NDOF_BUTTON_5,
+	NDOF_BUTTON_6,
+	NDOF_BUTTON_7,
+	NDOF_BUTTON_8,
+	NDOF_BUTTON_9,
+	NDOF_BUTTON_A,
+	NDOF_BUTTON_B,
+	NDOF_BUTTON_C
+};
+
 GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys)
 	: m_system(sys)
 	, m_deviceType(NDOF_UnknownDevice) // each platform has its own device detection code
@@ -237,12 +260,12 @@
 					m_buttonCount = 15;
 					break;
 				case 0xC629:
-					puts("ndof: using SpacePilotPro");
+					puts("ndof: using SpacePilot Pro");
 					m_deviceType = NDOF_SpacePilotPro;
 					m_buttonCount = 31;
 					break;
 				case 0xC62B:
-					puts("ndof: using SpaceMousePro");
+					puts("ndof: using SpaceMouse Pro");
 					m_deviceType = NDOF_SpaceMousePro;
 					m_buttonCount = 27;
 					// ^^ actually has 15 buttons, but their HID codes range from 0 to 26
@@ -255,6 +278,12 @@
 					m_buttonCount = 21;
 					break;
 
+				case 0xC621:
+					puts("ndof: using Spaceball 5000");
+					m_deviceType = NDOF_Spaceball5000;
+					m_buttonCount = 12;
+					break;
+
 				case 0xC623:
 					puts("ndof: SpaceTraveler not supported, please file a bug report");
 					m_buttonCount = 8;
@@ -385,8 +414,21 @@
 				default: sendButtonEvent(SpacePilot_HID_map[button_number], press, time, window);
 			}
 			break;
+		case NDOF_Spaceball5000:
+			// has no special 'keyboard' buttons
+			sendButtonEvent(Spaceball5000_HID_map[button_number], press, time, window);
+			break;
 		case NDOF_UnknownDevice:
-			printf("ndof: button %d on unknown device (ignoring)\n", button_number);
+			printf("ndof: button %d on unknown device (", button_number);
+			// map to the 'general purpose' buttons
+			// this is mainly for old serial devices
+			if (button_number < NDOF_BUTTON_LAST - NDOF_BUTTON_1) {
+				printf("sending)\n");
+				sendButtonEvent((NDOF_ButtonT)(NDOF_BUTTON_1 + button_number), press, time, window);
+			}
+			else {
+				printf("discarding)\n");
+			}
 	}
 
 	int mask = 1 << button_number;

Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManager.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManager.h	2012-01-26 01:46:16 UTC (rev 43705)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.h	2012-01-26 03:27:10 UTC (rev 43706)
@@ -40,7 +40,8 @@
 	NDOF_SpaceMousePro,
 
 	// older devices
-	NDOF_SpacePilot
+	NDOF_SpacePilot,
+	NDOF_Spaceball5000
 
 	} NDOF_DeviceT;
 
@@ -87,7 +88,12 @@
 	NDOF_BUTTON_8,
 	NDOF_BUTTON_9,
 	NDOF_BUTTON_10,
-
+	// more general-purpose buttons
+	NDOF_BUTTON_A,
+	NDOF_BUTTON_B,
+	NDOF_BUTTON_C,
+	// the end
+	NDOF_BUTTON_LAST
 	} NDOF_ButtonT;
 
 class GHOST_NDOFManager




More information about the Bf-blender-cvs mailing list