mirror of
https://github.com/lhns/steam-frame-nix.git
synced 2026-10-06 02:00:13 +02:00
Opt-in with steamFrame.keyboard.vr.enable; swipe, autocorrect and completion suggestions, Backspace drag and haptics are on under it. - vr-keyboard/patch.js (Steam UI): swipe decoder, a model of what the keyboard typed, suggestions that only replace what they typed, Backspace drag with word detents and retyping; checks its Steam internals by signature (signatures.json: vr-keyboard) and stays stock otherwise. - vr-keyboard/panel.js (SteamVR systemui) + relay.mjs (user service vr-keyboard-relay): the suggestion strip as a dashboard panel below or above the keyboard (signatures: vr-keyboard-panel). - Dictionary built from nixpkgs' wordfreq and hunspellDicts; default: the keyboard.layout language (de, fr, es, it, nl, pt, sv) plus English. - Tests: keyboard.vr.checks and the flake check vr-keyboard.
18 lines
1.1 KiB
JavaScript
18 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/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 p of JSON.parse(readFileSync(pathsPath, 'utf8'))) {
|
|
const lay = D.layout(dict, p.keys, p.unit);
|
|
const res = D.decode(lay, p.pts, { unit: p.unit, max: 8 });
|
|
console.log(`${p.t}: 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)'}`);
|
|
}
|
|
}
|