Skip to content

tecs.controller: read a controller's mapping back and report its conflicts - #18

Open
albanmgicquel wants to merge 1 commit into
tecs-dev:mainfrom
albanmgicquel:controller-readback
Open

albanmgicquel wants to merge 1 commit into
tecs-dev:mainfrom
albanmgicquel:controller-readback

Conversation

@albanmgicquel

Copy link
Copy Markdown
Collaborator

A controls screen has to show what each action is bound to, and warn when two actions share an input. This adds three read-only queries to Controller.

Changes

  • getActions() returns the mapping's action names, sorted.
  • getBindings(action) returns a copy of one action's binding strings in declaration order, or an empty list for an unknown action.
  • getConflicts() returns every pair of actions that one physical input triggers together, as Conflict records (first, second, binding), sorted by first action and then second. Keys, mouse buttons and gamepad buttons overlap when they name the same control. Axis bindings overlap on the same axis unless they read opposite halves. Conflicts are reported, never refused, since a player editing their bindings holds one for a moment. Two controllers never conflict, so a game that switches mappings for a menu checks each mapping on its own.
  • Docs: a new "Reading the mapping back" section in the binding guide, and Conflict is listed in the API page.

Tests

  • New controller tests: action names and bindings read back (returned lists are copies), and conflicts across keys, buttons, mouse buttons and axis halves.
  • On macOS ARM64: nupp check and nupp task format-check are clean, nupp test passes all 1,059 tests in 88 suites, and test-tools passes 10.
  • The nine headless component smokes in verify (ex-host through ex-shapes, 5 frames each) exit 0.
  • docs-check doesn't run in my local setup: it stops on a missing lunamark rock in the Nupp checkout, and main stops there too. The Rust gates weren't run, since this PR changes no Rust.

A controls screen shows what each action is bound to, lets a player
change it, and warns when two actions share an input. getActions returns
the action names sorted, getBindings a copy of one action's list, and
getConflicts the pairs of actions one key, mouse button, gamepad button
or overlapping axis triggers together. Conflicts are reported rather
than refused, since a player mid-edit holds one for a moment.

This branch has not been deployed

No deployments
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