[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31212] branches/soc-2010-merwin: SpaceNav works in 3D view on Windows.
Mike Erwin
significant.bit at gmail.com
Tue Aug 10 11:51:22 CEST 2010
Revision: 31212
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31212
Author: merwin
Date: 2010-08-10 11:51:22 +0200 (Tue, 10 Aug 2010)
Log Message:
-----------
SpaceNav works in 3D view on Windows. Cleaned up related WIP code.
Modified Paths:
--------------
branches/soc-2010-merwin/intern/ghost/GHOST_ISystem.h
branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp
branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.h
branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp
branches/soc-2010-merwin/intern/ghost/intern/GHOST_System.cpp
branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemWin32.cpp
branches/soc-2010-merwin/intern/ghost/intern/GHOST_WindowManager.cpp
branches/soc-2010-merwin/source/blender/editors/space_view3d/view3d_edit.c
branches/soc-2010-merwin/source/blender/windowmanager/intern/wm_event_system.c
Modified: branches/soc-2010-merwin/intern/ghost/GHOST_ISystem.h
===================================================================
--- branches/soc-2010-merwin/intern/ghost/GHOST_ISystem.h 2010-08-10 09:47:57 UTC (rev 31211)
+++ branches/soc-2010-merwin/intern/ghost/GHOST_ISystem.h 2010-08-10 09:51:22 UTC (rev 31212)
@@ -400,4 +400,3 @@
};
#endif // _GHOST_ISYSTEM_H_
-
Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp 2010-08-10 09:47:57 UTC (rev 31211)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp 2010-08-10 09:51:22 UTC (rev 31212)
@@ -39,15 +39,10 @@
#include "GHOST_Debug.h"
// for testing lo-fi
-#include "GHOST_EventPrinter.h"
-#include <iostream>
-using namespace std;
+// #include "GHOST_EventPrinter.h"
+// #include <iostream>
+// using namespace std;
-GHOST_EventManager::GHOST_EventManager()
-{
-}
-
-
GHOST_EventManager::~GHOST_EventManager()
{
disposeEvents();
@@ -110,14 +105,12 @@
bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event)
{
// [mce] this variant switches the "handled" flag to work as described in the header
- // it also stops after the first consumer has handled the event (no it doesn't)
bool handled = false;
if (event) {
TConsumerVector::iterator iter;
for (iter = m_consumers.begin(); iter != m_consumers.end(); iter++) {
if ((*iter)->processEvent(event)) {
handled = true;
- // break;
}
}
}
@@ -125,7 +118,7 @@
}
#if 0 // disable to test a variant
-bool GHOST_EventManager::dispatchEvent_original(GHOST_IEvent* event)
+bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) /* original version */
{
bool handled;
if (event) {
@@ -190,6 +183,7 @@
// cout << "\n--- lo-fi dispatch ---";
// cout << "\ndiscard:";
+
while ((event = popEvent()) != NULL) {
if (event->getType() == GHOST_kEventCursorMove) {
// just a simple (x,y) pair, nothing much to adjust
@@ -204,7 +198,7 @@
if (!dispatchEvent(event))
allHandled = false;
}
-
+
// finally dispatch the single cursor update
if (cursorMove) {
// cout << "\nsend:";
@@ -268,7 +262,7 @@
GHOST_IEvent* event = *iter;
if (event->getWindow() == window)
{
- GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n");
+ GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n");
/*
* Found an event for this window, remove it.
* The iterator will become invalid.
@@ -293,7 +287,7 @@
GHOST_IEvent* event = *iter;
if ((event->getType() == type) && (!window || (event->getWindow() == window)))
{
- GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n");
+ GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n");
/*
* Found an event of this type for the window, remove it.
* The iterator will become invalid.
Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.h
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.h 2010-08-10 09:47:57 UTC (rev 31211)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.h 2010-08-10 09:51:22 UTC (rev 31212)
@@ -53,32 +53,32 @@
/**
* Constructor.
*/
- GHOST_EventManager();
+ GHOST_EventManager() {};
/**
* Destructor.
*/
- virtual ~GHOST_EventManager();
+ ~GHOST_EventManager();
/**
* Returns the number of events currently on the stack.
* @return The number of events on the stack.
*/
- virtual GHOST_TUns32 getNumEvents();
+ GHOST_TUns32 getNumEvents();
/**
* Returns the number of events of a certain type currently on the stack.
* @param type The type of events to be counted.
* @return The number of events on the stack of this type.
*/
- virtual GHOST_TUns32 getNumEvents(GHOST_TEventType type);
+ GHOST_TUns32 getNumEvents(GHOST_TEventType type);
/**
* Return the event at the top of the stack without removal.
* Do not delete the event!
* @return The event at the top of the stack.
*/
- virtual GHOST_IEvent* peekEvent();
+ GHOST_IEvent* peekEvent();
/**
* Pushes an event on the stack.
@@ -86,27 +86,27 @@
* Do not delete the event!
* @param event The event to push on the stack.
*/
- virtual GHOST_TSuccess pushEvent(GHOST_IEvent* event);
+ GHOST_TSuccess pushEvent(GHOST_IEvent* event);
/**
* Dispatches the given event directly, bypassing the event stack.
* @return Indication as to whether any of the consumers handled the event.
*/
- virtual bool dispatchEvent(GHOST_IEvent* event);
+ bool dispatchEvent(GHOST_IEvent* event);
/**
* Dispatches the event at the back of the stack.
* The event will be removed from the stack.
* @return Indication as to whether any of the consumers handled the event.
*/
- virtual bool dispatchEvent();
+ bool dispatchEvent();
/**
* Dispatches all the events on the stack.
* The event stack will be empty afterwards.
* @return Indication as to whether any of the consumers handled the events.
*/
- virtual bool dispatchEvents();
+ bool dispatchEvents();
/**
* Dispatches most events on the stack, consolidating cursor moves into a single move.
@@ -115,29 +115,25 @@
*/
bool dispatchEvents_lo_fi();
-
/**
* Adds a consumer to the list of event consumers.
* @param consumer The consumer added to the list.
* @return Indication as to whether addition has succeeded.
*/
- virtual GHOST_TSuccess addConsumer(GHOST_IEventConsumer* consumer);
+ GHOST_TSuccess addConsumer(GHOST_IEventConsumer* consumer);
/**
* Removes a consumer from the list of event consumers.
* @param consumer The consumer removed from the list.
* @return Indication as to whether removal has succeeded.
*/
- virtual GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer);
+ GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer);
/**
* Removes all events for a window from the stack.
* @param window The window to remove events for.
*/
- virtual void
- removeWindowEvents(
- GHOST_IWindow* window
- );
+ void removeWindowEvents(GHOST_IWindow* window);
/**
* Removes all events of a certain type from the stack.
@@ -146,11 +142,7 @@
* @param type The type of events to be removed.
* @param window The window to remove the events for.
*/
- virtual void
- removeTypeEvents(
- GHOST_TEventType type,
- GHOST_IWindow* window = 0
- );
+ void removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* window = 0);
protected:
/**
@@ -179,4 +171,3 @@
};
#endif // _GHOST_EVENT_MANAGER_H_
-
Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp 2010-08-10 09:47:57 UTC (rev 31211)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp 2010-08-10 09:51:22 UTC (rev 31212)
@@ -55,8 +55,7 @@
void GHOST_NDOFManager::updateButtons(unsigned short buttons, GHOST_TUns64 time)
{
- GHOST_System* system = (GHOST_System*) GHOST_System::getSystem();
- GHOST_IWindow* window = system->getWindowManager()->getActiveWindow();
+ GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow();
unsigned short diff = m_buttons ^ buttons;
@@ -70,10 +69,9 @@
GHOST_TEventNDOFButtonData* data = (GHOST_TEventNDOFButtonData*) event->getData();
data->action = (buttons & mask) ? GHOST_kPress : GHOST_kRelease;
-// data->pressed = buttons & mask;
data->button = i + 1;
-// printf("sending button %d %s\n", data->button, (data->action == GHOST_kPress) ? "pressed" : "released");
+ // printf("sending button %d %s\n", data->button, (data->action == GHOST_kPress) ? "pressed" : "released");
m_system.pushEvent(event);
}
@@ -87,8 +85,7 @@
if (m_atRest)
return false;
- GHOST_System* system = (GHOST_System*) GHOST_System::getSystem();
- GHOST_IWindow* window = system->getWindowManager()->getActiveWindow();
+ GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow();
GHOST_EventNDOFMotion* event = new GHOST_EventNDOFMotion(m_motionTime, window);
GHOST_TEventNDOFMotionData* data = (GHOST_TEventNDOFMotionData*) event->getData();
@@ -109,11 +106,10 @@
data->dt = 0.001f * (m_motionTime - m_prevMotionTime); // in seconds
- printf("dt = %d ms\n", (int)(m_motionTime - m_prevMotionTime));
-
m_prevMotionTime = m_motionTime;
-// printf("sending T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f)\n", data->tx, data->ty, data->tz, data->rx, data->ry, data->rz);
+// printf("sending T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f\n",
+// data->tx, data->ty, data->tz, data->rx, data->ry, data->rz, data->dt);
m_system.pushEvent(event);
Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_System.cpp
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_System.cpp 2010-08-10 09:47:57 UTC (rev 31211)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_System.cpp 2010-08-10 09:51:22 UTC (rev 31212)
@@ -37,7 +37,6 @@
#include "GHOST_System.h"
#include <time.h>
-#include <stdio.h> /* just for printf */
#include "GHOST_DisplayManager.h"
#include "GHOST_EventManager.h"
@@ -196,19 +195,17 @@
bool GHOST_System::dispatchEvents()
{
+ bool handled = false;
+
// NDOF Motion event is sent only once per dispatch, so do it now:
- m_ndofManager->sendMotionEvent();
+ handled |= m_ndofManager->sendMotionEvent();
- bool handled;
if (m_eventManager) {
if (m_input_fidelity_hint == LO_FI)
- handled = m_eventManager->dispatchEvents_lo_fi();
+ handled |= m_eventManager->dispatchEvents_lo_fi();
else
- handled = m_eventManager->dispatchEvents();
+ handled |= m_eventManager->dispatchEvents();
}
- else {
- handled = false;
- }
m_timerManager->fireTimers(getMilliSeconds());
return handled;
@@ -276,8 +273,6 @@
m_timerManager = new GHOST_TimerManager ();
m_windowManager = new GHOST_WindowManager ();
m_eventManager = new GHOST_EventManager ();
-// m_ndofManager = new GHOST_NDOFManager();
-// Each platform now has their own NDOFManager subclass
#ifdef GHOST_DEBUG
if (m_eventManager) {
Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list