Index: intern/ghost/intern/GHOST_NDOFManager.cpp =================================================================== --- intern/ghost/intern/GHOST_NDOFManager.cpp (revision 11161) +++ intern/ghost/intern/GHOST_NDOFManager.cpp (working copy) @@ -20,10 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ - #include "GHOST_NDOFManager.h" -//#include "GHOST_WindowWin32.h" - // the variable is outside the class because it must be accessed from plugin static volatile GHOST_TEventNDOFData currentNdofValues = {0,0,0,0,0,0,0,0,0,0,0}; @@ -28,6 +25,10 @@ // the variable is outside the class because it must be accessed from plugin static volatile GHOST_TEventNDOFData currentNdofValues = {0,0,0,0,0,0,0,0,0,0,0}; +#if !defined(_WIN32) && !defined(__APPLE__) +#include "GHOST_SystemX11.h" +#endif + namespace { GHOST_NDOFLibraryInit_fp ndofLibraryInit = 0; @@ -34,11 +35,8 @@ 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() @@ -60,7 +58,6 @@ m_DeviceHandle = 0; } - void GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window, GHOST_NDOFLibraryInit_fp setNdofLibraryInit, @@ -74,14 +71,21 @@ // original patch // ndofEventHandler = setNdofEventHandler; - if (ndofLibraryInit && ndofDeviceOpen) - { - printf("%i client \n", ndofLibraryInit()); + if (ndofLibraryInit && ndofDeviceOpen) + { + printf("%i client \n", ndofLibraryInit()); + + #if defined(_WIN32) || defined(__APPLE__) m_DeviceHandle = ndofDeviceOpen((void *)¤tNdofValues); + #else + GHOST_SystemX11 *sys; + sys = static_cast(GHOST_ISystem::getSystem()); + void *ndofInfo = sys->prepareNdofInfo(¤tNdofValues); + m_DeviceHandle = ndofDeviceOpen(ndofInfo); + #endif } - - -/* + + /* if (ndofDeviceOpen) { GHOST_WindowWin32* win32 = (GHOST_WindowWin32*) window; // GHOST_IWindow doesn't have RTTI... @@ -111,7 +115,7 @@ */ bool -GHOST_NDOFManager::available() +GHOST_NDOFManager::available() const { return m_DeviceHandle != 0; } @@ -117,13 +121,13 @@ } 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; @@ -130,7 +134,8 @@ } -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; @@ -143,7 +148,6 @@ datas.address = currentNdofValues.address; datas.time = currentNdofValues.time; datas.delta = currentNdofValues.delta; - } /* @@ -151,5 +155,4 @@ OSStatus GHOST_SystemCarbon::blendEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData) { } - */ Index: intern/ghost/intern/GHOST_NDOFManager.h =================================================================== --- intern/ghost/intern/GHOST_NDOFManager.h (revision 11161) +++ intern/ghost/intern/GHOST_NDOFManager.h (working copy) @@ -26,8 +26,6 @@ #include "GHOST_System.h" #include "GHOST_IWindow.h" - - class GHOST_NDOFManager { public: @@ -46,12 +44,12 @@ 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(); - bool event_present(); + bool available() const; + bool event_present() const; /* original patch. unused now */ /* to do: abstract for Linux, MacOS, etc. */ Index: intern/ghost/intern/GHOST_SystemX11.cpp =================================================================== --- intern/ghost/intern/GHOST_SystemX11.cpp (revision 11161) +++ intern/ghost/intern/GHOST_SystemX11.cpp (working copy) @@ -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 #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 +typedef struct NDOFPlatformInfo { + Display *display; + Window window; + volatile GHOST_TEventNDOFData *currValues; +} NDOFPlatformInfo; + +static NDOFPlatformInfo sNdofInfo = {NULL, 0, NULL}; + using namespace std; GHOST_SystemX11:: @@ -146,8 +125,6 @@ return GHOST_kFailure; } - - GHOST_TUns64 GHOST_SystemX11:: getMilliSeconds( @@ -235,7 +212,6 @@ } } return window; - } GHOST_WindowX11 * @@ -474,8 +450,8 @@ case ClientMessage: { XClientMessageEvent & xcme = xe->xclient; - -#ifndef __sgi + +#ifndef __sgi if (xcme.data.l[0] == m_delete_window_atom) { g_event = new GHOST_Event( @@ -483,10 +459,32 @@ 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 */ } -#endif + break; } @@ -539,6 +537,17 @@ } } + void * +GHOST_SystemX11:: +prepareNdofInfo(volatile GHOST_TEventNDOFData *currentNdofValues) +{ + const vector& v(m_windowManager->getWindows()); + if (v.size() > 0) + sNdofInfo.window = static_cast(v[0])->getXWindow(); + sNdofInfo.display = m_display; + sNdofInfo.currValues = currentNdofValues; + return (void*)&sNdofInfo; +} GHOST_TSuccess GHOST_SystemX11:: Index: intern/ghost/intern/GHOST_SystemX11.h =================================================================== --- intern/ghost/intern/GHOST_SystemX11.h (revision 11161) +++ intern/ghost/intern/GHOST_SystemX11.h (working copy) @@ -195,7 +195,11 @@ ) { return m_display; } - + + void * + prepareNdofInfo( + volatile GHOST_TEventNDOFData *current_values + ); private :