stricter WITH_INPUT_NDOF guards, general cleanup
authorMike Erwin <significant.bit@gmail.com>
Sun, 7 Aug 2011 16:44:10 +0000 (16:44 +0000)
committerMike Erwin <significant.bit@gmail.com>
Sun, 7 Aug 2011 16:44:10 +0000 (16:44 +0000)
intern/ghost/intern/GHOST_NDOFManager.cpp
intern/ghost/intern/GHOST_NDOFManagerCocoa.h
intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
intern/ghost/intern/GHOST_NDOFManagerX11.cpp
intern/ghost/intern/GHOST_NDOFManagerX11.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemX11.cpp

index 855e27b99644411f61456f8a49f7e8fabf84d5c9..a24ccc3ff6c8d860eaae00ad196887d50e29c948 100644 (file)
@@ -375,7 +375,7 @@ void GHOST_NDOFManager::setDeadZone(float dz)
 
 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 @@ static bool nearHomePosition(GHOST_TEventNDOFMotionData* ndof, float threshold)
                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 @@ bool GHOST_NDOFManager::sendMotionEvent()
 
        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 @@ bool GHOST_NDOFManager::sendMotionEvent()
                        }
                        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 @@ bool GHOST_NDOFManager::sendMotionEvent()
                        }
                        break;
                default:
-                       break;
+                       ; // will always be one of the above
        }
 
 #ifdef DEBUG_NDOF_MOTION
index 27397b711b7a0e2df9840416a8429de4c33d2a54..e9897f30104c2122ae84de83f3c28dee395b0011 100644 (file)
  *
  * ***** 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 @@ private:
 };
 
 
-#endif
+#endif // WITH_INPUT_NDOF
+#endif // #include guard
index 53a991a7396f78ede325f01cbf93bfbdbf59d9ec..1d90b6daa6866198131ba9098424cbe6fc06242c 100644 (file)
@@ -22,7 +22,9 @@
  *
  * ***** END GPL LICENSE BLOCK *****
  */
+
+#ifdef WITH_INPUT_NDOF
+
 #include "GHOST_NDOFManagerCocoa.h"
 #include "GHOST_SystemCocoa.h"
 
@@ -170,3 +172,5 @@ bool GHOST_NDOFManagerCocoa::available()
        return InstallConnexionHandlers != NULL;
        // this means that the driver is installed and dynamically linked to blender
 }
+
+#endif // WITH_INPUT_NDOF
index 099fa15d179ee0335879bbfb278de277f19014c3..4dd5331903962875e8b01fa4f7c18e590a869c16 100644 (file)
@@ -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_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys)
       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 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys)
                                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 @@ bool GHOST_NDOFManagerX11::available()
        return m_available;
 }
 
-//bool GHOST_NDOFManagerX11::identifyDevice()
-//{
-//     
-//}
-
 bool GHOST_NDOFManagerX11::processEvents()
 {
        GHOST_TUns64 now = m_system.getMilliSeconds();
@@ -88,7 +85,7 @@ bool GHOST_NDOFManagerX11::processEvents()
                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 @@ bool GHOST_NDOFManagerX11::processEvents()
        }
        return anyProcessed;
 }
+
+#endif /* WITH_INPUT_NDOF */
index 82bd256c70736c6e869c50bf91217493f951672c..0a5497537563996ef6d5296d97ebe83acf1f5584 100644 (file)
@@ -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 @@ public:
        bool processEvents();
 
 private:
-       //      bool identifyDevice();
-
        bool m_available;
 };
 
-#endif
+#endif /* WITH_INPUT_NDOF */
+#endif /* #include guard */
 
index 17f0f2d6ecde753edc0da85d9d9a3ce18ec1325f..303c2b24497df406d08ee3aa47f8d0325af20a80 100644 (file)
@@ -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 *****
  */
 #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
index 105f71b514f9ad8b0f20dedaaa765d4263e87f13..d5100e589f2aa08933664c21d173bee751826d07 100644 (file)
 #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 @@ GHOST_SystemX11::processEvent(XEvent *xe)
        }
 }
 
-#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(