Class SpaceNavigatorHid
java.lang.Object
eu.svjatoslav.aukio.e3d.gui.spacemouse.SpaceNavigatorHid
HID transport for 3Dconnexion 6DOF mice, read via the Linux hidraw
interface using JNA — same approach as the RayNeo glasses transport.
Supported models are listed in
SpaceNavigatorHid.Model; all share the same
raw axis sign conventions and ±350 full deflection, so
SpaceMouseController drives them identically.
Protocol, SpaceNavigator USB (from libspnav/spacenavd documentation): 7-byte input reports, sent ONLY while the cap is deflected or a button changes — at rest the pipe is silent (so unlike the XR glasses there is no stream watchdog; silence is normal):
- report[0] = 1 — translation; int16 LE at [1,2]=X, [3,4]=Y, [5,6]=Z; full deflection ≈ ±350
- report[0] = 2 — rotation; int16 LE at [1,2]=RX, [3,4]=RY, [5,6]=RZ; full deflection ≈ ±350
- report[0] = 3 — buttons; report[1] bit0 = left, bit1 = right
Protocol, SpaceMouse Wireless over Bluetooth (from the device's own HID report descriptor): a single combined motion report plus separate button and battery reports:
- report[0] = 1 — all six axes at once; int16 LE at [1,2]=X, [3,4]=Y, [5,6]=Z, [7,8]=RX, [9,10]=RY, [11,12]=RZ (13 bytes total)
- report[0] = 3 — buttons; report[1] bit0 = left, bit1 = right (3 bytes total)
- report[0] = 0x17 — battery; report[1] = charge 0..100, report[2] bit0 = charging
Raw axis sign conventions (identical on both models):
- TX: push cap right → positive
- TY: pull cap toward you → positive (live-verified)
- TZ: pull cap up → positive (live-verified)
- RX: tilt cap top away → positive
- RY: tilt cap top right → positive
- RZ: twist cap clockwise (seen from above) → positive
Detection scans /sys/class/hidraw for the HID_ID of any known model — the hidraw node changes on replug/reconnect, so never cache the path. Unplug is detected by a read error (read returns <0).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA supported 3Dconnexion device. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleFull deflection of any axis, per the HID descriptor. -
Method Summary
Modifier and TypeMethodDescriptionintBattery charge 0..100 as last reported by a wireless device, or -1 when the device has not reported it (wired models never do).intgetModel()Which supported device this instance talks to.intgetRx()intgetRy()intgetRz()intgetTx()intgetTy()intgetTz()booleanTrue when a wireless device last reported itself charging.booleanTrue while the device is connected and the reader is alive.static SpaceNavigatorHidopen()Finds and opens the first supported SpaceMouse on the system, or null when none is connected.voidstart()voidstop()
-
Field Details
-
FULL_DEFLECTION
public static final double FULL_DEFLECTIONFull deflection of any axis, per the HID descriptor.- See Also:
-
-
Method Details
-
open
Finds and opens the first supported SpaceMouse on the system, or null when none is connected. Throws when a device is present but cannot be opened (permissions — see /etc/udev/rules.d/99-spacenavigator.rules). -
start
public void start() -
isRunning
public boolean isRunning()True while the device is connected and the reader is alive. -
getModel
Which supported device this instance talks to. -
getTx
public int getTx() -
getTy
public int getTy() -
getTz
public int getTz() -
getRx
public int getRx() -
getRy
public int getRy() -
getRz
public int getRz() -
getButtons
public int getButtons() -
getBatteryPercent
public int getBatteryPercent()Battery charge 0..100 as last reported by a wireless device, or -1 when the device has not reported it (wired models never do). -
isCharging
public boolean isCharging()True when a wireless device last reported itself charging. -
stop
public void stop()
-