Skip to content

tecs.controller: press and release actions when an axis crosses its own threshold - #17

Open
albanmgicquel wants to merge 2 commits into
tecs-dev:mainfrom
albanmgicquel:controller-axis-thresholds
Open

albanmgicquel wants to merge 2 commits into
tecs-dev:mainfrom
albanmgicquel:controller-axis-thresholds

Conversation

@albanmgicquel

Copy link
Copy Markdown
Collaborator

An axis binding can name its own threshold, as in axis:leftY+@0.5. Below the threshold it reads zero, and crossing it presses the action and falling back releases it. That lets a stick or a trigger drive a button with real press and release edges: a plunger pulled with a stick, or a flipper on a trigger. Bindings without @ are unchanged.

Changes

  • Bindings: axis:NAME@T, axis:NAME+@T and axis:NAME-@T, with T above zero and at most one. Below T the binding reads zero instead of using the controller's deadzone. A directional binding crosses on its own side, and a signed one crosses on either side. An invalid threshold raises when the mapping is created or rebound.
  • Edges: isPressed and isReleased report threshold crossings alongside the existing digital edges. getRaw reads a threshold binding against its own threshold.
  • Per-frame update: the edges advance in ControlManager:update(dt). An installed manager runs it once a frame in Ingress through a new system, tecs.UpdateControllers, after tecs.AssignControllers.
  • Fixed steps: tecs.EnterFixedControllers (FixedFirst) and tecs.ExitFixedControllers (FixedLast) switch queries to latched edges, as tecs.input does for key edges. A standalone manager calls update, enterFixedPhase and exitFixedPhase itself.
  • Capture layers: levels are read past capture layers, so opening a menu while the stick is held neither releases the action nor presses it again when the menu closes.
  • Compatibility: the three new system names are pinned in tests/tecs/compatibilitytest.nupp.
  • Docs: a new "Axis thresholds and edges" section in the binding guide, and the module introduction is updated.

Tests

  • New controller tests: edges on crossing, signed and directional axes, bindings without a threshold staying edgeless, latched edges in fixed steps, no edges invented across a capture layer, and threshold validation.
  • On macOS ARM64: nupp check and nupp task format-check are clean, nupp test passes all 1,061 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 plunger pulled with a stick, or a flipper on a trigger, has to arrive
as a key press and a key release, but axis bindings had no edges and one
deadzone served the whole controller. An axis binding may now name its
own threshold, as in axis:leftY+@0.5: below it the binding reads zero,
and crossing it presses the action and falling back releases it.
Bindings without a threshold are unchanged.

The manager advances the edges in update, which tecs.UpdateControllers
runs once a frame in Ingress after device assignment. Fixed steps read
latched edges through tecs.EnterFixedControllers and
tecs.ExitFixedControllers, as Input's latched key edges are; a
standalone manager calls update, enterFixedPhase and exitFixedPhase
itself. Levels are read past capture layers, so a menu neither releases
a held stick nor presses it again when it closes.
rebind rebuilt each threshold action's edges with the axis up, so a stick held past its threshold read as a new press at the next update. The new edges take the previous level of the same action.

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