ports/cad/freecad/files/patch-spnav-support
Christoph Moench-Tegeder 46d3b8f4a2 cad/freecad: optionize SpaceMouse support
Originially, FreeCAD picked up libspnav (SpaceMouse) support
when the library was present in the system during build. That
alone would be a minor problem, but people still insist on
building in unclean systems.
Additionally, libspnav support in FreeCAD was broken and resulted
in build failure when accidentially building with libspnav (see
above).
Upstream fixed this in a series of changes touching many places
and sometimes even depending on otherwise unrelated changes:
importing all that would be close to updating to a snapshot.
Instead, adopt the relevant fix for building with libspnav from
upstream, and put the whole libspnav detection behind a cmake
option (made accessible as a port option).

PR:		285542
Reported by:	Chad Jacob Milios
2025-03-24 23:04:24 +01:00

94 lines
3.7 KiB
Text

commit f2b872ba4dc509622bda2d86ce42e2464d40832b
Author: Christoph Moench-Tegeder <cmt@burggraben.net>
Date: Mon Mar 24 01:03:53 2025 +0100
attempt to fix building with libspnav
diff --git cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
index e9aa47fd6e..826c510ef0 100644
--- cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
+++ cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
@@ -142,6 +142,7 @@ macro(InitializeFreeCADBuildOptions)
option(BUILD_CLOUD "Build the FreeCAD cloud module" OFF)
option(ENABLE_DEVELOPER_TESTS "Build the FreeCAD unit tests suit" ON)
+ option(FREECAD_SPNAV_SUPPORT "Enable libspnav support" OFF)
if(MSVC)
set(FREECAD_3DCONNEXION_SUPPORT "NavLib" CACHE STRING "Select version of the 3Dconnexion device integration")
set_property(CACHE FREECAD_3DCONNEXION_SUPPORT PROPERTY STRINGS "NavLib" "Raw input")
diff --git src/Gui/CMakeLists.txt src/Gui/CMakeLists.txt
index 642f58568f..52cc393875 100644
--- src/Gui/CMakeLists.txt
+++ src/Gui/CMakeLists.txt
@@ -133,7 +133,8 @@ if(${Qt5WinExtras_FOUND})
)
endif()
-IF(SPNAV_FOUND)
+IF(FREECAD_SPNAV_SUPPORT AND SPNAV_FOUND)
+ add_definitions(-D_USE_3DCONNEXION_SDK)
if(SPNAV_USE_X11)
add_definitions(-DSPNAV_USE_X11)
if (FREECAD_QT_MAJOR_VERSION EQUAL 5 AND UNIX AND NOT APPLE)
@@ -175,7 +176,11 @@ IF(SPNAV_FOUND)
list(APPEND FreeCADGui_LIBS
${SPNAV_LIBRARIES}
)
-ENDIF(SPNAV_FOUND)
+ENDIF(FREECAD_SPNAV_SUPPORT AND SPNAV_FOUND)
+
+IF(FREECAD_SPNAV_SUPPORT AND NOT SPNAV_FOUND)
+ MESSAGE(FATAL_ERROR "libspnav support requested but libspnav not found")
+ENDIF(FREECAD_SPNAV_SUPPORT AND NOT SPNAV_FOUND)
IF(OCULUS_FOUND)
add_definitions(-DOCULUS_FOUND)
diff --git src/Gui/GuiApplicationNativeEventAware.cpp src/Gui/GuiApplicationNativeEventAware.cpp
index ba41901472..c0cf3c7666 100644
--- src/Gui/GuiApplicationNativeEventAware.cpp
+++ src/Gui/GuiApplicationNativeEventAware.cpp
@@ -33,7 +33,7 @@
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
-#if defined(Q_OS_LINUX)
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
#if defined(SPNAV_USE_X11)
#include "3Dconnexion/GuiNativeEventLinuxX11.h"
#else
@@ -59,7 +59,15 @@ Gui::GUIApplicationNativeEventAware::~GUIApplicationNativeEventAware() = default
void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
{
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
+# if defined(USE_3DCONNEXION_NAVLIB)
+ ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath(
+ "User parameter:BaseApp/Preferences/View");
+ if (nativeEvent && hViewGrp->GetBool("LegacySpaceMouseDevices", false)) {
+ nativeEvent->initSpaceball(window);
+ }
+# else
nativeEvent->initSpaceball(window);
+# endif
#else
Q_UNUSED(window);
#endif
diff --git src/Gui/View3DInventorViewer.cpp src/Gui/View3DInventorViewer.cpp
index 694f834583..d32c2486b5 100644
--- src/Gui/View3DInventorViewer.cpp
+++ src/Gui/View3DInventorViewer.cpp
@@ -555,7 +555,15 @@ void View3DInventorViewer::init()
//filter a few qt events
viewerEventFilter = new ViewerEventFilter;
installEventFilter(viewerEventFilter);
+#if defined(USE_3DCONNEXION_NAVLIB)
+ ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath(
+ "User parameter:BaseApp/Preferences/View");
+ if (hViewGrp->GetBool("LegacySpaceMouseDevices", false)) {
+ getEventFilter()->registerInputDevice(new SpaceNavigatorDevice);
+ }
+#else
getEventFilter()->registerInputDevice(new SpaceNavigatorDevice);
+#endif
getEventFilter()->registerInputDevice(new GesturesDevice(this));
try{