diff --git a/HANDOFF.md b/HANDOFF.md index cccec5d..3a41127 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -1,11 +1,12 @@ # Jellyfin Web VR180 — 项目交接文档 > 给新对话用。读完这份就能接手,不需要重新调查环境。 -> 最后更新:已部署版本 `6bf1021`(`NS.version = hud-10`;ADDENDUM 6 字幕深度/大小解耦 +> 最后更新:已部署版本 `917fde`(`NS.version = hud-11`;ADDENDUM 6 字幕深度/大小解耦 > + 7 唤出门限/前面板精简 + 7b 锁按钮与「锁定」面板模式 + 8/8b 画面搬迁(实时拖动) > + 9 rAF 代理修复(VR 内字幕不再冻结)+ 普通/双目字幕自动识别 > + 10 原生(SRT 等)字幕由插件自绘到 HUD;布局覆盖不再持久化 -> + 11 指针跟随正在操作/瞄准的那只手;11b 光标落在引导线上 + 点击归属操作手) +> + 11 指针跟随正在操作/瞄准的那只手;11b 光标落在引导线上 + 点击归属操作手 +> + 12 单一指针主人(主用手默认,按下接管,按住互斥,抬起按源匹配)) > > ⚠️ **Jellyfin web 注册了 service worker**(`serviceworker.js`,scope `/web/`),会把 > `index.html` 缓存在 SW cache 里。重新部署后如果只是普通刷新,浏览器可能仍用旧的 @@ -417,7 +418,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 / pressSrc / pressPtr ← ADDENDUM 11 +activeSrc / pressSrc / pressPtr / handPref ← ADDENDUM 11/12 ctlSubsOn / ctlSubDist / ctlSubAngle / ctlSubLock ← 控制条实际画出的值 ctlLock / ctlMode / ctlHold / pressAt / lastActivate ← ADDENDUM 7/7b 锁、面板保持与唤出判定 videoYaw / videoPitch / videoRotMode / videoTransformWritable ← ADDENDUM 8/8b 画面搬迁 @@ -730,3 +731,52 @@ Object.defineProperty(XRSession.prototype,'inputSources',{configurable:true,get: 面板外右手按下 pressSrc hand:right pressPtr "hand:right nohit" pressAt "MISS (no hit on the panel)" (没有用左手位置) ``` + +--- + +## 17. ADDENDUM 12 — 单一指针“主人”:主用手默认,按下接管(已部署 `917fde` / `hud-11`) + +之前的指针是**对称**的:谁最后操作谁拥有;谁都没操作时用「运行时第一个源」——本设备上就是**左手**, +所以右撇子一抬手引导线就在非惯用手上。而且两只手会互相打扰彼此的按住操作。 + +### 17.1 单一主人(像鼠标只有一个光标) + +`pickPointerCand(cands, preferKey, ownerKey, prefHand)`: + +``` +preferKey(正在操作的那个源) → 就是它;取不到 → null ⇒ 这次按下 MISS +主人且正瞄面板 → 主人 +主用手且正瞄面板 → 主用手 +任一只正瞄面板的手 → 它 +主人(没瞄面板) → 主人 +主用手(没瞄面板) → 主用手 + → 第一个源 +``` + +- **`state.handPref`**(`'right' | 'left'`,默认 `'right'`)= 指针的默认主人(惯用手)。 + 在**进 VR 前的面板**「操作 → 主用手」里设置,持久化在 `jfvr.settings.v1`。会话开始生效; + 会话中主人只会粘滞。 +- **按下即接管**(`preferKey`),之后主人粘在那只手上(只要它在瞄面板)。 + +### 17.2 两只手不再互相打扰 + +- **按住期间互斥**:某只手发起的长按/拖动(`grab` / `viewDrag`)进行中时,**另一只手的按下被忽略** + (`stats.pressAt = 'IGNORED (other hand is holding)'`)。 +- **抬起按源匹配**:`pointerUp(src)` 只结束 `src` 自己发起的那次抓取/拖动。之前它是无参的, + 所以**任一只手松手都会取消另一只手的字幕抓拖/画面搬迁**。现在 `onSelectEnd(ev)` 和 + `pollGamepads` 都会传源,`grab` / `viewDrag` 各自带 `key`。 +- **失效收尾**:`dropStaleHolds()` 每帧检查,若发起抓取的那只手从 `session.inputSources` 消失 + (手部追踪丢失)就主动结束,避免永远没有 release 事件而卡住。 + +新增诊断:`stats.handPref`、`stats.owner`(= `stats.activeSrc`),以及已有的 `pressSrc` / `pressPtr`。 + +### 17.3 实测(注入合成输入源,活动会话) + +``` +默认(handPref=right),两手都在面板上 pointer hand:right HIT 0.78,0.50 (原来是 hand:left) +handPref=left(持久化后重开会话) pointer hand:left HIT 0.22,0.50 +左手按下后松开 主人 hand:left,之后仍是 left +右手按住画面拖动条,左手按下 pressAt "IGNORED (other hand is holding)" +右手按住画面拖动条,左手松开 viewDrag 仍 "armed"(拖动存活) +右手按住画面拖动条,右手松开 viewDrag "reset (tap)"(拖动结束) +``` diff --git a/INTERFACES.md b/INTERFACES.md index 180e06d..d5fe0e3 100644 --- a/INTERFACES.md +++ b/INTERFACES.md @@ -1236,3 +1236,58 @@ both hands off panel state.pointer.hit = null 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) ``` + +# ADDENDUM 12 — one pointer owner: the dominant hand, taken over by a press + +The pointer was symmetric: whichever hand acted last owned it, and when neither had +acted the first source in runtime order won — which is the LEFT hand on this runtime, so +a right-handed user's guide line sat on the non-dominant hand. Two hands could also +disturb each other's holds. + +## 1. One owner (a mouse-like single cursor) + +`pickPointerCand(cands, preferKey, ownerKey, prefHand)`: + +``` +preferKey (the acting source) -> that source, or null => the press MISSES +owner aiming at the panel -> owner +the preferred hand aiming at the panel -> preferred hand +any hand aiming at the panel -> that hand +owner (not aiming) -> owner +the preferred hand (not aiming) -> preferred hand + -> the first source +``` + +- **`state.handPref`** (`'right' | 'left'`, default `'right'`) is the pointer's default + owner — the dominant hand. Set from the pre-VR panel ("操作 → 主用手"), persisted in + `jfvr.settings.v1`. It applies at the start of a session; during a session the owner + simply sticks. +- **A press takes the pointer over** (`preferKey`), and the owner then sticks to that + hand while it is aiming. + +## 2. The hands can no longer disturb each other + +- **Hold exclusion:** while a hold/drag started by one source is in progress + (`grab` / `viewDrag`), a press from the OTHER source is ignored + (`stats.pressAt = 'IGNORED (other hand is holding)'`). +- **Source-matched release:** `pointerUp(src)` only ends a hold that `src` started. + It used to be argument-less, so *either* hand's release cancelled the other hand's + subtitle grab / picture pan. `onSelectEnd(ev)` and `pollGamepads` now pass their + source. `grab` / `viewDrag` carry a `key`. +- **Stale holds:** `dropStaleHolds()` runs each frame and ends a hold whose source has + left `session.inputSources` (hand tracking lost) — otherwise no release would ever + arrive and the drag would stick. + +New diagnostics: `stats.handPref`, `stats.owner` (= `stats.activeSrc`), plus the +existing `pressSrc` / `pressPtr`. + +## Verification (injected synthetic input sources, live session) + +``` +default (handPref=right), both hands on panel pointer hand:right HIT 0.78,0.50 (was hand:left) +handPref=left (persisted, fresh session) pointer hand:left HIT 0.22,0.50 +left press, release owner hand:left, still left afterwards +right holds picture-pan, left press pressAt "IGNORED (other hand is holding)" +right holds picture-pan, LEFT releases viewDrag stays "armed" (drag survives) +right holds picture-pan, RIGHT releases viewDrag "reset (tap)" (drag ends) +``` diff --git a/dist/jfvr.js b/dist/jfvr.js index 5130f59..518d4c9 100644 --- a/dist/jfvr.js +++ b/dist/jfvr.js @@ -19,7 +19,7 @@ var NS = window.__JFVR = window.__JFVR || {}; - NS.version = 'hud-10'; // hud-10 = ADDENDUM 11 (pointer follows the acting/aiming hand) + ADDENDUM 10 (native subtitles) + 9 + NS.version = 'hud-11'; // hud-11 = ADDENDUM 12 (single pointer owner: dominant hand by default, press takes over, hold exclusion) + 11/10/9 NS.__core = true; /* ------------------------------------------------------------------ * @@ -75,6 +75,7 @@ subAngleDeg: 69.2, controls: true, + handPref: 'right', // ADDENDUM 12: dominant hand = the pointer's default owner ctlAutoHideMs: 4000, // in-VR control bar auto-hide // written every XR frame by 90-main.js, read by modules @@ -4586,6 +4587,7 @@ if (o.subAlpha === 'premultiplied' || o.subAlpha === 'straight') S.subAlpha = o.subAlpha; if (o.projection === '180' || o.projection === '360') S.projection = o.projection; if (o.stereo === 'mono' || o.stereo === 'sbs' || o.stereo === 'ou') S.stereo = o.stereo; + if (o.handPref === 'right' || o.handPref === 'left') S.handPref = o.handPref; if (typeof o.controls === 'boolean') S.controls = o.controls; // NOTE: `subtitles` is deliberately NOT restored. Persisting it meant a // session where the user toggled subtitles off came back with them off, @@ -4609,6 +4611,7 @@ subAlpha: S.subAlpha, projection: S.projection, stereo: S.stereo, + handPref: S.handPref, videoRotMode: S.videoRotMode, controls: S.controls, ctlAutoHideMs: S.ctlAutoHideMs @@ -4872,6 +4875,13 @@ '字幕的位置 / 距离 / 大小 / 不透明度都在 VR 里用控制条调(控制条最下面一行),' + '调好会自动记住。VR 空间右侧有个锁图标:锁上后面板不会再被唤出。')); + body.appendChild(NS.makeEl('div', 'jfvr-sec', '操作')); + body.appendChild(segRow('主用手', function () { return S.handPref || 'right'; }, + function (v) { S.handPref = v; saveSettings(); }, + [{ label: '右手', value: 'right' }, { label: '左手', value: 'left' }])); + body.appendChild(NS.makeEl('div', 'jfvr-hint', + '引导线/光标默认在主用手上;另一只手按下会立刻接管那一次操作。')); + // ADDENDUM 8: the picture-pan mechanism. Only touch this if panning does not // move the picture live (see stats.videoRotMode). body.appendChild(segRow('画面旋转', function () { return S.videoRotMode || 'auto'; }, @@ -5162,6 +5172,7 @@ try { updatePointer(frame); pollGamepads(frame); + dropStaleHolds(); updatePanelPose(frame, dt); updateGrabFrame(frame); updateViewDrag(frame); @@ -5448,27 +5459,48 @@ return null; } - // ADDENDUM 11 — pure: choose which input source owns the pointer. - // cands [{ key, onPanel, ... }] in runtime order + function candByHand(cands, hand) { + for (var i = 0; i < cands.length; i++) if (cands[i].hand === hand) return cands[i]; + return null; + } + + // ADDENDUM 12 — pure: choose which input source owns the pointer. + // cands [{ key, hand, onPanel, ... }] in runtime order // preferKey the source that is acting right now (select / gamepad press) - // activeKey the source that acted last - // When `preferKey` is given the acting source OWNS the shot: if it is not among - // the candidates (no resolvable ray) we return null so the press MISSES rather - // than silently reusing another hand's pointer. Otherwise: - // last-active-while-on-panel -> any-on-panel -> last-active -> first. - function pickPointerCand(cands, preferKey, activeKey) { + // ownerKey the source that owns the pointer (last accepted press) + // prefHand the dominant hand ('right' | 'left') — the default owner + // + // The acting source OWNS the shot: if it cannot be resolved the pick is null and + // the press MISSES (never another hand's position). Otherwise: + // owner aiming -> preferred hand aiming -> any hand aiming -> owner -> + // preferred hand -> first. + // A mouse-style single cursor: exactly ONE hand ever drives the guide line. + function pickPointerCand(cands, preferKey, ownerKey, prefHand) { if (preferKey) return candByKey(cands, preferKey); if (!cands || !cands.length) return null; - var i, c; - if (activeKey) { - c = candByKey(cands, activeKey); - if (c && c.onPanel) return c; - } - for (i = 0; i < cands.length; i++) if (cands[i].onPanel) return cands[i]; - if (activeKey) { c = candByKey(cands, activeKey); if (c) return c; } + var owner = ownerKey ? candByKey(cands, ownerKey) : null; + var pref = prefHand ? candByHand(cands, prefHand) : null; + if (owner && owner.onPanel) return owner; + if (pref && pref.onPanel) return pref; + for (var i = 0; i < cands.length; i++) if (cands[i].onPanel) return cands[i]; + if (owner) return owner; + if (pref) return pref; return cands[0]; } + // When the source that started a hold disappears (hand tracking lost), the hold + // would otherwise stick forever because no release event ever arrives. + function dropStaleHolds() { + var srcs = (S.session && S.session.inputSources) ? S.session.inputSources : []; + var i; + function present(src) { + for (i = 0; i < srcs.length; i++) if (srcs[i] === src) return true; + return false; + } + if (grab && !present(grab.src)) endGrab(); + if (viewDrag && !present(viewDrag.src)) endViewDrag(); + } + // ADDENDUM 11: which hand owns the pointer. var activeSrcKey = null; @@ -5508,12 +5540,12 @@ var hit = null; try { hit = panelHit(frame, ray, layer, 0.25, 0.6); } catch (e) { hit = null; } cands.push({ - src: src, ray: ray, hit: hit, key: srcKey(src), + src: src, ray: ray, hit: hit, key: srcKey(src), hand: src.handedness, onPanel: !!(hit && hit.inBounds) }); } - var pick = pickPointerCand(cands, preferSrc ? srcKey(preferSrc) : null, activeSrcKey); + var pick = pickPointerCand(cands, preferSrc ? srcKey(preferSrc) : null, activeSrcKey, S.handPref); if (pick) { activeSrcKey = pick.key; @@ -5542,6 +5574,7 @@ try { NS.Controls.setPointer(next); } catch (e) {} } S.stats.activeSrc = next.visible ? (activeSrcKey || '(none)') : '(none)'; + S.stats.handPref = S.handPref || 'right'; S.stats.pointer = next.source + (next.hit ? ' HIT ' + next.hit.nx.toFixed(2) + ',' + next.hit.ny.toFixed(2) : ' (no hit)'); S.stats.inputSources = srcs.map(function (s) { @@ -5793,7 +5826,7 @@ var a = rayAngles(ray); if (!a) { S.stats.viewDrag = 'no ray'; return; } viewDrag = { - src: src, t0: performance.now(), armed: false, + src: src, key: srcKey(src), t0: performance.now(), armed: false, a0: null, yaw0: S.videoYaw, pitch0: S.videoPitch, moved: false }; S.stats.viewDrag = 'pressed (hold ' + VIEW_HOLD_MS + 'ms to pan)'; @@ -5934,6 +5967,7 @@ if (!p0) { S.stats.grab = 'no source point'; return; } grab = { src: src, + key: srcKey(src), p0: p0, place0: { y: S.subPlacement.y, z: S.subPlacement.z, width: S.subPlacement.width }, moved: false @@ -6054,6 +6088,13 @@ // hand's position. frame = frame || S.lastFrame; if (src) { + var excludeKey = srcKey(src); + if (excludeKey && + ((grab && grab.key && grab.key !== excludeKey) || + (viewDrag && viewDrag.key && viewDrag.key !== excludeKey))) { + S.stats.pressAt = 'IGNORED (other hand is holding)'; + return; + } if (frame) { try { updatePointer(frame, src); } catch (e) {} } if (!pointer || !pointer.visible) { S.stats.pressAt = 'MISS (acting source has no ray)'; @@ -6121,7 +6162,14 @@ var pressUntil = 0; - function pointerUp() { + // ADDENDUM 12: only the source that STARTED a hold ends it. A release from the + // other hand used to cancel the first hand's drag (subtitle grab / picture pan). + function pointerUp(src) { + var key = srcKey(src); + if (key) { + if (grab && grab.key && grab.key !== key) return; + if (viewDrag && viewDrag.key && viewDrag.key !== key) return; + } endGrab(); endViewDrag(); } @@ -6141,7 +6189,7 @@ var prev = padPrev.get(src) || false; padPrev.set(src, pressed); if (pressed && !prev) pointerDown(src, frame, 'gamepad'); - else if (!pressed && prev) pointerUp(); + else if (!pressed && prev) pointerUp(src); } } @@ -6149,8 +6197,8 @@ pointerDown(ev && ev.inputSource, S.lastFrame, 'select'); } - function onSelectEnd() { - pointerUp(); + function onSelectEnd(ev) { + pointerUp(ev && ev.inputSource); } /* ---------------- live subtitle setters (single source of truth) ---------------- */ // state.subPlacement / subAngleDeg are re-read from the module after every diff --git a/src/00-core.js b/src/00-core.js index 822ba39..d739e41 100644 --- a/src/00-core.js +++ b/src/00-core.js @@ -11,7 +11,7 @@ var NS = window.__JFVR = window.__JFVR || {}; - NS.version = 'hud-10'; // hud-10 = ADDENDUM 11 (pointer follows the acting/aiming hand) + ADDENDUM 10 (native subtitles) + 9 + NS.version = 'hud-11'; // hud-11 = ADDENDUM 12 (single pointer owner: dominant hand by default, press takes over, hold exclusion) + 11/10/9 NS.__core = true; /* ------------------------------------------------------------------ * @@ -67,6 +67,7 @@ subAngleDeg: 69.2, controls: true, + handPref: 'right', // ADDENDUM 12: dominant hand = the pointer's default owner ctlAutoHideMs: 4000, // in-VR control bar auto-hide // written every XR frame by 90-main.js, read by modules diff --git a/src/90-main.js b/src/90-main.js index fb6a0bb..57e60f6 100644 --- a/src/90-main.js +++ b/src/90-main.js @@ -187,6 +187,7 @@ if (o.subAlpha === 'premultiplied' || o.subAlpha === 'straight') S.subAlpha = o.subAlpha; if (o.projection === '180' || o.projection === '360') S.projection = o.projection; if (o.stereo === 'mono' || o.stereo === 'sbs' || o.stereo === 'ou') S.stereo = o.stereo; + if (o.handPref === 'right' || o.handPref === 'left') S.handPref = o.handPref; if (typeof o.controls === 'boolean') S.controls = o.controls; // NOTE: `subtitles` is deliberately NOT restored. Persisting it meant a // session where the user toggled subtitles off came back with them off, @@ -210,6 +211,7 @@ subAlpha: S.subAlpha, projection: S.projection, stereo: S.stereo, + handPref: S.handPref, videoRotMode: S.videoRotMode, controls: S.controls, ctlAutoHideMs: S.ctlAutoHideMs @@ -473,6 +475,13 @@ '字幕的位置 / 距离 / 大小 / 不透明度都在 VR 里用控制条调(控制条最下面一行),' + '调好会自动记住。VR 空间右侧有个锁图标:锁上后面板不会再被唤出。')); + body.appendChild(NS.makeEl('div', 'jfvr-sec', '操作')); + body.appendChild(segRow('主用手', function () { return S.handPref || 'right'; }, + function (v) { S.handPref = v; saveSettings(); }, + [{ label: '右手', value: 'right' }, { label: '左手', value: 'left' }])); + body.appendChild(NS.makeEl('div', 'jfvr-hint', + '引导线/光标默认在主用手上;另一只手按下会立刻接管那一次操作。')); + // ADDENDUM 8: the picture-pan mechanism. Only touch this if panning does not // move the picture live (see stats.videoRotMode). body.appendChild(segRow('画面旋转', function () { return S.videoRotMode || 'auto'; }, @@ -763,6 +772,7 @@ try { updatePointer(frame); pollGamepads(frame); + dropStaleHolds(); updatePanelPose(frame, dt); updateGrabFrame(frame); updateViewDrag(frame); @@ -1049,27 +1059,48 @@ return null; } - // ADDENDUM 11 — pure: choose which input source owns the pointer. - // cands [{ key, onPanel, ... }] in runtime order + function candByHand(cands, hand) { + for (var i = 0; i < cands.length; i++) if (cands[i].hand === hand) return cands[i]; + return null; + } + + // ADDENDUM 12 — pure: choose which input source owns the pointer. + // cands [{ key, hand, onPanel, ... }] in runtime order // preferKey the source that is acting right now (select / gamepad press) - // activeKey the source that acted last - // When `preferKey` is given the acting source OWNS the shot: if it is not among - // the candidates (no resolvable ray) we return null so the press MISSES rather - // than silently reusing another hand's pointer. Otherwise: - // last-active-while-on-panel -> any-on-panel -> last-active -> first. - function pickPointerCand(cands, preferKey, activeKey) { + // ownerKey the source that owns the pointer (last accepted press) + // prefHand the dominant hand ('right' | 'left') — the default owner + // + // The acting source OWNS the shot: if it cannot be resolved the pick is null and + // the press MISSES (never another hand's position). Otherwise: + // owner aiming -> preferred hand aiming -> any hand aiming -> owner -> + // preferred hand -> first. + // A mouse-style single cursor: exactly ONE hand ever drives the guide line. + function pickPointerCand(cands, preferKey, ownerKey, prefHand) { if (preferKey) return candByKey(cands, preferKey); if (!cands || !cands.length) return null; - var i, c; - if (activeKey) { - c = candByKey(cands, activeKey); - if (c && c.onPanel) return c; - } - for (i = 0; i < cands.length; i++) if (cands[i].onPanel) return cands[i]; - if (activeKey) { c = candByKey(cands, activeKey); if (c) return c; } + var owner = ownerKey ? candByKey(cands, ownerKey) : null; + var pref = prefHand ? candByHand(cands, prefHand) : null; + if (owner && owner.onPanel) return owner; + if (pref && pref.onPanel) return pref; + for (var i = 0; i < cands.length; i++) if (cands[i].onPanel) return cands[i]; + if (owner) return owner; + if (pref) return pref; return cands[0]; } + // When the source that started a hold disappears (hand tracking lost), the hold + // would otherwise stick forever because no release event ever arrives. + function dropStaleHolds() { + var srcs = (S.session && S.session.inputSources) ? S.session.inputSources : []; + var i; + function present(src) { + for (i = 0; i < srcs.length; i++) if (srcs[i] === src) return true; + return false; + } + if (grab && !present(grab.src)) endGrab(); + if (viewDrag && !present(viewDrag.src)) endViewDrag(); + } + // ADDENDUM 11: which hand owns the pointer. var activeSrcKey = null; @@ -1109,12 +1140,12 @@ var hit = null; try { hit = panelHit(frame, ray, layer, 0.25, 0.6); } catch (e) { hit = null; } cands.push({ - src: src, ray: ray, hit: hit, key: srcKey(src), + src: src, ray: ray, hit: hit, key: srcKey(src), hand: src.handedness, onPanel: !!(hit && hit.inBounds) }); } - var pick = pickPointerCand(cands, preferSrc ? srcKey(preferSrc) : null, activeSrcKey); + var pick = pickPointerCand(cands, preferSrc ? srcKey(preferSrc) : null, activeSrcKey, S.handPref); if (pick) { activeSrcKey = pick.key; @@ -1143,6 +1174,7 @@ try { NS.Controls.setPointer(next); } catch (e) {} } S.stats.activeSrc = next.visible ? (activeSrcKey || '(none)') : '(none)'; + S.stats.handPref = S.handPref || 'right'; S.stats.pointer = next.source + (next.hit ? ' HIT ' + next.hit.nx.toFixed(2) + ',' + next.hit.ny.toFixed(2) : ' (no hit)'); S.stats.inputSources = srcs.map(function (s) { @@ -1394,7 +1426,7 @@ var a = rayAngles(ray); if (!a) { S.stats.viewDrag = 'no ray'; return; } viewDrag = { - src: src, t0: performance.now(), armed: false, + src: src, key: srcKey(src), t0: performance.now(), armed: false, a0: null, yaw0: S.videoYaw, pitch0: S.videoPitch, moved: false }; S.stats.viewDrag = 'pressed (hold ' + VIEW_HOLD_MS + 'ms to pan)'; @@ -1535,6 +1567,7 @@ if (!p0) { S.stats.grab = 'no source point'; return; } grab = { src: src, + key: srcKey(src), p0: p0, place0: { y: S.subPlacement.y, z: S.subPlacement.z, width: S.subPlacement.width }, moved: false @@ -1655,6 +1688,13 @@ // hand's position. frame = frame || S.lastFrame; if (src) { + var excludeKey = srcKey(src); + if (excludeKey && + ((grab && grab.key && grab.key !== excludeKey) || + (viewDrag && viewDrag.key && viewDrag.key !== excludeKey))) { + S.stats.pressAt = 'IGNORED (other hand is holding)'; + return; + } if (frame) { try { updatePointer(frame, src); } catch (e) {} } if (!pointer || !pointer.visible) { S.stats.pressAt = 'MISS (acting source has no ray)'; @@ -1722,7 +1762,14 @@ var pressUntil = 0; - function pointerUp() { + // ADDENDUM 12: only the source that STARTED a hold ends it. A release from the + // other hand used to cancel the first hand's drag (subtitle grab / picture pan). + function pointerUp(src) { + var key = srcKey(src); + if (key) { + if (grab && grab.key && grab.key !== key) return; + if (viewDrag && viewDrag.key && viewDrag.key !== key) return; + } endGrab(); endViewDrag(); } @@ -1742,7 +1789,7 @@ var prev = padPrev.get(src) || false; padPrev.set(src, pressed); if (pressed && !prev) pointerDown(src, frame, 'gamepad'); - else if (!pressed && prev) pointerUp(); + else if (!pressed && prev) pointerUp(src); } } @@ -1750,8 +1797,8 @@ pointerDown(ev && ev.inputSource, S.lastFrame, 'select'); } - function onSelectEnd() { - pointerUp(); + function onSelectEnd(ev) { + pointerUp(ev && ev.inputSource); } /* ---------------- live subtitle setters (single source of truth) ---------------- */ // state.subPlacement / subAngleDeg are re-read from the module after every