From 3755ef572da275d9db0d0c8259a014d062eeb688 Mon Sep 17 00:00:00 2001 From: WofWca Date: Sat, 13 Dec 2025 10:50:49 +0000 Subject: [PATCH] improvement: no mouse acceleration Utilize [`unadjustedMovement`](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestPointerLock#unadjustedmovement). For reference also see https://github.com/emscripten-core/emscripten/issues/24602 I have not build the code but I checked that things still work by adding the following before the main `eval()` in dev tools: ```javascript const originalRequestPointerLock = HTMLElement.prototype.requestPointerLock; HTMLElement.prototype.originalRequestPointerLock = originalRequestPointerLock; HTMLElement.prototype.requestPointerLock = function() { this.originalRequestPointerLock({ unadjustedMovement: true }) } ``` --- source/main.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/main.js b/source/main.js index 83142f2..347cc1d 100755 --- a/source/main.js +++ b/source/main.js @@ -124,7 +124,13 @@ game_load = async () => { f.onclick = () => g.requestFullscreen(); g.onclick = () => { - g.onclick = () => c.requestPointerLock(); + g.onclick = async () => { + try { + await c.requestPointerLock({ unadjustedMovement: true }); + } catch (error) { + await c.requestPointerLock(); + } + }; g.onclick(); audio_init(); @@ -182,4 +188,4 @@ run_frame = (time_now) => { requestAnimationFrame(run_frame); }; -game_load(); \ No newline at end of file +game_load();