Skip to content

Bind Pointer actions like Keyboard and Gamepad, and group devices in Controls - #63

Merged
SandroMaglione merged 1 commit into
mainfrom
feat/pointer-actions
Oct 23, 2026
Merged

SandroMaglione merged 1 commit into
mainfrom
feat/pointer-actions

Conversation

@SandroMaglione

Copy link
Copy Markdown
Member

Why

Pointer was the only device without bindings, actions or used, so it couldn't join a Controls merge. Merging the mouse as a separate device would also make lastUsed and available flicker while the player walks with the keyboard and aims with the mouse.

What

Pointer

  • Pointer.actions(target, blurHost, bindings, options?) replaces track. The snapshot is { actions, buttons, position, over, used }.
  • The back and forward buttons are added, with Pointer.buttonNames and isButton.
  • rebind and parseRebinding work as on Keyboard and Gamepad.
  • idle, scripted and recording now take the bindings first. Timelines still name buttons.

Controls

  • actions.group({ keyboard, mouse }) makes one merge entry. Its bindings are the union of its devices' bindings, and lastUsed and available follow the group as a whole.
  • devices, rebind and idle stay keyed by device name; lastUsed uses the group name.
  • lacking(group(...), [...]) covers actions none of the grouped devices binds.
  • These don't compile, each with an error naming the fix:
    • a group of fewer than two devices;
    • a lacking device inside a group;
    • a group nested in a group;
    • a grouped device that binds an undeclared action;
    • a name used twice across devices and groups.

Internal and integration

  • Gamepad and Pointer now share one button tracker (internal/buttons.ts): the same press, rebind and parse rules.
  • integration/top-down groups a mouse click (interact) with the keyboard. A test collects a pickup by clicking while walking, with lastUsed staying on desktop.
  • The unreleased Check that a drained service is drained once, at compile time and at run time #62 changeset is updated for the Pointer.Actions rename.

Checks

  • pnpm run check (632 tests, with type tests for every error above)
  • pnpm pack:check
  • pnpm bench --compare against main: no blocking regressions. Type metrics are unchanged; the benches don't cover the browser package.

🤖 Generated with Claude Code

…Controls

Pointer.actions(target, blurHost, bindings) reports bound actions, raw
buttons (with back and forward), position, and used, with rebind and
parseRebinding, so the mouse merges into Controls. actions.group makes
devices used together (keyboard and mouse) one merge entry for lastUsed
and available, with devices and rebind keyed by device name. Gamepad and
Pointer share one button tracker. The top-down integration groups a mouse
click with the keyboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SandroMaglione
SandroMaglione merged commit 852ac49 into main Oct 23, 2026
2 checks passed
@SandroMaglione
SandroMaglione deleted the feat/pointer-actions branch October 23, 2026 01:38
SandroMaglione added a commit that referenced this pull request Oct 23, 2026
…demo

main (#63) groups devices in Controls: the top-down controls now take a
keyboard, a mouse, and a gamepad. The browser host binds Pointer actions
on its canvas, and the devtools page's scripted run passes a scripted
mouse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant