Skip to content

Commit ee0f8f5

Browse files
Add doc changes and changelog entry.
1 parent fdea0bc commit ee0f8f5

5 files changed

Lines changed: 50 additions & 46 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2828
- Fixed an issue where `UIToolkit` `ClickEvent` could be fired on Android after device rotation due to inactive touch state being replayed during action initial state checks [UUM-100125](https://jira.unity3d.com/browse/UUM-100125).
2929
- Fixed InputSystem.onAnyButtonPress fails to trigger when the device receives a touch [UUM-137930](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-137930).
3030
- Fixed an incorrect ArraysHelper.HaveDuplicateReferences implementation that didn't use its arguments right [ISXB-1792] (https://github.com/Unity-Technologies/InputSystem/pull/2376)
31+
- Fixed `InputAction.IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` using the control's `pressPoint` when a binding also had an explicit `PressInteraction` with its own `pressPoint`, which could make those APIs disagree with the interaction's press and release behavior. Action-level press APIs now follow the interaction threshold when both are set explicitly.
3132

3233
### Changed
3334
- Removed 32-bit compilation check for HID on Windows players, which had no impact anymore. (ISX-2543)

Packages/com.unity.inputsystem/Documentation~/RespondingToActions.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ Finally, there are three methods you can use to poll for button presses and rele
9090

9191
The applicable press point is chosen from, in order:
9292

93-
1. A positive [`pressPoint`](xref:UnityEngine.InputSystem.Controls.ButtonControl.pressPoint) on the driving control when it is a [ButtonControl](xref:UnityEngine.InputSystem.Controls.ButtonControl).
94-
2. 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).
95-
3. If the binding lists one or more [Press](xref:UnityEngine.InputSystem.Interactions.PressInteraction) interactions, the `pressPoint` from the first interaction order whose `pressPoint` is greater than zero (any interactions before this that are either not `Press`, or `Press` with the default `pressPoint` of zero, are skipped for this step).
96-
4. [defaultButtonPressPoint](xref:UnityEngine.InputSystem.InputSettings.defaultButtonPressPoint).
93+
1. If the binding lists one or more [Press](xref:UnityEngine.InputSystem.Interactions.PressInteraction) interactions, the `pressPoint` from the first `Press` interaction in list order whose `pressPoint` is greater than zero (any interactions before this that are either not `Press`, or `Press` with the default `pressPoint` of zero, are skipped) so action-level press APIs stay aligned with the interaction.
94+
2. Otherwise, the driving [ButtonControl](xref:UnityEngine.InputSystem.Controls.ButtonControl), [Vector2Control](xref:UnityEngine.InputSystem.Controls.Vector2Control), or [StickControl](xref:UnityEngine.InputSystem.Controls.StickControl) [`pressPointOrDefault`](xref:UnityEngine.InputSystem.Controls.ButtonControl.pressPointOrDefault).
95+
3. [defaultButtonPressPoint](xref:UnityEngine.InputSystem.InputSettings.defaultButtonPressPoint).
9796

9897
On [composites](xref:input-system-action-bindings#composite-bindings), interaction parameters are taken from the composite binding.
9998

99+
[`InputControl.IsPressed`](xref:UnityEngine.InputSystem.InputControlExtensions.IsPressed) on a control always uses that control's threshold and does not consider binding interactions.
100+
100101
This example uses three actions called Shield, Teleport and Submit (which are not included in the [default actions](xref:project-wide-actions#the-default-actions)):
101102

102103
```CSharp

Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputAction.cs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,18 +1156,18 @@ public void Reset()
11561156
///
11571157
/// Press threshold (based on <see cref="InputControl.EvaluateMagnitude()"/> for the driving control):
11581158
///
1159-
/// 1. For a <see cref="ButtonControl"/>, <see cref="Vector2Control"/>, or <see cref="StickControl"/>, consult
1160-
/// <see cref="ButtonControl.pressPoint"/> / <see cref="ButtonControl.pressPointOrDefault"/> or
1161-
/// <see cref="Vector2Control.pressPoint"/> / <see cref="Vector2Control.pressPointOrDefault"/> (sticks use the vector rules)
1162-
/// when a positive control <c>pressPoint</c> is set.
1163-
/// 2. If not set on the control but the binding has a <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1164-
/// with <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> greater than zero, use that value so this
1165-
/// API stays aligned with the interaction.
1166-
/// 3. If the binding lists several <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1167-
/// instances, use the first in interaction list order with an explicit
1168-
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> greater than zero.
1169-
/// 4. For composite bindings, read interaction parameters from the composite binding.
1170-
/// 5. Otherwise use <see cref="InputSettings.defaultButtonPressPoint"/>.
1159+
/// 1. If the binding lists one or more <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1160+
/// instances, use the <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> from the first
1161+
/// in interaction list order whose <c>pressPoint</c> is greater than zero (earlier interactions that are not
1162+
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>, or that leave <c>pressPoint</c> at the
1163+
/// default of zero, are skipped) so this API stays aligned with the interaction.
1164+
/// 2. Otherwise, for a <see cref="ButtonControl"/>, <see cref="Vector2Control"/>, or <see cref="StickControl"/>, use
1165+
/// <see cref="ButtonControl.pressPointOrDefault"/> or <see cref="Vector2Control.pressPointOrDefault"/>.
1166+
/// 3. For composite bindings, read interaction parameters from the composite binding.
1167+
/// 4. Otherwise use <see cref="InputSettings.defaultButtonPressPoint"/>.
1168+
///
1169+
/// <see cref="InputControl.IsPressed"/> on the control itself always uses the control threshold and does not
1170+
/// consider binding interactions.
11711171
///
11721172
/// <example>
11731173
/// <code>
@@ -1244,18 +1244,18 @@ private int ExpectedFrame()
12441244
///
12451245
/// Press threshold (based on <see cref="InputControl.EvaluateMagnitude()"/> for the driving control):
12461246
///
1247-
/// 1. For a <see cref="ButtonControl"/>, <see cref="Vector2Control"/>, or <see cref="StickControl"/>, consult
1248-
/// <see cref="ButtonControl.pressPoint"/> / <see cref="ButtonControl.pressPointOrDefault"/> or
1249-
/// <see cref="Vector2Control.pressPoint"/> / <see cref="Vector2Control.pressPointOrDefault"/> (sticks use the vector rules)
1250-
/// when a positive control <c>pressPoint</c> is set.
1251-
/// 2. If not set on the control but the binding has a <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1252-
/// with <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> greater than zero, use that value so this
1253-
/// API stays aligned with the interaction.
1254-
/// 3. If the binding lists several <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1255-
/// instances, use the first in interaction list order with an explicit
1256-
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> greater than zero.
1257-
/// 4. For composite bindings, read interaction parameters from the composite binding.
1258-
/// 5. Otherwise use <see cref="InputSettings.defaultButtonPressPoint"/>.
1247+
/// 1. If the binding lists one or more <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1248+
/// instances, use the <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> from the first
1249+
/// in interaction list order whose <c>pressPoint</c> is greater than zero (earlier interactions that are not
1250+
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>, or that leave <c>pressPoint</c> at the
1251+
/// default of zero, are skipped) so this API stays aligned with the interaction.
1252+
/// 2. Otherwise, for a <see cref="ButtonControl"/>, <see cref="Vector2Control"/>, or <see cref="StickControl"/>, use
1253+
/// <see cref="ButtonControl.pressPointOrDefault"/> or <see cref="Vector2Control.pressPointOrDefault"/>.
1254+
/// 3. For composite bindings, read interaction parameters from the composite binding.
1255+
/// 4. Otherwise use <see cref="InputSettings.defaultButtonPressPoint"/>.
1256+
///
1257+
/// <see cref="InputControl.IsPressed"/> on the control itself always uses the control threshold and does not
1258+
/// consider binding interactions.
12591259
///
12601260
/// <example>
12611261
/// <code>
@@ -1352,18 +1352,18 @@ public unsafe bool WasPressedThisDynamicUpdate()
13521352
///
13531353
/// Press threshold (based on <see cref="InputControl.EvaluateMagnitude()"/> for the driving control):
13541354
///
1355-
/// 1. For a <see cref="ButtonControl"/>, <see cref="Vector2Control"/>, or <see cref="StickControl"/>, consult
1356-
/// <see cref="ButtonControl.pressPoint"/> / <see cref="ButtonControl.pressPointOrDefault"/> or
1357-
/// <see cref="Vector2Control.pressPoint"/> / <see cref="Vector2Control.pressPointOrDefault"/> (sticks use the vector rules)
1358-
/// when a positive control <c>pressPoint</c> is set.
1359-
/// 2. If not set on the control but the binding has a <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1360-
/// with <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> greater than zero, use that value so this
1361-
/// API stays aligned with the interaction.
1362-
/// 3. If the binding lists several <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1363-
/// instances, use the first in interaction list order with an explicit
1364-
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> greater than zero.
1365-
/// 4. For composite bindings, read interaction parameters from the composite binding.
1366-
/// 5. Otherwise use <see cref="InputSettings.defaultButtonPressPoint"/>.
1355+
/// 1. If the binding lists one or more <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>
1356+
/// instances, use the <see cref="UnityEngine.InputSystem.Interactions.PressInteraction.pressPoint"/> from the first
1357+
/// in interaction list order whose <c>pressPoint</c> is greater than zero (earlier interactions that are not
1358+
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/>, or that leave <c>pressPoint</c> at the
1359+
/// default of zero, are skipped) so this API stays aligned with the interaction.
1360+
/// 2. Otherwise, for a <see cref="ButtonControl"/>, <see cref="Vector2Control"/>, or <see cref="StickControl"/>, use
1361+
/// <see cref="ButtonControl.pressPointOrDefault"/> or <see cref="Vector2Control.pressPointOrDefault"/>.
1362+
/// 3. For composite bindings, read interaction parameters from the composite binding.
1363+
/// 4. Otherwise use <see cref="InputSettings.defaultButtonPressPoint"/>.
1364+
///
1365+
/// <see cref="InputControl.IsPressed"/> on the control itself always uses the control threshold and does not
1366+
/// consider binding interactions.
13671367
///
13681368
/// <example>
13691369
/// <code>

Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputActionState.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,9 +1598,10 @@ private void ProcessControlStateChange(int mapIndex, int controlIndex, int bindi
15981598
return bindingStatePtr;
15991599
}
16001600

1601-
// Resolves the explicit press threshold used to keep IsPressed / WasPressedThisFrame / WasReleasedThisFrame aligned
1602-
// with PressInteraction when the driving control does not set IActuationPressPoint.pressPoint. When multiple
1603-
// PressInteraction instances exist on the binding, uses the first in interaction list order with pressPoint > 0.
1601+
// Resolves the explicit press threshold from PressInteraction on the binding. When multiple PressInteraction
1602+
// instances exist, uses the first in interaction list order with pressPoint > 0. GetActuationPressThreshold
1603+
// prefers this over a control pressPoint so IsPressed / WasPressedThisFrame / WasReleasedThisFrame stay aligned
1604+
// with PressInteraction.
16041605
private bool TryGetExplicitPressInteractionPressPoint(BindingState* bindingStateForInteractions, ref float explicitPressInteraction)
16051606
{
16061607
var count = bindingStateForInteractions->interactionCount;

Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Vector2Control.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ public class Vector2Control : InputControl<Vector2>, IActuationPressPoint
4242
/// </summary>
4343
/// <remarks>
4444
/// By default, this field is set to -1. If the value of the property is negative,
45-
/// <see cref="UnityEngine.InputSystem.InputSettings.defaultButtonPressPoint"/> is used unless a
46-
/// <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/> on the binding sets an explicit
47-
/// <c>pressPoint</c> (see <see cref="UnityEngine.InputSystem.InputAction.IsPressed"/> remarks).
45+
/// <see cref="UnityEngine.InputSystem.InputSettings.defaultButtonPressPoint"/> is used for action-level press
46+
/// APIs unless a <see cref="UnityEngine.InputSystem.Interactions.PressInteraction"/> on the binding sets an
47+
/// explicit <c>pressPoint</c>, in which case that interaction threshold takes priority (see
48+
/// <see cref="UnityEngine.InputSystem.InputAction.IsPressed"/> remarks).
4849
/// </remarks>
4950
/// <seealso cref="pressPointOrDefault"/>
5051
/// <seealso cref="ButtonControl"/>

0 commit comments

Comments
 (0)