Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorJean-Luc Peurière <jlp@nerim.net>2008-03-22 04:39:11 +0300
committerJean-Luc Peurière <jlp@nerim.net>2008-03-22 04:39:11 +0300
commit126ab7974d304804971c32c2df534b726cd89835 (patch)
tree47b1cbaba2f07fc5d3783b17fa8d5b8ff17f19e2 /intern
parent1930a925c870e746c4fdba161a8af2c097eace74 (diff)
parent32b5138e6459df5298ca50865dafab4d22a4aeed (diff)
NDOF support added to trunk from ndof branch.
The latter is now obsolete and will be soon removed. Some tiny build tweaks for darwin committed in preparation of bigger changes for proper SDK suport both on intel and ppc
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h13
-rw-r--r--intern/ghost/GHOST_ISystem.h16
-rw-r--r--intern/ghost/GHOST_Types.h40
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp15
-rw-r--r--intern/ghost/intern/GHOST_EventNDOF.h57
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp124
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.h52
-rw-r--r--intern/ghost/intern/GHOST_System.cpp23
-rw-r--r--intern/ghost/intern/GHOST_System.h36
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp68
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp24
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp89
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h5
-rw-r--r--intern/ghost/intern/Makefile1
-rw-r--r--intern/ghost/make/msvc_7_0/ghost.vcproj9
16 files changed, 530 insertions, 46 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index c4a2da5e7de..11b0204eacb 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 int GHOST_OpenNDOF(GHOST_SystemHandle systemhandle,
+ GHOST_WindowHandle windowhandle,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen
+ );
/***************************************************************************************
** Cursor management functionality
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 5e0473203db..0cb860d8158 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -295,6 +295,22 @@ 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 int openNDOF(GHOST_IWindow*,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen
+ // original patch only
+ // GHOST_NDOFEventHandler_fp setNdofEventHandler
+ ) = 0;
+
+
/***************************************************************************************
** Cursor management functionality
***************************************************************************************/
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index d5575354370..7b791c44fd8 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -39,6 +39,11 @@ typedef unsigned short GHOST_TUns16;
typedef int GHOST_TInt32;
typedef unsigned int GHOST_TUns32;
+#ifdef WIN32
+#define WM_BLND_NDOF_AXIS WM_USER + 1
+#define WM_BLND_NDOF_BTN WM_USER + 2
+#endif
+
#if defined(WIN32) && !defined(FREE_WINDOWS)
typedef __int64 GHOST_TInt64;
typedef unsigned __int64 GHOST_TUns64;
@@ -133,6 +138,9 @@ typedef enum {
GHOST_kEventButtonUp, /// Mouse button event
GHOST_kEventWheel, /// Mouse wheel event
+ GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
+ GHOST_kEventNDOFButton, /// N degree of freedom device button event
+
GHOST_kEventKeyDown,
GHOST_kEventKeyUp,
// GHOST_kEventKeyAuto,
@@ -336,6 +344,38 @@ typedef struct {
GHOST_TInt32 z;
} GHOST_TEventWheelData;
+
+/* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
+/* as all USB device controls are likely to use ints, this is also more future proof */
+//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 {
+ /** N-degree of freedom device data v2*/
+ int changed;
+ GHOST_TUns64 client;
+ GHOST_TUns64 address;
+ GHOST_TInt16 tx, ty, tz; /** -x left, +y up, +z forward */
+ GHOST_TInt16 rx, ry, rz;
+ GHOST_TInt16 buttons;
+ GHOST_TUns64 time;
+ GHOST_TUns64 delta;
+} GHOST_TEventNDOFData;
+
+typedef int (*GHOST_NDOFLibraryInit_fp)();
+typedef void (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
+typedef void* (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
+
+// original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
+// not necessary faster, but better integration with other events.
+
+//typedef int (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
+//typedef void (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
+
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 60634eeff8c..fe5ed2bf86a 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -259,6 +259,21 @@ GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_Eve
return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
}
+int GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen)
+ //original patch only
+ /* GHOST_NDOFEventHandler_fp setNdofEventHandler)*/
+{
+ GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+ return system->openNDOF((GHOST_IWindow*) windowhandle,
+ setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen);
+// original patch
+// 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..76f5a9e0894
--- /dev/null
+++ b/intern/ghost/intern/GHOST_EventNDOF.h
@@ -0,0 +1,57 @@
+/*
+ * ***** BEGIN GPL 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.
+ *
+ * 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.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#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..5254952f03c
--- /dev/null
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -0,0 +1,124 @@
+/*
+ * ***** BEGIN GPL 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.
+ *
+ * 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.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#include "GHOST_NDOFManager.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};
+
+#if !defined(_WIN32) && !defined(__APPLE__)
+#include "GHOST_SystemX11.h"
+#endif
+
+namespace
+{
+ GHOST_NDOFLibraryInit_fp ndofLibraryInit = 0;
+ GHOST_NDOFLibraryShutdown_fp ndofLibraryShutdown = 0;
+ GHOST_NDOFDeviceOpen_fp ndofDeviceOpen = 0;
+}
+
+GHOST_NDOFManager::GHOST_NDOFManager()
+{
+ m_DeviceHandle = 0;
+
+ // discover the API from the plugin
+ ndofLibraryInit = 0;
+ ndofLibraryShutdown = 0;
+ ndofDeviceOpen = 0;
+}
+
+GHOST_NDOFManager::~GHOST_NDOFManager()
+{
+ if (ndofLibraryShutdown)
+ ndofLibraryShutdown(m_DeviceHandle);
+
+ m_DeviceHandle = 0;
+}
+
+
+int
+GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen)
+{
+ int Pid;
+
+ ndofLibraryInit = setNdofLibraryInit;
+ ndofLibraryShutdown = setNdofLibraryShutdown;
+ ndofDeviceOpen = setNdofDeviceOpen;
+
+ if (ndofLibraryInit && ndofDeviceOpen)
+ {
+ Pid= ndofLibraryInit();
+ printf("%i client \n", Pid);
+ #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
+ return (Pid > 0) ? 0 : 1;
+
+ } else
+ return 1;
+}
+
+
+bool
+GHOST_NDOFManager::available() const
+{
+ return m_DeviceHandle != 0;
+}
+
+bool
+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);
+ return true;
+ }else
+ return false;
+
+}
+
+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;
+}
diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h
new file mode 100644
index 00000000000..18d651b89af
--- /dev/null
+++ b/intern/ghost/intern/GHOST_NDOFManager.h
@@ -0,0 +1,52 @@
+/*
+ * ***** BEGIN GPL 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.
+ *
+ * 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.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef _GHOST_NDOFMANAGER_H_
+#define _GHOST_NDOFMANAGER_H_
+
+#include "GHOST_System.h"
+#include "GHOST_IWindow.h"
+
+
+
+class GHOST_NDOFManager
+{
+public:
+ GHOST_NDOFManager();
+ virtual ~GHOST_NDOFManager();
+
+ int deviceOpen(GHOST_IWindow* window,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen);
+
+ void GHOST_NDOFGetDatas(GHOST_TEventNDOFData &datas) const;
+
+ bool available() const;
+ bool event_present() const;
+
+protected:
+ void* m_DeviceHandle;
+};
+
+
+#endif
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index d91658787b9..a083dfd88d6 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,17 @@ GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent* event)
return success;
}
+int GHOST_System::openNDOF(GHOST_IWindow* w,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen)
+{
+ return m_ndofManager->deviceOpen(w,
+ setNdofLibraryInit,
+ setNdofLibraryShutdown,
+ setNdofDeviceOpen);
+}
+
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool& isDown) const
{
@@ -271,6 +283,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 +323,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 1ded6e77a36..8477d70c42f 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,27 @@ 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
+ * return 0 if device found, 1 otherwise
+ */
+ virtual int openNDOF(GHOST_IWindow* w,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen);
+
+// original patch only
+// GHOST_NDOFEventHandler_fp setNdofEventHandler);
+
+
+
+
/***************************************************************************************
** Cursor management functionality
***************************************************************************************/
@@ -243,6 +265,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).
@@ -305,6 +333,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;
@@ -329,5 +360,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_
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
index 46c0f51ede0..c14ea101c6b 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp
@@ -48,22 +48,33 @@
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
#include "GHOST_EventWheel.h"
+#include "GHOST_EventNDOF.h"
+
#include "GHOST_TimerManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowCarbon.h"
+#include "GHOST_NDOFManager.h"
#define GHOST_KEY_SWITCH(mac, ghost) { case (mac): ghostKey = (ghost); break; }
+/* blender class and types events */
+enum {
+ kEventClassBlender = 'blnd'
+};
+
+enum {
+ kEventBlenderNdofAxis = 1,
+ kEventBlenderNdofButtons = 2
+};
+
const EventTypeSpec kEvents[] =
{
{ kEventClassAppleEvent, kEventAppleEvent },
-
/*
{ kEventClassApplication, kEventAppActivated },
{ kEventClassApplication, kEventAppDeactivated },
*/
-
{ kEventClassKeyboard, kEventRawKeyDown },
{ kEventClassKeyboard, kEventRawKeyRepeat },
{ kEventClassKeyboard, kEventRawKeyUp },
@@ -84,7 +95,12 @@ const EventTypeSpec kEvents[] =
{ kEventClassWindow, kEventWindowActivated },
{ kEventClassWindow, kEventWindowDeactivated },
{ kEventClassWindow, kEventWindowUpdate },
- { kEventClassWindow, kEventWindowBoundsChanged }
+ { kEventClassWindow, kEventWindowBoundsChanged },
+
+ { kEventClassBlender, kEventBlenderNdofAxis },
+ { kEventClassBlender, kEventBlenderNdofButtons }
+
+
};
@@ -416,7 +432,9 @@ GHOST_IWindow* GHOST_SystemCarbon::createWindow(
return window;
}
-
+/* this is an old style low level event queue.
+ As we want to handle our own timers, this is ok.
+ the full screen hack should be removed */
bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
{
bool anyProcessed = false;
@@ -424,7 +442,7 @@ bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
do {
GHOST_TimerManager* timerMgr = getTimerManager();
-
+
if (waitForEvent) {
GHOST_TUns64 curtime = getMilliSeconds();
GHOST_TUns64 next = timerMgr->nextFireTime();
@@ -455,6 +473,8 @@ bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
}
}
+
+ /* end loop when no more events available */
while (::ReceiveNextEvent(0, NULL, 0, true, &event)==noErr) {
OSStatus status= ::SendEventToEventTarget(event, ::GetEventDispatcherTarget());
if (status==noErr) {
@@ -466,7 +486,9 @@ bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
* are, but we get a lot of them
*/
if (i!='cgs ') {
- //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event));
+ if (i!='tblt') { // tablet event. we use the one packaged in the mouse event
+ ; //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event));
+ }
}
}
::ReleaseEvent(event);
@@ -610,6 +632,7 @@ OSErr GHOST_SystemCarbon::sAEHandlerQuit(const AppleEvent *event, AppleEvent *re
GHOST_TSuccess GHOST_SystemCarbon::init()
{
+
GHOST_TSuccess success = GHOST_System::init();
if (success) {
/*
@@ -629,6 +652,7 @@ GHOST_TSuccess GHOST_SystemCarbon::init()
::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false);
::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false);
::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false);
+
}
return success;
}
@@ -765,6 +789,7 @@ OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event)
}
err = noErr;
}
+
}
OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
@@ -961,7 +986,7 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event)
GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
if (::TrackGoAway(window, mousePos))
{
- // todo: add option-close, because itØs in the HIG
+ // todo: add option-close, because itÿs in the HIG
// if (event.modifiers & optionKey) {
// Close the clean documents, others will be confirmed one by one.
//}
@@ -1039,11 +1064,15 @@ bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult)
return handled;
}
+
OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData)
{
GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) userData;
OSStatus err = eventNotHandledErr;
-
+ GHOST_IWindow* window;
+ GHOST_TEventNDOFData data;
+ UInt32 kind;
+
switch (::GetEventClass(event))
{
case kEventClassAppleEvent:
@@ -1061,7 +1090,28 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even
case kEventClassKeyboard:
err = sys->handleKeyEvent(event);
break;
- }
+ case kEventClassBlender :
+ window = sys->m_windowManager->getActiveWindow();
+ sys->m_ndofManager->GHOST_NDOFGetDatas(data);
+ kind = ::GetEventKind(event);
+
+ switch (kind)
+ {
+ case 1:
+ sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data));
+ // printf("motion\n");
+ break;
+ case 2:
+ sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data));
+// printf("button\n");
+ break;
+ }
+ err = noErr;
+ break;
+ default :
+ ;
+ break;
+ }
return err;
}
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h
index 14d4f67290c..68e2d059226 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.h
+++ b/intern/ghost/intern/GHOST_SystemCarbon.h
@@ -238,6 +238,10 @@ protected:
*/
bool handleMenuCommand(GHOST_TInt32 menuResult);
+ /* callback for blender generated events */
+// static OSStatus blendEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData);
+
+
/**
* Callback for Carbon when it has events.
*/
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index c423fbd29ad..c15e4f1246c 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -64,10 +64,12 @@
#include "GHOST_EventCursor.h"
#include "GHOST_EventKey.h"
#include "GHOST_EventWheel.h"
+#include "GHOST_EventNDOF.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
+#include "GHOST_NDOFManager.h"
// Key code values not found in winuser.h
#ifndef VK_MINUS
@@ -845,6 +847,28 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* In GHOST, we let DefWindowProc call the timer callback.
*/
break;
+ case WM_BLND_NDOF_AXIS:
+ {
+ GHOST_TEventNDOFData ndofdata;
+ system->m_ndofManager->GHOST_NDOFGetDatas(ndofdata);
+ system->m_eventManager->
+ pushEvent(new GHOST_EventNDOF(
+ system->getMilliSeconds(),
+ GHOST_kEventNDOFMotion,
+ window, ndofdata));
+ }
+ break;
+ case WM_BLND_NDOF_BTN:
+ {
+ GHOST_TEventNDOFData ndofdata;
+ system->m_ndofManager->GHOST_NDOFGetDatas(ndofdata);
+ system->m_eventManager->
+ pushEvent(new GHOST_EventNDOF(
+ system->getMilliSeconds(),
+ GHOST_kEventNDOFButton,
+ window, ndofdata));
+ }
+ break;
}
}
else {
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 6484d767b81..1b0d4448f1d 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -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"
@@ -95,9 +66,21 @@
#include <unistd.h>
#include <vector>
-
#include <stdio.h> // for fprintf only
+typedef struct NDOFPlatformInfo {
+ Display *display;
+ Window window;
+ volatile GHOST_TEventNDOFData *currValues;
+ Atom cmdAtom;
+ Atom motionAtom;
+ Atom btnPressAtom;
+ Atom btnRelAtom;
+} NDOFPlatformInfo;
+
+static NDOFPlatformInfo sNdofInfo = {NULL, 0, NULL, 0, 0, 0, 0};
+
+
//these are for copy and select copy
static char *txt_cut_buffer= NULL;
static char *txt_select_buffer= NULL;
@@ -151,8 +134,6 @@ init(
return GHOST_kFailure;
}
-
-
GHOST_TUns64
GHOST_SystemX11::
@@ -241,7 +222,6 @@ createWindow(
}
}
return window;
-
}
GHOST_WindowX11 *
@@ -489,10 +469,36 @@ GHOST_SystemX11::processEvent(XEvent *xe)
GHOST_kEventWindowClose,
window
);
+ } else
+#endif
+ if (sNdofInfo.currValues) {
+ static GHOST_TEventNDOFData data = {0,0,0,0,0,0,0,0,0,0,0};
+ if (xcme.message_type == sNdofInfo.motionAtom)
+ {
+ data.changed = 1;
+ data.delta = xcme.data.s[8] - data.time;
+ data.time = xcme.data.s[8];
+ data.tx = xcme.data.s[2];
+ data.ty = xcme.data.s[3];
+ data.tz = xcme.data.s[4];
+ data.rx = xcme.data.s[5];
+ data.ry = xcme.data.s[6];
+ data.rz = xcme.data.s[7];
+ g_event = new GHOST_EventNDOF(getMilliSeconds(),
+ GHOST_kEventNDOFMotion,
+ window, data);
+ } else if (xcme.message_type == sNdofInfo.btnPressAtom) {
+ data.changed = 2;
+ data.delta = xcme.data.s[8] - data.time;
+ data.time = xcme.data.s[8];
+ data.buttons = xcme.data.s[2];
+ g_event = new GHOST_EventNDOF(getMilliSeconds(),
+ GHOST_kEventNDOFButton,
+ window, data);
+ }
} else {
/* Unknown client message, ignore */
}
-#endif
break;
}
@@ -594,6 +600,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::
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index 0e947c12fde..1c100bee852 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -196,6 +196,11 @@ public:
return m_display;
}
+ void *
+ prepareNdofInfo(
+ volatile GHOST_TEventNDOFData *current_values
+ );
+
/**
* Returns unsinged char from CUT_BUFFER0
* @param flag Flag indicates which buffer to return 0 for clipboard 1 for selection
diff --git a/intern/ghost/intern/Makefile b/intern/ghost/intern/Makefile
index 32498222ac6..cccbf9a822b 100644
--- a/intern/ghost/intern/Makefile
+++ b/intern/ghost/intern/Makefile
@@ -39,6 +39,7 @@ CCSRCS += GHOST_EventManager.cpp GHOST_EventPrinter.cpp GHOST_WindowManager.cpp
CCSRCS += GHOST_ISystem.cpp GHOST_ModifierKeys.cpp GHOST_TimerManager.cpp
CCSRCS += GHOST_Rect.cpp GHOST_DisplayManager.cpp GHOST_C-api.cpp
CCSRCS += GHOST_CallbackEventConsumer.cpp
+CCSRCS += GHOST_NDOFManager.cpp
include nan_definitions.mk
diff --git a/intern/ghost/make/msvc_7_0/ghost.vcproj b/intern/ghost/make/msvc_7_0/ghost.vcproj
index 9d0aef451e7..e5b2e09a678 100644
--- a/intern/ghost/make/msvc_7_0/ghost.vcproj
+++ b/intern/ghost/make/msvc_7_0/ghost.vcproj
@@ -281,6 +281,9 @@ ECHO Done
RelativePath="..\..\intern\GHOST_EventManager.h">
</File>
<File
+ RelativePath="..\..\intern\GHOST_EventNDOF.h">
+ </File>
+ <File
RelativePath="..\..\intern\GHOST_EventPrinter.h">
</File>
<File
@@ -293,6 +296,9 @@ ECHO Done
RelativePath="..\..\intern\GHOST_ModifierKeys.h">
</File>
<File
+ RelativePath="..\..\intern\GHOST_NDOFManager.cpp">
+ </File>
+ <File
RelativePath="..\..\intern\GHOST_System.h">
</File>
<File
@@ -374,6 +380,9 @@ ECHO Done
RelativePath="..\..\intern\GHOST_ModifierKeys.cpp">
</File>
<File
+ RelativePath="..\..\intern\GHOST_NDOFManager.cpp">
+ </File>
+ <File
RelativePath="..\..\intern\GHOST_Rect.cpp">
</File>
<File