From c9216e390c240d48c5e2544a99ddb27317eef84d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 11 Aug 2011 15:59:19 +0000 Subject: Commiting patch from jensverwiebe for NDOF support on OSX --- SConstruct | 3 ++- build_files/scons/config/darwin-config.py | 5 +---- build_files/scons/tools/btools.py | 3 +-- intern/ghost/intern/GHOST_NDOFManagerCocoa.mm | 28 +++++++++++++++------------ 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/SConstruct b/SConstruct index 7b25f744103..81c12c7c318 100644 --- a/SConstruct +++ b/SConstruct @@ -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: diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 29695896921..ec6a3b082b8 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -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'] diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index aac16555df9..25e0582c536 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -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', ''), diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index 1d90b6daa68..409ed953134 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -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 -- cgit v1.2.3