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
+45 -2
View File
@@ -5,7 +5,7 @@
> + 7 唤出门限/前面板精简 + 7b 锁按钮与「锁定」面板模式 + 8/8b 画面搬迁(实时拖动)
> + 9 rAF 代理修复(VR 内字幕不再冻结)+ 普通/双目字幕自动识别
> + 10 原生(SRT 等)字幕由插件自绘到 HUD;布局覆盖不再持久化
> + 11 指针跟随正在操作/瞄准的那只手)
> + 11 指针跟随正在操作/瞄准的那只手;11b 光标落在引导线上 + 点击归属操作手)
>
> ⚠️ **Jellyfin web 注册了 service worker**(`serviceworker.js`,scope `/web/`),会把
> `index.html` 缓存在 SW cache 里。重新部署后如果只是普通刷新,浏览器可能仍用旧的
@@ -417,7 +417,7 @@ subMode / subCanvasSize / subCrop / subTex / subOpacity / subPlacement
subLockAngle / subAngleDeg / subTextDeg / subYOverZ ← ADDENDUM 6
subLayout / subDual / subEyeW / subCopyND / subCenterInk ← ADDENDUM 9
subSource / subNativeText ← ADDENDUM 10
activeSrc ← ADDENDUM 11
activeSrc / pressSrc / pressPtr ← ADDENDUM 11
ctlSubsOn / ctlSubDist / ctlSubAngle / ctlSubLock ← 控制条实际画出的值
ctlLock / ctlMode / ctlHold / pressAt / lastActivate ← ADDENDUM 7/7b 锁、面板保持与唤出判定
videoYaw / videoPitch / videoRotMode / videoTransformWritable ← ADDENDUM 8/8b 画面搬迁
@@ -687,3 +687,46 @@ Object.defineProperty(XRSession.prototype,'inputSources',{configurable:true,get:
> `XRInputSourceEvent('select', …)` 构造器要求真实 `XRInputSource`,所以无法伪造 select 事件;
> 但 select 与 gamepad 共用 `pointerDown`,已被上面覆盖。
---
## 16. ADDENDUM 11b — 光标落在引导线上;点击归属操作那只手(已部署 `3d3b5f`)
针对 ADDENDUM 11 实测后反馈的两点。
### 16.1 光标偏离引导线(越靠边缘越明显)
`panelHit()` 会把**打在面板外**的交点**夹取到边框**,并用 `inBounds` 标出来;但
`updatePointer()` 把夹取后的 `nx,ny` 当 `pointer.hit` 发布了。于是光标环画在**面板边框**上,
而光束末端在**真实交点**(面板之外)——射线越偏离面板,两者差得越远,与反馈完全一致。
现在 **只有 `hit.inBounds` 才发布 `pointer.hit`**:光标只在射线真正打在面板上时出现,必然落在
光束上。只要射线与面板平面相交就仍然发布 `distance`,且 `beamLength()` 不再要求 `p.hit`,
所以瞄边缘时引导线仍指到面板平面。擦边仍能**唤出**控制条(宽判 `panelHit(...,0.5,0.9)` 未动),
但擦边不再能**按下**。
### 16.2 右手点击仍会落在左手位置
三个独立原因,全部修掉:
- **冷却是全局的**:`ACTIVATE_COOLDOWN_MS`(250ms) 会压掉 250ms 内的任意一次按下,所以一只手的
gamepad 抖动会**吃掉另一只手的 `select`**,动作随即用了第一只手的位置。现改为**按输入源分别
计时**(`lastActivateByKey`):同一次捏合产生的 gamepad+select 仍会去重,但绝不会吃掉另一只手。
- **取不到射线时静默回退到另一只手**:现在只要给了 `preferKey`(正在操作的那个源),它就
**独占这次射击**;若它不在候选里,`pick` 返回 `null`,这次按下算 **MISS**。
- **`frame` 为空时根本没重新归属**:`pointerDown()` 原来写 `if (frame) updatePointer(...)`,
frame 为空时就沿用上一帧的指针(可能是另一只手)。现在回退到 `S.lastFrame`,且若仍算不出指针,
直接记 `MISS (acting source has no ray)`。
新增诊断:`stats.pressSrc`(本次按下归属的源)、`stats.pressPtr`(`hand:right HIT` /
`hand:right nohit` / `(no ray)`)。
### 16.3 实测(注入合成输入源,活动会话)
```
都在面板上,右手按下 pressSrc hand:right pressPtr "hand:right HIT" pressAt 0.78,0.50 seek 79.5%
左手按下后 100ms 右手按下 pressSrc hand:right pressAt 0.78,0.50 (右手没被吃掉)
两只手都在面板外 state.pointer.hit = null (不再夹取光标)
面板外右手按下 pressSrc hand:right pressPtr "hand:right nohit"
pressAt "MISS (no hit on the panel)" (没有用左手位置)
```