Keyboard patch cleanup; arrow icons centered again

- drop cruft: v4 DispatchKeypress undo, unused VKM import and
  __vrkbdPatched flag, redundant VRKBD_DISPLAY env in the unit
- one wrap() helper for all replaced functions; key names for the
  stylesheet derived from the key definitions instead of repeated
- unpatch: restore every layout ever patched (also ones disabled since)
  and the remembered component class instead of walking the tree again
- helper: debounce re-injects after bursts of new JS contexts; resolve
  pending DevTools calls when the connection closes
- arrow icons vertically centered again (hint stays at the bottom edge)
- updated header comments
This commit is contained in:
Pierre Kisters committed 2026-09-27 15:43:29 +02:00
1 parent 630357b886
commit 7d8e2f14cf
4 files changed
+128 -143

No files matched your search

+13 -18
View File
@@ -1,20 +1,16 @@
# Esc/Ctrl/Alt and four arrow keys on Steam's VR keyboard.
# The keyboard is part of Steam's UI (hardcoded layouts in steamui JS), and in
# VR it can only send text; SteamClient.Input.ControllerKeyboardSetKeyState
# throws "Unknown method". So:
# - patch.js is injected at runtime into Steam's UI through its CEF
# DevTools port (127.0.0.1:8080; SteamOS starts Steam with
# -cef-enable-debugging). Steam's files are untouched, so updates don't undo
# it. It rebuilds the bottom row and, while Ctrl/Alt is active (or for Esc),
# hands the key combo to the helper instead of typing text. It also holds
# the real Ctrl/Alt down while the toggle is on (Ctrl+scroll), and routes
# characters Steam's key emulation turns into "1" (non-ASCII, AltGr/dead
# keys on the de keymap: |@{[]}\~^`äöü€…) to the helper.
# - helper.mjs keeps that injection alive (Steam restarts, keyboard popup
# recreated) and presses the combos with `xdotool key` on :0, where gamescope
# keeps X focus on the window selected in VR. It only accepts ctrl/alt
# chords and the extra keys, so the Steam UI can't use it to type text or
# press Enter.
# Runtime patch of Steam's on-screen (VR) keyboard. Steam's layouts are
# hardcoded in its UI, and in VR it can only send text (no Ctrl/Alt/Esc;
# SteamClient.Input.ControllerKeyboardSetKeyState throws "Unknown method").
# - patch.js is injected into Steam's running UI through its CEF DevTools port
# (127.0.0.1:8080; SteamOS starts Steam with -cef-enable-debugging); Steam's
# files are untouched. Bottom row: Esc Ctrl Alt [space] AltGr ← ↑ ↓ →, with
# AltGr + arrows = Pos1/PgUp/PgDn/End. Chords, Shift+arrows and characters
# Steam's key emulation turns into "1" (non-ASCII, AltGr/dead keys on the
# de keymap) are handed to the helper; Ctrl/Alt are held while toggled.
# - helper.mjs keeps the injection alive (Steam restarts, popup recreated),
# performs those requests with xdotool on :0 (X focus follows the window
# selected in VR) and reverts the patch when stopped (unpatch.js). Its
# allowlist can't type ASCII text or press Enter.
# Depends on Steam UI internals; tested with Steam client 1790377368.
{ config, pkgs, lib, ... }: {
imports = [ ./session.nix ];
@@ -39,7 +35,6 @@
"${./steam-keyboard-patch/unpatch.js}"
"${pkgs.xdotool}/bin/xdotool"
];
Environment = "VRKBD_DISPLAY=:0";
Restart = "always";
RestartSec = 5;
TimeoutStopSec = 5; # the helper unpatches Steam's UI on SIGTERM