[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30685] branches/soc-2010-merwin/intern/ ghost/intern/GHOST_NDOFManagerCocoa.mm: Renamed Mac file to exclude it from Windows build.

Mike Erwin significant.bit at gmail.com
Sat Jul 24 08:49:25 CEST 2010


Revision: 30685
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30685
Author:   merwin
Date:     2010-07-24 08:49:24 +0200 (Sat, 24 Jul 2010)

Log Message:
-----------
Renamed Mac file to exclude it from Windows build. Revoke this cowardly commit once I figure out how to properly fix the build script!

Added Paths:
-----------
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm

Copied: branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm (from rev 30683, branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManagerCocoa.cpp)
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm	                        (rev 0)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm	2010-07-24 06:49:24 UTC (rev 30685)
@@ -0,0 +1,113 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+ 
+#include "GHOST_NDOFManagerCocoa.h"
+#include "GHOST_SystemCocoa.h"
+
+extern "C" {
+	#include <3DconnexionClient/ConnexionClientAPI.h>
+	#include <stdio.h>
+	}
+
+static void SpaceNavAdded(io_connect_t connection)
+	{
+	printf("SpaceNav added\n");
+	}
+
+static void SpaceNavRemoved(io_connect_t connection)
+	{
+	printf("SpaceNav removed\n");
+	}
+
+static void SpaceNavEvent(io_connect_t connection, natural_t messageType, void *messageArgument)
+	{
+	GHOST_SystemCocoa* system = (GHOST_SystemCocoa*) GHOST_ISystem::getSystem();
+	GHOST_NDOFManager* manager = system->getNDOFManager();
+	switch (messageType)
+		{
+		case kConnexionMsgDeviceState:
+			{
+			ConnexionDeviceState* s = (ConnexionDeviceState*)messageArgument;
+			switch (s->command)
+				{
+				case kConnexionCmdHandleAxis:
+					manager->updateTranslation(s->axis, s->time);
+					manager->updateRotation(s->axis + 3, s->time);
+					system->notifyExternalEventProcessed();
+					break;
+
+				case kConnexionCmdHandleButtons:
+					manager->updateButtons(s->buttons, s->time);
+					system->notifyExternalEventProcessed();
+					break;
+				}
+			break;
+			}
+		case kConnexionMsgPrefsChanged:
+			printf("prefs changed\n"); // this includes app switches
+			break;
+		case kConnexionMsgDoAction:
+			printf("do action\n"); // no idea what this means
+			// 'calibrate device' in System Prefs sends this
+			break;
+		default:
+			printf("<!> mystery event\n");
+		}
+	}
+
+GHOST_NDOFManagerCocoa::GHOST_NDOFManagerCocoa(GHOST_System& sys)
+	: GHOST_NDOFManager(sys)
+	{
+	if (available())
+		{
+		OSErr error = InstallConnexionHandlers(SpaceNavEvent, SpaceNavAdded, SpaceNavRemoved);
+		if (error)
+			{
+			printf("<!> error = %d\n", error);
+			return;
+			}
+
+		// Pascal string *and* a four-letter constant. How old-skool.
+		m_clientID = RegisterConnexionClient('blnd', (UInt8*) "\pBlender",
+			kConnexionClientModeTakeOver, kConnexionMaskAll);
+
+		printf("client id = %d\n", m_clientID);
+		}
+	else
+		{
+		printf("<!> SpaceNav driver not found\n");
+		// This isn't a hard error, just means the user doesn't have a SpaceNavigator.
+		}
+	}
+
+GHOST_NDOFManagerCocoa::~GHOST_NDOFManagerCocoa()
+	{
+	UnregisterConnexionClient(m_clientID);
+	CleanupConnexionHandlers();
+	}
+
+bool GHOST_NDOFManagerCocoa::available()
+	{
+//	extern OSErr InstallConnexionHandlers() __attribute__((weak_import));
+// ^-- not needed since the entire framework is weak-linked
+	return InstallConnexionHandlers != NULL;
+	}





More information about the Bf-blender-cvs mailing list