Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

SpaceMouse detection (#104): match by name for any vendor, list what SDL sees, Copy device report

islandmedc6b7836c157e
diff --git a/changes/fix-0.10.10-small-a.md b/changes/fix-0.10.10-small-a.md
new file mode 100644
index 00000000..bb2c2168
--- /dev/null
+++ b/changes/fix-0.10.10-small-a.md
@@ -0,0 +1,30 @@
+---
+whats_new: **SpaceMouse detection** (#104): more 3Dconnexion devices are recognised (by name, also over Bluetooth),
+ and **Edit > Preferences > Input > SpaceMouse** lists every controller SculptForge sees, says when another program
+ (3DxWare, spacenavd) holds the device, and has **Copy device report** for bug reports.
+whats_new: **Also new since 0.10.9** (missing from its notes): the brush ring is a true circle lying on the surface,
+ symmetry copies show as dots, the crosshair stays while you turn the view, and **Preferences > Cursor > Hide ring
+ while stroking** leaves only the dot while you sculpt (#88); drag empty panel space, or middle-drag anywhere in a
+ panel, to scroll it with a pen (#100); Neutral is the default look for new installs; **Look > Outlines** (#98);
+ the Strokes ring on <kbd>J</kbd>.
+added: SpaceMouse (#104, reported by fenixpoints): Preferences > Input > SpaceMouse lists each joystick SDL reports
+ (name, USB ids, and why it was or wasn't taken: not a SpaceMouse, cannot open, fewer than six axes), warns when the
+ SpaceMouse is open but no axis has moved (another program such as 3DxWare holds it), and **Copy device report**
+ copies that list with the version, platform and SDL version. Skipped devices are also logged.
+changed: SpaceMouse recognition (#104): a device whose name says 3Dconnexion counts whatever its USB ids, and one
+ with no vendor id (as some systems report Bluetooth devices) counts when its name says SpaceMouse / SpaceNavigator;
+ the CadMouse and the keyboards never do.
+changed: 0.10.9 notes, added late (they were lost in that release's merges; the code shipped in 0.10.9): brush cursor
+ (#88, TheRedWaxPolice, with rodrigomoretto): the ring is a true circle in the surface's tangent plane, symmetry and
+ radial copies are dots, the crosshair stays while the view turns, pans or zooms, and Preferences > Cursor has Hide
+ ring while stroking (off by default). Panels scroll with a left-drag on empty space or a middle-drag (#100,
+ ebarranco). Neutral is the default look for new installs; Look > Outlines and Outline opacity (#98); the Strokes
+ radial menu on J; viewport hints with Don't show again (Preferences > Hints).
+testers:
+ - macOS with a SpaceMouse (3DxWare installed): Preferences > Input > SpaceMouse; note what it lists, push the cap,
+ then quit 3DxWare, replug, and check the live bars move. Click Copy device report and paste it in #testers.
+ - Windows with a SpaceMouse, with and without 3DxWare running: the same; good = the view pans/turns with the cap.
+ - Any OS without a SpaceMouse but with a gamepad: it is listed as "not a SpaceMouse"; nothing moves the view.
+---
+#82 (Alt along the normal for Move / Snakehook) shipped before 0.10.9 (Preferences > Input > Along the normal); no
+code change, reply only.
diff --git a/docs/guide/navigation.md b/docs/guide/navigation.md
index 8f27995f..b028a2eb 100644
--- a/docs/guide/navigation.md
+++ b/docs/guide/navigation.md
@@ -165,10 +165,18 @@ Store Config (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd>) keeps these setting
absolute axes, which is how joysticks work. If the kernel reports them as relative motion, as it does for some
older models, the SpaceMouse doesn't show up at all. Reading it through spacenavd isn't supported yet.
+**If it shows up but the view doesn't move** (the live bars stay still when you push the cap), another program
+holds the device: quit 3DxWare (or spacenavd on Linux) as above, then unplug and plug the SpaceMouse back in.
+
+**To report a problem**, open **Edit > Preferences > Input > SpaceMouse** and click **Copy device report** (shown until the cap has moved the view): it puts
+every joystick SculptForge sees on the clipboard, with its USB ids and why it was or wasn't used. Paste it into
+your issue.
+
SculptForge recognises 3Dconnexion devices by their USB ids: everything under 3Dconnexion's own vendor id
(SpaceMouse Compact, Wireless, Pro, Enterprise, Module, the Universal Receiver) except the CadMouse and the
keyboards, and the older models sold under Logitech's id (SpaceNavigator, SpacePilot, SpaceExplorer, SpaceMouse
-Pro, SpaceBall 5000).
+Pro, SpaceBall 5000). A device that names itself 3Dconnexion counts whatever its ids, as does one whose system
+reports no vendor id (seen over Bluetooth) when its name says SpaceMouse or SpaceNavigator.
## Framing
diff --git a/src/app/App.h b/src/app/App.h
index c8018048..b76f6523 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -2016,6 +2016,10 @@ private:
std::array<float, kSmAxes> spaceMouseAxes_{}; // the last values read, -1 .. 1 (Preferences shows them)
bool spaceMouseMoving_ = false;
int spaceMouseLastButton_ = -1; // for Preferences: "Button N pressed"
+ bool spaceMouseReported_ = false; // an axis has moved since the device was opened (else 3DxWare may hold it, #104)
+ // Every joystick SDL listed at the last scan and why it was or wasn't taken, for Preferences and the device
+ // report a user can paste into an issue (#104).
+ std::vector<std::string> joysticksSeen_;
// ---- end SpaceMouse ----
// ---- Sculpt Timeline (PanelTimeline.cpp, core/Timeline.h) and proof mode (ProofMode.cpp) ----
// The history strip along the bottom of the canvas, the timelapse export, and Help > Benchmark: a scripted
diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cpp
index 41f5bf3d..40feb506 100644
--- a/src/app/I18nSpanish.cpp
+++ b/src/app/I18nSpanish.cpp
@@ -650,6 +650,11 @@ constexpr Entry kSpanish[] = {
{"Plug it in. If 3DxWare is installed it may keep the device to itself: see the Navigation page of the guide.",
"Conéctalo. Si 3DxWare está instalado puede quedarse con el dispositivo: consulta la página Navegación de la "
"guía."},
+ {"Push the cap: if the bars below stay still, another program (3DxWare, spacenavd) holds the SpaceMouse. See the "
+ "Navigation page of the guide.",
+ "Mueve el mando: si las barras de abajo no se mueven, otro programa (3DxWare, spacenavd) tiene el SpaceMouse. "
+ "Consulta la página Navegación de la guía."},
+ {"No joysticks or game controllers seen.", "No se ve ningún joystick ni mando."},
{"Plug it in. SculptForge reads it as a joystick (/dev/input): you need read access to it, and spacenavd may hold "
"it. See the Navigation page of the guide.",
"Conéctalo. SculptForge lo lee como un joystick (/dev/input): necesitas permiso de lectura, y spacenavd puede "
diff --git a/src/app/SpaceMouse.cpp b/src/app/SpaceMouse.cpp
index 3d482d17..0f62302f 100644
--- a/src/app/SpaceMouse.cpp
+++ b/src/app/SpaceMouse.cpp
@@ -57,27 +57,40 @@ void App::spaceMouseScan() {
if (spaceMouse_) return;
int count = 0;
SDL_JoystickID* ids = SDL_GetJoysticks(&count);
+ joysticksSeen_.clear();
if (!ids) return;
for (int i = 0; i < count && !spaceMouse_; ++i) {
// UI tests take only their own virtual SpaceMouse, not one plugged into the machine running them.
if (!options_.uiTest.empty() && !SDL_IsJoystickVirtual(ids[i])) continue;
const char* name = SDL_GetJoystickNameForID(ids[i]);
- if (!isSpaceMouseDevice(SDL_GetJoystickVendorForID(ids[i]), SDL_GetJoystickProductForID(ids[i]), name ? name : ""))
+ const uint16_t vendor = SDL_GetJoystickVendorForID(ids[i]), product = SDL_GetJoystickProductForID(ids[i]);
+ char seen[256];
+ std::snprintf(seen, sizeof seen, "%s (%04x:%04x)", name && *name ? name : "?", vendor, product);
+ auto skip = [&](const char* why) {
+ joysticksSeen_.push_back(std::string(seen) + ": " + why);
+ SDL_Log("SpaceMouse: skipped %s", joysticksSeen_.back().c_str());
+ };
+ if (!isSpaceMouseDevice(vendor, product, name ? name : "")) {
+ skip("not a SpaceMouse");
continue;
+ }
SDL_Joystick* j = SDL_OpenJoystick(ids[i]);
if (!j) {
- SDL_Log("SpaceMouse: cannot open %s: %s", name ? name : "?", SDL_GetError());
+ skip((std::string("cannot open: ") + SDL_GetError()).c_str());
continue;
}
if (SDL_GetNumJoystickAxes(j) < kSmAxes) { // a 3Dconnexion device without a 6-DoF cap
+ skip((std::to_string(SDL_GetNumJoystickAxes(j)) + " axes, needs 6").c_str());
SDL_CloseJoystick(j);
continue;
}
+ joysticksSeen_.push_back(std::string(seen) + ": in use");
spaceMouse_ = j;
spaceMouseId_ = ids[i];
spaceMouseName_ = name && *name ? name : "SpaceMouse";
spaceMouseButtonCount_ = std::max(SDL_GetNumJoystickButtons(j), 0);
spaceMouseAxes_ = {};
+ spaceMouseReported_ = false;
SDL_Log("SpaceMouse: %s (%04x:%04x, %d buttons)", spaceMouseName_.c_str(), SDL_GetJoystickVendor(j),
SDL_GetJoystickProduct(j), spaceMouseButtonCount_);
}
@@ -138,6 +151,7 @@ void App::updateSpaceMouse(float dt) {
if (!spaceMouse_) return;
for (int i = 0; i < kSmAxes; ++i)
spaceMouseAxes_[size_t(i)] = std::clamp(float(SDL_GetJoystickAxis(spaceMouse_, i)) / 32767.0f, -1.0f, 1.0f);
+ for (float v : spaceMouseAxes_) spaceMouseReported_ = spaceMouseReported_ || v != 0.0f;
const SpaceMouseSettings& s = uiPrefs_.spaceMouse;
const SpaceMouseMotion m = spaceMouseMotion(spaceMouseAxes_, dt, s);
if (!m.any()) return;
@@ -191,6 +205,36 @@ void App::drawSpaceMouseSection() {
ImGui::PopTextWrapPos();
ImGui::PopStyleColor();
}
+ // What SDL sees, so a report says why a device wasn't taken (#104); Copy puts it on the clipboard for an issue.
+ if (!spaceMouse_ || !spaceMouseReported_) {
+ ImGui::PushStyleColor(ImGuiCol_Text, col(ui::color::textDim));
+ ImGui::PushTextWrapPos(0.0f);
+ if (spaceMouse_)
+ ImGui::TextUnformatted(tr("Push the cap: if the bars below stay still, another program (3DxWare, spacenavd) "
+ "holds the SpaceMouse. See the Navigation page of the guide."));
+ if (joysticksSeen_.empty() && !spaceMouse_) ImGui::TextUnformatted(tr("No joysticks or game controllers seen."));
+ for (const std::string& d : joysticksSeen_) { // (wrapped: a name and its ids can be long)
+ ImGui::Bullet();
+ ImGui::TextUnformatted(d.c_str());
+ }
+ ImGui::PopTextWrapPos();
+ ImGui::PopStyleColor();
+ if (ImGui::SmallButton(ICON_LC_COPY " Copy device report##spacemouse.report")) {
+ std::string r = std::string("SculptForge ") + SCULPTFORGE_VERSION + ", " + SDL_GetPlatform() + ", SDL " +
+ std::to_string(SDL_MAJOR_VERSION) + "." + std::to_string(SDL_MINOR_VERSION) + "." +
+ std::to_string(SDL_MICRO_VERSION) + "\nSpaceMouse: " +
+ (spaceMouse_ ? spaceMouseName_ + (spaceMouseReported_ ? " (moving)" : " (no motion yet)")
+ : std::string("none")) +
+ "\nJoysticks seen:";
+ for (const std::string& d : joysticksSeen_) r += "\n- " + d;
+ if (joysticksSeen_.empty()) r += " none";
+ SDL_SetClipboardText(r.c_str());
+ }
+ ui::HelpText("Copy device report", nullptr,
+ "Copies what SculptForge sees (each joystick's name, USB ids and why it was or wasn't used) to "
+ "paste into a bug report.",
+ path);
+ }
ui::HelpText("SpaceMouse", nullptr,
"Experimental. A 3Dconnexion SpaceMouse moves the view with one hand while the other holds the pen: "
"push, pull and twist the cap to pan, zoom and turn the model about the pivot. Read directly as a USB "
diff --git a/src/core/SpaceMouse.cpp b/src/core/SpaceMouse.cpp
index 725d696b..8938a366 100644
--- a/src/core/SpaceMouse.cpp
+++ b/src/core/SpaceMouse.cpp
@@ -49,10 +49,17 @@ std::string lower(std::string s) {
bool isSpaceMouseDevice(uint16_t vendor, uint16_t product, const std::string& name) {
if (vendor == kVendor3Dconnexion) return std::find(std::begin(kNot6Dof), std::end(kNot6Dof), product) == std::end(kNot6Dof);
- if (vendor == kVendorLogitech) {
- if (std::find(std::begin(kLogitechSpaceMice), std::end(kLogitechSpaceMice), product) != std::end(kLogitechSpaceMice))
- return true;
- const std::string n = lower(name);
+ if (vendor == kVendorLogitech &&
+ std::find(std::begin(kLogitechSpaceMice), std::end(kLogitechSpaceMice), product) != std::end(kLogitechSpaceMice))
+ return true;
+ // By name (#104): a Logitech-id model missing above; a device whose vendor id the system could not read (0,
+ // seen over Bluetooth); any other id when the name says 3Dconnexion (a driver's virtual device). Never the
+ // CadMouse or the keyboards.
+ const std::string n = lower(name);
+ for (const char* word : {"cadmouse", "keyboard", "numpad"})
+ if (n.find(word) != std::string::npos) return false;
+ if (n.find("3dconnexion") != std::string::npos) return true;
+ if (vendor == kVendorLogitech || vendor == 0) {
for (const char* word : {"spacemouse", "space mouse", "spacenavigator", "space navigator", "spacepilot",
"spaceexplorer", "spaceball", "spacetraveler"})
if (n.find(word) != std::string::npos) return true;
diff --git a/src/core/SpaceMouse.h b/src/core/SpaceMouse.h
index 63d63de1..044890a7 100644
--- a/src/core/SpaceMouse.h
+++ b/src/core/SpaceMouse.h
@@ -28,7 +28,8 @@ enum SpaceMouseAxis { kSmTx, kSmTy, kSmTz, kSmRx, kSmRy, kSmRz, kSmAxes };
// vendor id 0x046D (SpaceNavigator, SpacePilot, SpaceExplorer...). SDL itself has no list of them (its
// controller_list.h only knows gamepads), so this is ours, from the ids spacenavd and Linux's hid-ids.h use.
// The CadMouse and the 3Dconnexion keyboards / numpads share the vendor id but are not SpaceMice.
-// `name` is the device's name: a Logitech-id device with an unknown product counts when it calls itself one.
+// `name` is the device's name: a Logitech-id or vendor-0 device with an unknown product counts when it calls itself
+// a SpaceMouse (SpaceNavigator...), any vendor when the name says 3Dconnexion (#104).
bool isSpaceMouseDevice(uint16_t vendor, uint16_t product, const std::string& name = {});
constexpr int kSpaceMouseButtonSlots = 8; // buttons whose action Preferences lists (an Enterprise has 31)
diff --git a/tests/test_spacemouse.cpp b/tests/test_spacemouse.cpp
index 36ce02db..50088d92 100644
--- a/tests/test_spacemouse.cpp
+++ b/tests/test_spacemouse.cpp
@@ -30,7 +30,13 @@ TEST(spacemouse_device_ids) {
CHECK(!isSpaceMouseDevice(0x046D, 0xC52B)); // a Logitech Unifying receiver
CHECK(!isSpaceMouseDevice(0x046D, 0xC215, "Logitech Extreme 3D")); // a flight stick
CHECK(isSpaceMouseDevice(0x046D, 0xC6AA, "3Dconnexion SpaceNavigator")); // by name
- CHECK(!isSpaceMouseDevice(0x045E, 0x028E, "SpaceMouse")); // another vendor never
+ CHECK(!isSpaceMouseDevice(0x045E, 0x028E, "SpaceMouse")); // another vendor: not by a bare model name
+ // #104: no vendor id (Bluetooth on some systems), or a name that says 3Dconnexion, whatever the id.
+ CHECK(isSpaceMouseDevice(0x0000, 0x0000, "SpaceMouse Wireless BT"));
+ CHECK(isSpaceMouseDevice(0x1234, 0x0001, "3Dconnexion SpaceMouse Pro"));
+ CHECK(!isSpaceMouseDevice(0x0000, 0x0000, "Wireless Controller"));
+ CHECK(!isSpaceMouseDevice(0x1234, 0x0001, "3Dconnexion CadMouse"));
+ CHECK(!isSpaceMouseDevice(0x0000, 0x0000, "3Dconnexion Keyboard Pro"));
}
TEST(spacemouse_dead_zone) {
diff --git a/tests/ui/spacemouse.sfui b/tests/ui/spacemouse.sfui
index 603addfd..9b8db5cd 100644
--- a/tests/ui/spacemouse.sfui
+++ b/tests/ui/spacemouse.sfui
@@ -148,3 +148,26 @@ expect_value camera_yaw > 25
remember camera_distance d3
spacemouse 0 0.8 0 0 0 0 0.3
expect_value camera_distance < $d3
+
+# #104: Preferences lists what SDL sees and why; a SpaceMouse that is open but has not moved gets the 3DxWare hint;
+# Copy device report puts the list on the clipboard; once the cap moves, the hint and the report go away.
+spacemouse_unplug
+click "Preferences##palette.preferences"
+hover "Copy device report##spacemouse.report"
+expect_text "No joysticks or game controllers seen."
+click "Copy device report##spacemouse.report"
+expect_clipboard SpaceMouse: none
+key escape
+spacemouse 0 0 0 0 0 0 0.2
+click "Preferences##palette.preferences"
+hover "Copy device report##spacemouse.report"
+expect_text "SpaceMouse Compact (UI test) (256f:c635): in use"
+expect_text "holds the SpaceMouse"
+click "Copy device report##spacemouse.report"
+expect_clipboard (256f:c635): in use
+shot spacemouse_report
+key escape
+spacemouse 0 0 0 0 0 0.8 0.2
+click "Preferences##palette.preferences"
+expect_no_text "holds the SpaceMouse"
+key escape