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

+7 -12
View File
@@ -2,28 +2,23 @@
// when it stops (service stopped, module disabled). Every patched function
// keeps its original as __vrkbdOrig. Safe to run when nothing is patched.
(() => {
const wr = window.__vrkbdWr;
if (!wr) return 'not patched';
if (!window.__vrkbdWr) return 'not patched';
const unwrap = (obj, name) => {
const f = obj?.[name];
if (f && f.__vrkbdOrig) obj[name] = f.__vrkbdOrig;
if (f?.__vrkbdOrig) obj[name] = f.__vrkbdOrig;
};
const Layouts = wr(40222);
for (const l of [...(Layouts.G$() || []), Layouts.r_()]) unwrap(l, 'rgLayout');
for (const l of window.__vrkbdLayouts || []) unwrap(l, 'rgLayout');
unwrap(SteamClient.Input, 'ControllerKeyboardSendText');
unwrap(wr(5363).PE.prototype, 'DispatchKeypress');
unwrap(window.__vrkbdProto, 'TypeKeyInternal');
clearInterval(window.__vrkbdHoldTimer);
const inst = window.__vrkbdInst;
if (inst) {
let proto = Object.getPrototypeOf(inst);
while (proto && !Object.prototype.hasOwnProperty.call(proto, 'TypeKeyInternal')) proto = Object.getPrototypeOf(proto);
unwrap(proto, 'TypeKeyInternal');
delete inst.__vrkbd;
inst.setState({ standardLayout: Layouts.r_() });
inst.setState({ standardLayout: window.__vrkbdWr(40222).r_() });
inst.forceUpdate();
}
for (const p of g_PopupManager.GetPopups?.() || []) p.window?.document.getElementById('vrkbd-style')?.remove();
for (const k of ['__vrkbdHoldTimer', '__vrkbdHeld', '__vrkbdInst', '__vrkbdPatched']) delete window[k];
for (const k of ['__vrkbdHoldTimer', '__vrkbdHeld', '__vrkbdInst', '__vrkbdProto', '__vrkbdLayouts']) delete window[k];
return 'unpatched';
})()