Support 3D mice on Linux and devices that send all six axes in report 1 (#343)
The space_mouse module was Windows-only (hidapi). On Linux it now finds the multi-axis HID interface through /sys/class/hidraw and reads /dev/hidrawN with plain std I/O, so there is no new dependency and no libudev needed. A small report descriptor parser tells devices apart: a top-level Multi-Axis Controller collection marks the 3D mouse, and report 1 declaring all six axes selects the combined layout (X Y Z Rx Ry Rz in one report) that some homemade devices use. Real split devices (report 1 translation, report 2 rotation) keep their existing decoding. Windows reads the descriptor through hidapi and falls back to the split layout if it is unavailable. Co-authored-by: jochenhammes <15869208+jochenhammes@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
6 files changed
+464
-26
No files matched your search
@@ -108,11 +108,25 @@ cargo xtask ci # fmt, clippy, tests, as
|
||||
|
||||
Windows builds: `cargo xwin build --release --target x86_64-pc-windows-msvc -p solvecraft`.
|
||||
|
||||
On Windows, SolidCraft detects a connected 3Dconnexion SpaceNavigator or SpaceMouse through its
|
||||
On Windows and Linux, SolidCraft detects a connected 3Dconnexion SpaceNavigator or SpaceMouse through its
|
||||
multi-axis HID interface. Move the cap to pan and zoom, and tilt or twist it to rotate the 3D view.
|
||||
While editing a sketch, the cap pans and zooms without changing the sketch view. The Navigation
|
||||
page in Preferences has an on/off switch and a speed control for the 3D mouse.
|
||||
|
||||
On Linux SolidCraft reads `/dev/hidrawN` directly, so the logged-in user needs access to the
|
||||
device. A udev rule that adds the `uaccess` tag does that, for example
|
||||
`/etc/udev/rules.d/70-3d-mouse.rules` for devices with 3Dconnexion's vendor id:
|
||||
|
||||
```
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="256f", TAG+="uaccess"
|
||||
```
|
||||
|
||||
Older SpaceNavigators use Logitech's vendor id `046d`; add a rule with their product id (see `lsusb`)
|
||||
instead of matching every Logitech device. Reload with `sudo udevadm control --reload && sudo udevadm trigger`, then replug the device. The Flatpak
|
||||
sandbox does not expose hidraw devices, so the 3D mouse only works with native builds there for now.
|
||||
Devices that send all six axes in HID report 1 (some homemade ones do) are recognised from their
|
||||
report descriptor, so they work as well.
|
||||
|
||||
In the browser: `cd apps/solvecraft-web && trunk build --release --public-url ./` (WebGPU, or
|
||||
WebGL2 with `?webgl`; `?sample` opens the sample part).
|
||||
|
||||
|
||||
Reference in new issue
Block a user