Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Map: a very fast swipe is a drag, not a tap (#1661 item 4) (#1777)

EllaSharakanski87c9cb0bd70d
diff --git a/changelog.d/1661-fast-swipe-pans.md b/changelog.d/1661-fast-swipe-pans.md
new file mode 100644
index 000000000..e658a5618
--- /dev/null
+++ b/changelog.d/1661-fast-swipe-pans.md
@@ -0,0 +1,8 @@
+### Fixed
+
+- A very fast one-finger swipe no longer selects a hex (#1661 item 4; owner's ruling of 26 October 2026). A finger is
+ sampled once a frame, so a press, a long travel and a lift inside one input update left the press and the sample at
+ the same point: the slop saw nothing move, however far the finger went, and the swipe came back as a tap at the
+ release point. The press now also carries the finger's travel within the frame, so the slop sees it and the gesture
+ is a drag. The mouse's right button is stepped from its action callbacks and reports no travel, so right-click
+ ordering is unchanged.
diff --git a/unity/Assets/Scripts/Map/MapPointer.cs b/unity/Assets/Scripts/Map/MapPointer.cs
index 08f5ee35a..39d4a6857 100644
--- a/unity/Assets/Scripts/Map/MapPointer.cs
+++ b/unity/Assets/Scripts/Map/MapPointer.cs
@@ -7,8 +7,9 @@ using UnityEngine.InputSystem;
namespace Statecraft.Game.Map
{
/// <summary>The tap rule, with no devices: a finger becomes a tap only when it lifts within
- /// <see cref="SlopPixels"/> of where it landed and no second finger was down while it was held. A moved finger
- /// drags the camera and two fingers pinch (CameraController), so neither may also select a hex.</summary>
+ /// <see cref="SlopPixels"/> of where it landed, travelled no further than that inside any one frame, and no second
+ /// finger was down while it was held. A moved finger drags the camera and two fingers pinch (CameraController), so
+ /// neither may also select a hex.</summary>
public struct TapPress
{
/// <summary>How far the finger may wander, in screen pixels, before the press stops being a tap (about
@@ -23,14 +24,22 @@ namespace Statecraft.Game.Map
/// pan, never both (#1654 review).</summary>
public bool TapCandidate => down && !moved && !pinched;
- /// <summary>One frame of the watched finger: its pressed and released edges, where it is, and whether any
- /// other finger is down. The tap's position on a release frame that still qualifies, otherwise null.</summary>
- public Vector2? Step(bool pressed, bool released, Vector2 position, bool otherFingerDown)
+ /// <summary>One frame of the watched finger: its pressed and released edges, where it is, whether any other
+ /// finger is down, and how far it travelled within this frame. The tap's position on a release frame that
+ /// still qualifies, otherwise null.
+ /// <para><paramref name="travel"/> is what makes a very fast swipe a pan rather than a tap (owner's ruling of
+ /// 26 October 2026, #1661 item 4). A finger sampled once per frame can press, cross the screen and lift inside
+ /// one input update, and then <c>position</c> and <c>start</c> are the same sample: the distance test below
+ /// sees nothing moved however far it went. The frame's own travel does see it. Callers with no travel to
+ /// report (the mouse's right button, which is stepped from its action callbacks) pass none, so their rule is
+ /// unchanged.</para></summary>
+ public Vector2? Step(bool pressed, bool released, Vector2 position, bool otherFingerDown, Vector2 travel = default)
{
if (pressed) { start = position; down = true; moved = false; pinched = false; }
if (!down) return null;
if (otherFingerDown) pinched = true; // a pinch is never a tap, even a still thumb
if ((position - start).sqrMagnitude > SlopPixels * SlopPixels) moved = true; // latched: coming back helps not
+ if (travel.sqrMagnitude > SlopPixels * SlopPixels) moved = true; // a whole flick inside one frame
if (!released) return null;
down = false;
return moved || pinched ? (Vector2?)null : start;
@@ -174,7 +183,7 @@ namespace Statecraft.Game.Map
if (touch.press.isPressed) pressed++;
// any other finger down cancels the tap (TapPress): a releasing pinch's thumb is inside the slop, yet must not select
var tapAt = tap.Step(t.press.wasPressedThisFrame, t.press.wasReleasedThisFrame,
- t.position.ReadValue(), pressed > (t.press.isPressed ? 1 : 0));
+ t.position.ReadValue(), pressed > (t.press.isPressed ? 1 : 0), t.delta.ReadValue());
if (tapAt.HasValue) OnPress(tapAt.Value); // a tap selects where the finger landed, like a click
}
diff --git a/unity/Assets/Tests/EditMode/MapPointerTickTests.cs b/unity/Assets/Tests/EditMode/MapPointerTickTests.cs
index dbfb630ee..fa6f1edfe 100644
--- a/unity/Assets/Tests/EditMode/MapPointerTickTests.cs
+++ b/unity/Assets/Tests/EditMode/MapPointerTickTests.cs
@@ -97,18 +97,18 @@ public class MapPointerTickTests : InputTestFixture
// and a test asserting it would be order-dependent. Reported on #1661 instead of pinned; the no-order half is
// already covered by RightClickOrPanTests.ARightDragOutAndBackInsideOneFrameIsNoClick.
- /// <summary>Item 4's touch half, pinning what happens **today**: a flick whose press, travel and release all land
- /// in one input update comes back as a <em>tap</em>, and at the release point rather than where the finger landed.
- /// <para>Why. <c>Tick</c> samples the touch once per frame, and <c>TapPress.Step</c> sets <c>start</c> from that
- /// same sample on the press edge, so <c>position - start</c> is zero and <c>moved</c> never latches however far the
- /// finger travelled. The 200 px of travel is invisible, and the one position the frame saw is the last one.</para>
- /// <para>The warming frame matters: <c>ButtonControl.wasPressedThisFrame</c> takes an old path on its first call
- /// ever and can miss a fast press (ButtonControl.cs:287-293, and its own remarks). Without it this test passed for
- /// the wrong reason, with the gesture not seen at all. In the game <c>Tick</c> queries every frame, so the control
- /// is warm, and this is what a real one-update flick would do. Reported on #1661; the fix would mean reading the
- /// touch's travel or phase rather than one sampled position, which changes the tap rule.</para></summary>
+ /// <summary>Item 4's touch half, as the owner ruled it on 26 October 2026: **a very fast one-finger swipe pans
+ /// the map and selects nothing.** A flick whose press, travel and release all land in one input update used to
+ /// come back as a tap, at the release point rather than where the finger landed, because <c>Tick</c> samples the
+ /// touch once per frame and <c>TapPress.Step</c> set <c>start</c> from that same sample on the press edge: the
+ /// 200 px of travel was invisible to <c>position - start</c> and <c>moved</c> never latched. The press now carries
+ /// the finger's travel within the frame, so the slop sees it.
+ /// <para>The warming frame matters and must stay: <c>ButtonControl.wasPressedThisFrame</c> takes an old path on
+ /// its first call ever and can miss a fast press (ButtonControl.cs:287-293, and its own remarks). Without it this
+ /// test passes for the wrong reason, with the gesture not seen at all. In the game <c>Tick</c> queries every
+ /// frame, so the control is warm.</para></summary>
[Test]
- public void AFlickInsideOneInputUpdateIsATapAtTheReleasePointToday()
+ public void AFlickInsideOneInputUpdateSelectsNothing()
{
using var rig = new Rig();
var start = rig.View.LookAt;
@@ -119,14 +119,38 @@ public class MapPointerTickTests : InputTestFixture
EndTouch(1, from + new Vector2(200, 0));
rig.Frame();
rig.SettleFrame();
- CollectionAssert.AreEqual(new[] { from + new Vector2(200, 0) }, rig.Asked,
- "today a one-update flick taps, and at the release point: the travel is invisible to the slop");
- Assert.AreEqual(start, rig.View.LookAt, "and it does not pan");
+ Assert.IsEmpty(rig.Asked, "a fast swipe selects nothing: the travel is inside the frame, and the slop sees it");
+ // The pan is not asserted here, and deliberately. In this extreme the finger is already up when the frame
+ // runs, so CameraController's FingersDown sees none and never reads its delta; panning it would mean changing
+ // the camera, which is ruling 2's file. A swipe the camera sees a finger during is the next test.
+ Assert.AreEqual(start, rig.View.LookAt, "today it also does not pan, because the finger is gone by the frame");
}
- /// <summary>The zero-travel control, and the reason the test above is a finding rather than an artefact: the same
- /// one-update press and release with the finger still selects where it was pressed, which is correct. So the
- /// difference between the two is the 200 px of travel being lost, not the gesture being dropped.</summary>
+ /// <summary>The same ruling for a swipe the camera can actually see: fast, but with the finger down across a
+ /// frame, as every swipe on a real screen is. Nothing is selected and the map pans by the swipe. This is the half
+ /// of the owner's ruling 3 that needs no change to the camera.</summary>
+ [Test]
+ public void AFastSwipeAcrossFramesPansAndSelectsNothing()
+ {
+ using var rig = new Rig();
+ var start = rig.View.LookAt;
+ var from = new Vector2(400, 400);
+ rig.Frame(); // warms press.wasPressedThisFrame, as above
+ BeginTouch(1, from);
+ rig.Frame();
+ MoveTouch(1, from + new Vector2(200, 0));
+ rig.Frame();
+ EndTouch(1, from + new Vector2(200, 0));
+ rig.Frame();
+ rig.SettleFrame();
+ Assert.IsEmpty(rig.Asked, "a swipe past the slop selects nothing");
+ Assert.AreNotEqual(start, rig.View.LookAt, "and the map pans by the swipe");
+ }
+
+ /// <summary>The zero-travel control for the two tests above: the same one-update press and release, with the
+ /// finger still, selects where it was pressed. The finger's travel in the frame is zero, so the slop sees nothing
+ /// and the press is a tap, as it should be. That is what makes the swipe above a travel rule rather than a
+ /// one-update gesture being dropped: the only difference between them is the 200 px.</summary>
[Test]
public void AStillPressInsideOneInputUpdateSelectsWhereItWasPressed()
{
diff --git a/unity/Assets/Tests/EditMode/MapPressTests.cs b/unity/Assets/Tests/EditMode/MapPressTests.cs
index a94839694..c0a8c6260 100644
--- a/unity/Assets/Tests/EditMode/MapPressTests.cs
+++ b/unity/Assets/Tests/EditMode/MapPressTests.cs
@@ -68,6 +68,29 @@ public class MapPressTests
tap.Step(true, false, new Vector2(300, 300), false);
Assert.AreEqual((Vector2?)new Vector2(300, 300), tap.Step(false, true, new Vector2(300, 300), false));
}
+
+ /// <summary>The travel rule with no devices (#1661 item 4, owner's ruling of 26 October 2026): a press whose
+ /// whole journey happens inside one frame is a drag, because <c>Step</c> is now told how far the finger went.
+ /// Position and start are the same sample here, so without the travel the slop would see nothing move.</summary>
+ [Test]
+ public void APressThatTravelsPastTheSlopInOneFrameIsNotATap()
+ {
+ var tap = new TapPress();
+ var at = new Vector2(600, 400);
+ Assert.IsNull(tap.Step(true, true, at, false, new Vector2(200, 0)),
+ "200 px of travel inside the frame is a drag, even though position equals start");
+ }
+
+ /// <summary>The other side of the same rule: travel inside the slop still taps, so the threshold is the slop and
+ /// not merely "any travel at all".</summary>
+ [Test]
+ public void APressThatTravelsInsideTheSlopInOneFrameStillTaps()
+ {
+ var tap = new TapPress();
+ var at = new Vector2(600, 400);
+ Assert.AreEqual((Vector2?)at, tap.Step(true, true, at, false, new Vector2(20, 0)),
+ "20 px is inside TapPress.SlopPixels (30), so it is still a tap at where the finger landed");
+ }
}
/// <summary>#1654 review (blocker): a mouse press is a click or the camera's drag pan, never both. That was first