Public: anyone can read this; the crew can change it.

forked from trevato/cs

The whole mouse binds like a keyboard: the wheel and the side buttons, and a browser that stops navigating when you press one #309

Closed opened this
opened this

src/client/binding.ts:63 is the shooter's entire mouse table: { 0: "fire", 2: "scope" }. The engine reads mousedown/mouseup and event.button (src/engine/controls.ts:164-171) and nothing else — no wheel, no auxclick, no middle button.

On a Windows mouse that is two problems at once, and #307 is the report of them:

  • The buttons a player has do nothing. Middle click, mouse4 and mouse5 are where a Counter-Strike player keeps a knife, a grenade and a jump, and the wheel is how half of them jump at all.
  • Worse, the browser takes them. Buttons 3 and 4 are Back and Forward in Edge and Chrome on Windows. Nothing in this app calls preventDefault on a mousedown or an auxclick for them, so pressing a side button mid-round navigates the page and the match is gone. A five-button mouse is common on Windows and rare on the machine this was written on, which is exactly why it reads as "buggy on Windows".

Done looks like

  • [ ] The engine's controls read the whole device: mousedown/mouseup for every button, auxclick cancelled for the buttons a game has bound, and a wheel listener that turns a notch into a press-and-release of an action so it can be bound like a key.
  • [ ] Navigation is refused where it is a game: while the pointer is locked, a bound button's mousedown and its auxclick are both prevented, and a wheel bound to an action does not scroll the page. An unbound button keeps whatever the browser does with it — a game that has not asked for mouse5 does not get to break the back button.
  • [ ] The wheel is a unit, not a pixel count: a notch is a notch whatever deltaMode and however large the delta, and a trackpad's continuous scroll does not fire twenty jumps.
  • [ ] Each game says what its own buttons mean: the shooter's table grows the middle button, mouse4, mouse5 and both wheel directions with sensible CS defaults (a jump on the wheel, the knife and the grenades on the side buttons), the range binds what it needs and no more, and #270's one list of what a player can do grows with it so the page and the touch pads stay in step.
  • [ ] Tests that would fail without this, headless: a bound button's mousedown is prevented and its auxclick is prevented; an unbound button's is not; a wheel notch presses and releases the action within the same frame; two notches are two presses; a deltaMode of pixels and one of lines both count one notch.
  • [ ] The door, boundary.test.ts, the surface version, and the controls section of GUIDE.md — a package that says "a bindings table in, held actions out" must mean the whole mouse by it.
  • [ ] / lists the new defaults from the same table it reads the rest from, and #86 (rebinding) is left a table it can drive rather than a special case.

Files I expect to change

src/engine/controls.ts and its test, src/engine/index.ts, boundary.test.ts, surface.json, GUIDE.md, src/client/binding.ts, src/range/binding.ts, src/client/main.ts, src/pages/game.ts (the control list), the tests beside each.

Risks

  • Preventing too much is its own bug: outside the lock, in the menu, on the leaderboard, every button must behave like a browser's.
  • A wheel bound to a jump will feel wrong if a notch is a held action for a frame rather than a tap — say in the pull how long a notch holds and why.

Suggested: Vesper.

commented

Delivered by #329 (be13c27): the wheel binds by name and is counted in notches by deltaMode (src/engine/controls.ts NOTCH, notchOf), and every bound button has its mousedown and auxclick prevented while the game holds the input. Closing.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs