[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29889] branches/soc-2010-merwin/ experimental/SpaceNav app: updated SpaceNav demo: added MacOS10.4 support, rescaled input according to vendor recommendation, and (hopefully) fixed crash when driver not installed
Mike Erwin
significant.bit at gmail.com
Sat Jul 3 08:50:52 CEST 2010
Revision: 29889
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29889
Author: merwin
Date: 2010-07-03 08:50:52 +0200 (Sat, 03 Jul 2010)
Log Message:
-----------
updated SpaceNav demo: added MacOS10.4 support, rescaled input according to vendor recommendation, and (hopefully) fixed crash when driver not installed
Modified Paths:
--------------
branches/soc-2010-merwin/experimental/SpaceNav app/SpaceNav app.xcodeproj/project.pbxproj
branches/soc-2010-merwin/experimental/SpaceNav app/main.mm
branches/soc-2010-merwin/experimental/SpaceNav app/ndof-update.mm
Added Paths:
-----------
branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.c
branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.h
Modified: branches/soc-2010-merwin/experimental/SpaceNav app/SpaceNav app.xcodeproj/project.pbxproj
===================================================================
--- branches/soc-2010-merwin/experimental/SpaceNav app/SpaceNav app.xcodeproj/project.pbxproj 2010-07-03 06:34:07 UTC (rev 29888)
+++ branches/soc-2010-merwin/experimental/SpaceNav app/SpaceNav app.xcodeproj/project.pbxproj 2010-07-03 06:50:52 UTC (rev 29889)
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
+ 593EDBAF11DEEDDA00065A03 /* ndof-device.c in Sources */ = {isa = PBXBuildFile; fileRef = 593EDBAE11DEEDDA00065A03 /* ndof-device.c */; };
599A1D2011C0799E007494A9 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 599A1D1F11C0799E007494A9 /* main.mm */; };
599A1D2311C079C1007494A9 /* 3DconnexionClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 599A1D2211C079C1007494A9 /* 3DconnexionClient.framework */; };
59C97D8E11C7033200505960 /* ndof-update.mm in Sources */ = {isa = PBXBuildFile; fileRef = 59C97D8D11C7033200505960 /* ndof-update.mm */; };
@@ -26,6 +27,8 @@
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32CA4F630368D1EE00C91783 /* SpaceNav app_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SpaceNav app_Prefix.pch"; sourceTree = "<group>"; };
+ 593EDBAD11DEEDDA00065A03 /* ndof-device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ndof-device.h"; sourceTree = "<group>"; };
+ 593EDBAE11DEEDDA00065A03 /* ndof-device.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "ndof-device.c"; sourceTree = "<group>"; };
599A1D1F11C0799E007494A9 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
599A1D2211C079C1007494A9 /* 3DconnexionClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = 3DconnexionClient.framework; path = /Library/Frameworks/3DconnexionClient.framework; sourceTree = "<absolute>"; };
59C97D8C11C7033200505960 /* ndof-update.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ndof-update.h"; sourceTree = "<group>"; };
@@ -113,6 +116,8 @@
599A1D1F11C0799E007494A9 /* main.mm */,
59C97D8C11C7033200505960 /* ndof-update.h */,
59C97D8D11C7033200505960 /* ndof-update.mm */,
+ 593EDBAD11DEEDDA00065A03 /* ndof-device.h */,
+ 593EDBAE11DEEDDA00065A03 /* ndof-device.c */,
);
name = "Other Sources";
sourceTree = "<group>";
@@ -195,6 +200,7 @@
59C97D8E11C7033200505960 /* ndof-update.mm in Sources */,
59CE970F11C81E6100FFB428 /* SpaceNav3DView.mm in Sources */,
59CE978E11C9CC1A00FFB428 /* Vec3.cpp in Sources */,
+ 593EDBAF11DEEDDA00065A03 /* ndof-device.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: branches/soc-2010-merwin/experimental/SpaceNav app/main.mm
===================================================================
--- branches/soc-2010-merwin/experimental/SpaceNav app/main.mm 2010-07-03 06:34:07 UTC (rev 29888)
+++ branches/soc-2010-merwin/experimental/SpaceNav app/main.mm 2010-07-03 06:50:52 UTC (rev 29889)
@@ -10,6 +10,7 @@
#include <3DconnexionClient/ConnexionClientAPI.h>
#include <stdio.h>
#include "ndof-update.h"
+#include "ndof-device.h"
void SpaceNavAdded(io_connect_t connection)
{
@@ -73,14 +74,33 @@
}
}
-// extern OSErr InstallConnexionHandlers() __attribute__((weak_import));
-// [mce] C liked the above line, but Obj-C++ does not. Make sure it works for
-// machines without the driver installed! Try it on the QuickSilver.
-
int main(int argc, const char* argv[])
{
- if (InstallConnexionHandlers == NULL)
+ if (device_available())
{
+ OSErr error = InstallConnexionHandlers(SpaceNavEvent, SpaceNavAdded, SpaceNavRemoved);
+ if (error)
+ {
+ printf("<!> error = %d\n", error);
+ return -1;
+ }
+
+ UInt16 clientID = RegisterConnexionClient('Mike', (UInt8*)"\pMike's SpaceNav test",
+ kConnexionClientModeTakeOver, kConnexionMaskAll);
+
+ printf("client id = %d\n", clientID);
+
+ // wait for input...
+ // CFRunLoopRun();
+ NSApplicationMain(argc, argv);
+
+ // NSApplicationMain never returns, so these don't get called:
+ UnregisterConnexionClient(clientID);
+ CleanupConnexionHandlers();
+ return 0;
+ }
+ else
+ {
printf("<!> SpaceNav driver not found\n");
// This isn't a hard error, just means the user doesn't have a SpaceNavigator.
// Could check this before loading the plugin.
@@ -88,24 +108,4 @@
return -1;
}
- OSErr error = InstallConnexionHandlers(SpaceNavEvent, SpaceNavAdded, SpaceNavRemoved);
- if (error)
- {
- printf("<!> error = %d\n", error);
- return -1;
- }
-
- UInt16 clientID = RegisterConnexionClient('Mike', (UInt8*)"\pMike's SpaceNav test",
- kConnexionClientModeTakeOver, kConnexionMaskAll);
-
- printf("client id = %d\n", clientID);
-
- // wait for input...
- // CFRunLoopRun();
- NSApplicationMain(argc, argv);
-
- // NSApplicationMain never returns, so these don't get called:
- UnregisterConnexionClient(clientID);
- CleanupConnexionHandlers();
- return 0;
}
Added: branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.c
===================================================================
--- branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.c (rev 0)
+++ branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.c 2010-07-03 06:50:52 UTC (rev 29889)
@@ -0,0 +1,20 @@
+/*
+ * ndof-device.c
+ * SpaceNav app
+ *
+ * Created by Mike Erwin on 7/2/10.
+ * Copyright 2010 Invisible Cow Productions. All rights reserved.
+ *
+ */
+
+#include "ndof-device.h"
+#include <3DconnexionClient/ConnexionClientAPI.h>
+
+extern OSErr InstallConnexionHandlers() __attribute__((weak_import));
+// [mce] C likes the above line, but Obj-C++ does not. Make sure it works for
+// machines without the driver installed! Try it on the QuickSilver.
+
+bool device_available()
+ {
+ return InstallConnexionHandlers != NULL;
+ }
Property changes on: branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.h
===================================================================
--- branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.h (rev 0)
+++ branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.h 2010-07-03 06:50:52 UTC (rev 29889)
@@ -0,0 +1,24 @@
+/*
+ * ndof-device.h
+ * SpaceNav app
+ *
+ * Created by Mike Erwin on 7/2/10.
+ * Copyright 2010 Invisible Cow Productions. All rights reserved.
+ *
+ */
+
+#ifndef ndof_device_h
+#define ndof_device_h
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool device_available();
+
+#ifdef __cplusplus
+ }
+#endif
+#endif
Property changes on: branches/soc-2010-merwin/experimental/SpaceNav app/ndof-device.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/soc-2010-merwin/experimental/SpaceNav app/ndof-update.mm
===================================================================
--- branches/soc-2010-merwin/experimental/SpaceNav app/ndof-update.mm 2010-07-03 06:34:07 UTC (rev 29888)
+++ branches/soc-2010-merwin/experimental/SpaceNav app/ndof-update.mm 2010-07-03 06:50:52 UTC (rev 29889)
@@ -43,7 +43,7 @@
}
else
{
- const float scale = 0.002; // SpaceNavigator sends +/- 500 usually
+ const float scale = 1.f / 350.f; // SpaceNavigator sends +/- 350 usually
Vec3 t = scale * Vec3(trans[0], trans[1], trans[2]);
// printf("T: %5.2f %5.2f %5.2f\n", t.x, t.y, t.z);
@@ -68,7 +68,7 @@
}
else
{
- const float scale = 0.002; // SpaceNavigator sends +/- 500 usually
+ const float scale = 1.f / 350.f; // SpaceNavigator sends +/- 350 usually
Vec3 r = scale * Vec3(rot[0], rot[1], rot[2]);
float mag = r.magnitude();
r.normalize();
@@ -79,7 +79,7 @@
r = -r;
mag = -mag;
}
-
+
// printf("R: %5.3f about: %5.2f %5.2f %5.2f\n", mag, r.x, r.y, r.z);
g_rotation_axis = r;
More information about the Bf-blender-cvs
mailing list