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.
This commit is contained in:
@@ -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 @@ 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;
|
||||
@@ -49,7 +42,6 @@ GHOST_NDOFManager::GHOST_NDOFManager()
|
||||
ndofLibraryInit = 0;
|
||||
ndofLibraryShutdown = 0;
|
||||
ndofDeviceOpen = 0;
|
||||
// ndofEventHandler = 0;
|
||||
}
|
||||
|
||||
GHOST_NDOFManager::~GHOST_NDOFManager()
|
||||
@@ -66,31 +58,26 @@ 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;
|
||||
// original patch
|
||||
// ndofEventHandler = setNdofEventHandler;
|
||||
|
||||
if (ndofLibraryInit && ndofDeviceOpen)
|
||||
{
|
||||
printf("%i client \n", ndofLibraryInit());
|
||||
|
||||
m_DeviceHandle = ndofDeviceOpen((void *)¤tNdofValues);
|
||||
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
m_DeviceHandle = ndofDeviceOpen((void *)¤tNdofValues);
|
||||
#else
|
||||
GHOST_SystemX11 *sys;
|
||||
sys = static_cast<GHOST_SystemX11*>(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...
|
||||
if (win32 != 0)
|
||||
{
|
||||
m_DeviceHandle = ndofDeviceOpen(win32->getHWND());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -111,45 +98,36 @@ GHOST_NDOFManager::handle(unsigned int message, unsigned int* wParam, unsigned l
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@@ -46,16 +46,10 @@ public:
|
||||
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();
|
||||
|
||||
/* original patch. unused now */
|
||||
/* to do: abstract for Linux, MacOS, etc. */
|
||||
// GHOST_TEventNDOFData* handle(unsigned int message, unsigned int* wparam, unsigned long* lparam);
|
||||
bool available() const;
|
||||
bool event_present() const;
|
||||
|
||||
protected:
|
||||
void* m_DeviceHandle;
|
||||
|
||||
@@ -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,8 +124,6 @@ init(
|
||||
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GHOST_TUns64
|
||||
GHOST_SystemX11::
|
||||
@@ -235,7 +212,6 @@ createWindow(
|
||||
}
|
||||
}
|
||||
return window;
|
||||
|
||||
}
|
||||
|
||||
GHOST_WindowX11 *
|
||||
@@ -483,6 +459,28 @@ GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
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 @@ GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
}
|
||||
}
|
||||
|
||||
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::
|
||||
|
||||
@@ -196,7 +196,11 @@ public:
|
||||
return m_display;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
prepareNdofInfo(
|
||||
volatile GHOST_TEventNDOFData *current_values
|
||||
);
|
||||
|
||||
private :
|
||||
|
||||
Display * m_display;
|
||||
|
||||
Reference in New Issue
Block a user