Files
lhns--steam-frame-nix/scripts/vr-keyboard-replay.mjs
T
Pierre Kisters 5d15902ba1 Clearer file names and layout; docs/development.md
- steam-keyboard-patch.nix -> vr-keyboard-extra-keys.nix (option
  keyboard.vr.extraKeys), helper.mjs -> xdotool-helper.mjs;
  homeManagerModules.steam-keyboard-patch stays as an alias.
- vr-keyboard: panel.js/unpatch-panel.js/relay.mjs ->
  suggestions-panel/{patch,unpatch}.js + relay.mjs; decoder.js ->
  swipe-decoder.js; build.nix split into dictionary.nix and check.nix.
- modules/lib -> modules/steam-ui-patches/lib (the UI patch library).
- docs/development.md: repository layout (what runs where), runtime names.

Patch names, user services and state files are unchanged.
2026-09-29 01:42:34 +02:00

19 lines
1.1 KiB
JavaScript

// Replays recorded swipes (window.__sfuiSwipePaths of Steam's SharedJSContext,
// saved as JSON) through the decoder: top candidates and the cost terms of
// the expected word. The dictionary is the built vr-keyboard-dictionary.js.
// usage: node scripts/vr-keyboard-replay.mjs modules/vr-keyboard/swipe-decoder.js
// <dictionary.js> <paths.json> [word]
import { readFileSync } from 'node:fs';
const [, , decoderPath, dictPath, pathsPath, expected] = process.argv;
const D = (0, eval)(readFileSync(decoderPath, 'utf8'));
const dict = D.parseDict(JSON.parse(readFileSync(dictPath, 'utf8')));
for (const [i, p] of JSON.parse(readFileSync(pathsPath, 'utf8')).entries()) {
const lay = D.layout(dict, p.keys, p.unit);
const res = D.decode(lay, p.pts, { unit: p.unit, max: 8 });
console.log(`#${i}: recorded ${p.top.join(' ')}\n now ${res.map((r) => `${r.word} ${r.cost.toFixed(2)}`).join(', ')}`);
if (expected) {
const f = D.decode(lay, p.pts, { unit: p.unit, features: true }).find((x) => x.word === expected);
console.log(` ${expected}: ${f ? JSON.stringify(f.f) : 'pruned (start/end key or a letter too far from the path)'}`);
}
}