Files
lhns--steam-frame-nix/modules/vr-keyboard-extra-keys/tests/allowlist.test.mjs
T
Pierre Kisters aa8ccc67c9 VR keyboard F-keys: F1-F12 in the suggestion strip while AltGr is active
keyboard.vr.functionKeys.enable (default off): while AltGr (Fn on layouts
without AltGr) is one-shot, locked or held, the strip shows F1-F12 instead
of the suggestions. A tap types the extra key VKX_F<n>, which the extra
keys' patch presses with xdotool together with the active Ctrl/Alt/Shift
(Alt+F4, Ctrl+F5) and releases the toggles; the text model resets, like
for Esc. The suggestions are kept as they are meanwhile, so when AltGr goes
off the strip shows the same items and selection again.

- vr-keyboard/function-keys.js: what the strip shows, the F-key keys.
- patch.js (VERSION 27): the strip's view, F-key picks, AltGr changes via
  a componentDidUpdate on the keyboard instance (and the poll).
- Allowlist: F1-F12 with any modifiers; Enter still refused.
- relay.mjs: up to 12 strip items.
- Assertions: needs keyboard.vr.enable, extraKeys.enable and a strip
  position "above"/"below" ("inside" would hide the AltGr number row).
- Tests: function-keys.test.mjs (switching and restoring, keys against
  the allowlist, text model), allowlist F-key cases.
2026-10-01 03:53:01 +02:00

22 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// allowlist.mjs: what the xdotool helper accepts from Steam's UI JS.
// usage: node allowlist.test.mjs <allowlist.mjs>
import assert from 'node:assert/strict';
import { pathToFileURL } from 'node:url';
const { allowedCombo, allowedChar } = await import(pathToFileURL(process.argv[2]).href);
const accept = ['shift+Tab', 'ctrl+Tab', 'ctrl+shift+Tab', 'ctrl+shift+t', 'alt+f',
'shift+Left', 'Escape', 'Delete', 'shift+End', 'ctrl+BackSpace'];
// F-keys (keyboard.vr.functionKeys): any of them with any modifiers.
const mods = [[], ['ctrl'], ['alt'], ['shift'], ['ctrl', 'alt'], ['ctrl', 'shift'], ['alt', 'shift'], ['ctrl', 'alt', 'shift']];
for (let n = 1; n <= 12; n++) for (const m of mods) accept.push([...m, `F${n}`].join('+'));
const reject = ['Tab', 'shift+a', 'a', 'Return', 'shift+Return', 'ctrl+Return', 'shift+BackSpace',
'shift+shift+Tab', 'super+Tab', 'shift+space', 'ctrl+a+b',
'F0', 'F13', 'F24', 'f5', 'super+F4', 'ctrl+ctrl+F5', 'F5+Return', 'ctrl+alt+shift+Return'];
const acceptChar = ['ä', '€', '|', '@', '\\', '`'];
const rejectChar = ['a', 'A', '1', ' ', '\n', '\t', 'ab', ' '];
for (const c of accept) assert.equal(allowedCombo(c), true, `accepts key:${c}`);
for (const c of reject) assert.equal(allowedCombo(c), false, `rejects key:${c}`);
for (const c of acceptChar) assert.equal(allowedChar(c), true, `accepts type:${c}`);
for (const c of rejectChar) assert.equal(allowedChar(c), false, `rejects type:${JSON.stringify(c)}`);
console.log(`allowlist: ${accept.length + reject.length + acceptChar.length + rejectChar.length} cases passed`);