VR keyboard: small Entf hint on the Delete key without AltGr

The key that becomes Delete on AltGr shows a small hint (the arrow hints'
7 px) on the baseline of Steam's AltGr hints, while the layout has such a
free key.
This commit is contained in:
Pierre Kisters committed 2026-09-28 04:07:56 +02:00
1 parent adbf53ea10
commit b987e822d0
3 files changed
+28 -14

No files matched your search

+2 -2
View File
@@ -461,8 +461,8 @@ reboot or Steam restart needed.
Shift + arrows select text.
- AltGr + the key left of Backspace (`´` on German, `=` on US): Delete,
labelled like Steam's Delete key in its language (`Entf`; `Del` if that is
longer); repeats while held. Layouts with an AltGr character on that key
get none.
longer), hinted on the key without AltGr; repeats while held. Layouts with
an AltGr character on that key get none.
- Ctrl/Alt chords and Esc are sent with `xdotool key` on `:0` (focus follows
the VR-selected window); a toggled Ctrl/Alt is held down while the
keyboard is open (e.g. Ctrl+scroll).
+22 -11
View File
@@ -21,7 +21,7 @@
// mkPatch patch (see lib/default.nix); no options. On a signature mismatch
// it returns an error and changes nothing. Idempotent.
((find, sigs) => {
const VERSION = 14;
const VERSION = 16;
const send = (msg) => window.__vrkbdKey && window.__vrkbdKey(msg);
let mods;
try {
@@ -95,19 +95,24 @@
// its type with an empty AltGr entry.
const keepSize = (x) => (Array.isArray(x) && x.length < 3 && first(x)?.type != null
? [x[0], x[1] ?? null, { key: '', label: '', type: first(x).type }] : x);
// Without AltGr the free key shows a small Delete hint (stylesheet, like
// the arrows' AltGr hints), enabled by the class vrkbd-del-hint on the
// keyboard document while the current layout has such a key.
const withDelete = (rows) => {
const kb = window.__vrkbdRendering;
const altGr = active(kb?.state?.toggleStates?.AltGr);
if (!kb || !(altGr || kb.__vrkbdDelHold)) return rows;
if (!kb) return rows;
const bsRow = rows.findIndex((row) => row.some((x) => !Array.isArray(x) && x?.key === 'Backspace'));
const i = bsRow < 0 ? -1 : rows[bsRow].findIndex((x) => !Array.isArray(x) && x?.key === 'Backspace');
const free = i >= 1 && freeOnAltGr(rows[bsRow][i - 1]);
try { kb.m_keyboardDiv?.ownerDocument?.documentElement.classList.toggle('vrkbd-del-hint', free); } catch { /* no document */ }
const altGr = active(kb.state?.toggleStates?.AltGr);
if (!(altGr || kb.__vrkbdDelHold)) return rows;
if (altGr) rows = rows.map((row) => row.map(keepSize));
let done = false;
return rows.map((row) => {
const i = done ? -1 : row.findIndex((x) => !Array.isArray(x) && x?.key === 'Backspace');
if (i < 0) return row;
done = true;
if (i < 1 || !freeOnAltGr(row[i - 1])) return row;
return [...row.slice(0, i - 1), { key: DEL, label: delLabel(), type: row[i].type }, ...row.slice(i)];
});
if (!free) return rows;
const row = rows[bsRow];
rows = [...rows];
rows[bsRow] = [...row.slice(0, i - 1), { key: DEL, label: delLabel(), type: row[i].type }, ...row.slice(i)];
return rows;
};
window.__vrkbdLayouts ??= new Set(); // for unpatch.js, incl. layouts disabled since
for (const l of [...(Layouts.enabledLayouts() || []), Layouts.currentLayout()]) {
@@ -207,6 +212,12 @@
`[data-key="${DEL}"] { width: 0 !important; flex-grow: 1 !important; }`,
`[data-key="${DEL}"] > div { justify-content: center !important; text-align: center !important; }`,
`[data-key="${DEL}"] > div > span { margin: 0 !important; }`,
// Delete hint on the free key without AltGr: the arrow hints' size, on
// the baseline of Steam's AltGr hints (e.g. } on 0: right/bottom 4px,
// 9px, line-height normal; 1px more for 7px's shorter descent).
`.vrkbd-del-hint [role="gridcell"]:has(+ [role="gridcell"] > [data-key="Backspace"]) > [data-key]:not([data-key="${DEL}"]) > div::after {` +
` content: ${JSON.stringify(delLabel())}; position: absolute; right: 4px; bottom: 5px; font-size: 7px; line-height: normal;` +
' opacity: 0.45; pointer-events: none; }',
].join('\n');
// ---- key handling ----------------------------------------------------------
+4 -1
View File
@@ -26,7 +26,10 @@
if (refs?.currentLayout) inst.setState({ standardLayout: refs.currentLayout() });
inst.forceUpdate();
}
for (const p of g_PopupManager.GetPopups?.() || []) p.window?.document.getElementById('vrkbd-style')?.remove();
for (const p of g_PopupManager.GetPopups?.() || []) {
p.window?.document.getElementById('vrkbd-style')?.remove();
p.window?.document.documentElement.classList.remove('vrkbd-del-hint');
}
for (const k of ['__vrkbdHoldTimer', '__vrkbdHeld', '__vrkbdInst', '__vrkbdProto', '__vrkbdLayouts', '__vrkbdRefs', '__vrkbdRendering']) delete window[k];
return 'unpatched';
})()