mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-26 11:54:14 +02:00
aaeaff55cc
The 3D mouse only worked on Linux, through spacenavd. This adds a second backend that reads the device directly over USB through hidapi, with no 3Dconnexion driver or SDK: the route to Windows and macOS (discussion #599), and usable on Linux without spacenavd. SpaceMouseHid decodes the raw reports from the device's own report descriptor -- where each axis and button sits, its range, absolute or relative -- so no per-model table is needed, with the classic report 1/2/3 layout as a fallback when the descriptor cannot be read and the 0x1c button list newer devices send. Absolute axes are rescaled to +-500 exactly as spacenavd does, so both backends give QET the same values. HidBackend polls from the main thread (fast while moving, slow when still), emits one sample per poll, and looks for a device every 3 s so plugging one in or back in needs no restart. QET_SPACEMOUSE_BACKEND (auto, spnav, hid) picks the backend; auto keeps libspnav on Linux when it is found and uses hidapi otherwise. hidapi is found through pkg-config as hidapi-hidraw (Linux) or hidapi (MSYS2, Homebrew). A sample arriving in the same millisecond as the previous one now counts for no time instead of a full period, so a burst of queued samples no longer moves the view further than the time it covers. Tested without a device: tst_spacemousehid (descriptor parsing, broken and hostile descriptors, every report form, recordings from real devices once they are added to fixtures/spacemouse), and end to end on Linux through a virtual USB device created with /dev/uhid: the same moves give byte-identical screenshots through the hidapi and libspnav backends, an absolute axis is rescaled as spacenavd does, buttons trigger their bound action, and unplugging and replugging while QET runs (including with a dialog open that a device button opened) reconnects cleanly. Not tested on Windows, macOS or real hardware. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.5 KiB
CMake
55 lines
2.5 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(" - developer_options")
|
|
|
|
# warn on *any* usage of deprecated APIs
|
|
add_definitions(-DQT_DEPRECATED_WARNINGS)
|
|
|
|
# You can make your code fail to compile if it uses deprecated APIs.
|
|
# In order to do so, uncomment the following line.
|
|
# disables all the APIs deprecated before Qt 6.0.0
|
|
#add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
|
|
|
|
# to enable function names and line numbers even for release builds
|
|
add_definitions(-DQT_MESSAGELOGCONTEXT)
|
|
|
|
# You can make your code warn on compile time for the TODO's
|
|
# In order to do so, uncomment the following line.
|
|
#add_definitions(-DTODO_LIST)
|
|
|
|
# Build with KDE Frameworks.
|
|
option(BUILD_WITH_KF "Build with KDE Frameworks" ON)
|
|
|
|
# Precompiled headers for the Qt umbrella headers.
|
|
#
|
|
# Off by default and intended for local development only. Building QET is
|
|
# dominated by re-parsing Qt's headers: a 214-line .cpp expands to ~198,000
|
|
# preprocessed lines, and compiling one translation unit costs ~4.1 s of which
|
|
# only ~0.35 s is optimisation (-O0 instead of -O3 saves 8%). A PCH caches the
|
|
# parsed header state and takes that ~4.1 s down to ~1.2 s.
|
|
#
|
|
# It is deliberately NOT on by default: a PCH satisfies includes that a source
|
|
# file forgot to make itself, so code written with it enabled can fail to
|
|
# compile for everyone else. Leaving it off keeps CI and contributors on the
|
|
# strict behaviour, and only developers who opt in trade that for the speed.
|
|
option(QET_ENABLE_PCH "Use precompiled headers (developer build speed; may mask missing #includes)" OFF)
|
|
|
|
# Discussion #599: 3Dconnexion SpaceMouse/SpacePilot pan/zoom support. Off by
|
|
# default -- see cmake/find_spacemouse.cmake for the backends and what happens
|
|
# when it is on but no library is found.
|
|
option(QET_ENABLE_SPACEMOUSE "Build with 3D mouse (3Dconnexion SpaceMouse) support for pan/zoom; needs libspnav or hidapi, see QET_SPACEMOUSE_BACKEND" OFF)
|