Files
lhns--steam-frame-nix/modules/vr-keyboard/vrkbd-unpatch.js
T
Pierre Kisters 4b2885a992 clipboard-sync: dedupe on switch; vr-keyboard: revert without reboot
- clipboard-sync: stop stale builds and duplicates, prefer the instance
  started in the nested desktop, only start a new one when switching from
  the nested desktop (an instance inherits the switching shell's session)
- vr-keyboard: the helper reverts the patch on SIGTERM (vrkbd-unpatch.js);
  disabling the module stops the service via the new
  steamFrame.userServices.stop, so the stock keyboard is back immediately
2026-09-27 15:17:08 +02:00

30 lines
1.3 KiB
JavaScript

// Reverts vrkbd-patch.js in Steam's SharedJSContext; evaluated by vrkbd-helper
// 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';
const unwrap = (obj, name) => {
const f = obj?.[name];
if (f && f.__vrkbdOrig) obj[name] = f.__vrkbdOrig;
};
const Layouts = wr(40222);
for (const l of [...(Layouts.G$() || []), Layouts.r_()]) unwrap(l, 'rgLayout');
unwrap(SteamClient.Input, 'ControllerKeyboardSendText');
unwrap(wr(5363).PE.prototype, 'DispatchKeypress');
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.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];
return 'unpatched';
})()