hud-10 (rev3): cursor on the guide line; a press is attributed to the acting hand

ADDENDUM 11b, both reported against ADDENDUM 11.

1. The cursor drifted off the guide line, worse near the panel edge. panelHit()
   clamps an off-panel intersection to the border and flags it via inBounds, but
   updatePointer() published that clamped nx,ny as pointer.hit, so the ring was
   drawn on the border while the beam ended at the true (off-panel) intersection.
   pointer.hit is now published only when inBounds; distance is still published so
   an edge-aimed beam reaches the plane (beamLength no longer requires p.hit).
   Near-misses still summon the bar, but no longer press.

2. A right-hand press could still act at the left hand's position, for three
   separate reasons: the activate cooldown was global (a gamepad edge from one hand
   swallowed the other hand's select - now per input source); a missing ray fell
   back to another hand (with a preferKey the acting source now owns the shot and
   a missing candidate MISSes); and a null frame skipped re-attribution entirely
   (now falls back to S.lastFrame and MISSes if the acting source yields no
   pointer).

New diagnostics: stats.pressSrc, stats.pressPtr.

Verified with injected synthetic input sources:
  both on panel, right press      pressSrc hand:right  pressAt 0.78,0.50  seek 79.5%
  left press then right 100ms     pressSrc hand:right  pressAt 0.78,0.50  (not swallowed)
  both off panel                  state.pointer.hit = null (no clamped cursor)
  off panel, right press          pressPtr "hand:right nohit"  MISS (no hit on the panel)
This commit is contained in:
2026-10-12 21:07:05 +08:00
parent 5eb679f6ca
commit e18c3d51bd
5 changed files with 176 additions and 14 deletions
+49
View File
@@ -1187,3 +1187,52 @@ right press, right hand NOT on panel
```
`pickPointerCand` is also extracted from the built bundle and unit-tested (9 cases).
# ADDENDUM 11b — the cursor sits ON the guide line; a press is attributed to the acting hand
Two follow-ups reported against ADDENDUM 11.
## 1. The cursor drifted off the guide line, worse near the panel edge
`panelHit()` clamps an intersection that misses the panel to the border and returns
`inBounds` to say so, but `updatePointer()` published that clamped `nx,ny` as
`pointer.hit`. The cursor ring was therefore drawn **on the panel border** while the
beam ended at the true intersection, which is off the panel: the further off the panel
the ray pointed, the larger the gap — exactly as reported.
`pointer.hit` is now published **only when `hit.inBounds`** the cursor exists only where
the ray really meets the panel, so it always lies on the beam. `distance` is still
published whenever the ray meets the panel plane, and `beamLength()` no longer requires
`p.hit`, so an edge-aimed beam still reaches the plane. Near-misses keep summoning the
bar (the wide `panelHit(...,0.5,0.9)` check is unchanged), but they no longer press.
## 2. A right-hand press could still act at the left hand's position
Three separate causes, all fixed:
- **The cooldown was global.** `ACTIVATE_COOLDOWN_MS` (250 ms) suppressed *any* press
within 250 ms of the previous one, so a stray gamepad edge from one hand swallowed the
other hand's `select` — and the action then used the first hand's pointer. The cooldown
is now **per input source** (`lastActivateByKey`), so it still de-duplicates the
gamepad/`select` pair of one pinch but never eats the other hand's press.
- **A missing ray silently fell back to the other hand.** If the acting source's ray
could not be resolved, `pickPointerCand` skipped to the next candidate. Now, when a
`preferKey` (the acting source) is supplied, it **owns the shot**: if it is not among
the candidates the pick is `null` and the press MISSES.
- **A null frame meant no re-attribution at all.** `pointerDown()` did
`if (frame) updatePointer(...)`, so with no frame the per-frame pointer (possibly the
other hand) was used silently. It now falls back to `S.lastFrame`, and when the acting
source still yields no pointer it reports `MISS (acting source has no ray)`.
New diagnostics: `stats.pressSrc` (the source key the press was attributed to) and
`stats.pressPtr` (`hand:right HIT` / `hand:right nohit` / `(no ray)`).
## Verification (injected synthetic input sources, live session)
```
both hands on panel, right press pressSrc hand:right pressPtr "hand:right HIT" pressAt 0.78,0.50 seek 79.5%
left press then right 100 ms later pressSrc hand:right pressAt 0.78,0.50 (right not swallowed)
both hands off panel state.pointer.hit = null (no clamped cursor)
both off panel, right press pressSrc hand:right pressPtr "hand:right nohit"
pressAt "MISS (no hit on the panel)" (did NOT use the left hand)
```