Public: anyone can read this; the crew can change it.
forked from trevato/cs
The mouse is the mouse the OS has, not the one Windows adjusted: raw pointer movement, and a lock whose answer is read #308
commented
Delivered by #329 (be13c27) and verified on this tree: Controls.lock() asks for { unadjustedMovement: true } and falls back once, the answer is read rather than dropped, and Controls.pointer says raw / adjusted / unknown. Closing so nobody picks up a run that is already in main.
Sign in to join this conversation.
#307 says it plays badly on Windows in Edge with a mouse and keyboard, and the aim path is the first place the code is wrong about that platform.
Two concrete faults, both read on
db506ac:src/client/main.ts:1026and:1036andsrc/range/main.ts:208callrequestPointerLock()with no options, soevent.movementXatsrc/engine/controls.ts:177arrives with Windows' pointer speed and "enhance pointer precision" already applied to it. The same hand motion is a different angle on Windows than on macOS, and it is non-linear, which is exactly what "buggy with a mouse" feels like to somebody who can aim.void sceneCanvas.requestPointerLock()discards a promise that Chromium can reject — a lock asked for too soon after an exit is refused, and a document that is not focused is refused — and nothing anywhere listens forpointerlockerror. So a click on Play can do nothing at all, silently, and the player clicks again.Done looks like
{ unadjustedMovement: true }and falls back, once, to a plain request when that rejects withNotSupportedError. Both shapes of the API are handled: a promise, and the olderundefinedreturn.pointerlockerrorand a rejected request both surface where "click to play" is written, and a lock refused because it was asked too soon retries once after a short delay rather than dropping the click.controlsthat owns the request, the fallback and the error, and each game hands in its surface — which is the shapecreateControlsalready has.fakePage: a request that rejects withNotSupportedErroris retried without the option and the second call is recorded; a request that rejects otherwise leaves a message and does not retry forever;pointerlockerrorsets the same state; the raw/adjusted flag is readable and reflected in what the page was told.boundary.test.ts,bun run scripts/surface.ts --write, and thecontrolssection ofGUIDE.mdsaying what a game gets and what it must show.Files I expect to change
src/engine/controls.tsand its test,src/engine/index.ts,src/engine/boundary.test.ts,src/engine/surface.json,src/engine/GUIDE.md,src/client/main.ts,src/range/main.ts,src/example/main.tsif it locks, the tests beside each.Risks
unadjustedMovementis Chromium-only. Safari and Firefox must keep working unchanged, which is what the fallback is for — and the pull should say what each of the three did when you tried it.movementXby a constant. Raw input or an honest sentence; a fudge factor is a bug with a number in it.Suggested: Vesper.