mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 22:24:13 +02:00
4381c6caa3
On macOS, 3DxWare installs a driver extension that takes the 3D mouse over. With it installed, HidBackend opens the device but receives nothing, so the mouse did nothing in QElectroTech until 3DxWare was uninstalled (discussion #599, PR #1028). Most Mac owners of a 3D mouse have 3DxWare installed. ConnexionBackend asks 3DxWare for the motion instead, through 3DconnexionClient.framework, as Blender does. SpaceMouseListener tries it first. When 3DxWare is not installed, or is installed but its driver is not running, it falls back to HidBackend, so the device works in both setups. Take-over mode stops 3DxWare's own actions in QET, so the view does not move twice. The library is loaded at run time from where 3DxWare installs it: nothing is linked or bundled, and the build needs no SDK. The few declarations are written here, from Blender's GHOST_NDOFManagerCocoa.mm, because 3Dconnexion's SDK headers may not be redistributed. 3DxWare's axes are y up and z away from the user; they are mapped to QET's raw USB convention by comparing Blender's 3DxWare and spacenavd code paths. The release script signs with the hardened runtime, which refuses a library another team signed. misc/qelectrotech.entitlements adds com.apple.security.cs.disable-library-validation (Blender's notarized build carries the same one), and MacQetDeploy_arm64_cmake.sh now passes it to all four signings of the app, including the re-sign inside the DMG. Tested: tst_spacemouseconnexion runs the backend on every platform against fakeconnexion, a stand-in library that answers from its own thread as 3DxWare does: registration, the axis mapping, buttons, other clients' messages, 3DxWare not installed or not running, deletion with a message in flight. Flipping an axis sign or dropping the client check turns it red. realLibrary() loads the real framework when 3DxWare is installed. Linux Qt 6 build with the 3D mouse enabled: all 18 tests pass. Not tested: on a Mac with a real device. The axis signs and whether buttons arrive as a bitmask with current 3DxWare are unverified. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
4.2 KiB
CMake
96 lines
4.2 KiB
CMake
# Copyright 2006 The QElectroTech Team
|
|
# This file is part of QElectroTech.
|
|
#
|
|
# QElectroTech is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# QElectroTech is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
message(" - find_spacemouse")
|
|
|
|
# QET_ENABLE_SPACEMOUSE (cmake/developer_options.cmake) is off by default,
|
|
# so none of this runs, and the default build is entirely unaffected: no new
|
|
# dependency, no new source files, no new symbols.
|
|
#
|
|
# When it is on, QET_SPACEMOUSE_BACKEND picks how the device is read -- see
|
|
# sources/spacemouse/spacemousebackend.h for what a backend is:
|
|
# spnav Linux, through the spacenavd daemon (libspnav)
|
|
# hid any platform, directly over USB (hidapi), no 3Dconnexion driver
|
|
# auto spnav on Linux when libspnav is found, hid otherwise
|
|
# On macOS the 3DxWare backend is added to whichever of these is chosen.
|
|
# A backend whose library is not found downgrades the option to off with a
|
|
# warning, rather than failing configure for an opt-in feature.
|
|
set(QET_SPACEMOUSE_BACKEND "auto" CACHE STRING "3D mouse backend: auto, spnav or hid")
|
|
set_property(CACHE QET_SPACEMOUSE_BACKEND PROPERTY STRINGS auto spnav hid)
|
|
|
|
set(QET_SPACEMOUSE_ENABLED FALSE)
|
|
set(QET_SPACEMOUSE_BACKEND_SPNAV_ENABLED FALSE)
|
|
set(QET_SPACEMOUSE_BACKEND_HID_ENABLED FALSE)
|
|
set(QET_SPACEMOUSE_BACKEND_CONNEXION_ENABLED FALSE)
|
|
|
|
if(QET_ENABLE_SPACEMOUSE)
|
|
find_package(PkgConfig)
|
|
|
|
set(_qet_spacemouse_try_spnav FALSE)
|
|
set(_qet_spacemouse_try_hid FALSE)
|
|
if(QET_SPACEMOUSE_BACKEND STREQUAL "spnav")
|
|
set(_qet_spacemouse_try_spnav TRUE)
|
|
elseif(QET_SPACEMOUSE_BACKEND STREQUAL "hid")
|
|
set(_qet_spacemouse_try_hid TRUE)
|
|
else()
|
|
if(UNIX AND NOT APPLE)
|
|
set(_qet_spacemouse_try_spnav TRUE)
|
|
endif()
|
|
set(_qet_spacemouse_try_hid TRUE)
|
|
endif()
|
|
|
|
# libspnav: Debian/Ubuntu's libspnav-dev ships spnav.pc.
|
|
if(_qet_spacemouse_try_spnav AND PkgConfig_FOUND)
|
|
pkg_check_modules(SPNAV IMPORTED_TARGET spnav)
|
|
if(SPNAV_FOUND)
|
|
set(QET_SPACEMOUSE_ENABLED TRUE)
|
|
set(QET_SPACEMOUSE_BACKEND_SPNAV_ENABLED TRUE)
|
|
add_definitions(-DQET_SPACEMOUSE_BACKEND_SPNAV)
|
|
message("QET_ENABLE_SPACEMOUSE ON (backend: libspnav ${SPNAV_VERSION})")
|
|
endif()
|
|
endif()
|
|
|
|
# hidapi: hidapi-hidraw.pc on Linux (libhidapi-dev), hidapi.pc from
|
|
# MSYS2 (mingw-w64-ucrt-x86_64-hidapi) and Homebrew (hidapi).
|
|
if(NOT QET_SPACEMOUSE_ENABLED AND _qet_spacemouse_try_hid AND PkgConfig_FOUND)
|
|
pkg_search_module(HIDAPI IMPORTED_TARGET hidapi-hidraw hidapi)
|
|
if(HIDAPI_FOUND)
|
|
set(QET_SPACEMOUSE_ENABLED TRUE)
|
|
set(QET_SPACEMOUSE_BACKEND_HID_ENABLED TRUE)
|
|
add_definitions(-DQET_SPACEMOUSE_BACKEND_HID)
|
|
message("QET_ENABLE_SPACEMOUSE ON (backend: hidapi ${HIDAPI_VERSION})")
|
|
endif()
|
|
endif()
|
|
|
|
# macOS: with 3DxWare installed the device can only be read through
|
|
# 3DxWare, so its backend comes too, whichever backend was asked for.
|
|
# It loads 3DxWare's library at run time and needs nothing to build.
|
|
if(APPLE)
|
|
set(QET_SPACEMOUSE_ENABLED TRUE)
|
|
set(QET_SPACEMOUSE_BACKEND_CONNEXION_ENABLED TRUE)
|
|
add_definitions(-DQET_SPACEMOUSE_BACKEND_CONNEXION)
|
|
message("QET_ENABLE_SPACEMOUSE ON (backend: 3DxWare when installed)")
|
|
endif()
|
|
|
|
if(QET_SPACEMOUSE_ENABLED)
|
|
add_definitions(-DQET_SPACEMOUSE_SUPPORT)
|
|
else()
|
|
message(WARNING "QET_ENABLE_SPACEMOUSE is ON but no library was found for the "
|
|
"'${QET_SPACEMOUSE_BACKEND}' backend (libspnav-dev for spnav, "
|
|
"hidapi for hid, via pkg-config) -- building WITHOUT 3D mouse support.")
|
|
endif()
|
|
endif()
|