[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11216] branches/ndof/intern/ghost/intern: committing Ettore Pasquini 6DOF patch for linux

JLuc Peuriere jlp at nerim.net
Tue Jul 10 21:32:30 CEST 2007


Revision: 11216
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11216
Author:   lukep
Date:     2007-07-10 21:32:30 +0200 (Tue, 10 Jul 2007)

Log Message:
-----------
committing Ettore Pasquini 6DOF patch for linux

As previously the plugin itself is available
on his site : 
http://cubelogic.org/blender/3dcnxplug-lin.c
or on mine (soon) :
http://jlp.nerim.net/dev/6dof/

Please let me know if any problem, i cannot
test.

We have now patches for our 3 main platforms
features are still minimal, but will follow
soon.

Modified Paths:
--------------
    branches/ndof/intern/ghost/intern/GHOST_NDOFManager.cpp
    branches/ndof/intern/ghost/intern/GHOST_NDOFManager.h
    branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp
    branches/ndof/intern/ghost/intern/GHOST_SystemX11.h

Modified: branches/ndof/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- branches/ndof/intern/ghost/intern/GHOST_NDOFManager.cpp	2007-07-10 19:13:03 UTC (rev 11215)
+++ branches/ndof/intern/ghost/intern/GHOST_NDOFManager.cpp	2007-07-10 19:32:30 UTC (rev 11216)
@@ -22,7 +22,6 @@
 
 
 #include "GHOST_NDOFManager.h"
-//#include "GHOST_WindowWin32.h"
 
 
 // the variable is outside the class because it must be accessed from plugin
@@ -33,14 +32,8 @@
     GHOST_NDOFLibraryInit_fp ndofLibraryInit = 0;
     GHOST_NDOFLibraryShutdown_fp ndofLibraryShutdown = 0;
     GHOST_NDOFDeviceOpen_fp ndofDeviceOpen = 0;
-//    GHOST_NDOFEventHandler_fp ndofEventHandler = 0;
-    
-    
 }
 
-
-//typedef enum SpwRetVal (WINAPI *PFNSI_INIT) (void);
-
 GHOST_NDOFManager::GHOST_NDOFManager()
 {
     m_DeviceHandle = 0;
@@ -49,7 +42,6 @@
     ndofLibraryInit = 0;
     ndofLibraryShutdown = 0;
     ndofDeviceOpen = 0;
- //   ndofEventHandler = 0;
 }
 
 GHOST_NDOFManager::~GHOST_NDOFManager()
@@ -66,31 +58,26 @@
         GHOST_NDOFLibraryInit_fp setNdofLibraryInit, 
         GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
         GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen)
-//        GHOST_NDOFEventHandler_fp setNdofEventHandler)
 {
     ndofLibraryInit = setNdofLibraryInit;
     ndofLibraryShutdown = setNdofLibraryShutdown;
     ndofDeviceOpen = setNdofDeviceOpen;
-//	 original patch    
-//    ndofEventHandler = setNdofEventHandler;
 
     if (ndofLibraryInit  && ndofDeviceOpen)
     {
        printf("%i client \n", ndofLibraryInit());
+		
 		m_DeviceHandle = ndofDeviceOpen((void *)&currentNdofValues);    
+		
+		#if defined(_WIN32) || defined(__APPLE__)
+			m_DeviceHandle = ndofDeviceOpen((void *)&currentNdofValues);    
+		#else
+			GHOST_SystemX11 *sys;
+			sys = static_cast<GHOST_SystemX11*>(GHOST_ISystem::getSystem());
+			void *ndofInfo = sys->prepareNdofInfo(&currentNdofValues);
+			m_DeviceHandle = ndofDeviceOpen(ndofInfo);
+		#endif
 	}
-    
-    
-/*
-    if (ndofDeviceOpen)
-    {
-        GHOST_WindowWin32* win32 = (GHOST_WindowWin32*) window; // GHOST_IWindow doesn't have RTTI...
-        if (win32 != 0)
-        {
-            m_DeviceHandle = ndofDeviceOpen(win32->getHWND());
-        }
-    }
-    */
 }
 
 
@@ -111,45 +98,36 @@
 */
 
 bool 
-GHOST_NDOFManager::available() 
+GHOST_NDOFManager::available() const
 { 
     return m_DeviceHandle != 0; 
 }
 
 bool 
-GHOST_NDOFManager::event_present() 
+GHOST_NDOFManager::event_present() const
 { 
     if( currentNdofValues.changed >0) {
-   			printf("time %llu but%u x%i y%i z%i rx%i ry%i rz%i \n"	, 			
-   						currentNdofValues.time,		currentNdofValues.buttons,
-   						currentNdofValues.tx,currentNdofValues.ty,currentNdofValues.tz,
-   						currentNdofValues.rx,currentNdofValues.ry,currentNdofValues.rz);
+		printf("time %llu but%u x%i y%i z%i rx%i ry%i rz%i \n"	, 			
+				currentNdofValues.time,		currentNdofValues.buttons,
+				currentNdofValues.tx,currentNdofValues.ty,currentNdofValues.tz,
+				currentNdofValues.rx,currentNdofValues.ry,currentNdofValues.rz);
     	return true;
 	}else
 	return false;
 
 }
 
-void        GHOST_NDOFManager::GHOST_NDOFGetDatas(GHOST_TEventNDOFData &datas)
+void        GHOST_NDOFManager::GHOST_NDOFGetDatas(GHOST_TEventNDOFData &datas) const
 {
-		datas.tx = currentNdofValues.tx;
-		datas.ty = currentNdofValues.ty;
-		datas.tz = currentNdofValues.tz;
-		datas.rx = currentNdofValues.rx;
-		datas.ry = currentNdofValues.ry;
-		datas.rz = currentNdofValues.rz;
-		datas.buttons = currentNdofValues.buttons;
-		datas.client = currentNdofValues.client;
-		datas.address = currentNdofValues.address;
-		datas.time = currentNdofValues.time;
-		datas.delta = currentNdofValues.delta;
-
+	datas.tx = currentNdofValues.tx;
+	datas.ty = currentNdofValues.ty;
+	datas.tz = currentNdofValues.tz;
+	datas.rx = currentNdofValues.rx;
+	datas.ry = currentNdofValues.ry;
+	datas.rz = currentNdofValues.rz;
+	datas.buttons = currentNdofValues.buttons;
+	datas.client = currentNdofValues.client;
+	datas.address = currentNdofValues.address;
+	datas.time = currentNdofValues.time;
+	datas.delta = currentNdofValues.delta;
 }
-
-/*
-//#ifdef
-OSStatus GHOST_SystemCarbon::blendEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData)
-{
-}
-
-*/

Modified: branches/ndof/intern/ghost/intern/GHOST_NDOFManager.h
===================================================================
--- branches/ndof/intern/ghost/intern/GHOST_NDOFManager.h	2007-07-10 19:13:03 UTC (rev 11215)
+++ branches/ndof/intern/ghost/intern/GHOST_NDOFManager.h	2007-07-10 19:32:30 UTC (rev 11216)
@@ -46,17 +46,11 @@
         GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
         GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen);
         
-    void GHOST_NDOFGetDatas(GHOST_TEventNDOFData &datas);
+    void GHOST_NDOFGetDatas(GHOST_TEventNDOFData &datas) const;
         
-//        GHOST_NDOFEventHandler_fp setNdofEventHandler);
+    bool available() const;
+    bool event_present() const;
 
-    bool available();
-    bool event_present();
-
-/* original patch. unused now */
-    /* to do: abstract for Linux, MacOS, etc. */
-//    GHOST_TEventNDOFData* handle(unsigned int message, unsigned int* wparam, unsigned long* lparam);
-
 protected:
     void* m_DeviceHandle;
 };

Modified: branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp	2007-07-10 19:13:03 UTC (rev 11215)
+++ branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp	2007-07-10 19:32:30 UTC (rev 11216)
@@ -29,37 +29,6 @@
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -72,6 +41,8 @@
 #include "GHOST_EventKey.h"
 #include "GHOST_EventButton.h"
 #include "GHOST_EventWheel.h"
+#include "GHOST_EventNDOF.h"
+#include "GHOST_NDOFManager.h"
 #include "GHOST_DisplayManagerX11.h"
 
 #include "GHOST_Debug.h"
@@ -96,6 +67,14 @@
 
 #include <vector>
 
+typedef struct NDOFPlatformInfo {
+	Display *display;
+	Window window;
+	volatile GHOST_TEventNDOFData *currValues;
+} NDOFPlatformInfo;
+
+static NDOFPlatformInfo sNdofInfo = {NULL, 0, NULL};
+
 using namespace std;
 
 GHOST_SystemX11::
@@ -145,9 +124,7 @@
 
 	return GHOST_kFailure;
 }
-	
 
-
 	GHOST_TUns64
 GHOST_SystemX11::
 getMilliSeconds(
@@ -235,7 +212,6 @@
 		}
 	}
 	return window;
-
 }
 
 	GHOST_WindowX11 * 
@@ -483,6 +459,28 @@
 					GHOST_kEventWindowClose,
 					window
 				);
+			} else 
+#endif
+			if (sNdofInfo.currValues) {
+				sNdofInfo.currValues->changed = 1;
+				sNdofInfo.currValues->delta = xcme.data.s[8] - sNdofInfo.currValues->time;
+				sNdofInfo.currValues->time = xcme.data.s[8];
+				sNdofInfo.currValues->tx = xcme.data.s[2] >> 4;
+				sNdofInfo.currValues->ty = xcme.data.s[3] >> 4;
+				sNdofInfo.currValues->tz = xcme.data.s[4] >> 4;
+				sNdofInfo.currValues->rx = xcme.data.s[5];
+				sNdofInfo.currValues->ry = xcme.data.s[6];
+				sNdofInfo.currValues->rz = xcme.data.s[7];
+
+				/*fprintf(stderr, "ClientMessage: [%d %d %d][%d %d %d] t=%llu\n",
+				        sNdofInfo.currValues->tx, sNdofInfo.currValues->ty, 
+				        sNdofInfo.currValues->tz, sNdofInfo.currValues->rx, 
+				        sNdofInfo.currValues->ry, sNdofInfo.currValues->rz, 
+						sNdofInfo.currValues->time); */
+				
+				g_event = new GHOST_EventNDOF(getMilliSeconds(), 
+				                              GHOST_kEventNDOFMotion, 
+				                              window, *sNdofInfo.currValues);
 			} else {
 				/* Unknown client message, ignore */
 			}
@@ -539,6 +537,17 @@
 	}
 }
 
+	void *
+GHOST_SystemX11::
+prepareNdofInfo(volatile GHOST_TEventNDOFData *currentNdofValues)
+{
+	const vector<GHOST_IWindow*>& v(m_windowManager->getWindows());
+	if (v.size() > 0)
+	sNdofInfo.window = static_cast<GHOST_WindowX11*>(v[0])->getXWindow();
+	sNdofInfo.display = m_display;
+	sNdofInfo.currValues = currentNdofValues;
+	return (void*)&sNdofInfo;
+}
 
 	GHOST_TSuccess 
 GHOST_SystemX11::

Modified: branches/ndof/intern/ghost/intern/GHOST_SystemX11.h
===================================================================
--- branches/ndof/intern/ghost/intern/GHOST_SystemX11.h	2007-07-10 19:13:03 UTC (rev 11215)
+++ branches/ndof/intern/ghost/intern/GHOST_SystemX11.h	2007-07-10 19:32:30 UTC (rev 11216)
@@ -196,7 +196,11 @@
 		return m_display;
 	}	
 
-	
+		void *
+	prepareNdofInfo(
+		volatile GHOST_TEventNDOFData *current_values
+	);
+		
 private :
 
 	Display * m_display;





More information about the Bf-blender-cvs mailing list