2 // Insert Blender compatible license here :-)
4 // note: an implementation is currently only provided for Windows, but designed to be easy to move to Linux, etc.
8 To use this implemenation, you must specify the #define WITH_SPACEBALL for the ghost library.
9 Only this cpp file is affected by the macro, the header file and everything else are independent
10 of the spaceball libraries.
12 The 3dXWare SDK is available from the tab on the left side of -
13 http://www.3dconnexion.com/support/4a.php
15 The SDK is necessary to build this file with WITH_SPACEBALL defined.
17 For this stuff to work, siappdll.dll and spwini.dll must be in the executable path of blender
22 #include "GHOST_NDOFManager.h"
23 //#include "GHOST_WindowWin32.h"
31 GHOST_NDOFLibraryInit_fp ndofLibraryInit = 0;
32 GHOST_NDOFLibraryShutdown_fp ndofLibraryShutdown = 0;
33 GHOST_NDOFDeviceOpen_fp ndofDeviceOpen = 0;
34 GHOST_NDOFEventHandler_fp ndofEventHandler = 0;
38 //typedef enum SpwRetVal (WINAPI *PFNSI_INIT) (void);
40 GHOST_NDOFManager::GHOST_NDOFManager()
44 // discover the API from the plugin
46 ndofLibraryShutdown = 0;
52 GHOST_NDOFManager::~GHOST_NDOFManager()
54 if (ndofLibraryShutdown)
55 ndofLibraryShutdown(m_DeviceHandle);
62 GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window,
63 GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
64 GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
65 GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
66 GHOST_NDOFEventHandler_fp setNdofEventHandler)
68 ndofLibraryInit = setNdofLibraryInit;
69 ndofLibraryShutdown = setNdofLibraryShutdown;
70 ndofDeviceOpen = setNdofDeviceOpen;
71 ndofEventHandler = setNdofEventHandler;
73 if (ndofLibraryInit && ndofDeviceOpen)
75 printf("%i client \n", ndofLibraryInit());
80 GHOST_WindowWin32* win32 = (GHOST_WindowWin32*) window; // GHOST_IWindow doesn't have RTTI...
83 m_DeviceHandle = ndofDeviceOpen(win32->getHWND());
92 GHOST_NDOFManager::handle(unsigned int message, unsigned int* wParam, unsigned long* lParam)
94 static GHOST_TEventNDOFData sbdata;
96 if (ndofEventHandler && m_DeviceHandle != 0)
98 handled = ndofEventHandler(&sbdata.tx, m_DeviceHandle, message, wParam, lParam);
100 printf("handled %i\n", handled);
101 return handled ? &sbdata : 0;
106 GHOST_NDOFManager::available()
108 return m_DeviceHandle != 0;