Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

3D mouse: choose which motion drives each axis (#2782)

The Nomadf22a026c27bb
diff --git a/apps/solidcraft/src/space_mouse.rs b/apps/solidcraft/src/space_mouse.rs
index 9089ceac7a..245107f2bb 100644
--- a/apps/solidcraft/src/space_mouse.rs
+++ b/apps/solidcraft/src/space_mouse.rs
@@ -8,6 +8,8 @@ mod hidraw;
#[cfg(target_os = "linux")]
mod spacenavd;
+#[cfg(target_os = "linux")]
+use std::sync::atomic::AtomicU8;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
@@ -19,9 +21,22 @@ use quick_xml::Reader;
use quick_xml::events::Event;
use solidcraft_space_mouse::Layout;
use solidcraft_ui_egui::SolveApp;
+#[cfg(target_os = "linux")]
+use solidcraft_ui_egui::prefs::SpaceMouseDriver;
+#[cfg(target_os = "linux")]
+use solidcraft_ui_egui::space_mouse::DriversPresent;
use solidcraft_ui_egui::space_mouse::{Axes, AxisRule, Calibration, DriverMapping, WheelGuard, calibrated, calibration, navigate_frame};
const STALE_AFTER: Duration = Duration::from_millis(150);
+/// How long a held (spacenavd) reading that is nearly at rest may go without a new record before
+/// it reads as rest: spacenavd sends no final record when the cap springs back, only the last
+/// small leftover. Longer than `STALE_AFTER` so a light, steady hold gets a moment before it ends.
+const HELD_SETTLE_AFTER: Duration = Duration::from_millis(500);
+/// How far from rest (raw units, full deflection is 350) every axis of a held reading must be for
+/// it to settle. The dead zone is 20, but the last records of real releases reach 129 on one axis
+/// (tangency-labs/solidcraft#3523), so this sits well above it. A firmer push is a deliberate
+/// hold and stays.
+const HELD_SETTLE_BAND: u16 = 150;
/// Whether the 3Dconnexion driver (macOS) has the device: it then reports the cap, and reading
/// the HID device would fail or report it twice.
static DRIVER_CONNECTED: AtomicBool = AtomicBool::new(false);
@@ -199,9 +214,11 @@ struct Reading {
/// When each of X, Y, Z, Rx, Ry and Rz last arrived. Each ages on its own: a device may send
/// translation and rotation in separate reports, or spread even one group over several.
at: [Instant; 6],
- /// The source says when the cap is back at rest, so a reading stays until the next one.
- /// A HID device repeats its report while the cap is held; spacenavd sends a record only when
- /// the values change, and a steady hold can go seconds without one.
+ /// The source sends a record only when the values change, so a reading stays until the next
+ /// one: a steady hold can go seconds without one. It never says when the cap springs back,
+ /// though, so a reading within `HELD_SETTLE_BAND` of rest on every axis settles after
+ /// `HELD_SETTLE_AFTER`. A HID device repeats its report while the cap is held, so it ages out
+ /// per axis instead.
held: bool,
}
@@ -214,7 +231,14 @@ impl Reading {
/// is calibrated, so a device that rests off zero calibrates to no motion rather than drifting.
fn current(self, now: Instant, rest: Axes) -> Axes {
let mut axes = self.axes;
- if !self.held {
+ if self.held {
+ let values = axes.translation.into_iter().chain(axes.rotation);
+ let rests = rest.translation.into_iter().chain(rest.rotation);
+ let near_rest = values.zip(rests).all(|(value, rest)| value.abs_diff(rest) <= HELD_SETTLE_BAND);
+ if near_rest && now.duration_since(self.at[0]) >= HELD_SETTLE_AFTER {
+ return rest;
+ }
+ } else {
let rest = rest.translation.into_iter().chain(rest.rotation);
for ((value, at), rest) in axes.translation.iter_mut().chain(axes.rotation.iter_mut()).zip(self.at).zip(rest) {
if now.duration_since(at) >= STALE_AFTER {
@@ -359,39 +383,130 @@ fn device_layout(device: &hidapi::HidDevice, vendor_id: u16) -> Option<Layout> {
}
}
-/// Reads the 3D mouse through spacenavd when it runs, so what `spnavcfg` sets (swapped and inverted
-/// axes, sensitivity, dead zones) applies here as in other programs. Without the daemon it reads
-/// `/dev/hidrawN` with plain blocking reads, which end with an error when the device is unplugged.
-/// Opening needs permission: most distributions grant it to the logged-in user for devices that
-/// carry the `uaccess` udev tag, which a rule for the 3D mouse has to add.
+/// What the user chose for the reader and what the reader found, shared with the egui thread.
#[cfg(target_os = "linux")]
-fn reader(ctx: Context, shared: Arc<Mutex<Reading>>) {
- use std::io::Read;
+#[derive(Default)]
+struct Drivers {
+ /// `SpaceMouseDriver::to_u8` of the preference.
+ choice: AtomicU8,
+ /// `PRESENT_SPACENAVD` and `PRESENT_DIRECT`, as of the reader's last look.
+ found: AtomicU8,
+}
+
+#[cfg(target_os = "linux")]
+const PRESENT_SPACENAVD: u8 = 1;
+#[cfg(target_os = "linux")]
+const PRESENT_DIRECT: u8 = 2;
+/// How often a connected reader looks again at what is there, and how long a read of spacenavd
+/// waits for a record before it checks the choice.
+#[cfg(target_os = "linux")]
+const LOOK_EVERY: Duration = Duration::from_secs(1);
+#[cfg(target_os = "linux")]
+const SPACENAVD_WAKE: Duration = Duration::from_millis(250);
+
+#[cfg(target_os = "linux")]
+impl Drivers {
+ fn choice(&self) -> SpaceMouseDriver {
+ SpaceMouseDriver::from_u8(self.choice.load(Ordering::Relaxed))
+ }
+
+ fn present(&self) -> DriversPresent {
+ let found = self.found.load(Ordering::Relaxed);
+ DriversPresent { spacenavd: found & PRESENT_SPACENAVD != 0, direct: found & PRESENT_DIRECT != 0 }
+ }
+
+ fn publish(&self, present: DriversPresent) {
+ let found = (u8::from(present.spacenavd) * PRESENT_SPACENAVD) | (u8::from(present.direct) * PRESENT_DIRECT);
+ self.found.store(found, Ordering::Relaxed);
+ }
+}
+
+/// The reader that was picked.
+#[cfg(target_os = "linux")]
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum Pick {
+ Spacenavd,
+ Direct,
+}
+
+/// Which reader to use: the one asked for when it is there, else the other, else none. Automatic
+/// asks for spacenavd, which is what has always been read first.
+#[cfg(target_os = "linux")]
+fn choose(wanted: SpaceMouseDriver, spacenavd: bool, direct: bool) -> Option<Pick> {
+ let first = match wanted {
+ SpaceMouseDriver::Automatic | SpaceMouseDriver::Spacenavd => Pick::Spacenavd,
+ SpaceMouseDriver::Direct => Pick::Direct,
+ };
+ let there = |pick| match pick {
+ Pick::Spacenavd => spacenavd,
+ Pick::Direct => direct,
+ };
+ let other = if first == Pick::Spacenavd { Pick::Direct } else { Pick::Spacenavd };
+ [first, other].into_iter().find(|&pick| there(pick))
+}
+
+/// Reads the 3D mouse through spacenavd or `/dev/hidrawN`, as `Drivers::choice` says (Automatic
+/// is spacenavd when it runs, so what `spnavcfg` sets, swapped and inverted axes, sensitivity,
+/// dead zones, applies here as in other programs). Both reads wake up when idle to see whether
+/// the choice changed, which then moves to the other reader without a restart. hidraw is opened
+/// non-blocking and ends with an error when the device is unplugged. Opening needs permission:
+/// most distributions grant it to the logged-in user for devices that carry the `uaccess` udev
+/// tag, which a rule for the 3D mouse has to add.
+#[cfg(target_os = "linux")]
+fn reader(ctx: Context, shared: Arc<Mutex<Reading>>, drivers: Arc<Drivers>) {
+ use std::os::unix::fs::OpenOptionsExt;
+ let look = || DriversPresent { spacenavd: spacenavd::exists(), direct: hidraw::find().is_some() };
let mut denied = None;
+ let mut told = None;
loop {
- if let Some(daemon) = spacenavd::connect() {
- log::info!("3D mouse: reading spacenavd, which applies the spnavcfg settings");
- connected(&ctx, &shared, Source::Spacenavd);
- spacenavd::read(daemon, |axes| publish_held(&ctx, &shared, axes));
- reset(&ctx, &shared);
- } else if let Some(device) = hidraw::find() {
- match std::fs::File::open(&device.path) {
- Ok(mut file) => {
+ let device = hidraw::find();
+ let present = DriversPresent { spacenavd: spacenavd::exists(), direct: device.is_some() };
+ drivers.publish(present);
+ let wanted = drivers.choice();
+ let mut pick = choose(wanted, present.spacenavd, present.direct);
+ // A socket file with no daemon behind it is no spacenavd.
+ let daemon = if pick == Some(Pick::Spacenavd) { spacenavd::connect() } else { None };
+ if pick == Some(Pick::Spacenavd) && daemon.is_none() {
+ pick = choose(wanted, false, present.direct);
+ }
+ let asked_for = match wanted {
+ SpaceMouseDriver::Automatic => None,
+ SpaceMouseDriver::Spacenavd => Some(Pick::Spacenavd),
+ SpaceMouseDriver::Direct => Some(Pick::Direct),
+ };
+ if let (Some(asked), Some(pick)) = (asked_for, pick)
+ && asked != pick
+ && told != Some((wanted, pick))
+ {
+ log::info!("3D mouse: {asked:?} is not available, reading {pick:?} instead");
+ told = Some((wanted, pick));
+ }
+ // Asked at every idle moment of a read: has the choice changed, and what is there now.
+ let mut looked = Instant::now();
+ let mut stop = || {
+ if looked.elapsed() >= LOOK_EVERY {
+ looked = Instant::now();
+ drivers.publish(look());
+ }
+ drivers.choice() != wanted
+ };
+ match (pick, daemon, device) {
+ (Some(Pick::Spacenavd), Some(daemon), _) => {
+ log::info!("3D mouse: reading spacenavd, which applies the spnavcfg settings");
+ if let Err(error) = daemon.set_read_timeout(Some(SPACENAVD_WAKE)) {
+ log::warn!("3D mouse: spacenavd reads cannot time out ({error}); a change of driver waits for the next event");
+ }
+ connected(&ctx, &shared, Source::Spacenavd);
+ spacenavd::read(daemon, |axes| publish_held(&ctx, &shared, axes), &mut stop);
+ reset(&ctx, &shared);
+ }
+ (Some(Pick::Direct), _, Some(device)) => match std::fs::OpenOptions::new().read(true).custom_flags(hidraw::O_NONBLOCK).open(&device.path)
+ {
+ Ok(file) => {
denied = None;
log::info!("3D mouse: reading {}", device.path.display());
connected(&ctx, &shared, Source::Hid(device.ids));
- let mut report = [0_u8; REPORT_BUFFER_BYTES];
- loop {
- match file.read(&mut report) {
- Ok(0) => break,
- Ok(size) => publish(&ctx, &shared, device.layout, report.get(..size).unwrap_or_default()),
- Err(error) if error.kind() == std::io::ErrorKind::Interrupted => {}
- Err(error) => {
- log::info!("3D mouse disconnected: {error}");
- break;
- }
- }
- }
+ hidraw::read_reports(file, |report| publish(&ctx, &shared, device.layout, report), &mut stop);
reset(&ctx, &shared);
}
// Say so once per device node, not every retry.
@@ -400,9 +515,13 @@ fn reader(ctx: Context, shared: Arc<Mutex<Reading>>) {
denied = Some(device.path);
}
Err(_) => {}
- }
+ },
+ _ => {}
+ }
+ // A new choice is taken up at once; anything else waits to try again.
+ if drivers.choice() == wanted {
+ std::thread::sleep(RETRY_AFTER);
}
- std::thread::sleep(RETRY_AFTER);
}
}
@@ -445,6 +564,8 @@ fn start_driver_client(ctx: &Context, shared: &Arc<Mutex<Reading>>) {
pub struct SpaceMouse {
shared: Arc<Mutex<Reading>>,
+ #[cfg(target_os = "linux")]
+ drivers: Arc<Drivers>,
last_frame: Instant,
driver_mapping: DriverMapping,
mapping_checked_at: Instant,
@@ -462,13 +583,25 @@ impl SpaceMouse {
let shared = Arc::new(Mutex::new(Reading::new(now)));
let worker_state = Arc::clone(&shared);
let worker_ctx = ctx.clone();
- if let Err(error) = std::thread::Builder::new().name("solidcraft-3d-mouse".into()).spawn(move || reader(worker_ctx, worker_state)) {
+ #[cfg(target_os = "linux")]
+ let drivers = Arc::new(Drivers::default());
+ #[cfg(target_os = "linux")]
+ let worker_drivers = Arc::clone(&drivers);
+ let spawned = std::thread::Builder::new().name("solidcraft-3d-mouse".into()).spawn(move || {
+ #[cfg(target_os = "linux")]
+ reader(worker_ctx, worker_state, worker_drivers);
+ #[cfg(not(target_os = "linux"))]
+ reader(worker_ctx, worker_state);
+ });
+ if let Err(error) = spawned {
log::warn!("3D mouse: reader could not start: {error}");
}
#[cfg(target_os = "macos")]
start_driver_client(ctx, &shared);
Self {
shared,
+ #[cfg(target_os = "linux")]
+ drivers,
last_frame: now,
driver_mapping: load_driver_mapping().unwrap_or_else(without_profile),
mapping_checked_at: now,
@@ -516,6 +649,11 @@ impl SpaceMouse {
}
self.mapping_checked_at = now;
}
+ #[cfg(target_os = "linux")]
+ {
+ self.drivers.choice.store(app.preferences.space_mouse_driver.to_u8(), Ordering::Relaxed);
+ app.space_mouse.drivers = Some(self.drivers.present());
+ }
let Ok(reading) = self.shared.lock().map(|reading| *reading) else { return };
app.space_mouse.device = reading.device.map(Source::key);
let calibration = calibration(app);
@@ -529,11 +667,108 @@ impl SpaceMouse {
}
}
+/// A stream that answers reads from a script, for the timeout paths.
+#[cfg(all(test, target_os = "linux"))]
+mod fake {
+ use std::collections::VecDeque;
+ use std::io::{Error, ErrorKind, Read, Result};
+
+ enum Step {
+ Data(Vec<u8>),
+ Fail(ErrorKind),
+ End,
+ }
+
+ #[derive(Default)]
+ pub struct Script(VecDeque<Step>);
+
+ impl Script {
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ pub fn data(&mut self, bytes: &[u8]) -> &mut Self {
+ self.0.push_back(Step::Data(bytes.to_vec()));
+ self
+ }
+
+ pub fn timeout(&mut self, kind: ErrorKind) -> &mut Self {
+ self.fail(kind)
+ }
+
+ pub fn fail(&mut self, kind: ErrorKind) -> &mut Self {
+ self.0.push_back(Step::Fail(kind));
+ self
+ }
+
+ pub fn end(&mut self) -> &mut Self {
+ self.0.push_back(Step::End);
+ self
+ }
+ }
+
+ /// Past the script's last step the stream has ended.
+ impl Read for Script {
+ fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
+ match self.0.pop_front() {
+ Some(Step::Data(bytes)) => {
+ let size = bytes.len().min(buf.len());
+ buf[..size].copy_from_slice(&bytes[..size]);
+ Ok(size)
+ }
+ Some(Step::Fail(kind)) => Err(Error::from(kind)),
+ Some(Step::End) | None => Ok(0),
+ }
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
use solidcraft_ui_egui::space_mouse::{DeviceMotion, Motion};
+ #[cfg(target_os = "linux")]
+ #[test]
+ fn the_reader_asked_for_is_used_when_it_is_there_and_the_other_when_it_is_not() {
+ use Pick::{Direct, Spacenavd};
+ use SpaceMouseDriver::{Automatic, Direct as AskDirect, Spacenavd as AskSpacenavd};
+ // (asked, spacenavd there, device there) and what is read.
+ let cases = [
+ (Automatic, true, true, Some(Spacenavd)),
+ (Automatic, true, false, Some(Spacenavd)),
+ (Automatic, false, true, Some(Direct)),
+ (Automatic, false, false, None),
+ (AskSpacenavd, true, true, Some(Spacenavd)),
+ (AskSpacenavd, true, false, Some(Spacenavd)),
+ (AskSpacenavd, false, true, Some(Direct)),
+ (AskSpacenavd, false, false, None),
+ (AskDirect, true, true, Some(Direct)),
+ (AskDirect, true, false, Some(Spacenavd)),
+ (AskDirect, false, true, Some(Direct)),
+ (AskDirect, false, false, None),
+ ];
+ for (asked, spacenavd, direct, expected) in cases {
+ assert_eq!(choose(asked, spacenavd, direct), expected, "{asked:?}, spacenavd {spacenavd}, device {direct}");
+ }
+ }
+
+ #[cfg(target_os = "linux")]
+ #[test]
+ fn what_the_reader_found_and_the_choice_pass_between_threads() {
+ let drivers = Drivers::default();
+ assert_eq!(drivers.present(), DriversPresent::default());
+ for (spacenavd, direct) in [(true, false), (false, true), (true, true), (false, false)] {
+ drivers.publish(DriversPresent { spacenavd, direct });
+ assert_eq!(drivers.present(), DriversPresent { spacenavd, direct });
+ }
+ assert_eq!(drivers.choice(), SpaceMouseDriver::Automatic);
+ for choice in SpaceMouseDriver::ALL {
+ drivers.choice.store(choice.to_u8(), Ordering::Relaxed);
+ assert_eq!(drivers.choice(), choice);
+ }
+ }
+
/// The logical axes a reading reaches. Logical Rz rolls the view and logical Ry turns it about
/// its vertical (`navigation::device_camera` in solidcraft-ui-egui, tested there).
fn rotation(mapping: DriverMapping, rotation: [i16; 3]) -> [f64; 3] {
@@ -625,6 +860,55 @@ mod tests {
assert_eq!(hid.current(later, Axes::default()), Axes::default());
}
+ #[test]
+ fn a_held_reading_near_rest_settles_after_the_timeout() {
+ // The last records of seven releases from tangency-labs/solidcraft#3523: spacenavd sends
+ // nothing after them.
+ let leftovers = [
+ [15, -60, 13, 59, 34, 129],
+ [-12, -69, 4, -26, 7, -6],
+ [0, -45, -3, 16, 8, -60],
+ [-31, 27, 22, -5, 6, -10],
+ [0, -30, -3, 3, -6, 0],
+ [5, 32, -2, 43, -8, 12],
+ [3, 2, -22, 3, 6, 5],
+ ];
+ let now = Instant::now();
+ for [x, y, z, rx, ry, rz] in leftovers {
+ let axes = Axes { translation: [x, y, z], rotation: [rx, ry, rz] };
+ let held = Reading { axes, held: true, ..Reading::new(now) };
+ assert_eq!(held.current(now + HELD_SETTLE_AFTER - Duration::from_millis(1), Axes::default()), axes);
+ assert_eq!(held.current(now + HELD_SETTLE_AFTER, Axes::default()), Axes::default());
+ }
+ }
+
+ #[test]
+ fn a_settled_held_reading_reads_as_the_devices_own_rest() {
+ let now = Instant::now();
+ let rest = Axes { translation: [10, -8, 0], rotation: [0, 5, 0] };
+ // 40 from zero on X, but only 30 from this device's rest.
+ let held = Reading { axes: Axes { translation: [40, -8, 0], rotation: [0, 5, 0] }, held: true, ..Reading::new(now) };
+ assert_eq!(held.current(now + HELD_SETTLE_AFTER, rest), rest);
+ }
+
+ #[test]
+ fn a_firm_held_push_stays_however_long_it_lasts() {
+ let now = Instant::now();
+ let later = now + Duration::from_secs(10);
+ let push = Axes { translation: [0, 350, 0], rotation: [0; 3] };
+ let held = Reading { axes: push, held: true, ..Reading::new(now) };
+ assert_eq!(held.current(later, Axes::default()), push);
+ // One firm axis keeps the small ones with it.
+ let mixed = Axes { translation: [5, 300, -10], rotation: [3, 0, 20] };
+ let held = Reading { axes: mixed, held: true, ..Reading::new(now) };
+ assert_eq!(held.current(later, Axes::default()), mixed);
+ // The band is per reading, edge included: at it is a leftover, one past it is a hold.
+ let band = HELD_SETTLE_BAND as i16;
+ let twist = |value| Reading { axes: Axes { translation: [0; 3], rotation: [0, 0, value] }, held: true, ..Reading::new(now) };
+ assert_eq!(twist(band).current(later, Axes::default()), Axes::default());
+ assert_eq!(twist(band + 1).current(later, Axes::default()).rotation, [0, 0, band + 1]);
+ }
+
#[test]
fn applies_3dxware_axis_swaps_and_reversals() {
let profile = br#"
@@ -689,6 +973,8 @@ mod tests {
reading.axes.rotation = [0, 350, 0];
let mut mouse = SpaceMouse {
shared: Arc::new(Mutex::new(reading)),
+ #[cfg(target_os = "linux")]
+ drivers: Arc::default(),
last_frame: now - Duration::from_millis(20),
driver_mapping: DriverMapping::object_mode(),
mapping_checked_at: now,
@@ -717,6 +1003,8 @@ mod tests {
fn mouse(reading: Reading, now: Instant) -> SpaceMouse {
SpaceMouse {
shared: Arc::new(Mutex::new(reading)),
+ #[cfg(target_os = "linux")]
+ drivers: Arc::default(),
last_frame: now,
driver_mapping: DriverMapping::object_mode(),
mapping_checked_at: now,
diff --git a/apps/solidcraft/src/space_mouse/hidraw.rs b/apps/solidcraft/src/space_mouse/hidraw.rs
index 45e8f2ba5c..29b5dd8271 100644
--- a/apps/solidcraft/src/space_mouse/hidraw.rs
+++ b/apps/solidcraft/src/space_mouse/hidraw.rs
@@ -2,13 +2,23 @@
//! its report descriptor and ids under `/sys/class/hidraw/hidrawN/device/`. Reading them is plain
//! file I/O, so no udev or hidapi library is needed.
+use std::io::Read;
use std::path::{Path, PathBuf};
+use std::time::Duration;
use solidcraft_space_mouse::{Descriptor, Layout};
const SYSFS: &str = "/sys/class/hidraw";
const DEV: &str = "/dev";
+/// `O_NONBLOCK` on Linux's common architectures (x86, ARM, RISC-V). The device is opened with it so
+/// a read with nothing to read returns at once and the reader can see whether it should stop.
+pub const O_NONBLOCK: i32 = 0o4000;
+
+/// How long the reader waits when the device has nothing to say, which is also the most a report
+/// can be delayed.
+const IDLE_POLL: Duration = Duration::from_millis(5);
+
pub struct Device {
pub path: PathBuf,
pub layout: Layout,
@@ -23,6 +33,30 @@ pub fn find() -> Option<Device> {
names.into_iter().find_map(|name| probe(&Path::new(SYSFS).join(&name), Path::new(DEV).join(&name)))
}
+/// Hands every report to `publish` until the device is gone (end of file or an error) or `stop`
+/// says so. `source` is non-blocking: when it has nothing, `stop` is asked and the reader waits
+/// [`IDLE_POLL`]. Reports are read and handed over exactly as they were with blocking reads.
+pub fn read_reports(mut source: impl Read, mut publish: impl FnMut(&[u8]), mut stop: impl FnMut() -> bool) {
+ let mut report = [0_u8; super::REPORT_BUFFER_BYTES];
+ loop {
+ match source.read(&mut report) {
+ Ok(0) => return,
+ Ok(size) => publish(report.get(..size).unwrap_or_default()),
+ Err(error) if error.kind() == std::io::ErrorKind::Interrupted => {}
+ Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => {
+ if stop() {
+ return;
+ }
+ std::thread::sleep(IDLE_POLL);
+ }
+ Err(error) => {
+ log::info!("3D mouse disconnected: {error}");
+ return;
+ }
+ }
+ }
+}
+
fn probe(sysfs: &Path, path: PathBuf) -> Option<Device> {
let descriptor = Descriptor::parse(&std::fs::read(sysfs.join("device/report_descriptor")).ok()?);
// A controller that declares no motion axis (buttons only, say) isn't read.
@@ -42,6 +76,35 @@ fn ids(uevent: &str) -> Option<(u16, u16)> {
mod tests {
use super::*;
+ #[test]
+ fn reports_come_through_idle_gaps_until_the_device_ends_or_a_stop() {
+ use crate::space_mouse::fake::Script;
+ let mut script = Script::new();
+ script.timeout(std::io::ErrorKind::WouldBlock).data(&[1, 2, 3]).timeout(std::io::ErrorKind::WouldBlock).data(&[4]).end();
+ let (mut seen, mut asked) = (Vec::new(), 0);
+ read_reports(
+ script,
+ |report| seen.push(report.to_vec()),
+ || {
+ asked += 1;
+ false
+ },
+ );
+ assert_eq!(seen, [vec![1, 2, 3], vec![4]]);
+ assert_eq!(asked, 2);
+ let mut script = Script::new();
+ script.data(&[1]).timeout(std::io::ErrorKind::WouldBlock).data(&[2]);
+ let mut seen = Vec::new();
+ read_reports(script, |report| seen.push(report.to_vec()), || true);
+ assert_eq!(seen, [vec![1]], "a stop at an idle moment ends the read");
+ // An unplugged device is an error, which ends the read as before.
+ let mut script = Script::new();
+ script.data(&[1]).fail(std::io::ErrorKind::BrokenPipe).data(&[2]);
+ let mut seen = Vec::new();
+ read_reports(script, |report| seen.push(report.to_vec()), || false);
+ assert_eq!(seen, [vec![1]]);
+ }
+
#[test]
fn ids_come_from_the_uevent() {
let wireless = "DRIVER=hid-generic\nHID_ID=0005:0000256F:0000C63A\nHID_NAME=SpaceMouse Wireless BT\n";
diff --git a/apps/solidcraft/src/space_mouse/spacenavd.rs b/apps/solidcraft/src/space_mouse/spacenavd.rs
index 4e282764bb..7a27eb2402 100644
--- a/apps/solidcraft/src/space_mouse/spacenavd.rs
+++ b/apps/solidcraft/src/space_mouse/spacenavd.rs
@@ -23,6 +23,11 @@ const RECORD_BYTES: usize = 32;
/// sensitivity). Our axes are in the raw HID units of [`FULL_SCALE`].
const DAEMON_FULL_SCALE: i64 = 500;
+/// Whether the daemon's socket is there, without connecting to it.
+pub fn exists() -> bool {
+ SOCKETS.iter().any(|path| Path::new(path).exists())
+}
+
pub fn connect() -> Option<UnixStream> {
SOCKETS.iter().find_map(|path| connect_to(Path::new(path)))
}
@@ -56,18 +61,34 @@ fn unit(value: impl Into<i64>) -> i16 {
i16::try_from(scaled.clamp(i64::from(i16::MIN), i64::from(i16::MAX))).unwrap_or_default()
}
-/// Hands every motion record to `publish` until the daemon closes the connection or fails. A
-/// partial record at the end is dropped.
-pub fn read(mut stream: impl Read, mut publish: impl FnMut(Axes)) {
+/// Hands every motion record to `publish` until the daemon closes the connection or fails, or
+/// `stop` says so. A stream with a read timeout (`set_read_timeout`) times out when the daemon is
+/// quiet, which is no record and no disconnect: `stop` is asked, and the read goes on, with what
+/// of a record had arrived kept. A partial record at the end is dropped.
+pub fn read(mut stream: impl Read, mut publish: impl FnMut(Axes), mut stop: impl FnMut() -> bool) {
let mut record = [0_u8; RECORD_BYTES];
+ let mut filled = 0;
loop {
- match stream.read_exact(&mut record) {
- Ok(()) => {
- if let Some(axes) = decode(&record) {
- publish(axes);
+ match stream.read(record.get_mut(filled..).unwrap_or_default()) {
+ Ok(0) => {
+ log::info!("3D mouse: spacenavd connection ended");
+ return;
+ }
+ Ok(size) => {
+ filled += size;
+ if filled == RECORD_BYTES {
+ filled = 0;
+ if let Some(axes) = decode(&record) {
+ publish(axes);
+ }
}
}
Err(error) if error.kind() == std::io::ErrorKind::Interrupted => {}
+ Err(error) if matches!(error.kind(), std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut) => {
+ if stop() {
+ return;
+ }
+ }
Err(error) => {
log::info!("3D mouse: spacenavd connection ended: {error}");
return;
@@ -132,10 +153,41 @@ mod tests {
daemon.write_all(&bytes).expect("written");
drop(daemon);
let mut seen = Vec::new();
- read(client, |axes| seen.push(axes.translation));
+ read(client, |axes| seen.push(axes.translation), || false);
assert_eq!(seen, [[70, 0, 0], [0, 0, 0]]);
}
+ #[test]
+ fn a_quiet_daemon_times_out_without_losing_the_record_it_was_sending() {
+ use crate::space_mouse::fake::Script;
+ use std::io::ErrorKind::{TimedOut, WouldBlock};
+ let bytes = record([0, 100, 0, 0, 0, 0, 0, 8]);
+ let mut script = Script::new();
+ script.timeout(WouldBlock).data(&bytes[..10]).timeout(TimedOut).timeout(WouldBlock).data(&bytes[10..]).timeout(WouldBlock).end();
+ let (mut seen, mut asked) = (Vec::new(), 0);
+ read(
+ script,
+ |axes| seen.push(axes.translation),
+ || {
+ asked += 1;
+ false
+ },
+ );
+ assert_eq!(seen, [[70, 0, 0]]);
+ assert_eq!(asked, 4, "each timeout asks whether to stop");
+ }
+
+ #[test]
+ fn a_stop_ends_the_read_at_the_next_timeout_only() {
+ use crate::space_mouse::fake::Script;
+ let bytes = record([0, 100, 0, 0, 0, 0, 0, 8]);
+ let mut script = Script::new();
+ script.data(&bytes).timeout(std::io::ErrorKind::WouldBlock).data(&bytes);
+ let mut seen = 0;
+ read(script, |_| seen += 1, || true);
+ assert_eq!(seen, 1, "the record before the timeout arrived; the one after never was read");
+ }
+
#[test]
fn no_daemon_means_no_connection() {
let missing = std::env::temp_dir().join(format!("sc-no-spnav-{}.sock", std::process::id()));
diff --git a/assets/locales/cs.json b/assets/locales/cs.json
index dfc9aae17e..260faad8ee 100644
--- a/assets/locales/cs.json
+++ b/assets/locales/cs.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Plynulé přiblížení kolečkem",
"ui.smooth_wheel_zoom_tip": "Vypnutím se každý pohyb kolečka projeví okamžitě, bez dobíhání",
"ui.snap": "Přichytávání",
+ "ui.space_mouse_axes_reassigned": "Osy jsou v Předvolbách přeřazené a to platí i po této kalibraci.",
"ui.space_mouse_calibrate": "Kalibrovat…",
"ui.space_mouse_calibrate_tip": "Pohybujte hlavicí podle pokynů v okně, aby se SolidCraft naučil, kterým směrem a jak daleko se pohybuje každá osa této 3D myši. Uloží se pro tuto 3D myš.",
"ui.space_mouse_calibrate_title": "Kalibrace 3D myši",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Jedna osa se skoro nepohnula, takže ji nelze zkalibrovat. Začněte znovu a pokaždé hlavicí pohněte dál.",
"ui.space_mouse_dead_zone": "Mrtvá zóna",
"ui.space_mouse_dead_zone_tip": "Jak daleko se musí hlavice pohnout, než se pohne pohled, jako podíl jejího plného rozsahu. Zvyšte ji, pokud pohled ujíždí, i když je hlavice v klidu.",
+ "ui.space_mouse_driven_by": "Který kalibrovaný pohyb zařízení ovládá tuto osu. Když vyberete pohyb, který už používá jiná osa, obě se prohodí.",
+ "ui.space_mouse_driven_by_label": "ovládá",
+ "ui.space_mouse_driver": "Ovladač 3D myši",
+ "ui.space_mouse_driver_auto": "Automaticky",
+ "ui.space_mouse_driver_direct": "Přímo (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Zařízení se čte přímo; spacenavd neběží",
+ "ui.space_mouse_driver_only_spacenavd": "Čte se přes spacenavd, jiná možnost není",
"ui.space_mouse_forget": "Zapomenout kalibraci",
"ui.space_mouse_hint": "Posun a otáčení pohledu současně; náčrty používají jen posun a přiblížení.",
+ "ui.space_mouse_motion_rotation_x": "Rotace X",
+ "ui.space_mouse_motion_rotation_y": "Rotace Y",
+ "ui.space_mouse_motion_rotation_z": "Rotace Z",
+ "ui.space_mouse_motion_translation_x": "Posun X",
+ "ui.space_mouse_motion_translation_y": "Posun Y",
+ "ui.space_mouse_motion_translation_z": "Posun Z",
"ui.space_mouse_navigate": "Navigace pomocí SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "3D myš nenalezena",
"ui.space_mouse_not_calibrated": "Nezkalibrováno",
"ui.space_mouse_reading": "Hodnoty",
+ "ui.space_mouse_reset_axes": "Obnovit přiřazení os",
"ui.space_mouse_step_lift": "Zvedněte hlavici nahoru, podržte a pusťte.",
"ui.space_mouse_step_press": "Zatlačte hlavici dolů, podržte a pusťte.",
"ui.space_mouse_step_pull": "Přitáhněte hlavici k sobě, podržte a pusťte.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Nakloňte hlavici doprava (pravá hrana dolů), podržte a pusťte.",
"ui.space_mouse_step_twist_clockwise": "Otočte hlavici po směru hodinových ručiček, podržte a pusťte.",
"ui.space_mouse_step_twist_counterclockwise": "Otočte hlavici proti směru hodinových ručiček, podržte a pusťte.",
+ "ui.space_mouse_view_axis": "Osa pohledu",
+ "ui.space_mouse_view_off": "Vypnuto",
+ "ui.space_mouse_view_off_tip": "Profil ovladače 3D myši tuto osu vypíná, takže její pohyb s pohledem nehýbe. Když tu vyberete pohyb jiné osy, prohodí se s ní a s pohledem přestane hýbat.",
+ "ui.space_mouse_view_orbit_sideways": "Orbit vlevo / vpravo",
+ "ui.space_mouse_view_orbit_up_down": "Orbit nahoru / dolů",
+ "ui.space_mouse_view_pan_sideways": "Posun vlevo / vpravo",
+ "ui.space_mouse_view_pan_up_down": "Posun nahoru / dolů",
+ "ui.space_mouse_view_roll": "Natočení",
+ "ui.space_mouse_view_unmapped": "Osa {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Rozteč",
"ui.spacing_2": "Rozteč 2",
"ui.sphere": "Koule",
diff --git a/assets/locales/de.json b/assets/locales/de.json
index 29a4e0516b..3c586cdd76 100644
--- a/assets/locales/de.json
+++ b/assets/locales/de.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Sanftes Zoomen mit dem Rad",
"ui.smooth_wheel_zoom_tip": "Ausschalten, um jedes Radereignis sofort anzuwenden, ohne Nachlauf",
"ui.snap": "Einrasten",
+ "ui.space_mouse_axes_reassigned": "Die Achsen sind in den Einstellungen neu zugeordnet, und das gilt auch nach dieser Kalibrierung.",
"ui.space_mouse_calibrate": "Kalibrieren…",
"ui.space_mouse_calibrate_tip": "Bewegen Sie die Kappe so, wie das Fenster es verlangt. So lernt SolidCraft, in welche Richtung und wie weit jede Achse dieser 3D-Maus geht. Wird für diese 3D-Maus gespeichert.",
"ui.space_mouse_calibrate_title": "3D-Maus kalibrieren",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Eine Achse hat sich kaum bewegt und lässt sich nicht kalibrieren. Beginnen Sie von vorn und bewegen Sie die Kappe jedes Mal weiter.",
"ui.space_mouse_dead_zone": "Totzone",
"ui.space_mouse_dead_zone_tip": "Wie weit sich die Kappe bewegen muss, bevor sich die Ansicht bewegt, als Anteil ihres vollen Wegs. Erhöhen Sie sie, wenn die Ansicht wandert, obwohl die Kappe ruht.",
+ "ui.space_mouse_driven_by": "Welche kalibrierte Bewegung des Geräts diese Achse steuert. Wählen Sie eine, die schon eine andere Achse nutzt, werden die beiden getauscht.",
+ "ui.space_mouse_driven_by_label": "gesteuert von",
+ "ui.space_mouse_driver": "3D-Maus-Treiber",
+ "ui.space_mouse_driver_auto": "Automatisch",
+ "ui.space_mouse_driver_direct": "Direkt (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Das Gerät wird direkt gelesen; spacenavd läuft nicht",
+ "ui.space_mouse_driver_only_spacenavd": "Lesen über spacenavd, die einzige verfügbare Möglichkeit",
"ui.space_mouse_forget": "Kalibrierung vergessen",
"ui.space_mouse_hint": "Ansicht gleichzeitig verschieben und drehen; Skizzen verwenden nur Schwenken und Zoomen.",
+ "ui.space_mouse_motion_rotation_x": "Rotation X",
+ "ui.space_mouse_motion_rotation_y": "Rotation Y",
+ "ui.space_mouse_motion_rotation_z": "Rotation Z",
+ "ui.space_mouse_motion_translation_x": "Translation X",
+ "ui.space_mouse_motion_translation_y": "Translation Y",
+ "ui.space_mouse_motion_translation_z": "Translation Z",
"ui.space_mouse_navigate": "Mit SpaceNavigator / SpaceMouse navigieren",
"ui.space_mouse_none": "Keine 3D-Maus gefunden",
"ui.space_mouse_not_calibrated": "Nicht kalibriert",
"ui.space_mouse_reading": "Werte",
+ "ui.space_mouse_reset_axes": "Achsenzuordnung zurücksetzen",
"ui.space_mouse_step_lift": "Kappe nach oben ziehen, halten, dann loslassen.",
"ui.space_mouse_step_press": "Kappe nach unten drücken, halten, dann loslassen.",
"ui.space_mouse_step_pull": "Kappe zu sich heranziehen, halten, dann loslassen.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Kappe nach rechts kippen (rechte Kante runter), halten, dann loslassen.",
"ui.space_mouse_step_twist_clockwise": "Kappe im Uhrzeigersinn drehen, halten, dann loslassen.",
"ui.space_mouse_step_twist_counterclockwise": "Kappe gegen den Uhrzeigersinn drehen, halten, dann loslassen.",
+ "ui.space_mouse_view_axis": "Ansichtsachse",
+ "ui.space_mouse_view_off": "Aus",
+ "ui.space_mouse_view_off_tip": "Das Profil des 3D-Maus-Treibers schaltet diese Achse ab, daher bewegt ihre Bewegung die Ansicht nicht. Wählen Sie hier die Bewegung einer anderen Achse, werden die beiden getauscht und sie bewegt die Ansicht nicht mehr.",
+ "ui.space_mouse_view_orbit_sideways": "Orbit links / rechts",
+ "ui.space_mouse_view_orbit_up_down": "Orbit hoch / runter",
+ "ui.space_mouse_view_pan_sideways": "Schwenken links / rechts",
+ "ui.space_mouse_view_pan_up_down": "Schwenken hoch / runter",
+ "ui.space_mouse_view_roll": "Rollen",
+ "ui.space_mouse_view_unmapped": "Achse {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Abstand",
"ui.spacing_2": "Abstand 2",
"ui.sphere": "Sphäre",
diff --git a/assets/locales/en.json b/assets/locales/en.json
index 0e3cb0ae73..35de93051d 100644
--- a/assets/locales/en.json
+++ b/assets/locales/en.json
@@ -1742,6 +1742,7 @@
"ui.smooth_wheel_zoom": "Smooth wheel zoom",
"ui.smooth_wheel_zoom_tip": "Turn off to apply each wheel event immediately, without a smoothing tail",
"ui.snap": "Snap",
+ "ui.space_mouse_axes_reassigned": "Axes are reassigned in Preferences, and that still applies on top of this calibration.",
"ui.space_mouse_calibrate": "Calibrate…",
"ui.space_mouse_calibrate_tip": "Move the cap as the window asks, so SolidCraft learns which way each axis of this 3D mouse goes and how far. Saved for this 3D mouse.",
"ui.space_mouse_calibrate_title": "Calibrate 3D mouse",
@@ -1751,12 +1752,26 @@
"ui.space_mouse_calibration_no_response": "One axis barely moved, so it can't be calibrated. Start over and move the cap further each time.",
"ui.space_mouse_dead_zone": "Dead zone",
"ui.space_mouse_dead_zone_tip": "How far the cap has to move before the view does, as a share of its full travel. Raise it if the view drifts while the cap is at rest.",
+ "ui.space_mouse_driven_by": "Which calibrated motion of the device drives this axis. Picking a motion another axis already uses swaps the two.",
+ "ui.space_mouse_driven_by_label": "driven by",
+ "ui.space_mouse_driver": "3D mouse driver",
+ "ui.space_mouse_driver_auto": "Automatic",
+ "ui.space_mouse_driver_direct": "Direct (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Reading the device directly; spacenavd is not running",
+ "ui.space_mouse_driver_only_spacenavd": "Reading through spacenavd, the only way available",
"ui.space_mouse_forget": "Forget calibration",
"ui.space_mouse_hint": "Move and rotate the view together; sketches use pan and zoom only.",
+ "ui.space_mouse_motion_rotation_x": "Rotation X",
+ "ui.space_mouse_motion_rotation_y": "Rotation Y",
+ "ui.space_mouse_motion_rotation_z": "Rotation Z",
+ "ui.space_mouse_motion_translation_x": "Translation X",
+ "ui.space_mouse_motion_translation_y": "Translation Y",
+ "ui.space_mouse_motion_translation_z": "Translation Z",
"ui.space_mouse_navigate": "Navigate with SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "No 3D mouse found",
"ui.space_mouse_not_calibrated": "Not calibrated",
"ui.space_mouse_reading": "Reading",
+ "ui.space_mouse_reset_axes": "Reset axis assignment",
"ui.space_mouse_step_lift": "Lift the cap up, hold it, then let go.",
"ui.space_mouse_step_press": "Press the cap down, hold it, then let go.",
"ui.space_mouse_step_pull": "Pull the cap toward you, hold it, then let go.",
@@ -1770,6 +1785,16 @@
"ui.space_mouse_step_tilt_right": "Tilt the cap right (right edge down), hold it, then let go.",
"ui.space_mouse_step_twist_clockwise": "Twist the cap clockwise, hold it, then let go.",
"ui.space_mouse_step_twist_counterclockwise": "Twist the cap anticlockwise, hold it, then let go.",
+ "ui.space_mouse_view_axis": "View axis",
+ "ui.space_mouse_view_off": "Off",
+ "ui.space_mouse_view_off_tip": "The 3D mouse driver's profile turns this axis off, so its motion doesn't move the view. Picking another axis's motion here swaps the two, and that motion stops moving the view.",
+ "ui.space_mouse_view_orbit_sideways": "Orbit left / right",
+ "ui.space_mouse_view_orbit_up_down": "Orbit up / down",
+ "ui.space_mouse_view_pan_sideways": "Pan left / right",
+ "ui.space_mouse_view_pan_up_down": "Pan up / down",
+ "ui.space_mouse_view_roll": "Roll",
+ "ui.space_mouse_view_unmapped": "Axis {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Spacing",
"ui.spacing_2": "Spacing 2",
"ui.sphere": "Sphere",
diff --git a/assets/locales/es.json b/assets/locales/es.json
index 73b9ef0d5c..bd09496fcb 100644
--- a/assets/locales/es.json
+++ b/assets/locales/es.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Zoom suave con la rueda",
"ui.smooth_wheel_zoom_tip": "Desactívalo para aplicar cada movimiento de la rueda inmediatamente, sin suavizado posterior",
"ui.snap": "Referencia a objetos",
+ "ui.space_mouse_axes_reassigned": "Los ejes están reasignados en Preferencias, y eso sigue aplicándose sobre esta calibración.",
"ui.space_mouse_calibrate": "Calibrar…",
"ui.space_mouse_calibrate_tip": "Mueve el capuchón como pide la ventana para que SolidCraft aprenda hacia dónde y hasta dónde va cada eje de este ratón 3D. Se guarda para este ratón 3D.",
"ui.space_mouse_calibrate_title": "Calibrar ratón 3D",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Un eje apenas se movió, así que no se puede calibrar. Vuelve a empezar y mueve el capuchón más lejos cada vez.",
"ui.space_mouse_dead_zone": "Zona muerta",
"ui.space_mouse_dead_zone_tip": "Cuánto tiene que moverse el capuchón antes de que se mueva la vista, como parte de su recorrido completo. Auméntala si la vista se desplaza con el capuchón en reposo.",
+ "ui.space_mouse_driven_by": "Qué movimiento calibrado del dispositivo controla este eje. Si eliges uno que ya usa otro eje, se intercambian.",
+ "ui.space_mouse_driven_by_label": "controlado por",
+ "ui.space_mouse_driver": "Controlador del ratón 3D",
+ "ui.space_mouse_driver_auto": "Automático",
+ "ui.space_mouse_driver_direct": "Directo (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Lectura directa del dispositivo; spacenavd no se está ejecutando",
+ "ui.space_mouse_driver_only_spacenavd": "Lectura mediante spacenavd, la única opción disponible",
"ui.space_mouse_forget": "Olvidar calibración",
"ui.space_mouse_hint": "Desplaza y gira la vista a la vez; los bocetos solo permiten desplazamiento y zoom.",
+ "ui.space_mouse_motion_rotation_x": "Rotación X",
+ "ui.space_mouse_motion_rotation_y": "Rotación Y",
+ "ui.space_mouse_motion_rotation_z": "Rotación Z",
+ "ui.space_mouse_motion_translation_x": "Traslación X",
+ "ui.space_mouse_motion_translation_y": "Traslación Y",
+ "ui.space_mouse_motion_translation_z": "Traslación Z",
"ui.space_mouse_navigate": "Navegar con SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "No se encontró ningún ratón 3D",
"ui.space_mouse_not_calibrated": "Sin calibrar",
"ui.space_mouse_reading": "Lectura",
+ "ui.space_mouse_reset_axes": "Restablecer asignación de ejes",
"ui.space_mouse_step_lift": "Levanta el capuchón, mantenlo y suéltalo.",
"ui.space_mouse_step_press": "Presiona el capuchón hacia abajo, mantenlo y suéltalo.",
"ui.space_mouse_step_pull": "Tira del capuchón hacia ti, mantenlo y suéltalo.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Inclina el capuchón a la derecha (borde derecho abajo), mantenlo y suéltalo.",
"ui.space_mouse_step_twist_clockwise": "Gira el capuchón en sentido horario, mantenlo y suéltalo.",
"ui.space_mouse_step_twist_counterclockwise": "Gira el capuchón en sentido antihorario, mantenlo y suéltalo.",
+ "ui.space_mouse_view_axis": "Eje de la vista",
+ "ui.space_mouse_view_off": "Desactivado",
+ "ui.space_mouse_view_off_tip": "El perfil del controlador del ratón 3D desactiva este eje, así que su movimiento no mueve la vista. Si eliges aquí el movimiento de otro eje, se intercambian y ese movimiento deja de mover la vista.",
+ "ui.space_mouse_view_orbit_sideways": "Orbitar izquierda / derecha",
+ "ui.space_mouse_view_orbit_up_down": "Orbitar arriba / abajo",
+ "ui.space_mouse_view_pan_sideways": "Desplazar izquierda / derecha",
+ "ui.space_mouse_view_pan_up_down": "Desplazar arriba / abajo",
+ "ui.space_mouse_view_roll": "Girar sobre la vista",
+ "ui.space_mouse_view_unmapped": "Eje {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Espaciado",
"ui.spacing_2": "Espaciado 2",
"ui.sphere": "Esfera",
diff --git a/assets/locales/fr.json b/assets/locales/fr.json
index 27268a8544..1d4821ed6d 100644
--- a/assets/locales/fr.json
+++ b/assets/locales/fr.json
@@ -1740,6 +1740,7 @@
"ui.smooth_wheel_zoom": "Zoom fluide à la molette",
"ui.smooth_wheel_zoom_tip": "Désactiver pour appliquer chaque cran de molette immédiatement, sans lissage",
"ui.snap": "Accrochage",
+ "ui.space_mouse_axes_reassigned": "Les axes sont réattribués dans les Préférences, et cela s'applique toujours en plus de ce calibrage.",
"ui.space_mouse_calibrate": "Calibrer…",
"ui.space_mouse_calibrate_tip": "Déplacez le capuchon comme la fenêtre le demande, pour que SolidCraft apprenne dans quel sens et jusqu'où va chaque axe de cette souris 3D. Enregistré pour cette souris 3D.",
"ui.space_mouse_calibrate_title": "Calibrer la souris 3D",
@@ -1749,12 +1750,26 @@
"ui.space_mouse_calibration_no_response": "Un axe a à peine bougé, il ne peut donc pas être calibré. Recommencez en déplaçant le capuchon plus loin à chaque fois.",
"ui.space_mouse_dead_zone": "Zone morte",
"ui.space_mouse_dead_zone_tip": "De combien le capuchon doit bouger avant que la vue ne bouge, en part de sa course complète. Augmentez-la si la vue dérive alors que le capuchon est au repos.",
+ "ui.space_mouse_driven_by": "Quel mouvement calibré de l'appareil pilote cet axe. Choisir un mouvement déjà utilisé par un autre axe les échange.",
+ "ui.space_mouse_driven_by_label": "piloté par",
+ "ui.space_mouse_driver": "Pilote de la souris 3D",
+ "ui.space_mouse_driver_auto": "Automatique",
+ "ui.space_mouse_driver_direct": "Direct (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Lecture directe du périphérique ; spacenavd n'est pas lancé",
+ "ui.space_mouse_driver_only_spacenavd": "Lecture via spacenavd, seule possibilité disponible",
"ui.space_mouse_forget": "Oublier le calibrage",
"ui.space_mouse_hint": "Déplace et fait pivoter la vue en même temps ; dans les esquisses, seuls le panoramique et le zoom sont utilisés.",
+ "ui.space_mouse_motion_rotation_x": "Rotation X",
+ "ui.space_mouse_motion_rotation_y": "Rotation Y",
+ "ui.space_mouse_motion_rotation_z": "Rotation Z",
+ "ui.space_mouse_motion_translation_x": "Translation X",
+ "ui.space_mouse_motion_translation_y": "Translation Y",
+ "ui.space_mouse_motion_translation_z": "Translation Z",
"ui.space_mouse_navigate": "Naviguer avec SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "Aucune souris 3D trouvée",
"ui.space_mouse_not_calibrated": "Non calibrée",
"ui.space_mouse_reading": "Lecture",
+ "ui.space_mouse_reset_axes": "Réinitialiser l'attribution des axes",
"ui.space_mouse_step_lift": "Soulevez le capuchon, maintenez, puis relâchez.",
"ui.space_mouse_step_press": "Appuyez sur le capuchon, maintenez, puis relâchez.",
"ui.space_mouse_step_pull": "Tirez le capuchon vers vous, maintenez, puis relâchez.",
@@ -1768,6 +1783,16 @@
"ui.space_mouse_step_tilt_right": "Inclinez le capuchon vers la droite (bord droit vers le bas), maintenez, puis relâchez.",
"ui.space_mouse_step_twist_clockwise": "Tournez le capuchon dans le sens horaire, maintenez, puis relâchez.",
"ui.space_mouse_step_twist_counterclockwise": "Tournez le capuchon dans le sens antihoraire, maintenez, puis relâchez.",
+ "ui.space_mouse_view_axis": "Axe de la vue",
+ "ui.space_mouse_view_off": "Désactivé",
+ "ui.space_mouse_view_off_tip": "Le profil du pilote de la souris 3D désactive cet axe : son mouvement ne déplace pas la vue. Choisir ici le mouvement d'un autre axe les échange, et ce mouvement cesse de déplacer la vue.",
+ "ui.space_mouse_view_orbit_sideways": "Orbite gauche / droite",
+ "ui.space_mouse_view_orbit_up_down": "Orbite haut / bas",
+ "ui.space_mouse_view_pan_sideways": "Panoramique gauche / droite",
+ "ui.space_mouse_view_pan_up_down": "Panoramique haut / bas",
+ "ui.space_mouse_view_roll": "Roulis",
+ "ui.space_mouse_view_unmapped": "Axe {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Espacement",
"ui.spacing_2": "Espacement 2",
"ui.sphere": "Sphère",
diff --git a/assets/locales/gl.json b/assets/locales/gl.json
index d4f2a1b563..5f9c5b23cf 100644
--- a/assets/locales/gl.json
+++ b/assets/locales/gl.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Zoom suave coa roda",
"ui.smooth_wheel_zoom_tip": "Desactívao para aplicar cada movemento da roda de inmediato, sen suavizado",
"ui.snap": "Axuste",
+ "ui.space_mouse_axes_reassigned": "Os eixes están reasignados en Preferencias, e iso segue aplicándose sobre esta calibración.",
"ui.space_mouse_calibrate": "Calibrar…",
"ui.space_mouse_calibrate_tip": "Move o capuchón como pide a xanela para que SolidCraft aprenda cara a onde e ata onde vai cada eixe deste rato 3D. Gárdase para este rato 3D.",
"ui.space_mouse_calibrate_title": "Calibrar o rato 3D",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Un eixe case non se moveu, así que non se pode calibrar. Volve comezar e move o capuchón máis lonxe cada vez.",
"ui.space_mouse_dead_zone": "Zona morta",
"ui.space_mouse_dead_zone_tip": "Canto ten que moverse o capuchón antes de que se mova a vista, como parte do seu percorrido completo. Auméntaa se a vista se despraza co capuchón en repouso.",
+ "ui.space_mouse_driven_by": "Que movemento calibrado do dispositivo controla este eixe. Se escolles un que xa usa outro eixe, intercámbianse.",
+ "ui.space_mouse_driven_by_label": "controlado por",
+ "ui.space_mouse_driver": "Controlador do rato 3D",
+ "ui.space_mouse_driver_auto": "Automático",
+ "ui.space_mouse_driver_direct": "Directo (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Lectura directa do dispositivo; spacenavd non está en execución",
+ "ui.space_mouse_driver_only_spacenavd": "Lectura mediante spacenavd, a única opción dispoñible",
"ui.space_mouse_forget": "Esquecer a calibración",
"ui.space_mouse_hint": "Move e rota a vista á vez; os bosquexos só usan desprazamento e zoom.",
+ "ui.space_mouse_motion_rotation_x": "Rotación X",
+ "ui.space_mouse_motion_rotation_y": "Rotación Y",
+ "ui.space_mouse_motion_rotation_z": "Rotación Z",
+ "ui.space_mouse_motion_translation_x": "Translación X",
+ "ui.space_mouse_motion_translation_y": "Translación Y",
+ "ui.space_mouse_motion_translation_z": "Translación Z",
"ui.space_mouse_navigate": "Navegar con SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "Non se atopou ningún rato 3D",
"ui.space_mouse_not_calibrated": "Sen calibrar",
"ui.space_mouse_reading": "Lectura",
+ "ui.space_mouse_reset_axes": "Restablecer asignación de eixes",
"ui.space_mouse_step_lift": "Levanta o capuchón, mantéño e sóltao.",
"ui.space_mouse_step_press": "Preme o capuchón cara abaixo, mantéño e sóltao.",
"ui.space_mouse_step_pull": "Tira do capuchón cara a ti, mantéño e sóltao.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Inclina o capuchón á dereita (bordo dereito abaixo), mantéño e sóltao.",
"ui.space_mouse_step_twist_clockwise": "Xira o capuchón no sentido horario, mantéño e sóltao.",
"ui.space_mouse_step_twist_counterclockwise": "Xira o capuchón no sentido antihorario, mantéño e sóltao.",
+ "ui.space_mouse_view_axis": "Eixe da vista",
+ "ui.space_mouse_view_off": "Desactivado",
+ "ui.space_mouse_view_off_tip": "O perfil do controlador do rato 3D desactiva este eixe, así que o seu movemento non move a vista. Se escolles aquí o movemento doutro eixe, intercámbianse e ese movemento deixa de mover a vista.",
+ "ui.space_mouse_view_orbit_sideways": "Orbitar á esquerda / dereita",
+ "ui.space_mouse_view_orbit_up_down": "Orbitar arriba / abaixo",
+ "ui.space_mouse_view_pan_sideways": "Desprazar á esquerda / dereita",
+ "ui.space_mouse_view_pan_up_down": "Desprazar arriba / abaixo",
+ "ui.space_mouse_view_roll": "Xirar sobre a vista",
+ "ui.space_mouse_view_unmapped": "Eixe {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Espazado",
"ui.spacing_2": "Espazado 2",
"ui.sphere": "Esfera",
diff --git a/assets/locales/it.json b/assets/locales/it.json
index b531e0adb9..233e5846fd 100644
--- a/assets/locales/it.json
+++ b/assets/locales/it.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Zoom fluido con rotellina",
"ui.smooth_wheel_zoom_tip": "Disattiva per applicare immediatamente ogni evento della rotellina, senza coda di interpolazione",
"ui.snap": "Aggancio",
+ "ui.space_mouse_axes_reassigned": "Gli assi sono riassegnati nelle Preferenze, e questo vale anche dopo questa calibrazione.",
"ui.space_mouse_calibrate": "Calibra…",
"ui.space_mouse_calibrate_tip": "Muovi la manopola come chiede la finestra, così SolidCraft impara in che direzione e quanto va ogni asse di questo mouse 3D. Viene salvata per questo mouse 3D.",
"ui.space_mouse_calibrate_title": "Calibra mouse 3D",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Un asse si è mosso appena, quindi non si può calibrare. Ricomincia e muovi la manopola più a fondo ogni volta.",
"ui.space_mouse_dead_zone": "Zona morta",
"ui.space_mouse_dead_zone_tip": "Quanto deve muoversi la manopola prima che si muova la vista, come quota della sua corsa completa. Aumentala se la vista si sposta con la manopola a riposo.",
+ "ui.space_mouse_driven_by": "Quale movimento calibrato del dispositivo comanda questo asse. Se ne scegli uno già usato da un altro asse, i due si scambiano.",
+ "ui.space_mouse_driven_by_label": "comandato da",
+ "ui.space_mouse_driver": "Driver del mouse 3D",
+ "ui.space_mouse_driver_auto": "Automatico",
+ "ui.space_mouse_driver_direct": "Diretto (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Lettura diretta del dispositivo; spacenavd non è in esecuzione",
+ "ui.space_mouse_driver_only_spacenavd": "Lettura tramite spacenavd, l'unica possibilità disponibile",
"ui.space_mouse_forget": "Dimentica calibrazione",
"ui.space_mouse_hint": "Sposta e ruota la vista insieme; gli schizzi usano solo panoramica e zoom.",
+ "ui.space_mouse_motion_rotation_x": "Rotazione X",
+ "ui.space_mouse_motion_rotation_y": "Rotazione Y",
+ "ui.space_mouse_motion_rotation_z": "Rotazione Z",
+ "ui.space_mouse_motion_translation_x": "Traslazione X",
+ "ui.space_mouse_motion_translation_y": "Traslazione Y",
+ "ui.space_mouse_motion_translation_z": "Traslazione Z",
"ui.space_mouse_navigate": "Naviga con SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "Nessun mouse 3D trovato",
"ui.space_mouse_not_calibrated": "Non calibrato",
"ui.space_mouse_reading": "Lettura",
+ "ui.space_mouse_reset_axes": "Ripristina assegnazione assi",
"ui.space_mouse_step_lift": "Solleva la manopola, tienila, poi lasciala.",
"ui.space_mouse_step_press": "Premi la manopola verso il basso, tienila, poi lasciala.",
"ui.space_mouse_step_pull": "Tira la manopola verso di te, tienila, poi lasciala.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Inclina la manopola a destra (bordo destro in basso), tienila, poi lasciala.",
"ui.space_mouse_step_twist_clockwise": "Ruota la manopola in senso orario, tienila, poi lasciala.",
"ui.space_mouse_step_twist_counterclockwise": "Ruota la manopola in senso antiorario, tienila, poi lasciala.",
+ "ui.space_mouse_view_axis": "Asse della vista",
+ "ui.space_mouse_view_off": "Disattivato",
+ "ui.space_mouse_view_off_tip": "Il profilo del driver del mouse 3D disattiva questo asse, quindi il suo movimento non muove la vista. Se qui scegli il movimento di un altro asse, i due si scambiano e quel movimento smette di muovere la vista.",
+ "ui.space_mouse_view_orbit_sideways": "Orbita sinistra / destra",
+ "ui.space_mouse_view_orbit_up_down": "Orbita su / giù",
+ "ui.space_mouse_view_pan_sideways": "Panoramica sinistra / destra",
+ "ui.space_mouse_view_pan_up_down": "Panoramica su / giù",
+ "ui.space_mouse_view_roll": "Rollio",
+ "ui.space_mouse_view_unmapped": "Asse {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Spaziatura",
"ui.spacing_2": "Spaziatura 2",
"ui.sphere": "Sfera",
diff --git a/assets/locales/ja.json b/assets/locales/ja.json
index fedd2fb0d7..7b64c07d6b 100644
--- a/assets/locales/ja.json
+++ b/assets/locales/ja.json
@@ -1742,6 +1742,7 @@
"ui.smooth_wheel_zoom": "滑らかなホイールズーム",
"ui.smooth_wheel_zoom_tip": "オフにすると、ホイール操作のたびにズームが即座に反映され、滑らかな減速効果は適用されません。",
"ui.snap": "スナップ",
+ "ui.space_mouse_axes_reassigned": "軸の割り当ては環境設定で変更されており、このキャリブレーションの後も適用されます。",
"ui.space_mouse_calibrate": "キャリブレーション…",
"ui.space_mouse_calibrate_tip": "ウィンドウの指示どおりにキャップを動かすと、この3Dマウスの各軸の向きと移動量をSolidCraftが学習します。この3Dマウス用に保存されます。",
"ui.space_mouse_calibrate_title": "3Dマウスのキャリブレーション",
@@ -1751,12 +1752,26 @@
"ui.space_mouse_calibration_no_response": "ほとんど動かなかった軸があるため、キャリブレーションできません。最初からやり直し、毎回キャップをもっと大きく動かしてください。",
"ui.space_mouse_dead_zone": "デッドゾーン",
"ui.space_mouse_dead_zone_tip": "視点が動き出すまでにキャップを動かす量(全ストロークに対する割合)。キャップに触れていないのに視点が動く場合は大きくしてください。",
+ "ui.space_mouse_driven_by": "この軸を操作するデバイスのキャリブレーション済みの動き。他の軸で使われている動きを選ぶと、2つが入れ替わります。",
+ "ui.space_mouse_driven_by_label": "操作元",
+ "ui.space_mouse_driver": "3Dマウスのドライバー",
+ "ui.space_mouse_driver_auto": "自動",
+ "ui.space_mouse_driver_direct": "直接 (hidraw)",
+ "ui.space_mouse_driver_only_direct": "デバイスを直接読み取り中(spacenavd は起動していません)",
+ "ui.space_mouse_driver_only_spacenavd": "spacenavd 経由で読み取り中(他の方法はありません)",
"ui.space_mouse_forget": "キャリブレーションを削除",
"ui.space_mouse_hint": "視点の移動と回転を同時に行います(スケッチ中はパンとズームのみ)",
+ "ui.space_mouse_motion_rotation_x": "回転 X",
+ "ui.space_mouse_motion_rotation_y": "回転 Y",
+ "ui.space_mouse_motion_rotation_z": "回転 Z",
+ "ui.space_mouse_motion_translation_x": "平行移動 X",
+ "ui.space_mouse_motion_translation_y": "平行移動 Y",
+ "ui.space_mouse_motion_translation_z": "平行移動 Z",
"ui.space_mouse_navigate": "SpaceNavigator / SpaceMouseで視点を操作",
"ui.space_mouse_none": "3Dマウスが見つかりません",
"ui.space_mouse_not_calibrated": "未キャリブレーション",
"ui.space_mouse_reading": "読み取り値",
+ "ui.space_mouse_reset_axes": "軸の割り当てをリセット",
"ui.space_mouse_step_lift": "キャップを持ち上げて保持し、離してください。",
"ui.space_mouse_step_press": "キャップを押し下げて保持し、離してください。",
"ui.space_mouse_step_pull": "キャップを手前に引いて保持し、離してください。",
@@ -1770,6 +1785,16 @@
"ui.space_mouse_step_tilt_right": "キャップを右に傾け(右の縁を下げて)保持し、離してください。",
"ui.space_mouse_step_twist_clockwise": "キャップを時計回りにひねって保持し、離してください。",
"ui.space_mouse_step_twist_counterclockwise": "キャップを反時計回りにひねって保持し、離してください。",
+ "ui.space_mouse_view_axis": "ビューの軸",
+ "ui.space_mouse_view_off": "オフ",
+ "ui.space_mouse_view_off_tip": "3D マウスのドライバーのプロファイルがこの軸をオフにしているため、この軸の動きではビューは動きません。ここで他の軸の動きを選ぶと 2 つが入れ替わり、その動きではビューが動かなくなります。",
+ "ui.space_mouse_view_orbit_sideways": "左右オービット",
+ "ui.space_mouse_view_orbit_up_down": "上下オービット",
+ "ui.space_mouse_view_pan_sideways": "左右パン",
+ "ui.space_mouse_view_pan_up_down": "上下パン",
+ "ui.space_mouse_view_roll": "ロール",
+ "ui.space_mouse_view_unmapped": "軸 {n}",
+ "ui.space_mouse_view_zoom": "ズーム",
"ui.spacing": "間隔",
"ui.spacing_2": "間隔 2",
"ui.sphere": "球",
diff --git a/assets/locales/ko.json b/assets/locales/ko.json
index 6904996a3c..bc8fdc4342 100644
--- a/assets/locales/ko.json
+++ b/assets/locales/ko.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "부드러운 휠 확대/축소",
"ui.smooth_wheel_zoom_tip": "끄면 휠 이벤트를 부드러운 꼬리 없이 즉시 적용합니다",
"ui.snap": "스냅",
+ "ui.space_mouse_axes_reassigned": "축이 환경설정에서 다시 지정되어 있으며, 이 보정 후에도 적용됩니다.",
"ui.space_mouse_calibrate": "보정…",
"ui.space_mouse_calibrate_tip": "창의 안내대로 캡을 움직이면 SolidCraft가 이 3D 마우스의 각 축이 어느 방향으로 얼마나 움직이는지 학습합니다. 이 3D 마우스에 저장됩니다.",
"ui.space_mouse_calibrate_title": "3D 마우스 보정",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "거의 움직이지 않은 축이 있어 보정할 수 없습니다. 처음부터 다시 하고 매번 캡을 더 멀리 움직이세요.",
"ui.space_mouse_dead_zone": "데드존",
"ui.space_mouse_dead_zone_tip": "보기가 움직이기 전에 캡이 움직여야 하는 정도로, 전체 이동 범위에 대한 비율입니다. 캡을 건드리지 않았는데 보기가 움직이면 높이세요.",
+ "ui.space_mouse_driven_by": "이 축을 움직이는 장치의 보정된 동작입니다. 다른 축이 이미 쓰는 동작을 고르면 둘이 서로 바뀝니다.",
+ "ui.space_mouse_driven_by_label": "제어 동작",
+ "ui.space_mouse_driver": "3D 마우스 드라이버",
+ "ui.space_mouse_driver_auto": "자동",
+ "ui.space_mouse_driver_direct": "직접 (hidraw)",
+ "ui.space_mouse_driver_only_direct": "장치를 직접 읽는 중 (spacenavd가 실행 중이 아님)",
+ "ui.space_mouse_driver_only_spacenavd": "spacenavd로 읽는 중 (다른 방법이 없음)",
"ui.space_mouse_forget": "보정 삭제",
"ui.space_mouse_hint": "뷰를 함께 이동하고 회전합니다. 스케치는 이동과 확대/축소만 사용합니다.",
+ "ui.space_mouse_motion_rotation_x": "회전 X",
+ "ui.space_mouse_motion_rotation_y": "회전 Y",
+ "ui.space_mouse_motion_rotation_z": "회전 Z",
+ "ui.space_mouse_motion_translation_x": "이동 X",
+ "ui.space_mouse_motion_translation_y": "이동 Y",
+ "ui.space_mouse_motion_translation_z": "이동 Z",
"ui.space_mouse_navigate": "SpaceNavigator / SpaceMouse로 탐색",
"ui.space_mouse_none": "3D 마우스를 찾을 수 없음",
"ui.space_mouse_not_calibrated": "보정 안 됨",
"ui.space_mouse_reading": "읽은 값",
+ "ui.space_mouse_reset_axes": "축 지정 초기화",
"ui.space_mouse_step_lift": "캡을 위로 들어 유지한 다음 놓으세요.",
"ui.space_mouse_step_press": "캡을 아래로 눌러 유지한 다음 놓으세요.",
"ui.space_mouse_step_pull": "캡을 몸 쪽으로 당겨 유지한 다음 놓으세요.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "캡을 오른쪽으로 기울여(오른쪽 가장자리를 아래로) 유지한 다음 놓으세요.",
"ui.space_mouse_step_twist_clockwise": "캡을 시계 방향으로 돌려 유지한 다음 놓으세요.",
"ui.space_mouse_step_twist_counterclockwise": "캡을 시계 반대 방향으로 돌려 유지한 다음 놓으세요.",
+ "ui.space_mouse_view_axis": "보기 축",
+ "ui.space_mouse_view_off": "끔",
+ "ui.space_mouse_view_off_tip": "3D 마우스 드라이버 프로필이 이 축을 끄므로, 이 축의 동작으로는 뷰가 움직이지 않습니다. 여기서 다른 축의 동작을 고르면 둘이 바뀌고, 그 동작은 더 이상 뷰를 움직이지 않습니다.",
+ "ui.space_mouse_view_orbit_sideways": "좌우 궤도",
+ "ui.space_mouse_view_orbit_up_down": "상하 궤도",
+ "ui.space_mouse_view_pan_sideways": "좌우 이동",
+ "ui.space_mouse_view_pan_up_down": "상하 이동",
+ "ui.space_mouse_view_roll": "롤",
+ "ui.space_mouse_view_unmapped": "축 {n}",
+ "ui.space_mouse_view_zoom": "확대/축소",
"ui.spacing": "간격",
"ui.spacing_2": "간격 2",
"ui.sphere": "구",
diff --git a/assets/locales/pt-BR.json b/assets/locales/pt-BR.json
index 3307fbbfdc..278ecbd0ba 100644
--- a/assets/locales/pt-BR.json
+++ b/assets/locales/pt-BR.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Zoom suave com a roda",
"ui.smooth_wheel_zoom_tip": "Desative para aplicar cada evento da roda na hora, sem rastro de suavização",
"ui.snap": "Encaixe",
+ "ui.space_mouse_axes_reassigned": "Os eixos estão reatribuídos nas Preferências, e isso continua valendo sobre esta calibração.",
"ui.space_mouse_calibrate": "Calibrar…",
"ui.space_mouse_calibrate_tip": "Mova a tampa como a janela pedir, para que o SolidCraft aprenda para onde e até onde vai cada eixo deste mouse 3D. Salvo para este mouse 3D.",
"ui.space_mouse_calibrate_title": "Calibrar mouse 3D",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Um eixo quase não se moveu, então não dá para calibrá-lo. Recomece e mova a tampa mais longe a cada vez.",
"ui.space_mouse_dead_zone": "Zona morta",
"ui.space_mouse_dead_zone_tip": "Quanto a tampa precisa se mover antes de a vista se mover, como fração do curso completo. Aumente se a vista se mexer com a tampa parada.",
+ "ui.space_mouse_driven_by": "Qual movimento calibrado do dispositivo controla este eixo. Escolher um que outro eixo já usa troca os dois.",
+ "ui.space_mouse_driven_by_label": "controlado por",
+ "ui.space_mouse_driver": "Driver do mouse 3D",
+ "ui.space_mouse_driver_auto": "Automático",
+ "ui.space_mouse_driver_direct": "Direto (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Lendo o dispositivo diretamente; o spacenavd não está em execução",
+ "ui.space_mouse_driver_only_spacenavd": "Lendo pelo spacenavd, a única opção disponível",
"ui.space_mouse_forget": "Esquecer calibração",
"ui.space_mouse_hint": "Move e gira a vista juntos; esboços usam apenas deslocamento e zoom.",
+ "ui.space_mouse_motion_rotation_x": "Rotação X",
+ "ui.space_mouse_motion_rotation_y": "Rotação Y",
+ "ui.space_mouse_motion_rotation_z": "Rotação Z",
+ "ui.space_mouse_motion_translation_x": "Translação X",
+ "ui.space_mouse_motion_translation_y": "Translação Y",
+ "ui.space_mouse_motion_translation_z": "Translação Z",
"ui.space_mouse_navigate": "Navegar com SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "Nenhum mouse 3D encontrado",
"ui.space_mouse_not_calibrated": "Não calibrado",
"ui.space_mouse_reading": "Leitura",
+ "ui.space_mouse_reset_axes": "Redefinir atribuição de eixos",
"ui.space_mouse_step_lift": "Levante a tampa, segure e solte.",
"ui.space_mouse_step_press": "Pressione a tampa para baixo, segure e solte.",
"ui.space_mouse_step_pull": "Puxe a tampa na sua direção, segure e solte.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Incline a tampa para a direita (borda direita para baixo), segure e solte.",
"ui.space_mouse_step_twist_clockwise": "Gire a tampa no sentido horário, segure e solte.",
"ui.space_mouse_step_twist_counterclockwise": "Gire a tampa no sentido anti-horário, segure e solte.",
+ "ui.space_mouse_view_axis": "Eixo da vista",
+ "ui.space_mouse_view_off": "Desligado",
+ "ui.space_mouse_view_off_tip": "O perfil do driver do mouse 3D desliga este eixo, então o movimento dele não move a vista. Escolher aqui o movimento de outro eixo troca os dois, e esse movimento deixa de mover a vista.",
+ "ui.space_mouse_view_orbit_sideways": "Orbitar esquerda / direita",
+ "ui.space_mouse_view_orbit_up_down": "Orbitar cima / baixo",
+ "ui.space_mouse_view_pan_sideways": "Deslocar esquerda / direita",
+ "ui.space_mouse_view_pan_up_down": "Deslocar cima / baixo",
+ "ui.space_mouse_view_roll": "Girar a vista",
+ "ui.space_mouse_view_unmapped": "Eixo {n}",
+ "ui.space_mouse_view_zoom": "Zoom",
"ui.spacing": "Espaçamento",
"ui.spacing_2": "Espaçamento 2",
"ui.sphere": "Esfera",
diff --git a/assets/locales/ru.json b/assets/locales/ru.json
index 3fc4c2dae4..bfcee7c0dc 100644
--- a/assets/locales/ru.json
+++ b/assets/locales/ru.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Плавное масштабирование колесом",
"ui.smooth_wheel_zoom_tip": "Отключите, чтобы каждое движение колеса применялось сразу, без сглаживания",
"ui.snap": "Привязка",
+ "ui.space_mouse_axes_reassigned": "Оси переназначены в настройках, и это действует и поверх этой калибровки.",
"ui.space_mouse_calibrate": "Калибровать…",
"ui.space_mouse_calibrate_tip": "Двигайте колпачок так, как просит окно, чтобы SolidCraft узнал, куда и насколько далеко движется каждая ось этой 3D-мыши. Сохраняется для этой 3D-мыши.",
"ui.space_mouse_calibrate_title": "Калибровка 3D-мыши",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Одна ось почти не сдвинулась, поэтому её нельзя откалибровать. Начните заново и каждый раз двигайте колпачок дальше.",
"ui.space_mouse_dead_zone": "Мёртвая зона",
"ui.space_mouse_dead_zone_tip": "Насколько нужно сдвинуть колпачок, прежде чем сдвинется вид, в доле от полного хода. Увеличьте, если вид смещается, когда колпачок в покое.",
+ "ui.space_mouse_driven_by": "Какое откалиброванное движение устройства управляет этой осью. Если выбрать движение, которое уже использует другая ось, они поменяются местами.",
+ "ui.space_mouse_driven_by_label": "управляется",
+ "ui.space_mouse_driver": "Драйвер 3D-мыши",
+ "ui.space_mouse_driver_auto": "Автоматически",
+ "ui.space_mouse_driver_direct": "Напрямую (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Чтение напрямую с устройства; spacenavd не запущен",
+ "ui.space_mouse_driver_only_spacenavd": "Чтение через spacenavd, других вариантов нет",
"ui.space_mouse_forget": "Забыть калибровку",
"ui.space_mouse_hint": "Совместное перемещение и вращение вида; в эскизе — только панорама и масштаб.",
+ "ui.space_mouse_motion_rotation_x": "Вращение X",
+ "ui.space_mouse_motion_rotation_y": "Вращение Y",
+ "ui.space_mouse_motion_rotation_z": "Вращение Z",
+ "ui.space_mouse_motion_translation_x": "Смещение X",
+ "ui.space_mouse_motion_translation_y": "Смещение Y",
+ "ui.space_mouse_motion_translation_z": "Смещение Z",
"ui.space_mouse_navigate": "Навигация через SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "3D-мышь не найдена",
"ui.space_mouse_not_calibrated": "Не откалибрована",
"ui.space_mouse_reading": "Показания",
+ "ui.space_mouse_reset_axes": "Сбросить назначение осей",
"ui.space_mouse_step_lift": "Поднимите колпачок вверх, удержите и отпустите.",
"ui.space_mouse_step_press": "Нажмите на колпачок вниз, удержите и отпустите.",
"ui.space_mouse_step_pull": "Потяните колпачок на себя, удержите и отпустите.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Наклоните колпачок вправо (правый край вниз), удержите и отпустите.",
"ui.space_mouse_step_twist_clockwise": "Поверните колпачок по часовой стрелке, удержите и отпустите.",
"ui.space_mouse_step_twist_counterclockwise": "Поверните колпачок против часовой стрелки, удержите и отпустите.",
+ "ui.space_mouse_view_axis": "Ось вида",
+ "ui.space_mouse_view_off": "Выкл.",
+ "ui.space_mouse_view_off_tip": "Профиль драйвера 3D-мыши отключает эту ось, поэтому её движение не двигает вид. Если выбрать здесь движение другой оси, они поменяются местами, и это движение перестанет двигать вид.",
+ "ui.space_mouse_view_orbit_sideways": "Орбита влево / вправо",
+ "ui.space_mouse_view_orbit_up_down": "Орбита вверх / вниз",
+ "ui.space_mouse_view_pan_sideways": "Сдвиг влево / вправо",
+ "ui.space_mouse_view_pan_up_down": "Сдвиг вверх / вниз",
+ "ui.space_mouse_view_roll": "Крен",
+ "ui.space_mouse_view_unmapped": "Ось {n}",
+ "ui.space_mouse_view_zoom": "Масштаб",
"ui.spacing": "Интервал",
"ui.spacing_2": "Интервал 2",
"ui.sphere": "Сфера",
diff --git a/assets/locales/tr.json b/assets/locales/tr.json
index a0e18b92dc..52db14dc4f 100644
--- a/assets/locales/tr.json
+++ b/assets/locales/tr.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Yumuşak tekerlek yakınlaştırması",
"ui.smooth_wheel_zoom_tip": "Her tekerlek hareketini yumuşatma olmadan hemen uygulamak için kapatın",
"ui.snap": "Yakala",
+ "ui.space_mouse_axes_reassigned": "Eksenler Tercihler'de yeniden atanmış; bu, bu kalibrasyonun üstüne de uygulanır.",
"ui.space_mouse_calibrate": "Kalibre et…",
"ui.space_mouse_calibrate_tip": "Pencerenin istediği gibi başlığı hareket ettirin; SolidCraft bu 3B farenin her ekseninin hangi yöne ve ne kadar gittiğini öğrensin. Bu 3B fare için kaydedilir.",
"ui.space_mouse_calibrate_title": "3B fareyi kalibre et",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Bir eksen neredeyse hiç hareket etmedi, bu yüzden kalibre edilemiyor. Baştan başlayın ve başlığı her seferinde daha fazla hareket ettirin.",
"ui.space_mouse_dead_zone": "Ölü bölge",
"ui.space_mouse_dead_zone_tip": "Görünüm hareket etmeden önce başlığın ne kadar hareket etmesi gerektiği, tam hareket aralığının oranı olarak. Başlık dururken görünüm kayıyorsa artırın.",
+ "ui.space_mouse_driven_by": "Bu ekseni cihazın hangi kalibre edilmiş hareketinin yönettiği. Başka bir eksenin zaten kullandığını seçerseniz ikisi yer değiştirir.",
+ "ui.space_mouse_driven_by_label": "kumanda eden",
+ "ui.space_mouse_driver": "3B fare sürücüsü",
+ "ui.space_mouse_driver_auto": "Otomatik",
+ "ui.space_mouse_driver_direct": "Doğrudan (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Aygıt doğrudan okunuyor; spacenavd çalışmıyor",
+ "ui.space_mouse_driver_only_spacenavd": "spacenavd üzerinden okunuyor, tek seçenek bu",
"ui.space_mouse_forget": "Kalibrasyonu unut",
"ui.space_mouse_hint": "Görünümü aynı anda kaydırın ve döndürün; eskizlerde yalnızca kaydırma ve yakınlaştırma kullanılır.",
+ "ui.space_mouse_motion_rotation_x": "Dönme X",
+ "ui.space_mouse_motion_rotation_y": "Dönme Y",
+ "ui.space_mouse_motion_rotation_z": "Dönme Z",
+ "ui.space_mouse_motion_translation_x": "Öteleme X",
+ "ui.space_mouse_motion_translation_y": "Öteleme Y",
+ "ui.space_mouse_motion_translation_z": "Öteleme Z",
"ui.space_mouse_navigate": "SpaceNavigator / SpaceMouse ile gezin",
"ui.space_mouse_none": "3B fare bulunamadı",
"ui.space_mouse_not_calibrated": "Kalibre edilmedi",
"ui.space_mouse_reading": "Okunan değer",
+ "ui.space_mouse_reset_axes": "Eksen atamasını sıfırla",
"ui.space_mouse_step_lift": "Başlığı yukarı kaldırın, tutun, sonra bırakın.",
"ui.space_mouse_step_press": "Başlığı aşağı bastırın, tutun, sonra bırakın.",
"ui.space_mouse_step_pull": "Başlığı kendinize doğru çekin, tutun, sonra bırakın.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Başlığı sağa eğin (sağ kenar aşağı), tutun, sonra bırakın.",
"ui.space_mouse_step_twist_clockwise": "Başlığı saat yönünde çevirin, tutun, sonra bırakın.",
"ui.space_mouse_step_twist_counterclockwise": "Başlığı saat yönünün tersine çevirin, tutun, sonra bırakın.",
+ "ui.space_mouse_view_axis": "Görünüm ekseni",
+ "ui.space_mouse_view_off": "Kapalı",
+ "ui.space_mouse_view_off_tip": "3D fare sürücüsünün profili bu ekseni kapatıyor, bu yüzden hareketi görünümü oynatmaz. Burada başka bir eksenin hareketini seçerseniz ikisi yer değiştirir ve o hareket görünümü oynatmayı bırakır.",
+ "ui.space_mouse_view_orbit_sideways": "Sola / sağa yörünge",
+ "ui.space_mouse_view_orbit_up_down": "Yukarı / aşağı yörünge",
+ "ui.space_mouse_view_pan_sideways": "Sola / sağa kaydır",
+ "ui.space_mouse_view_pan_up_down": "Yukarı / aşağı kaydır",
+ "ui.space_mouse_view_roll": "Yuvarlanma",
+ "ui.space_mouse_view_unmapped": "Eksen {n}",
+ "ui.space_mouse_view_zoom": "Yakınlaştır",
"ui.spacing": "Aralık",
"ui.spacing_2": "Aralık 2",
"ui.sphere": "Küre",
diff --git a/assets/locales/uk.json b/assets/locales/uk.json
index 43a7f6523f..720bff2574 100644
--- a/assets/locales/uk.json
+++ b/assets/locales/uk.json
@@ -1734,6 +1734,7 @@
"ui.smooth_wheel_zoom": "Плавне масштабування колесом",
"ui.smooth_wheel_zoom_tip": "Вимкніть, щоб застосовувати кожну подію колеса негайно, без плавного завершення",
"ui.snap": "Прив'язка",
+ "ui.space_mouse_axes_reassigned": "Осі перепризначено в налаштуваннях, і це діє й поверх цього калібрування.",
"ui.space_mouse_calibrate": "Калібрувати…",
"ui.space_mouse_calibrate_tip": "Рухайте ковпачок так, як просить вікно, щоб SolidCraft дізнався, куди й наскільки далеко рухається кожна вісь цієї 3D-миші. Зберігається для цієї 3D-миші.",
"ui.space_mouse_calibrate_title": "Калібрування 3D-миші",
@@ -1743,12 +1744,26 @@
"ui.space_mouse_calibration_no_response": "Одна вісь майже не зрушила, тому її не можна відкалібрувати. Почніть спочатку й щоразу рухайте ковпачок далі.",
"ui.space_mouse_dead_zone": "Мертва зона",
"ui.space_mouse_dead_zone_tip": "Наскільки треба зсунути ковпачок, перш ніж зрушить вигляд, у частці від повного ходу. Збільште, якщо вигляд зміщується, коли ковпачок у спокої.",
+ "ui.space_mouse_driven_by": "Який відкалібрований рух пристрою керує цією віссю. Якщо вибрати рух, який уже використовує інша вісь, вони поміняються місцями.",
+ "ui.space_mouse_driven_by_label": "керується",
+ "ui.space_mouse_driver": "Драйвер 3D-миші",
+ "ui.space_mouse_driver_auto": "Автоматично",
+ "ui.space_mouse_driver_direct": "Напряму (hidraw)",
+ "ui.space_mouse_driver_only_direct": "Читання напряму з пристрою; spacenavd не запущено",
+ "ui.space_mouse_driver_only_spacenavd": "Читання через spacenavd, інших варіантів немає",
"ui.space_mouse_forget": "Забути калібрування",
"ui.space_mouse_hint": "Переміщуйте й обертайте вид разом; в ескізах доступні лише панорамування та масштаб.",
+ "ui.space_mouse_motion_rotation_x": "Обертання X",
+ "ui.space_mouse_motion_rotation_y": "Обертання Y",
+ "ui.space_mouse_motion_rotation_z": "Обертання Z",
+ "ui.space_mouse_motion_translation_x": "Зміщення X",
+ "ui.space_mouse_motion_translation_y": "Зміщення Y",
+ "ui.space_mouse_motion_translation_z": "Зміщення Z",
"ui.space_mouse_navigate": "Навігація за допомогою SpaceNavigator / SpaceMouse",
"ui.space_mouse_none": "3D-мишу не знайдено",
"ui.space_mouse_not_calibrated": "Не відкалібровано",
"ui.space_mouse_reading": "Показники",
+ "ui.space_mouse_reset_axes": "Скинути призначення осей",
"ui.space_mouse_step_lift": "Підніміть ковпачок угору, утримайте й відпустіть.",
"ui.space_mouse_step_press": "Натисніть ковпачок униз, утримайте й відпустіть.",
"ui.space_mouse_step_pull": "Потягніть ковпачок до себе, утримайте й відпустіть.",
@@ -1762,6 +1777,16 @@
"ui.space_mouse_step_tilt_right": "Нахиліть ковпачок праворуч (правий край униз), утримайте й відпустіть.",
"ui.space_mouse_step_twist_clockwise": "Поверніть ковпачок за годинниковою стрілкою, утримайте й відпустіть.",
"ui.space_mouse_step_twist_counterclockwise": "Поверніть ковпачок проти годинникової стрілки, утримайте й відпустіть.",
+ "ui.space_mouse_view_axis": "Вісь вигляду",
+ "ui.space_mouse_view_off": "Вимк.",
+ "ui.space_mouse_view_off_tip": "Профіль драйвера 3D-миші вимикає цю вісь, тож її рух не рухає вигляд. Якщо вибрати тут рух іншої осі, вони поміняються місцями, і цей рух перестане рухати вигляд.",
+ "ui.space_mouse_view_orbit_sideways": "Орбіта ліворуч / праворуч",
+ "ui.space_mouse_view_orbit_up_down": "Орбіта вгору / вниз",
+ "ui.space_mouse_view_pan_sideways": "Зсув ліворуч / праворуч",
+ "ui.space_mouse_view_pan_up_down": "Зсув угору / вниз",
+ "ui.space_mouse_view_roll": "Крен",
+ "ui.space_mouse_view_unmapped": "Вісь {n}",
+ "ui.space_mouse_view_zoom": "Масштаб",
"ui.spacing": "Крок",
"ui.spacing_2": "Крок 2",
"ui.sphere": "Куля",
diff --git a/assets/locales/zh.json b/assets/locales/zh.json
index b90f051306..f6851834bc 100644
--- a/assets/locales/zh.json
+++ b/assets/locales/zh.json
@@ -1742,6 +1742,7 @@
"ui.smooth_wheel_zoom": "平滑滚轮缩放",
"ui.smooth_wheel_zoom_tip": "关闭后每个滚轮事件立即生效,不做平滑延迟",
"ui.snap": "捕捉",
+ "ui.space_mouse_axes_reassigned": "轴已在偏好设置中重新分配,在此次校准之上仍然生效。",
"ui.space_mouse_calibrate": "校准…",
"ui.space_mouse_calibrate_tip": "按窗口提示移动摇杆帽,SolidCraft 会记住这个 3D 鼠标每个轴的方向和行程。校准结果按此 3D 鼠标保存。",
"ui.space_mouse_calibrate_title": "校准 3D 鼠标",
@@ -1751,12 +1752,26 @@
"ui.space_mouse_calibration_no_response": "有一个轴几乎没有移动,因此无法校准。请重新开始,并且每次把摇杆帽移得更远。",
"ui.space_mouse_dead_zone": "死区",
"ui.space_mouse_dead_zone_tip": "视图开始移动前摇杆帽需要移动的距离,以其全行程的比例表示。如果摇杆帽静止时视图仍在漂移,请调大。",
+ "ui.space_mouse_driven_by": "由设备的哪个校准动作控制此轴。选择另一个轴已在使用的动作时,两者会互换。",
+ "ui.space_mouse_driven_by_label": "控制来源",
+ "ui.space_mouse_driver": "3D 鼠标驱动",
+ "ui.space_mouse_driver_auto": "自动",
+ "ui.space_mouse_driver_direct": "直接 (hidraw)",
+ "ui.space_mouse_driver_only_direct": "直接读取设备(spacenavd 未运行)",
+ "ui.space_mouse_driver_only_spacenavd": "通过 spacenavd 读取(没有其他方式)",
"ui.space_mouse_forget": "清除校准",
"ui.space_mouse_hint": "同时移动和旋转视图;草图中仅支持平移和缩放。",
+ "ui.space_mouse_motion_rotation_x": "旋转 X",
+ "ui.space_mouse_motion_rotation_y": "旋转 Y",
+ "ui.space_mouse_motion_rotation_z": "旋转 Z",
+ "ui.space_mouse_motion_translation_x": "平移 X",
+ "ui.space_mouse_motion_translation_y": "平移 Y",
+ "ui.space_mouse_motion_translation_z": "平移 Z",
"ui.space_mouse_navigate": "使用 SpaceNavigator / SpaceMouse 导航",
"ui.space_mouse_none": "未找到 3D 鼠标",
"ui.space_mouse_not_calibrated": "未校准",
"ui.space_mouse_reading": "读数",
+ "ui.space_mouse_reset_axes": "重置轴分配",
"ui.space_mouse_step_lift": "向上提起摇杆帽,保持住,然后松开。",
"ui.space_mouse_step_press": "向下按压摇杆帽,保持住,然后松开。",
"ui.space_mouse_step_pull": "把摇杆帽拉向自己,保持住,然后松开。",
@@ -1770,6 +1785,16 @@
"ui.space_mouse_step_tilt_right": "向右倾斜摇杆帽(右缘向下),保持住,然后松开。",
"ui.space_mouse_step_twist_clockwise": "顺时针扭转摇杆帽,保持住,然后松开。",
"ui.space_mouse_step_twist_counterclockwise": "逆时针扭转摇杆帽,保持住,然后松开。",
+ "ui.space_mouse_view_axis": "视图轴",
+ "ui.space_mouse_view_off": "关闭",
+ "ui.space_mouse_view_off_tip": "3D 鼠标驱动程序的配置文件关闭了此轴,因此它的动作不会移动视图。在此选择另一个轴的动作会将两者互换,该动作将不再移动视图。",
+ "ui.space_mouse_view_orbit_sideways": "左右环绕",
+ "ui.space_mouse_view_orbit_up_down": "上下环绕",
+ "ui.space_mouse_view_pan_sideways": "左右平移",
+ "ui.space_mouse_view_pan_up_down": "上下平移",
+ "ui.space_mouse_view_roll": "滚转",
+ "ui.space_mouse_view_unmapped": "轴 {n}",
+ "ui.space_mouse_view_zoom": "缩放",
"ui.spacing": "间距",
"ui.spacing_2": "间距 2",
"ui.sphere": "球体",
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 7b8600f89d..ed56a365d4 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -281,6 +281,33 @@ pub enum OrbitAround {
Cursor,
}
+/// Which program reads the 3D mouse on Linux when both spacenavd and the device itself (hidraw)
+/// are there (Preferences: "3D mouse driver"). Read by the app's reader, not by this crate.
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum SpaceMouseDriver {
+ /// spacenavd when it runs, else the device itself (how it always was).
+ #[default]
+ Automatic,
+ Spacenavd,
+ /// The hidraw device, bypassing spacenavd's settings.
+ Direct,
+}
+
+impl SpaceMouseDriver {
+ pub const ALL: [Self; 3] = [Self::Automatic, Self::Spacenavd, Self::Direct];
+
+ /// The choice as the reader thread shares it (an `AtomicU8`).
+ pub fn to_u8(self) -> u8 {
+ self as u8
+ }
+
+ /// Back from [`Self::to_u8`]; anything else reads as Automatic.
+ pub fn from_u8(value: u8) -> Self {
+ Self::ALL.into_iter().find(|driver| driver.to_u8() == value).unwrap_or_default()
+ }
+}
+
/// The browser sidebar's first width, and the width [`Prefs::default`] restores; the panel
/// itself clamps what the user drags to its own range.
pub const DEFAULT_BROWSER_WIDTH: f32 = 250.0;
@@ -374,6 +401,11 @@ preference_settings! {
space_mouse_reverse: [bool; 6] = [false; 6], 1;
/// Per physical axis of the cap, a multiplier on top of `space_mouse_speed`; 0 switches it off.
space_mouse_axis_speed: [f32; 6] = [1.0; 6], 1;
+ /// Per physical axis of the cap, which of its motions drives it (`space_mouse::reassigned`),
+ /// applied after calibration; each motion drives exactly one axis.
+ space_mouse_axis_source: [usize; 6] = crate::space_mouse::SAME_AXES, 1;
+ /// Which program reads the 3D mouse when spacenavd and the device itself are both there (Linux).
+ space_mouse_driver: SpaceMouseDriver = SpaceMouseDriver::default(), 1;
/// Per 3D mouse (`space_mouse::Input::device`), the calibration that puts its axes on
/// 3Dconnexion's. A device without one is read as it reports. Page resets keep calibrations.
#[serde(deserialize_with = "calibrations_that_read")]
@@ -1229,23 +1261,103 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
});
setting::space_mouse_enabled(app, ui);
setting::space_mouse_speed(app, ui);
- for (axis, name) in SPACE_MOUSE_AXES.iter().enumerate() {
- ui_kit::row(ui, crate::i18n::tr_label(name), |ui| {
+ // Rows say what they do to the view, through the mapping navigation uses; the choices
+ // are the device's calibrated motions. Neither names a kind of device.
+ let mapping = app.space_mouse.mapping;
+ let rows: Vec<(String, bool)> = (0..6)
+ .map(|row| {
+ let label = crate::space_mouse::row_label(mapping, row);
+ let text = crate::i18n::Locale::for_language(&app.preferences.language).format(label, &[("n", &(row + 1).to_string())]);
+ (text, label == "ui.space_mouse_view_off")
+ })
+ .collect();
+ let (driven_by, driven_by_label) = (app.tr("ui.space_mouse_driven_by").to_owned(), app.tr("ui.space_mouse_driven_by_label").to_owned());
+ let off_tip = app.tr("ui.space_mouse_view_off_tip").to_owned();
+ let motions: Vec<String> = crate::space_mouse::MOTIONS.iter().map(|motion| app.tr(motion).to_owned()).collect();
+ ui_kit::row(ui, app.tr("ui.space_mouse_view_axis"), |ui| {
+ let header = format!("{} · {} · {}", crate::i18n::tr_label("Invert"), crate::i18n::tr_label("Speed"), driven_by_label);
+ ui_kit::text(ui, &header, ui_kit::Text::Note("space_mouse_rows"));
+ });
+ for (axis, (name, off)) in rows.iter().enumerate() {
+ let group = ui_kit::row(ui, name, |ui| {
ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
- ui.horizontal(|ui| {
- if let Some(reverse) = app.preferences.space_mouse_reverse.get_mut(axis) {
- ui_kit::checkbox(ui, crate::i18n::tr_label("Invert"), reverse);
+ // Invert and speed do nothing on a row the driver turns off. The motion
+ // choice below stays live, so a motion can still be swapped out of it.
+ ui.add_enabled_ui(!off, |ui| {
+ ui.horizontal(|ui| {
+ if let Some(reverse) = app.preferences.space_mouse_reverse.get_mut(axis) {
+ ui_kit::checkbox(ui, crate::i18n::tr_label("Invert"), reverse);
+ }
+ if let Some(speed) = app.preferences.space_mouse_axis_speed.get_mut(axis) {
+ ui_kit::slider(
+ ui,
+ speed,
+ 0.0..=3.0,
+ ui_kit::Slider { step: Some(0.05), format: |v| format!("{v:.2}×"), ..Default::default() },
+ );
+ }
+ });
+ });
+ })
+ .response
+ });
+ if *off {
+ group.on_hover_text(&off_tip);
+ }
+ ui_kit::row(ui, &driven_by_label, |ui| {
+ ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
+ let source = &mut app.preferences.space_mouse_axis_source;
+ let current = source.get(axis).copied().unwrap_or(axis);
+ let mut chosen = current;
+ ui_kit::dropdown_menu(ui, ("sc_space_mouse_source", axis), motions.get(current).map_or("", String::as_str), |ui| {
+ for (from, name) in motions.iter().enumerate() {
+ if ui_kit::list_picker(ui, name, name, chosen == from).clicked() {
+ chosen = from;
+ }
}
- if let Some(speed) = app.preferences.space_mouse_axis_speed.get_mut(axis) {
- ui_kit::slider(
- ui,
- speed,
- 0.0..=3.0,
- ui_kit::Slider { step: Some(0.05), format: |v| format!("{v:.2}×"), ..Default::default() },
- );
+ })
+ .on_hover_text(&driven_by);
+ if chosen != current {
+ crate::space_mouse::reassign(source, axis, chosen);
+ }
+ });
+ });
+ }
+ ui_kit::row(ui, "", |ui| {
+ let reassigned = app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES;
+ ui.add_enabled_ui(app.preferences.space_mouse_enabled && reassigned, |ui| {
+ if ui_kit::button(ui, app.tr("ui.space_mouse_reset_axes"), ui_kit::Button::Normal).clicked() {
+ app.preferences.space_mouse_axis_source = crate::space_mouse::SAME_AXES;
+ }
+ });
+ });
+ // Only where the reader has seen the choice: Linux, with spacenavd and the device both there.
+ if let Some(present) = app.space_mouse.drivers.filter(|present| present.spacenavd || present.direct) {
+ let [label, auto, direct, only_spacenavd, only_direct] =
+ ["driver", "driver_auto", "driver_direct", "driver_only_spacenavd", "driver_only_direct"]
+ .map(|key| app.tr(&format!("ui.space_mouse_{key}")).to_owned());
+ let driver = &mut app.preferences.space_mouse_driver;
+ ui_kit::row(ui, &label, |ui| match (present.spacenavd, present.direct) {
+ (true, true) => {
+ let name = |driver| match driver {
+ SpaceMouseDriver::Automatic => auto.as_str(),
+ SpaceMouseDriver::Spacenavd => "spacenavd",
+ SpaceMouseDriver::Direct => direct.as_str(),
+ };
+ ui_kit::dropdown_menu(ui, "sc_space_mouse_driver", name(*driver), |ui| {
+ for choice in SpaceMouseDriver::ALL {
+ if ui_kit::list_picker(ui, name(choice), name(choice), *driver == choice).clicked() {
+ *driver = choice;
+ }
}
});
- });
+ }
+ (true, false) => {
+ ui_kit::text(ui, &only_spacenavd, ui_kit::Text::Note("space_mouse_driver"));
+ }
+ (false, _) => {
+ ui_kit::text(ui, &only_direct, ui_kit::Text::Note("space_mouse_driver"));
+ }
});
}
ui_kit::row(ui, app.tr("ui.space_mouse_calibration"), |ui| {
@@ -1631,10 +1743,6 @@ fn current_theme_file(app: &SolveApp) -> serde_json::Value {
}
}
-/// The cap's physical axes, in the order of `Prefs::space_mouse_reverse`.
-pub(crate) const SPACE_MOUSE_AXES: [&str; 6] =
- ["Push left / right", "Push forward / back", "Lift / press", "Tilt forward / back", "Tilt left / right", "Twist"];
-
/// Fold a setting an older release kept in its own field into the one this version reads.
/// `orbit_cursor` (`true` = the point under the cursor) became `orbit_around`. A 3D mouse
/// calibration that can't be used as it is (a hand edit) is dropped, so the device is read as it
@@ -1644,6 +1752,10 @@ pub fn migrate(mut p: Prefs) -> Prefs {
p.orbit_around = OrbitAround::Cursor;
p.orbit_cursor = false;
}
+ if !crate::space_mouse::drives_each_once(p.space_mouse_axis_source) {
+ log::warn!("preferences: the 3D mouse axis assignment {:?} doesn't drive each axis once; using the default", p.space_mouse_axis_source);
+ p.space_mouse_axis_source = crate::space_mouse::SAME_AXES;
+ }
p.space_mouse_calibrations.retain(|device, calibration| {
let usable = calibration.is_usable();
if !usable {
diff --git a/crates/ui-egui/src/space_mouse.rs b/crates/ui-egui/src/space_mouse.rs
index c2295ce67e..664e0f6f5f 100644
--- a/crates/ui-egui/src/space_mouse.rs
+++ b/crates/ui-egui/src/space_mouse.rs
@@ -51,6 +51,18 @@ pub struct Input {
pub raw: Axes,
/// The guided calibration while its window is open, and the device it is for.
pub calibrating: Option<(String, solidcraft_space_mouse::Wizard)>,
+ /// The driver mapping navigation used last frame, which says what each axis does to the view.
+ pub mapping: Option<DriverMapping>,
+ /// Which of the Linux readers exist, as the app's reader last saw them; none where there is
+ /// only one way to read the device.
+ pub drivers: Option<DriversPresent>,
+}
+
+/// What the Linux reader found: the spacenavd socket and a direct (hidraw) 3D mouse.
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub struct DriversPresent {
+ pub spacenavd: bool,
+ pub direct: bool,
}
/// Seconds after the cap last moved that wheel events are still taken for 3DxWare's: one can be
@@ -173,6 +185,69 @@ pub fn calibrated(axes: Axes, calibration: Option<Calibration>) -> Axes {
calibration.map_or(axes, |calibration| calibration.apply(axes.into()).into())
}
+/// The device's six calibrated motions, in the order of a reading: what each axis can be driven
+/// by. They name no kind of device, since calibration defined them: Translation X is whatever the
+/// user did for "slide right".
+pub const MOTIONS: [&str; 6] = [
+ "ui.space_mouse_motion_translation_x",
+ "ui.space_mouse_motion_translation_y",
+ "ui.space_mouse_motion_translation_z",
+ "ui.space_mouse_motion_rotation_x",
+ "ui.space_mouse_motion_rotation_y",
+ "ui.space_mouse_motion_rotation_z",
+];
+
+/// What each logical axis does to the view, as `navigation::device_camera` applies it.
+const VIEW_AXES: [&str; 6] = [
+ "ui.space_mouse_view_pan_sideways",
+ "ui.space_mouse_view_zoom",
+ "ui.space_mouse_view_pan_up_down",
+ "ui.space_mouse_view_orbit_up_down",
+ "ui.space_mouse_view_orbit_sideways",
+ "ui.space_mouse_view_roll",
+];
+
+/// The label of axis row `row`: what it does to the view through `mapping`, the mapping
+/// navigation really uses, or "off" when that mapping leaves it out. Without a mapping (a build
+/// with no 3D mouse reader, since the apps run navigation every frame before drawing), a plain
+/// "Axis {n}": neither a guess at the view nor a motion name, which the dropdown already uses.
+/// Two rows a driver profile sends to the same output both get its label; that's what they do.
+pub fn row_label(mapping: Option<DriverMapping>, row: usize) -> &'static str {
+ match mapping.and_then(|mapping| mapping.axes.get(row).copied()) {
+ Some(rule) if rule.enabled => VIEW_AXES.get(rule.output).copied().unwrap_or("ui.space_mouse_view_off"),
+ Some(_) => "ui.space_mouse_view_off",
+ None => "ui.space_mouse_view_unmapped",
+ }
+}
+
+/// Which of the cap's motions drives each of its axes (`Prefs::space_mouse_axis_source`): row
+/// `r` reads motion `source[r]`. Each motion drives exactly one row.
+pub const SAME_AXES: [usize; 6] = [0, 1, 2, 3, 4, 5];
+
+/// The reading with its rows reassigned: row `r` takes motion `source[r]`. A `source` that
+/// isn't one motion per row reads as [`SAME_AXES`].
+pub fn reassigned(axes: Axes, source: [usize; 6]) -> Axes {
+ let source = if drives_each_once(source) { source } else { SAME_AXES };
+ let raw: [i16; 6] = axes.into();
+ source.map(|from| raw.get(from).copied().unwrap_or(0)).into()
+}
+
+/// Makes `row` read motion `from`. The row that read `from` before takes this row's old motion,
+/// so each motion still drives exactly one row.
+pub fn reassign(source: &mut [usize; 6], row: usize, from: usize) {
+ if let Some(other) = source.iter().position(|&s| s == from)
+ && row < source.len()
+ {
+ source.swap(row, other);
+ }
+}
+
+/// Whether each of the six motions drives exactly one row.
+pub fn drives_each_once(source: [usize; 6]) -> bool {
+ let mut seen = [false; 6];
+ source.iter().all(|&from| seen.get_mut(from).is_some_and(|seen| !std::mem::replace(seen, true)))
+}
+
/// Hands one frame of 3D mouse input, `seconds` after the previous frame, to the page showing
/// the camera. Nothing happens with navigation switched off, on the start page or while a file
/// picker is open, or while the reading is inside the dead zone (after calibration, which takes
@@ -182,6 +257,7 @@ pub fn calibrated(axes: Axes, calibration: Option<Calibration>) -> Axes {
/// calibration window is open, the reading goes to it instead and the view stays put.
pub fn navigate_frame(app: &mut SolveApp, ctx: &egui::Context, mapping: DriverMapping, axes: Axes, seconds: f64) -> bool {
app.space_mouse.raw = axes;
+ app.space_mouse.mapping = Some(mapping);
if let Some((device, wizard)) = &mut app.space_mouse.calibrating {
if app.space_mouse.device.as_ref() == Some(device) {
wizard.feed(axes.into(), seconds);
@@ -191,7 +267,9 @@ pub fn navigate_frame(app: &mut SolveApp, ctx: &egui::Context, mapping: DriverMa
// Another device is being read now, or none: what was recorded isn't its.
app.space_mouse.calibrating = None;
}
- let axes = calibrated(axes, calibration(app));
+ // Calibrated first, so the calibration puts the device's axes in order, then the user's choice
+ // of which motion drives which axis. Invert and speed then go with the axis, not the motion.
+ let axes = reassigned(calibrated(axes, calibration(app)), app.preferences.space_mouse_axis_source);
// Only the window with focus: with two windows open, the cap moves the one being used, not both.
if !app.preferences.space_mouse_enabled || app.home.open || app.file_picker_busy() || !axes.moving() || !ctx.input(|i| i.focused) {
return false;
@@ -374,6 +452,26 @@ mod tests {
assert_eq!(DriverMapping::object_mode().apply(all), DriverMapping::default().apply(all));
}
+ #[test]
+ fn the_driver_choice_is_saved_and_an_older_file_reads_automatic() {
+ use crate::prefs::SpaceMouseDriver;
+ let mut saved = serde_json::to_value(crate::prefs::Prefs::default()).unwrap();
+ assert_eq!(saved["space_mouse_driver"], "automatic");
+ for driver in SpaceMouseDriver::ALL {
+ saved["space_mouse_driver"] = serde_json::to_value(driver).unwrap();
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_driver, driver);
+ assert_eq!(SpaceMouseDriver::from_u8(driver.to_u8()), driver);
+ }
+ saved["space_mouse_driver"] = "direct".into();
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_driver, SpaceMouseDriver::Direct);
+ // One saved before the setting existed, or with a driver this version doesn't know.
+ saved.as_object_mut().unwrap().remove("space_mouse_driver");
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_driver, SpaceMouseDriver::Automatic);
+ saved["space_mouse_driver"] = "evdev".into();
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_driver, SpaceMouseDriver::Automatic);
+ assert_eq!(SpaceMouseDriver::from_u8(200), SpaceMouseDriver::Automatic);
+ }
+
#[test]
fn the_dead_zone_is_rest() {
assert!(!Axes::default().moving());
@@ -628,4 +726,191 @@ mod tests {
saved["space_mouse_calibrations"]["hid 1234:5678"] = older;
assert_eq!(crate::prefs::lenient(&saved), prefs);
}
+
+ #[test]
+ fn picking_a_motion_another_axis_uses_swaps_the_two() {
+ let mut source = SAME_AXES;
+ reassign(&mut source, 1, 2);
+ assert_eq!(source, [0, 2, 1, 3, 4, 5], "Y and Z swapped");
+ reassign(&mut source, 4, 5);
+ assert_eq!(source, [0, 2, 1, 3, 5, 4], "then roll and twist");
+ reassign(&mut source, 1, 1);
+ assert_eq!(source, [0, 1, 2, 3, 5, 4], "back again");
+ assert!(drives_each_once(source));
+ // A row or a motion that doesn't exist changes nothing.
+ reassign(&mut source, 9, 0);
+ reassign(&mut source, 0, 9);
+ assert_eq!(source, [0, 1, 2, 3, 5, 4]);
+ assert!(!drives_each_once([0, 0, 2, 3, 4, 5]) && !drives_each_once([0, 1, 2, 3, 4, 9]));
+ // A value that doesn't drive each axis once is read as the default.
+ let reading = Axes { translation: [1, 2, 3], rotation: [4, 5, 6] };
+ assert_eq!(reassigned(reading, [0, 2, 1, 3, 5, 4]), Axes { translation: [1, 3, 2], rotation: [4, 6, 5] });
+ assert_eq!(reassigned(reading, [0, 0, 2, 3, 4, 5]), reading);
+ }
+
+ #[test]
+ fn a_reassigned_motion_drives_its_new_axis_and_invert_stays_with_the_axis() {
+ let ctx = window(true);
+ let press = Axes { translation: [0, 0, 350], rotation: [0; 3] };
+ // With Y and Z swapped, pressing the cap does what pushing it back would.
+ let mut reference = app();
+ frame(&mut reference, &ctx, DriverMapping::default(), PUSH, 0.02);
+ let mut swapped = app();
+ swapped.preferences.space_mouse_axis_source = [0, 2, 1, 3, 4, 5];
+ assert!(frame(&mut swapped, &ctx, DriverMapping::default(), press, 0.02));
+ assert_eq!(swapped.cam, reference.cam);
+ // Inverting the Y axis inverts whatever motion drives it now, not the Y motion.
+ let mut inverted = app();
+ inverted.preferences.space_mouse_reverse[1] = true;
+ frame(&mut inverted, &ctx, DriverMapping::default(), PUSH, 0.02);
+ let mut swapped_inverted = app();
+ swapped_inverted.preferences.space_mouse_axis_source = [0, 2, 1, 3, 4, 5];
+ swapped_inverted.preferences.space_mouse_reverse[1] = true;
+ frame(&mut swapped_inverted, &ctx, DriverMapping::default(), press, 0.02);
+ assert_eq!(swapped_inverted.cam, inverted.cam);
+ assert_ne!(swapped_inverted.cam, reference.cam);
+ // The same for the axis's speed.
+ let mut slowed = app();
+ slowed.preferences.space_mouse_axis_speed[1] = 0.5;
+ frame(&mut slowed, &ctx, DriverMapping::default(), PUSH, 0.02);
+ let mut swapped_slowed = app();
+ swapped_slowed.preferences.space_mouse_axis_source = [0, 2, 1, 3, 4, 5];
+ swapped_slowed.preferences.space_mouse_axis_speed[1] = 0.5;
+ frame(&mut swapped_slowed, &ctx, DriverMapping::default(), press, 0.02);
+ assert_eq!(swapped_slowed.cam, slowed.cam);
+ assert_ne!(swapped_slowed.cam, reference.cam);
+ }
+
+ #[test]
+ fn a_motion_swapped_into_a_row_the_driver_turns_off_moves_nothing_until_swapped_back() {
+ let ctx = window(true);
+ let mut pan_up_down_off = DriverMapping::default();
+ pan_up_down_off.axes[2].enabled = false;
+ let mut slowed = app();
+ slowed.preferences.space_mouse_axis_speed[1] = 0.5;
+ frame(&mut slowed, &ctx, pan_up_down_off, PUSH, 0.02);
+ // Picking the push motion in the off row swaps the off row's motion into row 1.
+ let mut app = app();
+ app.preferences.space_mouse_axis_speed[1] = 0.5;
+ reassign(&mut app.preferences.space_mouse_axis_source, 2, 1);
+ assert_eq!(app.preferences.space_mouse_axis_source, [0, 2, 1, 3, 4, 5]);
+ let still = app.cam;
+ assert_ne!(slowed.cam, still);
+ frame(&mut app, &ctx, pan_up_down_off, PUSH, 0.02);
+ assert_eq!(app.cam, still);
+ // Picking it back in row 1 recovers it, at the speed row 1 kept.
+ reassign(&mut app.preferences.space_mouse_axis_source, 1, 1);
+ assert_eq!(app.preferences.space_mouse_axis_source, SAME_AXES);
+ frame(&mut app, &ctx, pan_up_down_off, PUSH, 0.02);
+ assert_eq!(app.cam, slowed.cam);
+ }
+
+ #[test]
+ fn the_choice_is_between_calibrated_motions_on_a_device_whose_calibration_shuffles_its_channels() {
+ // `homemade()` reads Y from raw channel 4, reversed, and Ry from raw 1. With Y and Z
+ // swapped, the choices are calibrated motions: pressing the cap (calibrated Z, raw 2)
+ // drives Y, and pushing it back (calibrated Y, raw 4 the other way) drives Z.
+ let ctx = window(true);
+ let device = "hid 1234:5678";
+ let setup = |source: [usize; 6]| {
+ let mut app = app();
+ app.space_mouse.device = Some(device.into());
+ app.preferences.space_mouse_calibrations.insert(device.into(), homemade());
+ app.preferences.space_mouse_axis_source = source;
+ app
+ };
+ // Mixed motion: a press and a push back together, on the device's own channels.
+ let mixed = Axes { translation: [0, 0, 1750], rotation: [0, -3500, 0] };
+ let expected = Axes { translation: [0, 175, 350], rotation: [0; 3] };
+ let mut reference = app();
+ frame(&mut reference, &ctx, DriverMapping::default(), expected, 0.02);
+ let mut swapped = setup([0, 2, 1, 3, 4, 5]);
+ assert!(frame(&mut swapped, &ctx, DriverMapping::default(), mixed, 0.02));
+ assert_eq!(swapped.cam, reference.cam, "calibrated first, then the motions swapped, once");
+ // Saved and loaded, it's the same choice; reset, the device reads as calibrated.
+ let saved = serde_json::to_value(&swapped.preferences).unwrap();
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_axis_source, [0, 2, 1, 3, 4, 5]);
+ let mut unswapped_reference = app();
+ frame(&mut unswapped_reference, &ctx, DriverMapping::default(), Axes { translation: [0, 350, 175], rotation: [0; 3] }, 0.02);
+ let mut reset = setup(SAME_AXES);
+ frame(&mut reset, &ctx, DriverMapping::default(), mixed, 0.02);
+ assert_eq!(reset.cam, unswapped_reference.cam);
+ }
+
+ #[test]
+ fn rows_say_what_they_do_to_the_view_through_the_mapping_navigation_uses() {
+ let labels = |mapping| (0..6).map(|row| row_label(mapping, row)).collect::<Vec<_>>();
+ assert_eq!(labels(Some(DriverMapping::default())), VIEW_AXES);
+ // Linux, and Windows without a 3DxWare profile: object mode swaps the last two rows'
+ // effect, so their labels swap with it.
+ let object = labels(Some(DriverMapping::object_mode()));
+ assert_eq!((object[4], object[5]), (VIEW_AXES[5], VIEW_AXES[4]));
+ // An axis the mapping switches off says so.
+ let mut off = DriverMapping::default();
+ off.axes[2].enabled = false;
+ assert_eq!(row_label(Some(off), 2), "ui.space_mouse_view_off");
+ // Without a mapping, rows claim no view effect and name none of the dropdown's motions.
+ assert_eq!(labels(None), ["ui.space_mouse_view_unmapped"; 6]);
+ }
+
+ #[test]
+ fn each_frame_records_the_mapping_it_navigated_with() {
+ let ctx = window(true);
+ let mut app = app();
+ assert!(app.space_mouse.mapping.is_none());
+ frame(&mut app, &ctx, DriverMapping::object_mode(), Axes::default(), 0.02);
+ assert_eq!(app.space_mouse.mapping, Some(DriverMapping::object_mode()));
+ // A changed profile shows on the next frame, calibrating or not; a reassignment changes
+ // which motion drives a row, never the row's label.
+ app.space_mouse.device = Some("hid 1234:5678".into());
+ app.preferences.space_mouse_axis_source = [0, 2, 1, 3, 4, 5];
+ crate::space_mouse_calibration::start(&mut app);
+ frame(&mut app, &ctx, DriverMapping::default(), Axes::default(), 0.02);
+ assert_eq!(app.space_mouse.mapping, Some(DriverMapping::default()));
+ assert_eq!(row_label(app.space_mouse.mapping, 1), VIEW_AXES[1]);
+ }
+
+ #[test]
+ fn calibrating_records_the_device_before_the_axis_choice() {
+ // With Y and Z swapped, a new calibration still learns the device's own channels.
+ // Recorded after the swap, it would bake the swap in, and the swap would then apply twice.
+ let ctx = window(true);
+ let mut app = app();
+ app.space_mouse.device = Some("hid 1234:5678".into());
+ app.preferences.space_mouse_axis_source = [0, 2, 1, 3, 4, 5];
+ crate::space_mouse_calibration::start(&mut app);
+ let feed = |app: &mut SolveApp, axes: Axes, seconds: f64| {
+ for _ in 0..(seconds / 0.02).round() as usize {
+ frame(app, &ctx, DriverMapping::default(), axes, 0.02);
+ }
+ };
+ feed(&mut app, Axes::default(), 1.6);
+ for step in solidcraft_space_mouse::STEPS {
+ let mut raw = [0_i16; 6];
+ raw[step.axis] = if step.positive { 300 } else { -300 };
+ feed(&mut app, raw.into(), 0.5);
+ feed(&mut app, Axes::default(), 0.1);
+ }
+ let (_, wizard) = app.space_mouse.calibrating.as_ref().unwrap();
+ let calibration = wizard.result().unwrap().unwrap();
+ assert!(calibration.axes.iter().enumerate().all(|(c, axis)| axis.source == c && !axis.reversed), "{calibration:?}");
+ }
+
+ #[test]
+ fn a_saved_axis_assignment_that_doesnt_drive_each_axis_once_loads_as_the_default() {
+ let mut saved = serde_json::to_value(crate::prefs::Prefs::default()).unwrap();
+ saved["space_mouse_axis_source"] = serde_json::json!([0, 2, 1, 3, 4, 5]);
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_axis_source, [0, 2, 1, 3, 4, 5]);
+ saved["space_mouse_axis_source"] = serde_json::json!([1, 1, 2, 3, 4, 5]);
+ assert_eq!(crate::prefs::lenient(&saved).space_mouse_axis_source, SAME_AXES);
+ // An older file without it, or one with the wrong length, loads with the default and
+ // keeps every other setting.
+ saved["space_mouse_speed"] = serde_json::json!(2.0);
+ saved.as_object_mut().unwrap().remove("space_mouse_axis_source");
+ let older = crate::prefs::lenient(&saved);
+ assert_eq!((older.space_mouse_axis_source, older.space_mouse_speed), (SAME_AXES, 2.0));
+ saved["space_mouse_axis_source"] = serde_json::json!([0, 1, 2, 3, 4]);
+ let short = crate::prefs::lenient(&saved);
+ assert_eq!((short.space_mouse_axis_source, short.space_mouse_speed), (SAME_AXES, 2.0));
+ }
}
diff --git a/crates/ui-egui/src/space_mouse_calibration.rs b/crates/ui-egui/src/space_mouse_calibration.rs
index 23301277e1..06e2b0b3e6 100644
--- a/crates/ui-egui/src/space_mouse_calibration.rs
+++ b/crates/ui-egui/src/space_mouse_calibration.rs
@@ -98,9 +98,9 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
(Stage::Done, Some(Ok(_))) => "ui.space_mouse_calibration_done",
(Stage::Done, _) => "ui.space_mouse_calibration_no_response",
};
- // The axis that barely moved, as Preferences names it.
+ // The calibrated motion that barely moved, as Preferences names it.
let weak = match result {
- Some(Err(Problem::NoResponse(axis))) => crate::prefs::SPACE_MOUSE_AXES.get(axis).copied(),
+ Some(Err(Problem::NoResponse(axis))) => crate::space_mouse::MOTIONS.get(axis).copied(),
_ => None,
};
let counter = match stage {
@@ -116,7 +116,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
.show(ctx, |ui| {
ui.label(app.tr(prompt));
if let Some(axis) = weak {
- ui.label(egui::RichText::new(app.tr_label(axis)).strong());
+ ui.label(egui::RichText::new(app.tr(axis)).strong());
}
ui.add_space(6.0);
crate::ui_kit::progress(ui, "space_mouse_calibration", progress as f32);
@@ -128,6 +128,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
// The device's six raw axes as they come, so the jitter at rest is there to see.
let reading = raw.map(|value| format!("{value:>6}")).join(" ");
ui.label(egui::RichText::new(format!("{}: {reading}", app.tr("ui.space_mouse_reading"))).monospace());
+ // A reassignment made in Preferences stays on top of whatever this records.
+ if app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES {
+ ui.label(egui::RichText::new(app.tr("ui.space_mouse_axes_reassigned")).small());
+ }
ui.horizontal(|ui| {
ui.label(app.tr("ui.space_mouse_dead_zone"));
dead_zone_slider(ui, &mut dead_zone).on_hover_text(app.tr("ui.space_mouse_dead_zone_tip"));