[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38884] branches/merwin-spacenav/intern/ ghost/intern: support for older SpacePilot (sans Pro), minor tidying
Mike Erwin
significant.bit at gmail.com
Mon Aug 1 00:59:37 CEST 2011
Revision: 38884
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38884
Author: merwin
Date: 2011-07-31 22:59:36 +0000 (Sun, 31 Jul 2011)
Log Message:
-----------
support for older SpacePilot (sans Pro), minor tidying
Modified Paths:
--------------
branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.cpp
branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.cpp 2011-07-31 16:26:02 UTC (rev 38883)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.cpp 2011-07-31 22:59:36 UTC (rev 38884)
@@ -139,6 +139,33 @@
NDOF_BUTTON_MINUS
};
+static const NDOF_ButtonT SpacePilot_HID_map[] =
+// this is the older SpacePilot (sans Pro)
+// thanks to polosson for the info in this table
+ {
+ NDOF_BUTTON_1,
+ NDOF_BUTTON_2,
+ NDOF_BUTTON_3,
+ NDOF_BUTTON_4,
+ NDOF_BUTTON_5,
+ NDOF_BUTTON_6,
+ NDOF_BUTTON_TOP,
+ NDOF_BUTTON_LEFT,
+ NDOF_BUTTON_RIGHT,
+ NDOF_BUTTON_FRONT,
+ NDOF_BUTTON_NONE, // esc key
+ NDOF_BUTTON_NONE, // alt key
+ NDOF_BUTTON_NONE, // shift key
+ NDOF_BUTTON_NONE, // ctrl key
+ NDOF_BUTTON_FIT,
+ NDOF_BUTTON_MENU,
+ NDOF_BUTTON_PLUS,
+ NDOF_BUTTON_MINUS,
+ NDOF_BUTTON_DOMINANT,
+ NDOF_BUTTON_ROTATE,
+ NDOF_BUTTON_NONE // the CONFIG button -- what does it do?
+ };
+
GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys)
: m_system(sys)
, m_deviceType(NDOF_UnknownDevice) // each platform has its own device detection code
@@ -159,6 +186,9 @@
bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short product_id)
{
+ // default to NDOF_UnknownDevice so rogue button events will get discarded
+ // "mystery device" owners can help build a HID_map for their hardware
+
switch (vendor_id)
{
case 0x046D: // Logitech (3Dconnexion)
@@ -187,16 +217,16 @@
break;
// -- older devices --
- // keep unknown device type so rogue button events will get discarded
- // "mystery device" owners can help build another HID_map for their hardware
+ case 0xC625:
+ puts("ndof: using SpacePilot");
+ m_deviceType = NDOF_SpacePilot;
+ m_buttonCount = 21;
+ break;
+
case 0xC623:
puts("ndof: SpaceTraveler not supported, please file a bug report");
m_buttonCount = 8;
break;
- case 0xC625:
- puts("ndof: SpacePilot not supported, please file a bug report");
- m_buttonCount = 21;
- break;
default:
printf("ndof: unknown Logitech product %04hx\n", product_id);
@@ -295,6 +325,17 @@
default: sendButtonEvent(SpacePilotPro_HID_map[button_number], press, time, window);
}
break;
+ case NDOF_SpacePilot:
+ switch (button_number)
+ {
+ case 10: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break;
+ case 11: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break;
+ case 12: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break;
+ case 13: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break;
+ case 20: puts("ndof: ignoring CONFIG button"); break;
+ default: sendButtonEvent(SpacePilot_HID_map[button_number], press, time, window);
+ }
+ break;
case NDOF_UnknownDevice:
printf("ndof: button %d on unknown device (ignoring)\n", button_number);
}
@@ -369,11 +410,11 @@
GHOST_EventNDOFMotion* event = new GHOST_EventNDOFMotion(m_motionTime, window);
GHOST_TEventNDOFMotionData* data = (GHOST_TEventNDOFMotionData*) event->getData();
+ // scale axis values here to normalize them to around +/- 1
+ // they are scaled again for overall sensitivity in the WM based on user prefs
+
const float scale = 1.f / 350.f; // 3Dconnexion devices send +/- 350 usually
- // probable future enhancement
- // scale *= U.ndof_sensitivity;
-
data->tx = scale * m_translation[0];
data->ty = scale * m_translation[1];
data->tz = scale * m_translation[2];
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h 2011-07-31 16:26:02 UTC (rev 38883)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h 2011-07-31 22:59:36 UTC (rev 38884)
@@ -32,9 +32,15 @@
typedef enum {
NDOF_UnknownDevice, // <-- motion will work fine, buttons are ignored
+
+ // current devices
NDOF_SpaceNavigator,
NDOF_SpaceExplorer,
- NDOF_SpacePilotPro
+ NDOF_SpacePilotPro,
+
+ // older devices
+ NDOF_SpacePilot
+
} NDOF_DeviceT;
// NDOF device button event types
@@ -69,7 +75,7 @@
NDOF_BUTTON_PLUS,
NDOF_BUTTON_MINUS,
// general-purpose buttons
- // TODO: expose these to keymap editor so users can assign functions
+ // users can assign functions via keymap editor
NDOF_BUTTON_1,
NDOF_BUTTON_2,
NDOF_BUTTON_3,
@@ -80,6 +86,7 @@
NDOF_BUTTON_8,
NDOF_BUTTON_9,
NDOF_BUTTON_10,
+
} NDOF_ButtonT;
class GHOST_NDOFManager
More information about the Bf-blender-cvs
mailing list