[Bf-blender-cvs] [31632e7] master: NDof device: Check for socket exists before connecting to spnavd

Sergey Sharybin noreply at git.blender.org
Fri Apr 22 10:15:40 CEST 2016


Commit: 31632e7f74423aec01d64e3964200a03a70491d8
Author: Sergey Sharybin
Date:   Fri Apr 22 10:14:30 2016 +0200
Branches: master
https://developer.blender.org/rB31632e7f74423aec01d64e3964200a03a70491d8

NDof device: Check for socket exists before connecting to spnavd

This allows us to get rid of annoying and misleading error printed to the console
about being unable to connect to something.

===================================================================

M	intern/ghost/intern/GHOST_NDOFManagerUnix.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
index df51635..8fea2a0 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
@@ -28,13 +28,22 @@
 
 #include <spnav.h>
 #include <stdio.h>
+#include <unistd.h>
 
+#define SPNAV_SOCK_PATH "/var/run/spnav.sock"
 
 GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System& sys)
     : GHOST_NDOFManager(sys),
       m_available(false)
 {
-	if (spnav_open() != -1) {
+	if (access(SPNAV_SOCK_PATH, F_OK) != 0) {
+#ifdef DEBUG
+		/* annoying for official builds, just adds noise and most people don't own these */
+		puts("ndof: spacenavd not found");
+		/* This isn't a hard error, just means the user doesn't have a 3D mouse. */
+#endif
+	}
+	else if (spnav_open() != -1) {
 		m_available = true;
 
 		/* determine exactly which device (if any) is plugged in */
@@ -55,13 +64,6 @@ GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System& sys)
 			pclose(command_output);
 		}
 	}
-	else {
-#ifdef DEBUG
-		/* annoying for official builds, just adds noise and most people don't own these */
-		puts("ndof: spacenavd not found");
-		/* This isn't a hard error, just means the user doesn't have a 3D mouse. */
-#endif
-	}
 }
 
 GHOST_NDOFManagerUnix::~GHOST_NDOFManagerUnix()




More information about the Bf-blender-cvs mailing list