diff options
author | Jean-Luc Peurière <jlp@nerim.net> | 2007-05-29 08:34:09 +0400 |
---|---|---|
committer | Jean-Luc Peurière <jlp@nerim.net> | 2007-05-29 08:34:09 +0400 |
commit | 16340dfe1235391bb675a633a099c17af3a731c7 (patch) | |
tree | d8f2b76f6a9539519b191bb896ce6941f6dbe444 /intern/ghost | |
parent | 9fec189e7a5793676675f10eb9484b0bbabc5527 (diff) |
adding the initial patch updated to 2.44 in ndof branch
notes :
it compiles but is non functional
lacks the platform specific changes in ghost ( i cant test windows)
lacks the code for plug-in.
the platform specific code will be added when we sync with Ettore work
the plug-in itself cannot be added here
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 13 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 14 | ||||
-rw-r--r-- | intern/ghost/GHOST_Types.h | 14 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 12 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventNDOF.h | 69 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManager.cpp | 107 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManager.h | 39 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 25 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.h | 33 |
9 files changed, 325 insertions, 1 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 4c4094409dd..d5fc87c16f6 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -265,6 +265,19 @@ extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle); +/*************************************************************************************** + ** N-degree of freedom device management functionality + ***************************************************************************************/ + +/** +* Open N-degree of freedom devices + */ +extern void GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, + GHOST_WindowHandle windowhandle, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler); /*************************************************************************************** ** Cursor management functionality diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index dffd81bdb13..9c0cef2b4f0 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -295,6 +295,20 @@ public: */ virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer) = 0; + /*************************************************************************************** + ** N-degree of freedom device management functionality + ***************************************************************************************/ + + /** + * Starts the N-degree of freedom device manager + */ + virtual void openNDOF(GHOST_IWindow*, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler) = 0; + + /*************************************************************************************** ** Cursor management functionality ***************************************************************************************/ diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index d5575354370..c0f7245eff1 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -133,6 +133,8 @@ typedef enum { GHOST_kEventButtonUp, /// Mouse button event GHOST_kEventWheel, /// Mouse wheel event + GHOST_kEventNDOFMotion, /// N degree of freedom device motion event + GHOST_kEventKeyDown, GHOST_kEventKeyUp, // GHOST_kEventKeyAuto, @@ -336,6 +338,18 @@ typedef struct { GHOST_TInt32 z; } GHOST_TEventWheelData; +typedef int (*GHOST_NDOFLibraryInit_fp)(); +typedef void (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle); +typedef void* (*GHOST_NDOFDeviceOpen_fp)(void* platformData); +typedef int (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam); + +typedef struct { + /** N-degree of freedom device data */ + float tx, ty, tz; /** -x left, +y up, +z forward */ + float rx, ry, rz; + float dt; +} GHOST_TEventNDOFData; + typedef struct { /** The key code. */ GHOST_TKey key; diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index c2b8eca9573..cbecb49c80b 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -259,6 +259,18 @@ GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_Eve return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle); } +void GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler) +{ + GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + + system->openNDOF((GHOST_IWindow*) windowhandle, + setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen, setNdofEventHandler); +} + GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle) diff --git a/intern/ghost/intern/GHOST_EventNDOF.h b/intern/ghost/intern/GHOST_EventNDOF.h new file mode 100644 index 00000000000..1eadebd92ac --- /dev/null +++ b/intern/ghost/intern/GHOST_EventNDOF.h @@ -0,0 +1,69 @@ +/** + * $Id: GHOST_EventNdof.h,v 1.6 2002/12/28 22:26:45 maarten Exp $ + * ***** 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 ***** + */ +/** + * @file GHOST_EventNdof.h + * Declaration of GHOST_EventNdof class. + */ + +#ifndef _GHOST_EVENT_NDOF_H_ +#define _GHOST_EVENT_NDOF_H_ + +#include "GHOST_Event.h" + +/** + * N-degree of freedom device event. + */ +class GHOST_EventNDOF : public GHOST_Event +{ +public: + /** + * Constructor. + * @param msec The time this event was generated. + * @param type The type of this event. + * @param x The x-coordinate of the location the cursor was at at the time of the event. + * @param y The y-coordinate of the location the cursor was at at the time of the event. + */ + GHOST_EventNDOF(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, + GHOST_TEventNDOFData data) + : GHOST_Event(msec, type, window) + { + m_ndofEventData = data; + m_data = &m_ndofEventData; + } + +protected: + /** translation & rotation from the device. */ + GHOST_TEventNDOFData m_ndofEventData; +}; + + +#endif // _GHOST_EVENT_NDOF_H_ + diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp new file mode 100644 index 00000000000..86a9b56c7cc --- /dev/null +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -0,0 +1,107 @@ + +// Insert Blender compatible license here :-) + +// note: an implementation is currently only provided for Windows, but designed to be easy to move to Linux, etc. + +/** + + To use this implemenation, you must specify the #define WITH_SPACEBALL for the ghost library. + Only this cpp file is affected by the macro, the header file and everything else are independent + of the spaceball libraries. + + The 3dXWare SDK is available from the tab on the left side of - + http://www.3dconnexion.com/support/4a.php + + The SDK is necessary to build this file with WITH_SPACEBALL defined. + + For this stuff to work, siappdll.dll and spwini.dll must be in the executable path of blender + + */ + + +#include "GHOST_NDOFManager.h" +//#include "GHOST_WindowWin32.h" + + + + + +namespace +{ + 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; + + // discover the API from the plugin + ndofLibraryInit = 0; + ndofLibraryShutdown = 0; + ndofDeviceOpen = 0; + ndofEventHandler = 0; +} + +GHOST_NDOFManager::~GHOST_NDOFManager() +{ + if (ndofLibraryShutdown) + ndofLibraryShutdown(m_DeviceHandle); + + m_DeviceHandle = 0; +} + + +void +GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler) +{ + ndofLibraryInit = setNdofLibraryInit; + ndofLibraryShutdown = setNdofLibraryShutdown; + ndofDeviceOpen = setNdofDeviceOpen; + ndofEventHandler = setNdofEventHandler; + + if (ndofLibraryInit) + { + ndofLibraryInit(); + } +/* + if (ndofDeviceOpen) + { + GHOST_WindowWin32* win32 = (GHOST_WindowWin32*) window; // GHOST_IWindow doesn't have RTTI... + if (win32 != 0) + { + m_DeviceHandle = ndofDeviceOpen(win32->getHWND()); + } + } + */ +} + + + +GHOST_TEventNDOFData* +GHOST_NDOFManager::handle(unsigned int message, unsigned int* wParam, unsigned long* lParam) +{ + static GHOST_TEventNDOFData sbdata; + int handled = 0; + if (ndofEventHandler && m_DeviceHandle != 0) + { + handled = ndofEventHandler(&sbdata.tx, m_DeviceHandle, message, wParam, lParam); + } + return handled ? &sbdata : 0; +} + + +bool +GHOST_NDOFManager::available() +{ + return m_DeviceHandle != 0; +} diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h new file mode 100644 index 00000000000..69e7f8e25f0 --- /dev/null +++ b/intern/ghost/intern/GHOST_NDOFManager.h @@ -0,0 +1,39 @@ + +#ifndef _GHOST_NDOFMANAGER_H_ +#define _GHOST_NDOFMANAGER_H_ + +#include "GHOST_System.h" +#include "GHOST_IWindow.h" + + + +class GHOST_NDOFManager +{ +public: + /** + * Constructor. + */ + GHOST_NDOFManager(); + + /** + * Destructor. + */ + virtual ~GHOST_NDOFManager(); + + void deviceOpen(GHOST_IWindow* window, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler); + + bool available(); + + /* to do: abstract for Linux, MacOS, etc. */ + GHOST_TEventNDOFData* handle(unsigned int message, unsigned int* wparam, unsigned long* lparam); + +protected: + void* m_DeviceHandle; +}; + + +#endif diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index d91658787b9..7daeca9566b 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -47,13 +47,14 @@ #include "GHOST_DisplayManager.h" #include "GHOST_EventManager.h" +#include "GHOST_NDOFManager.h" #include "GHOST_TimerTask.h" #include "GHOST_TimerManager.h" #include "GHOST_WindowManager.h" GHOST_System::GHOST_System() -: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0) +: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0), m_ndofManager(0) { } @@ -239,6 +240,19 @@ GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent* event) return success; } +void GHOST_System::openNDOF(GHOST_IWindow* w, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler) +{ + m_ndofManager->deviceOpen(w, + setNdofLibraryInit, + setNdofLibraryShutdown, + setNdofDeviceOpen, + setNdofEventHandler); +} + GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool& isDown) const { @@ -271,6 +285,11 @@ GHOST_TSuccess GHOST_System::init() m_timerManager = new GHOST_TimerManager (); m_windowManager = new GHOST_WindowManager (); m_eventManager = new GHOST_EventManager (); + m_ndofManager = new GHOST_NDOFManager(); + + if(m_ndofManager) + printf("ndof manager \n"); + #ifdef GHOST_DEBUG if (m_eventManager) { m_eventManager->addConsumer(&m_eventPrinter); @@ -306,6 +325,10 @@ GHOST_TSuccess GHOST_System::exit() delete m_eventManager; m_eventManager = 0; } + if (m_ndofManager) { + delete m_ndofManager; + m_ndofManager = 0; + } return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 85e7b2d6b44..e7014b14f51 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -51,6 +51,7 @@ class GHOST_Event; class GHOST_TimerManager; class GHOST_Window; class GHOST_WindowManager; +class GHOST_NDOFManager; /** * Implementation of platform independent functionality of the GHOST_ISystem @@ -184,6 +185,24 @@ public: */ virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer); + + + /*************************************************************************************** + ** N-degree of freedom devcice management functionality + ***************************************************************************************/ + + /** Inherited from GHOST_ISystem + * Opens the N-degree of freedom device manager + */ + virtual void openNDOF(GHOST_IWindow* w, + GHOST_NDOFLibraryInit_fp setNdofLibraryInit, + GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown, + GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen, + GHOST_NDOFEventHandler_fp setNdofEventHandler); + + + + /*************************************************************************************** ** Cursor management functionality ***************************************************************************************/ @@ -243,6 +262,12 @@ public: */ virtual inline GHOST_WindowManager* getWindowManager() const; + /** + * Returns a pointer to our n-degree of freedeom manager. + * @return A pointer to our n-degree of freedeom manager. + */ + virtual inline GHOST_NDOFManager* getNDOFManager() const; + /** * Returns the state of all modifier keys. * @param keys The state of all modifier keys (true == pressed). @@ -290,6 +315,9 @@ protected: /** The event manager. */ GHOST_EventManager* m_eventManager; + /** The N-degree of freedom device manager */ + GHOST_NDOFManager* m_ndofManager; + /** Prints all the events. */ #ifdef GHOST_DEBUG GHOST_EventPrinter m_eventPrinter; @@ -314,5 +342,10 @@ inline GHOST_WindowManager* GHOST_System::getWindowManager() const return m_windowManager; } +inline GHOST_NDOFManager* GHOST_System::getNDOFManager() const +{ + return m_ndofManager; +} + #endif // _GHOST_SYSTEM_H_ |