Files
qelectrotech-source-mirror/sources/ui/configpage/spacemouseconfigpage.h
T
ispyisail 17ebbffbca Add 3D mouse speed, direction, dead zone and twist-to-zoom settings
The 3D mouse's pan and zoom speeds were fixed guesses, and each sample
was applied as it came, so the speed on screen depended on how often
the driver sends samples -- different for every platform and device.

Motion now goes through SpaceMouseMotion::map(), which scales each
sample by the time since the previous one, and applies the user's
settings from a new "Mouvement" section of Configuration > Souris 3D:
pan and zoom speed, a dead zone, inverting each axis, and zooming by
push/pull (as before) or by twisting the cap. The defaults keep the
previous behaviour. Zoom is now exponential in the deflection, so the
factor stays positive however hard the cap is pulled (1 + z/1000 went
negative past z = -1000) and an equal push and pull cancel out. Sub-
pixel pan is carried over between samples instead of being rounded
away. The backend now reports all six axes.

tst_spacemousemotion covers the mapping without a device and is built
whether or not QET_ENABLE_SPACEMOUSE is on. The new behaviour was also
checked end to end with tools/spnav-shim (qelectrotech-docker): twist
with a dead zone of 10 ignores push/pull and small drift, and a twist of
60 gives the same frame as a push of 50 with the defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 09:56:04 +12:00

85 lines
2.7 KiB
C++

/*
Copyright 2006-2026 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/>.
*/
#ifndef SPACEMOUSECONFIGPAGE_H
#define SPACEMOUSECONFIGPAGE_H
#include "configpage.h"
class QCheckBox;
class QComboBox;
class QGroupBox;
class QSpinBox;
class QTableWidget;
/**
@brief The SpaceMouseConfigPage class
Configuration page for the 3D mouse: how motion pans and zooms the view
(SpaceMouseSettings: speeds, dead zone, which axes are inverted, and
whether zoom follows push/pull or twist), then every
device-button-to-action binding (SpaceMouseButtonMap), letting the
user add, edit and remove them.
Modelled directly on ShortcutsConfigPage, one row per binding instead
of one row per shortcut, since the two are close cousins: both end in
the same place -- ShortcutManager::trigger()/registerAction() -- just
from a different input source. Bindings are only persisted (via
SpaceMouseButtonMap::setActionId()) when applyConf() runs, i.e. when
the user validates the surrounding ConfigDialog.
Only compiled in, and only added to the Configuration dialog, when
QET_SPACEMOUSE_SUPPORT is defined -- see qetapp.cpp.
Button numbering is intentionally not fixed to any particular device:
it is exactly whatever integer SpaceMouseBackend::buttonPressed()
reports for the button pressed, which is backend- and device-specific.
Rows are added/removed freely rather than the page assuming a button
count, since that varies from 2 (SpaceMouse Compact) to over 30
(SpacePilot Pro).
*/
class SpaceMouseConfigPage : public ConfigPage
{
Q_OBJECT
public:
explicit SpaceMouseConfigPage(QWidget *parent = nullptr);
~SpaceMouseConfigPage() override;
void applyConf() override;
QString title() const override;
QIcon icon() const override;
private slots:
void addRow();
void removeSelectedRow();
private:
QGroupBox *buildMotionGroup();
void populateTable();
void appendRow(int button, const QString &action_id);
QSpinBox *m_pan_speed;
QSpinBox *m_zoom_speed;
QSpinBox *m_dead_zone;
QComboBox *m_zoom_axis;
QCheckBox *m_invert_pan_x;
QCheckBox *m_invert_pan_y;
QCheckBox *m_invert_zoom;
QTableWidget *m_table;
};
#endif // SPACEMOUSECONFIGPAGE_H