Commiting patch from jensverwiebe for NDOF support on OSX v2.59
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 11 Aug 2011 15:59:19 +0000 (15:59 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 11 Aug 2011 15:59:19 +0000 (15:59 +0000)
SConstruct
build_files/scons/config/darwin-config.py
build_files/scons/tools/btools.py
intern/ghost/intern/GHOST_NDOFManagerCocoa.mm

index 7b25f744103c0c2f9b20576d18f4785d691eb6b9..81c12c7c318091e2ee6ce19ae4bb84dcfb1d502c 100644 (file)
@@ -268,7 +268,8 @@ if env['OURPLATFORM']=='darwin':
     if env['WITH_BF_3DMOUSE'] == 1 and not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
         print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
         env['WITH_BF_3DMOUSE'] = 0
-        env['FOUND_NDOF_DRIVERS'] = 0
+    else:
+        env.Append(LINKFLAGS=['-weak_framework','3DconnexionClient'])
 
 
 if env['WITH_BF_OPENMP'] == 1:
index 29695896921d10bec48aa322bd1723ed963fc2c4..ec6a3b082b8a0bead7854284080d489d5960e377 100644 (file)
@@ -284,7 +284,7 @@ if MACOSX_ARCHITECTURE == 'i386':
 elif MACOSX_ARCHITECTURE == 'x86_64':
     BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
 
-# SpaceNavigator and related 3D mice
+# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later !
 WITH_BF_3DMOUSE = True
 
 #############################################################################
@@ -315,9 +315,6 @@ if WITH_BF_QUICKTIME:
        else:
                PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
 
-if FOUND_NDOF_DRIVERS:
-       PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS + ['-weak_framework','3DconnexionClient']
-
 #note to build succesfully on 10.3.9 SDK you need to patch  10.3.9 by adding the SystemStubs.a lib from 10.4
 LLIBS = ['stdc++', 'SystemStubs']
 
index aac16555df98bcc81d520fc9e5bb7435e6f2849c..25e0582c536f13089213fe92763045a367804df7 100644 (file)
@@ -136,7 +136,7 @@ def validate_arguments(args, bc):
             'BF_NO_ELBEEM',
             'WITH_BF_CXX_GUARDEDALLOC',
             'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC',
-            'BUILDBOT_BRANCH', 'WITH_BF_3DMOUSE', 'FOUND_NDOF_DRIVERS', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC'
+            'BUILDBOT_BRANCH', 'WITH_BF_3DMOUSE', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC'
             ]
     
     # Have options here that scons expects to be lists
@@ -439,7 +439,6 @@ def read_opts(env, cfg, args):
         (BoolVariable('WITH_BF_NOBLENDER', 'Do not build blender if true', False)),
 
         (BoolVariable('WITH_BF_3DMOUSE', 'Build blender with support of 3D mouses', False)),
-        (BoolVariable('FOUND_NDOF_DRIVERS', 'We detected NDOF libs or framework', False)),
         (BoolVariable('WITH_BF_STATIC3DMOUSE', 'Staticly link to 3d mouse library', False)),
         ('BF_3DMOUSE', '3d mouse library base path', ''),
         ('BF_3DMOUSE_INC', '3d mouse library include path', ''),
index 1d90b6daa6866198131ba9098424cbe6fc06242c..409ed953134b517286d2666517da8849bb7349e1 100644 (file)
@@ -159,18 +159,22 @@ GHOST_NDOFManagerCocoa::GHOST_NDOFManagerCocoa(GHOST_System& sys)
 
 GHOST_NDOFManagerCocoa::~GHOST_NDOFManagerCocoa()
 {
-       UnregisterConnexionClient(m_clientID);
-       CleanupConnexionHandlers();
-       ghost_system = NULL;
-       ndof_manager = NULL;
+       if (available())
+       {
+               UnregisterConnexionClient(m_clientID);
+               CleanupConnexionHandlers();
+               ghost_system = NULL;
+               ndof_manager = NULL;
+       }
 }
-
-bool GHOST_NDOFManagerCocoa::available()
-{
-       // extern OSErr InstallConnexionHandlers() __attribute__((weak_import));
-       // ^^ not needed since the entire framework is weak-linked
-       return InstallConnexionHandlers != NULL;
-       // this means that the driver is installed and dynamically linked to blender
+extern "C" {
+       bool GHOST_NDOFManagerCocoa::available()
+       {
+               extern OSErr InstallConnexionHandlers() __attribute__((weak_import));
+               // Make the linker happy for the framework check (see link below for more info)
+               // http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
+               return InstallConnexionHandlers != NULL;
+               // this means that the driver is installed and dynamically linked to blender
+       }
 }
-
 #endif // WITH_INPUT_NDOF