Skip to content

FIX: uum 138143 button press points for stickcontrol and vector2 add functionality#2411

Open
Darren-Kelly-Unity wants to merge 42 commits into
developfrom
bugfix/uum-138143-button-press-points-for-stickcontrol-and-vector2-add-functionality
Open

FIX: uum 138143 button press points for stickcontrol and vector2 add functionality#2411
Darren-Kelly-Unity wants to merge 42 commits into
developfrom
bugfix/uum-138143-button-press-points-for-stickcontrol-and-vector2-add-functionality

Conversation

@Darren-Kelly-Unity
Copy link
Copy Markdown
Collaborator

@Darren-Kelly-Unity Darren-Kelly-Unity commented Apr 29, 2026

Purpose of this PR

Fixes UUM-138143InputAction.IsPressed() / in-progress style checks could fire at the wrong effective magnitude for Vector2 / stick bindings when developers set pressPoint on the control or on PressInteraction, instead of honoring those thresholds consistently.

Introduces IActuationPressPoint, implements it on ButtonControl, Vector2Control, and (via Vector2Control) StickControl, and threads pressPoint / pressPointOrDefault through InputAction, InputActionState, and InputControlExtensions so press-style polling matches the documented interaction defaults. Adds ActuationPressPointTests and refreshes RespondingToActions.md.

Release Notes

  • UUM-138143InputAction.IsPressed() (and related press / in-progress behavior) for actions bound to Vector2Control and StickControl now respects per-control pressPoint and binding PressInteraction.pressPoint, aligning with ButtonControl and fixing incorrect early triggers when rewriting default interaction thresholds.

Functional Testing status

  • Automated: new ActuationPressPointTests and updates in CoreTests_Actions / CoreTests_Controls cover press-point actuation paths.
  • Manual: repro project IN-136917 / scene Input Bug from the ticket; verify console no longer shows IsPressed before processed magnitude reaches the configured press threshold for vector / stick cases.

Performance Testing Status

I have added performance testing for the hot path methods that Hakan flagged and I don't see any major issues when comparing. There is a slight increase in cost of performance of about 0.1ms for 1000 iterations on the GetActuationPressThreshold() method that was asked to be checked.

No new per-frame allocations identified in scope.

Overall Product Risks

Technical Risk: 2 — Touches InputActionState and widely used press APIs; edge cases around magnitude, deadzones, and interactions need regression confidence.

Halo Effect: 2 — Any title using IsPressed / WasPressedThisFrame on Vector2 / stick actions may see timing changes until bindings are tuned; behavior is intended to match documented pressPoint semantics.

Class diagram

Git range analyzed: origin/develop...HEAD (4 commits).

Mermaid class diagram (GitHub)
classDiagram
  direction TB

  class IActuationPressPoint {
    <<interface>>
    +pressPoint
    +pressPointOrDefault
  }

  class ButtonControl {
    +pressPoint
    +pressPointOrDefault
  }

  class Vector2Control {
    +pressPoint
    +pressPointOrDefault
  }

  class StickControl {
  }

  class InputAction {
    +IsPressed()
    +WasPressedThisFrame()
    +WasReleasedThisFrame()
  }

  class InputActionState {
  }

  class InputControlExtensions {
    <<static>>
  }

  IActuationPressPoint <|.. ButtonControl
  IActuationPressPoint <|.. Vector2Control
  Vector2Control <|-- StickControl
  InputAction --> InputActionState : uses
  InputControlExtensions ..> IActuationPressPoint : pressPointOrDefault
Loading

Documentation Impact

Changes analyzed: origin/develop...HEAD (4 commits).

User-facing: New public IActuationPressPoint; InputAction press-helper remarks/behavior; ButtonControl, Vector2Control, StickControl docs around pressPoint; RespondingToActions.md updated for polling vs pressPoint.

Documentation updates in this PR

  • RespondingToActions.md — Clarifies IsPressed / frame helpers vs interactions and pressPoint; review wording and cross-refs after merge.

Follow-up (optional)

  • If QA/docs want a dedicated IActuationPressPoint callout in a control reference page, add a short subsection and link from Responding to Actions.

Jira (fetched via MCP): Bug, In Progress, TBD priority, assignee Darren Kelly, label Input-Actions. Ticket summary: InputAction.IsPressed() and IsInProgress() triggers on wrong values when rewriting the default values of Vector2 interactions.

@u-pr
Copy link
Copy Markdown
Contributor

u-pr Bot commented Apr 29, 2026

⚠️ Review skipped — this PR is too large to process.

The diff contains approximately 325,668 tokens (~977,005 characters), which exceeds the maximum limit of 150,000 tokens.

Please consider splitting this PR into smaller, focused changes.

🤖 Helpful? 👍/👎

@codecov-github-com
Copy link
Copy Markdown

codecov-github-com Bot commented Apr 29, 2026

Codecov Report

Attention: Patch coverage is 72.14137% with 134 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...sets/Tests/InputSystem/ActuationPressPointTests.cs 57.46% 131 Missing ⚠️
Assets/Tests/InputSystem/CoreTests_Actions.cs 97.24% 3 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2411      +/-   ##
===========================================
+ Coverage    78.13%   78.91%   +0.78%     
===========================================
  Files          483      756     +273     
  Lines        98770   139229   +40459     
===========================================
+ Hits         77169   109867   +32698     
- Misses       21601    29362    +7761     
Flag Coverage Δ
inputsystem_MacOS_6000.0 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.0_project 77.24% <70.28%> (-0.07%) ⬇️
inputsystem_MacOS_6000.3 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.3_project 77.23% <70.28%> (-0.04%) ⬇️
inputsystem_MacOS_6000.4 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.4_project 77.24% <70.28%> (-0.04%) ⬇️
inputsystem_MacOS_6000.5 5.31% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.5_project 77.28% <70.28%> (-0.04%) ⬇️
inputsystem_MacOS_6000.6 5.31% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.6_project 77.28% <70.28%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.0 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.0_project 77.14% <70.28%> (-0.07%) ⬇️
inputsystem_Ubuntu_6000.3 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.3_project 77.14% <70.28%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.4 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.4_project 77.15% <70.28%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.5 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.5_project 77.18% <70.28%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.6 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.6_project 77.18% <70.28%> (-0.04%) ⬇️
inputsystem_Windows_6000.0 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.0_project 77.36% <70.28%> (-0.07%) ⬇️
inputsystem_Windows_6000.3 5.32% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.3_project 77.36% <70.28%> (-0.04%) ⬇️
inputsystem_Windows_6000.4 5.33% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.4_project 77.36% <70.28%> (-0.05%) ⬇️
inputsystem_Windows_6000.5 5.31% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.5_project 77.41% <70.28%> (-0.04%) ⬇️
inputsystem_Windows_6000.6 5.31% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.6_project 77.41% <70.28%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Tests/InputSystem/CoreTests_Controls.cs 99.80% <100.00%> (-0.02%) ⬇️
...tsystem/InputSystem/Runtime/Actions/InputAction.cs 92.81% <100.00%> (ø)
...em/InputSystem/Runtime/Actions/InputActionState.cs 92.44% <100.00%> (ø)
...m/Runtime/Actions/Interactions/PressInteraction.cs 88.60% <ø> (ø)
...stem/InputSystem/Runtime/Controls/ButtonControl.cs 88.37% <100.00%> (ø)
...tSystem/Runtime/Controls/InputControlExtensions.cs 76.12% <100.00%> (ø)
...ystem/InputSystem/Runtime/Controls/StickControl.cs 100.00% <ø> (ø)
...tem/InputSystem/Runtime/Controls/Vector2Control.cs 100.00% <100.00%> (ø)
Assets/Tests/InputSystem/CoreTests_Actions.cs 98.89% <97.24%> (+0.48%) ⬆️
...sets/Tests/InputSystem/ActuationPressPointTests.cs 57.46% <57.46%> (ø)

... and 256 files with indirect coverage changes

ℹ️ Need help interpreting these results?

@Darren-Kelly-Unity Darren-Kelly-Unity changed the title Bugfix/uum 138143 button press points for stickcontrol and vector2 add functionality FIX: uum 138143 button press points for stickcontrol and vector2 add functionality Apr 29, 2026
…-stickcontrol-and-vector2-add-functionality

# Conflicts:
#	Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/InputControlExtensions.cs
Copy link
Copy Markdown
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Darren-Kelly-Unity Would it be possible to get rid of all the whitespace diffs on this PR? It would be much easier to review if this was corrected.

Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputAction.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/ButtonControl.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/ButtonControl.cs Outdated
Copy link
Copy Markdown
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed, I had quite a lot of questions and some remaining from last review so leaving this as comment-only for now.

/// <summary>
/// Effective press threshold: <see cref="pressPoint"/> when set, otherwise the global default.
/// </summary>
float pressPointOrDefault { get; }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need two? Would it be better to have one, e.g. pressPoint that returns default if not having a layout-configured press threshold? Since both go through an interface anyway I wouldn't expect it to be an optimisation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just following the format that was already there for now, not sure about removing one as it was publicly available before.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it was public we cannot remove it now (unless it fits a scheme to deprecate), but I am afraid two variants creates confusion around the interface contract that a user should implement.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if the new interface only implemented the previous implicit function:
pressPointOrDefault wouldn't this still work since it takes the same value if available and otherwise fall back?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since if (control is IActuationPressPoint actuation) is the new condition also covering Button?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try that and see if it works, you may be right yes!

Comment thread Packages/com.unity.inputsystem/InputSystem/Controls/IActuationPressPoint.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputActionState.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputActionState.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Vector2Control.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Vector2Control.cs Outdated
…ctor2Control.cs

Co-authored-by: Håkan Sidenvall <hakan.sidenvall@unity3d.com>
|[`InputAction.IsPressed()`](xref:UnityEngine.InputSystem.InputAction.IsPressed)|True if the level of [actuation](xref:UnityEngine.InputSystem.InputControl.EvaluateMagnitude) on the action has crossed the applicable press point and did not yet fall to or below the [release threshold](xref:UnityEngine.InputSystem.InputSettings.buttonReleaseThreshold).|
|[`InputAction.WasPressedThisFrame()`](xref:UnityEngine.InputSystem.InputAction.WasPressedThisFrame)|True if the level of [actuation](xref:UnityEngine.InputSystem.InputControl.EvaluateMagnitude) on the action has, at any point during the current frame, reached or gone above the applicable press point.|
|[`InputAction.WasReleasedThisFrame()`](xref:UnityEngine.InputSystem.InputAction.WasReleasedThisFrame)|True if the level of [actuation](xref:UnityEngine.InputSystem.InputControl.EvaluateMagnitude) on the action has, at any point during the current frame, gone from being at or above the applicable press point to at or below the [release threshold](xref:UnityEngine.InputSystem.InputSettings.buttonReleaseThreshold).|
The applicable press point is chosen from, in order: a positive [`pressPoint`](xref:UnityEngine.InputSystem.Controls.ButtonControl.pressPoint) on the driving control when it is a [ButtonControl](xref:UnityEngine.InputSystem.Controls.ButtonControl), or a positive [`pressPoint`](xref:UnityEngine.InputSystem.Controls.Vector2Control.pressPoint) when it is a [Vector2Control](xref:UnityEngine.InputSystem.Controls.Vector2Control) or [StickControl](xref:UnityEngine.InputSystem.Controls.StickControl); otherwise, if the binding lists one or more [Press](xref:UnityEngine.InputSystem.Interactions.PressInteraction) interactions, the `pressPoint` from the first in the binding's interaction order whose `pressPoint` is greater than zero (any interactions before it that are not `Press`, or `Press` with the default `pressPoint` of zero, are skipped for this step); otherwise [defaultButtonPressPoint](xref:UnityEngine.InputSystem.InputSettings.defaultButtonPressPoint). On [composites](xref:input-system-action-bindings#composite-bindings), interaction parameters are taken from the composite binding.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the generated preview put that line in the array.

Image

Make sure to add doc to review the doc changes

///
/// Finally, note that custom button press points of controls (see <see cref="ButtonControl.pressPoint"/>)
/// are respected and will take precedence over <see cref="InputSettings.defaultButtonPressPoint"/>.
/// Press threshold (based on <see cref="InputControl.EvaluateMagnitude()"/> for the driving control): for a
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1st copy-paste from line 1157. This is a maintenance burden.
I'd recommend going for only defining for IsPressed() and then just a oneline:
/// The press threshold is resolved as described in remarks.
This is what you did for WasPressedThisDynamicUpdate and WasReleasedThisDynamicUpdate.

Note that the block (starting by Also note that because ...) above is also duplicated and would benefit from the same treatment.

///
/// Finally, note that custom button press points of controls (see <see cref="ButtonControl.pressPoint"/>)
/// are respected and will take precedence over <see cref="InputSettings.defaultButtonPressPoint"/>.
/// Press threshold (based on <see cref="InputControl.EvaluateMagnitude()"/> for the driving control): for a
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd copy-paste from line 1157. Same as above.

///
/// Finally, note that custom button press points of controls (see <see cref="ButtonControl.pressPoint"/>)
/// are respected and will take precedence over <see cref="InputSettings.defaultButtonPressPoint"/>.
/// Press threshold (based on <see cref="InputControl.EvaluateMagnitude()"/> for the driving control): for a
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very dense, even with the formatting in doc. I had to write it down myself and split it in a bullet point to understand. I don't know if it's possible to have a numbered list in xml doc? Would be a question for doc team.

I asked Claude, supposedly this is the way in xml doc:

/// The press threshold is resolved in priority order:
/// <list type="number">
/// <item>A positive <see cref="ButtonControl.pressPoint"/> or <see cref="Vector2Control.pressPoint"/>
/// on the driving control.</item>
/// <item>The <see cref="PressInteraction.pressPoint"/> from the first
/// <see cref="PressInteraction"/> on the binding with a value greater than zero.
/// For composites, interactions are read from the composite binding.</item>
/// <item><see cref="InputSettings.defaultButtonPressPoint"/>.</item>
/// </list>

However I am doubtful that our in house documentation parser is able to work with it because it only support a subsets of tag and rules.

/// <see cref="UnityEngine.InputSystem.InputAction.IsPressed"/> when this control drives the action.
/// </summary>
/// <remarks>
/// By default, this property is set to -1. If the value of the property is negative,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
/// By default, this property is set to -1. If the value of the property is negative,
/// By default, this field is set to -1. If the value of the property is negative,

@MorganHoarau
Copy link
Copy Markdown
Collaborator

The tickets mentions a deadzone issue: "Deadzone(0.3) WasPerformedThisFrame triggers incorrectly at Magnitude 0.000".

Have you tried to repro that issue? I could not find tests for it.

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.

4 participants