[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39153] trunk/blender/intern/ghost/intern: stricter WITH_INPUT_NDOF guards, general cleanup
Mike Erwin
significant.bit at gmail.com
Sun Aug 7 18:44:10 CEST 2011
Revision: 39153
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39153
Author: merwin
Date: 2011-08-07 16:44:10 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
stricter WITH_INPUT_NDOF guards, general cleanup
Modified Paths:
--------------
trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp
trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.h
trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp 2011-08-07 16:44:10 UTC (rev 39153)
@@ -375,7 +375,7 @@
static bool atHomePosition(GHOST_TEventNDOFMotionData* ndof)
{
-#define HOME(foo) (ndof->foo == 0)
+#define HOME(foo) (ndof->foo == 0.f)
return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz);
#undef HOME
}
@@ -386,9 +386,9 @@
return atHomePosition(ndof);
}
else {
-#define HOME1(foo) (fabsf(ndof->foo) < threshold)
- return HOME1(tx) && HOME1(ty) && HOME1(tz) && HOME1(rx) && HOME1(ry) && HOME1(rz);
-#undef HOME1
+#define HOME(foo) (fabsf(ndof->foo) < threshold)
+ return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz);
+#undef HOME
}
}
@@ -423,17 +423,17 @@
data->dt = 0.001f * (m_motionTime - m_prevMotionTime); // in seconds
- bool handMotion = !nearHomePosition(data, m_deadZone);
+ bool weHaveMotion = !nearHomePosition(data, m_deadZone);
// determine what kind of motion event to send (Starting, InProgress, Finishing)
// and where that leaves this NDOF manager (NotStarted, InProgress, Finished)
switch (m_motionState) {
case GHOST_kNotStarted:
case GHOST_kFinished:
- if (handMotion) {
+ if (weHaveMotion) {
data->progress = GHOST_kStarting;
m_motionState = GHOST_kInProgress;
- // prev motion time will be ancient, so just make up something reasonable
+ // prev motion time will be ancient, so just make up a reasonable time delta
data->dt = 0.0125f;
}
else {
@@ -443,9 +443,9 @@
}
break;
case GHOST_kInProgress:
- if (handMotion) {
+ if (weHaveMotion) {
data->progress = GHOST_kInProgress;
- // keep InProgress state
+ // remain 'InProgress'
}
else {
data->progress = GHOST_kFinishing;
@@ -453,7 +453,7 @@
}
break;
default:
- break;
+ ; // will always be one of the above
}
#ifdef DEBUG_NDOF_MOTION
Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.h 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.h 2011-08-07 16:44:10 UTC (rev 39153)
@@ -22,10 +22,12 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
#ifndef _GHOST_NDOFMANAGERCOCOA_H_
#define _GHOST_NDOFMANAGERCOCOA_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
// Event capture is handled within the NDOF manager on Macintosh,
@@ -47,4 +49,5 @@
};
-#endif
+#endif // WITH_INPUT_NDOF
+#endif // #include guard
Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm 2011-08-07 16:44:10 UTC (rev 39153)
@@ -22,7 +22,9 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManagerCocoa.h"
#include "GHOST_SystemCocoa.h"
@@ -170,3 +172,5 @@
return InstallConnexionHandlers != NULL;
// this means that the driver is installed and dynamically linked to blender
}
+
+#endif // WITH_INPUT_NDOF
Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.cpp 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.cpp 2011-08-07 16:44:10 UTC (rev 39153)
@@ -22,7 +22,9 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManagerX11.h"
#include "GHOST_SystemX11.h"
#include <spnav.h>
@@ -34,14 +36,14 @@
GHOST_NDOFManager(sys),
m_available(false)
{
- setDeadZone(0.1f); // how to calibrate on Linux? throw away slight motion!
+ setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */
if (spnav_open() != -1) {
- // determine exactly which device (if any) is plugged in
+ /* determine exactly which device (if any) is plugged in */
#define MAX_LINE_LENGTH 100
- // look for USB devices with Logitech's vendor ID
+ /* look for USB devices with Logitech's vendor ID */
FILE* command_output = popen("lsusb -d 046d:","r");
if (command_output) {
char line[MAX_LINE_LENGTH] = {0};
@@ -50,15 +52,15 @@
if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2)
if (setDevice(vendor_id, product_id)) {
m_available = true;
- break; // stop looking once the first 3D mouse is found
+ break; /* stop looking once the first 3D mouse is found */
}
}
pclose(command_output);
}
}
else {
- printf("ndof: spacenavd not found\n");
- // This isn't a hard error, just means the user doesn't have a 3D mouse.
+ puts("ndof: spacenavd not found");
+ /* This isn't a hard error, just means the user doesn't have a 3D mouse. */
}
}
@@ -73,11 +75,6 @@
return m_available;
}
-//bool GHOST_NDOFManagerX11::identifyDevice()
-//{
-//
-//}
-
bool GHOST_NDOFManagerX11::processEvents()
{
GHOST_TUns64 now = m_system.getMilliSeconds();
@@ -88,7 +85,7 @@
switch (e.type) {
case SPNAV_EVENT_MOTION:
{
- // convert to blender view coords
+ /* convert to blender view coords */
short t[3] = {e.motion.x, e.motion.y, -e.motion.z};
short r[3] = {-e.motion.rx, -e.motion.ry, e.motion.rz};
@@ -104,3 +101,5 @@
}
return anyProcessed;
}
+
+#endif /* WITH_INPUT_NDOF */
Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.h 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManagerX11.h 2011-08-07 16:44:10 UTC (rev 39153)
@@ -26,6 +26,8 @@
#ifndef _GHOST_NDOFMANAGERX11_H_
#define _GHOST_NDOFMANAGERX11_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
/* Event capture is handled within the NDOF manager on Linux,
@@ -40,10 +42,9 @@
bool processEvents();
private:
- // bool identifyDevice();
-
bool m_available;
};
-#endif
+#endif /* WITH_INPUT_NDOF */
+#endif /* #include guard */
Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm 2011-08-07 16:44:10 UTC (rev 39153)
@@ -21,8 +21,8 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): Maarten Gribnau 05/2001
- * Damien Plisson 09/2009
+ * Contributors: Maarten Gribnau 05/2001
+ * Damien Plisson 09/2009
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -43,16 +43,17 @@
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
#include "GHOST_EventWheel.h"
-#include "GHOST_EventNDOF.h"
#include "GHOST_EventTrackpad.h"
#include "GHOST_EventDragnDrop.h"
#include "GHOST_EventString.h"
-
#include "GHOST_TimerManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowCocoa.h"
+#ifdef WITH_INPUT_NDOF
#include "GHOST_NDOFManagerCocoa.h"
+#endif
+
#include "AssertMacros.h"
#pragma mark KeyMap, mouse converters
Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp 2011-08-07 16:29:05 UTC (rev 39152)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp 2011-08-07 16:44:10 UTC (rev 39153)
@@ -42,8 +42,10 @@
#include "GHOST_EventKey.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventWheel.h"
-#include "GHOST_NDOFManagerX11.h"
#include "GHOST_DisplayManagerX11.h"
+#ifdef WITH_INPUT_NDOF
+#include "GHOST_NDOFManagerX11.h"
+#endif
#include "GHOST_Debug.h"
@@ -815,22 +817,6 @@
}
}
-#if 0 // obsolete SpaceNav code
-
- 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;
-}
-
-#endif
-
GHOST_TSuccess
GHOST_SystemX11::
getModifierKeys(
More information about the Bf-blender-cvs
mailing list