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.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
SpaceMouse beside a pen (fenix 11-06): driver echo ignored while the cap is pushed, grabs stay put as the view turns, anchored drags hold
islandmed4525e7bdf83a
diff --git a/changes/fix-spacemouse-pen-hover.md b/changes/fix-spacemouse-pen-hover.mdnew file mode 100644index 00000000..be04df3e--- /dev/null+++ b/changes/fix-spacemouse-pen-hover.md@@ -0,0 +1,14 @@+---+whats_new: **SpaceMouse with a pen**: turning the cap while the pen hovers or rests on the model only turns the view: the cursor stays on the pen and the model stays put. Thanks @fenix.+fixed: SpaceMouse beside a pen (Discord, @fenix, the first report from a real SpaceMouse): while the cap is pushed, the+ pointer motion and wheel a SpaceMouse driver sends for programs it doesn't know (3DxWare's defaults) no longer move+ the cursor off the pen or zoom toward it; with Hold during strokes off, a Move, Snake Hook or KelvinGrab drag no+ longer pulls the grabbed part across the view when the view turns under a still pen; gizmo, selection and stamp+ drags hold the view whatever the setting. Guide: Navigation > SpaceMouse troubleshooting.+testers:+ - Windows with 3DxWare running and a pen tablet: hover the pen over the model, twist the cap for a few seconds; the+ view turns, the brush ring stays under the pen, the model doesn't zoom or jump. Then rest the pen tip on the+ model with Move and twist again: the view turns, the model's surface doesn't follow.+ - Same with Preferences > Input > SpaceMouse > Hold during strokes on and off.+---+UI test: tests/ui/spacemouse_pen.sfui (driver echo replay: spacemouse_echo; pen_press / pen_lift; resting tip).diff --git a/docs/guide/navigation.md b/docs/guide/navigation.mdindex 52a397de..1d21016d 100644--- a/docs/guide/navigation.md+++ b/docs/guide/navigation.md@@ -185,6 +185,11 @@ These settings save themselves.**If it shows up but the view doesn't move** (the live bars stay still when you push the cap), another programholds the device: quit 3DxWare (or spacenavd on Linux) as above, then unplug and plug the SpaceMouse back in.+**If the cursor jumps or the model flies off while you turn the cap** (the pen hovering or resting on the model,+whatever the speed and dead zone): 3DxWare is probably also driving SculptForge as it would a program it doesn't+know, moving the pointer and scrolling the wheel. SculptForge ignores the pointer and the wheel while it reads the+cap moving itself; if Preferences doesn't show the SpaceMouse moving, quit 3DxWare as above.+**To report a problem**, open **Edit > Preferences > Input > SpaceMouse** and click **Copy device report** (shown until the cap has moved the view): it putsevery joystick SculptForge sees on the clipboard, with its USB ids and why it was or wasn't used. Paste it intoyour issue.diff --git a/src/app/App.cpp b/src/app/App.cppindex d07cbc89..179bf307 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -1468,6 +1468,7 @@ void App::dispatchEvent(const SDL_Event& event) {if (strayMouseMotion(event)) return; // neither the canvas nor the UI follows a driver's stray mouse eventsif (event.type == SDL_EVENT_MOUSE_MOTION && event.motion.which != SDL_PEN_MOUSEID) mouseSincePen_ = true;if (sixDofPointerEvent(event)) return; // nor a SpaceMouse that also says it is a mouse (SpaceMouse.cpp)+ if (spaceMouseEcho(event)) return; // nor the pointer a SpaceMouse driver moves while the cap is pushedif ((event.type >= SDL_EVENT_KEY_DOWN && event.type < SDL_EVENT_JOYSTICK_AXIS_MOTION &&event.type != SDL_EVENT_KEYMAP_CHANGED && event.type != SDL_EVENT_KEYBOARD_ADDED &&event.type != SDL_EVENT_KEYBOARD_REMOVED && event.type != SDL_EVENT_MOUSE_ADDED &&@@ -2144,6 +2145,8 @@ void App::beginStroke(float x, float y, const RayHit& hit) {dabAccuracy_ = {};precisionActive_ = false;steadyCursor_ = glm::vec2(x, y);+ grabScreen_ = glm::vec2(x, y);+ grabScreenOffset_ = glm::vec2(0.0f);pickSmoother_.reset();strokeInvert_ = invertToggle_ != (((inputMods() & SDL_KMOD_ALT) != 0) || (erasing() && eraserAction() == PenAction::Invert));// Shift still smooths geometry while the Paint brush is active.@@ -2224,7 +2227,7 @@ void App::beginStroke(float x, float y, const RayHit& hit) {!doc_.mesh.hasHidden() && doc_.mesh.layers.empty() && !doc_.sculptor.dyntopo.enabled &&&displayedMesh() == &doc_.mesh)liveMove_ = {true, p.center, glm::vec3(0.0f), p.radius, std::clamp(p.strength * 2.0f, 0.0f, 1.0f)};- grabPlanePoint_ = grabLast_ = hit.position;+ grabLast_ = hit.position;beginAlongNormal(hit, p.radius);return;}@@ -2235,7 +2238,7 @@ void App::beginStroke(float x, float y, const RayHit& hit) {}lazyMouse_.reset(glm::vec2(x, y));if ((strokeBrush_ == BrushType::SnakeHook || strokeBrush_ == BrushType::KelvinSnake) && !recipe && strokeSculpt_) {- grabPlanePoint_ = grabLast_ = hit.position; // the pulled tip (see snakeHookTo)+ grabLast_ = hit.position; // the pulled tip (see snakeHookTo)beginAlongNormal(hit, radiusPx_ * camera_.worldPerPixel(hit.position, canvasHeight()));return;}@@ -2279,6 +2282,11 @@ void App::strokeTo(float x, float y) {x = p.x;y = p.y;}+ if (grabStroke()) { // by the pen's motion from the grabbed point (regrabAfterViewMove)+ grabScreen_ = glm::vec2(x, y);+ x += grabScreenOffset_.x;+ y += grabScreenOffset_.y;+ }const BrushRecipe* recipe = strokeRecipe();if (strokeBrush_ == BrushType::Move && !recipe && strokeSculpt_ && strokeAlongNormal_) {const glm::vec3 p = alongNormalTarget(x, y);@@ -2293,7 +2301,7 @@ void App::strokeTo(float x, float y) {glm::vec3 n = camera_.forward();float denom = glm::dot(dir, n);if (std::abs(denom) < 1e-6f) return;- float t = glm::dot(grabPlanePoint_ - origin, n) / denom;+ float t = glm::dot(grabLast_ - origin, n) / denom; // (the plane through the grabbed point, facing the view)glm::vec3 p = origin + dir * t;if (liveMove_.active) liveMove_.delta += p - grabLast_;else queueGrab(p - grabLast_);diff --git a/src/app/App.h b/src/app/App.hindex f4c643c6..3109c12e 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -417,7 +417,14 @@ private:bool penSeen_ = false;BrushType strokeBrush_ = BrushType::Standard;bool strokeInvert_ = false;- glm::vec3 grabPlanePoint_{0.0f}, grabLast_{0.0f};+ glm::vec3 grabLast_{0.0f};+ // A grab (Move, Snake Hook, KelvinGrab) follows the pen's motion on screen, not where the pen points: when the view+ // turns under a still pen (a SpaceMouse with Hold during strokes off), the grabbed point stays where it is in the+ // world and the pen carries on from it (fenix, Discord 11-06: the model flew off as the cap turned).+ // grabScreen_: the pen's last position the grab used; grabScreenOffset_: from it to the grabbed point on screen.+ glm::vec2 grabScreen_{0.0f}, grabScreenOffset_{0.0f};+ bool grabStroke() const; // a Move / Snake Hook / KelvinGrab stroke under way+ void regrabAfterViewMove(); // the view moved mid-grab: the grabbed point stays put (grabScreenOffset_)// Live Move (Preferences > Performance, experimental; docs/design/perf-moonshots.md): a Move drag on a plain mesh// isn't applied frame by frame; the GPU draws it (render/Ghost.h, GhostKind::Move) from the grab's start, and// the whole move is applied once when the stroke ends (finishStrokeNow): one grab instead of one a frame.@@ -2405,8 +2412,13 @@ private:// pointer events never reach the canvas or the UI (phoenix, Discord 11-05). Names cached per mouse id.bool sixDofPointerEvent(const SDL_Event& e);std::unordered_map<SDL_MouseID, bool> sixDofMice_;- // The view held still and the buttons ignored while a stroke runs (SpaceMouseSettings::holdWhileStroking).- bool spaceMouseHeldByStroke() const;+ // The view held still and the buttons ignored while a stroke runs (SpaceMouseSettings::holdWhileStroking), and+ // always during a drag anchored in the view it began in (a gizmo, a selection, a stamp...).+ bool spaceMouseHeld() const;+ // The cap is pushed past the dead zone (SpaceMouse on) at the last read, held or not: the system pointer's motion+ // and wheel meanwhile are the driver's echo of it (3DxWare's mouse emulation), not the user (spaceMouseEcho).+ bool spaceMousePushed_ = false;+ bool spaceMouseEcho(const SDL_Event& e) const;// ---- end SpaceMouse ----// ---- Touch (Touch.cpp, core/TouchGesture.h, docs/guide/navigation.md) ----// Two fingers on a touch screen pan, pinch-zoom and twist the view; on a trackpad they pinch-zoom and twistdiff --git a/src/app/Demo.cpp b/src/app/Demo.cppindex ef20df7c..6eddab6e 100644--- a/src/app/Demo.cpp+++ b/src/app/Demo.cpp@@ -216,6 +216,7 @@ void Demo::update(float dt) {mouse_.y, int(buttonDown_));stride_ = 1;if (penResting_) penRestNoise(); // (UiTest.cpp)+ if (spaceMouseEcho_) spaceMouseEchoFrame();{const auto now = std::chrono::steady_clock::now();if (lastFrame_.time_since_epoch().count() != 0)diff --git a/src/app/Demo.h b/src/app/Demo.hindex fee846b3..5482a603 100644--- a/src/app/Demo.h+++ b/src/app/Demo.h@@ -20,6 +20,7 @@#include <SDL3/SDL.h>+#include <array>#include <chrono>#include <functional>#include <map>@@ -193,7 +194,13 @@ private:bool penResting_ = false;ImVec2 penRestAt_{0, 0};int penRestFrame_ = 0;+ bool penPressed_ = false; // pen_press: down until pen_lift (pen_rest's noise then rests the tip)void penRestNoise();+ // spacemouse_echo on: while the virtual cap is pushed, a SpaceMouse driver that doesn't know the app (3DxWare's+ // defaults) moves the system pointer and scrolls the wheel every frame (fenix, Discord 11-06).+ bool spaceMouseEcho_ = false;+ std::array<float, 6> virtualAxes_{};+ void spaceMouseEchoFrame();static constexpr SDL_MouseID kDriverMouse = 7; // the driver's own mouse device// `snapshot` saves the active mesh; moved* values compare against it. `remember` keeps values for $NAME.std::vector<glm::vec3> basePositions_, baseNormals_;diff --git a/src/app/PanelKelvinlet.cpp b/src/app/PanelKelvinlet.cppindex ac086d85..3862bf14 100644--- a/src/app/PanelKelvinlet.cpp+++ b/src/app/PanelKelvinlet.cpp@@ -55,7 +55,7 @@ void App::kelvinBegin(const RayHit& hit) {// Full brush size, as Move: the press pressure of a pen is near zero, so Pressure > Size would shrink the grab (#122).kelvinCenter_ = hit.position;kelvinRadius_ = radiusPx_ * camera_.worldPerPixel(hit.position, canvasHeight());- grabPlanePoint_ = grabLast_ = kelvinTarget_ = hit.position;+ grabLast_ = kelvinTarget_ = hit.position;kelvinPending_ = 0.0f;kelvinLastX_ = lastX_;lastDabScreen_ = glm::vec2(lastX_, lastY_);@@ -74,7 +74,7 @@ void App::kelvinTo(float x, float y) {const float denom = glm::dot(dir, n);if (strokeAlongNormal_) kelvinTarget_ = alongNormalTarget(x, y);else if (std::abs(denom) < 1e-6f) return;- else kelvinTarget_ = origin + dir * (glm::dot(grabPlanePoint_ - origin, n) / denom);+ else kelvinTarget_ = origin + dir * (glm::dot(kelvinTarget_ - origin, n) / denom); // (through the grabbed point)} else {// Twist / Scale: the drag's sideways distance in brush radii (Alt reverses).const float dx = (x - kelvinLastX_) / std::max(radiusPx_, 1.0f) * kelvinAmount_ * (strokeInvert_ ? -1.0f : 1.0f);diff --git a/src/app/SpaceMouse.cpp b/src/app/SpaceMouse.cppindex 8a6d793f..b3ac1b9d 100644--- a/src/app/SpaceMouse.cpp+++ b/src/app/SpaceMouse.cpp@@ -104,7 +104,7 @@ void App::spaceMouseClose() {spaceMouseName_.clear();spaceMouseButtonCount_ = 0;spaceMouseAxes_ = {};- spaceMouseMoving_ = false;+ spaceMouseMoving_ = spaceMousePushed_ = false;}bool App::spaceMouseDeflected() const {@@ -131,7 +131,7 @@ void App::spaceMouseEvent(const SDL_Event& e) {if (!spaceMouse_ || e.jbutton.which != spaceMouseId_) break;spaceMouseLastButton_ = e.jbutton.button;const SpaceMouseSettings& s = uiPrefs_.spaceMouse;- if (!s.enabled || e.jbutton.button >= s.buttons.size() || spaceMouseHeldByStroke()) break;+ if (!s.enabled || e.jbutton.button >= s.buttons.size() || spaceMouseHeld()) break;const std::string& id = s.buttons[e.jbutton.button];if (id.empty()) break;const Action* a = actions_.find(id);@@ -147,14 +147,15 @@ void App::updateSpaceMouse(float dt) {// The first frame of a move counts as one frame, not the time since the last frame drawn (a loop that sleeps// while idle wakes on the axis event: the cap has only just left the centre).if (!spaceMouseMoving_) dt = std::min(dt, 1.0f / 60.0f);- spaceMouseMoving_ = false;+ spaceMouseMoving_ = spaceMousePushed_ = false;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;- if (spaceMouseHeldByStroke()) return; // (the axes above still show in Preferences)const SpaceMouseMotion m = spaceMouseMotion(spaceMouseAxes_, dt, s);+ spaceMousePushed_ = m.any();+ if (spaceMouseHeld()) return; // (the axes above still show in Preferences)if (!m.any()) return;spaceMouseMoving_ = true;if (m.spin != 0.0f || m.tip != 0.0f || m.roll != 0.0f) {@@ -175,12 +176,57 @@ void App::updateSpaceMouse(float dt) {if (m.panX != 0.0f || m.panY != 0.0f) camera_.pan(m.panX * h, m.panY * h, h);if (m.zoom != 0.0f) camera_.zoom(m.zoom);// With Hold during strokes off, a stroke held by the pen carries on: its dabs follow the pen on screen, so the- // next sample sculpts where the pen now points on the turned model; nothing else about the stroke changes.+ // next sample sculpts where the pen now points on the turned model. A grab instead stays where it is: a pen+ // held still while the view turns moves nothing (fenix, Discord 11-06: the model flew off).+ regrabAfterViewMove();}-bool App::spaceMouseHeldByStroke() const {- return uiPrefs_.spaceMouse.holdWhileStroking &&- (drag_ == Drag::Stroke || drag_ == Drag::MaskCanvas || drag_ == Drag::AirStroke || strokeFinishing_);+bool App::spaceMouseHeld() const {+ switch (drag_) {+ case Drag::None:+ case Drag::Orbit: // the mouse's and the cap's navigation add up+ case Drag::Pan:+ case Drag::Zoom:+ case Drag::Roll:+ break;+ case Drag::Stroke:+ // A stamp dragged out (Drag Rectangle, Drag Dot) is sized and turned in the view it began in.+ if (strokeType_ == StrokeType::DragRect || strokeType_ == StrokeType::DragDot) return true;+ [[fallthrough]];+ case Drag::MaskCanvas:+ case Drag::AirStroke:+ return uiPrefs_.spaceMouse.holdWhileStroking;+ default: // a gizmo, a selection, a Forge Sphere, a guide...: anchored in the view the drag began in+ return true;+ }+ return uiPrefs_.spaceMouse.holdWhileStroking && strokeFinishing_;+}++bool App::grabStroke() const {+ if (drag_ != Drag::Stroke || !strokeSculpt_ || strokeRecipe()) return false;+ return strokeBrush_ == BrushType::Move || strokeBrush_ == BrushType::SnakeHook ||+ strokeBrush_ == BrushType::KelvinSnake || (strokeBrush_ == BrushType::KelvinGrab && kelvinStrokeBrush());+}++void App::regrabAfterViewMove() {+ if (!grabStroke()) return;+ // Where the grabbed point is on screen now: the pen's next motion moves it from there, by as much as the pen moves.+ ImVec2 at;+ if (!gizmoProject(strokeBrush_ == BrushType::KelvinGrab ? kelvinTarget_ : grabLast_, at)) return;+ grabScreenOffset_ = glm::vec2(at.x, at.y) - grabScreen_;+}++// A SpaceMouse driver that doesn't know SculptForge (3DxWare's defaults) also moves the system pointer or scrolls the+// wheel while the cap is pushed: the cursor jumped from the pen to wherever the driver put it, and the wheel zoomed+// toward it (fenix, Discord 11-06). While the cap moves the view, only the pen and touch move the cursor; a mouse's+// buttons still click.+bool App::spaceMouseEcho(const SDL_Event& e) const {+ if (!spaceMousePushed_) return false;+ SDL_MouseID which = 0;+ if (e.type == SDL_EVENT_MOUSE_MOTION) which = e.motion.which;+ else if (e.type == SDL_EVENT_MOUSE_WHEEL) which = e.wheel.which;+ else return false;+ return which != SDL_PEN_MOUSEID && which != SDL_TOUCH_MOUSEID;}bool App::sixDofPointerEvent(const SDL_Event& e) {diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex c1bc0541..59a507d5 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -241,7 +241,11 @@// pen_enter U V the pen comes into range at a point on the model (put down elsewhere, no hover)// pen_out the pen leaves proximity// pen_rest on|off the pen lies still in range, sending tilt and sub-pixel motion every frame (a Wacom-// laid on the tablet); the mouse and trackpad work beside it+// laid on the tablet); the mouse and trackpad work beside it; touching (pen_press): sub-pixel+// motion and pressure, as a pen resting its tip on the tablet+// pen_press U V [P] the pen moves to a point on the model and touches down (pressure P, default 0.5), and+// stays down until pen_lift+// pen_lift the touching pen lifts// tablet_plug [NAME] a tablet plugged in while running (default name: a generic HID mouse); its pen gets// a new id// tablet_unplug ... and unplugged@@ -276,6 +280,8 @@// spacemouse_hold TX TY TZ RX RY RZ hold the cap there until the next spacemouse step (for steps in between,// e.g. a pen stroke while the view turns); spacemouse_hold 0 0 0 0 0 0 lets go// spacemouse_button N press and release button N (1 = left side button, 2 = right)+// spacemouse_echo on|off while the cap is pushed, the system pointer drifts and the wheel scrolls every frame, as+// a SpaceMouse driver does for an app it doesn't know (3DxWare's defaults; fenix 11-06)// spacemouse_unplug unplug it// expect_value spacemouse_connected (1 when the app opened it), spacemouse_moving (1 while it moves the view)// ui_scale PERCENT | auto Preferences > Interface > UI scale (applied live, #87); display_scale PERCENT: the display's@@ -503,6 +509,7 @@ void Demo::detachVirtualSpaceMouse() {SDL_DetachVirtualJoystick(virtualSpaceMouse_);virtualSpaceMouse_ = 0;virtualSpaceMouseHandle_ = nullptr;+ virtualAxes_ = {};}double Demo::query(const std::string& name, bool& known) const {@@ -2678,6 +2685,7 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& ereturn t > 2.0f;});auto setAxes = [this](const std::array<float, 6>& a) {+ virtualAxes_ = a;for (int i = 0; i < 6; ++i)SDL_SetJoystickVirtualAxis(virtualSpaceMouseHandle_, i, Sint16(std::lround(a[size_t(i)] * 32767.0f)));};@@ -2736,6 +2744,29 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e} else if (verb == "pen_out") {run([this] { penProximity(false); });wait(0.05f);+ } else if (verb == "pen_press") {+ if (!need(2)) return false;+ const float u = num(1, 0.5f), v = num(2, 0.5f), pressure = num(3, 0.5f);+ run([this, u, v, pressure] {+ if (!penIn_) penProximity(true);+ const ImVec2 p = onModel(u, v);+ penMove(p.x, p.y);+ penTouch(true, false);+ penPressure(pressure);+ penPressed_ = true;+ });+ wait(0.1f);+ } else if (verb == "pen_lift") {+ run([this] {+ penPressed_ = false;+ if (!penDown_) return;+ penTouch(false, false);+ penPressure(0.0f);+ });+ wait(0.1f);+ } else if (verb == "spacemouse_echo") {+ if (!need(1)) return false;+ run([this, on = w[1] != "off"] { spaceMouseEcho_ = on; });} else if (verb == "pen_rest") {if (!need(1)) return false;run([this, on = w[1] != "off"] {@@ -2832,10 +2863,14 @@ void Demo::penMove(float x, float y) {}void Demo::penRestNoise() {- if (!penIn_ || penDown_) return;+ if (!penIn_ || (penDown_ && !penPressed_)) return; // (not during a pen_stroke)if (std::hypot(penAt_.x - penRestAt_.x, penAt_.y - penRestAt_.y) > 2.0f) penRestAt_ = penAt_; // laid down elsewhereconst float jitter = (++penRestFrame_ & 1) ? 0.4f : -0.4f;penMove(penRestAt_.x + jitter, penRestAt_.y);+ if (penDown_) { // the tip resting on the tablet: its pressure wavers a little+ penPressure(0.5f + jitter * 0.05f);+ return;+ }SDL_Event e{};e.type = SDL_EVENT_PEN_AXIS;e.paxis.windowID = SDL_GetWindowID(app_.window_);@@ -2848,6 +2883,21 @@ void Demo::penRestNoise() {app_.handleEvent(e);}+void Demo::spaceMouseEchoFrame() {+ bool pushed = false;+ for (float a : virtualAxes_) pushed = pushed || std::abs(a) > 0.1f;+ if (!pushed || !virtualSpaceMouseHandle_) return;+ // The system pointer (no device: injected input) drifts away from the pen, and the wheel zooms.+ mouseMotion(mouse_.x + 7.0f, mouse_.y + 3.0f);+ SDL_Event e{};+ e.type = SDL_EVENT_MOUSE_WHEEL;+ e.wheel.windowID = SDL_GetWindowID(app_.window_);+ e.wheel.y = 1.0f;+ e.wheel.mouse_x = mouse_.x;+ e.wheel.mouse_y = mouse_.y;+ app_.handleEvent(e);+}+void Demo::penPressure(float pressure) {SDL_Event e{};e.type = SDL_EVENT_PEN_AXIS;diff --git a/tests/ui/spacemouse_pen.sfui b/tests/ui/spacemouse_pen.sfuinew file mode 100644index 00000000..72108c61--- /dev/null+++ b/tests/ui/spacemouse_pen.sfui@@ -0,0 +1,124 @@+# A SpaceMouse beside a pen (fenix, Discord 11-06, the first report from a real SpaceMouse): with the pen hovering+# over the model or resting its tip on it, turning the cap made the mouse and pen cursors jump and the model fly+# off, with Hold during strokes on or off. Replayed here with the driver's echo a SpaceMouse driver sends for an app+# it doesn't know (3DxWare's defaults: the system pointer drifts and the wheel scrolls while the cap is pushed).+# Either way the cursor stays on the pen, the view only orbits, and nothing moves the model.+run ui_look look=classic layout=classic # written for the Classic look and the classic palette bar and shelves+run new_sphere subdivisions=4+key f+camera 0 0+spacemouse 0 0 0 0 0 0 0.1 # plugged in, cap at rest+spacemouse_echo on++# Hold during strokes on (the default). The pen hovers, lying still over the model: twisting the cap for longer than+# the second the pen keeps the cursor for turns the view about its pivot and nothing else.+snapshot+pen_hover 0.5 0.5+pen_rest on+remember cursor_x cx+remember cursor_y cy+remember camera_distance d0+remember camera_pan p0+spacemouse 0 0 0 0 0 0.8 1.5+expect_value camera_yaw > 25+expect_value cursor_x >= $cx-1+expect_value cursor_x <= $cx+1+expect_value cursor_y >= $cy-1+expect_value cursor_y <= $cy+1+expect_value camera_distance >= $d0-0.0001+expect_value camera_distance <= $d0+0.0001+expect_value camera_pan >= $p0-0.0001+expect_value camera_pan <= $p0+0.0001+expect_value moved == 0+shot spacemouse_pen_hover++# The tip resting on the model (a stroke, held): the view and the model stay still, and so does the cursor.+pen_rest off+pen_out # (while the pen is in range the panels follow only the pen)+click "Move##brush.move"+key f+camera 0 0+snapshot+pen_press 0.5 0.5+pen_rest on+remember cursor_x cx+remember camera_distance d1+spacemouse 0 0 0 0 0 0.8 1.5+expect_value stroking == 1+expect_value camera_yaw == 0+expect_value camera_distance >= $d1-0.0001+expect_value camera_distance <= $d1+0.0001+expect_value cursor_x >= $cx-1+expect_value cursor_x <= $cx+1+expect_value moved_max < 0.02+pen_lift+key ctrl+z++# Hold during strokes off.+pen_rest off+pen_out+click "Preferences##palette.preferences"+click "Input##preferences.input"+click "Hold during strokes##spacemouse.hold"+key escape++# Hovering: as above.+key f+camera 0 0+snapshot+pen_hover 0.5 0.5+pen_rest on+remember cursor_x cx+remember camera_distance d2+spacemouse 0 0 0 0 0 0.8 1.5+expect_value camera_yaw > 25+expect_value cursor_x >= $cx-1+expect_value cursor_x <= $cx+1+expect_value camera_distance >= $d2-0.0001+expect_value camera_distance <= $d2+0.0001+expect_value moved == 0++# Move with its tip resting on the model: the view turns under the still pen, and the grabbed part stays where it+# was (it used to follow the pen across the turning view: the model flew off).+key f+camera 0 0+snapshot+pen_press 0.5 0.5+pen_rest on+spacemouse 0 0 0 0 0 0.8 1.5+expect_value stroking == 1+expect_value camera_yaw > 25+expect_value moved_max < 0.02+shot spacemouse_pen_move+# The pen moving on from there still moves the grabbed part.+pen_rest off+pen_hover 0.6 0.5 0.3+expect_value moved_max > 0.02+pen_lift+key ctrl+z++# KelvinGrab the same.+pen_out+click "KelvinGrab##brush.kelvingrab"+key f+camera 0 0+snapshot+pen_press 0.5 0.5+pen_rest on+spacemouse 0 0 0 0 0 0.8 1.5+expect_value camera_yaw > 25+expect_value moved_max < 0.02+pen_lift+pen_rest off+key ctrl+z++# Without the cap pushed the mouse and its wheel work as ever.+pen_out+spacemouse_echo off+key f+remember camera_distance d3+wheel 0.5 0.5 2+expect_value camera_distance < $d3+click "Preferences##palette.preferences"+click "Hold during strokes##spacemouse.hold"+key escape