Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
ede1b9f
Update documentation for press point usage & default settings thresho…
Darren-Kelly-Unity Apr 28, 2026
4786635
Add fix for Vector2Controls & StickControls not using pressPoint's th…
Darren-Kelly-Unity Apr 29, 2026
85e63df
Add documentation for changes.
Darren-Kelly-Unity Apr 29, 2026
9255610
Separate and add tests for press point actuation.
Darren-Kelly-Unity Apr 29, 2026
3a30637
Merge branch 'develop' into bugfix/uum-138143-button-press-points-for…
Darren-Kelly-Unity May 5, 2026
1edbc32
Remove old comment in test.
Darren-Kelly-Unity May 5, 2026
f5500dc
Add formatting!
Darren-Kelly-Unity May 6, 2026
6b3acd1
Merge branch 'develop' into bugfix/uum-138143-button-press-points-for…
Darren-Kelly-Unity May 6, 2026
89c29e4
Merge branch 'develop' into bugfix/uum-138143-button-press-points-for…
Darren-Kelly-Unity May 11, 2026
509fd55
Add test format commit!
Darren-Kelly-Unity May 11, 2026
04e7d31
Add missing meta files.
Darren-Kelly-Unity May 11, 2026
fb11b47
Add more meta files. Not sure why they show up though.
Darren-Kelly-Unity May 11, 2026
2e84fa9
Remove redundant IActuationPressPoint.pressPointOrDefault property as…
Darren-Kelly-Unity May 11, 2026
577945b
Move positioning of press point forwarding properties.
Darren-Kelly-Unity May 11, 2026
e09e2c1
Revert weird meta file changes.
Darren-Kelly-Unity May 11, 2026
24300ba
Update whitespace changes for InputAction.cs
Darren-Kelly-Unity May 11, 2026
d392a56
Fix more white space formatting issues.
Darren-Kelly-Unity May 11, 2026
b1fbc4f
Fix StickControl white space.
Darren-Kelly-Unity May 11, 2026
0e622e4
Fix whitespace in Vector2Control.cs
Darren-Kelly-Unity May 11, 2026
f323b65
Fix more whitespace.
Darren-Kelly-Unity May 11, 2026
e4f0290
Remove fomratting issues with InputControlExtensions.cs
Darren-Kelly-Unity May 11, 2026
bb4e745
Add another batch of whitespace fixing.
Darren-Kelly-Unity May 11, 2026
773a44a
Update Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Ve…
Darren-Kelly-Unity May 12, 2026
6a08e2f
Update Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Ve…
Darren-Kelly-Unity May 12, 2026
ceb494c
Fix more whitespace issues.
Darren-Kelly-Unity May 12, 2026
2b72b4e
Fix compiler error.
Darren-Kelly-Unity May 12, 2026
ef60059
Make IActuationPressPoint.cs internal.
Darren-Kelly-Unity May 12, 2026
d7d7762
Refactor and add documentation for PR review.
Darren-Kelly-Unity May 12, 2026
c1cf34d
Refactor for code review.
Darren-Kelly-Unity May 12, 2026
26e92f4
Add performance tests addressing Hakan's worrys about hot path issues.
Darren-Kelly-Unity May 12, 2026
bce3776
Test updating codecov.yml to see if code coverage shown improves.
Darren-Kelly-Unity May 12, 2026
7209d0c
Revert "Test updating codecov.yml to see if code coverage shown impro…
Darren-Kelly-Unity May 12, 2026
674c649
Update documentation.
Darren-Kelly-Unity May 12, 2026
1243bc4
Test yamato configuration to exlude tests to see if it improves test …
Darren-Kelly-Unity May 12, 2026
db81e01
Revert "Test yamato configuration to exlude tests to see if it improv…
Darren-Kelly-Unity May 12, 2026
8ff8746
Revert "Revert "Test yamato configuration to exlude tests to see if i…
Darren-Kelly-Unity May 12, 2026
a9facb6
Revert "Revert "Revert "Test yamato configuration to exlude tests to …
Darren-Kelly-Unity May 12, 2026
3806cd9
Fix missing api links due to internal switch of IActuationPressPoint.
Darren-Kelly-Unity May 13, 2026
76df896
Remove reundant meta file.
Darren-Kelly-Unity May 13, 2026
d0f1978
Merge branch 'develop' into bugfix/uum-138143-button-press-points-for…
Pauliusd01 May 15, 2026
cae3ba8
Merge branch 'develop' into bugfix/uum-138143-button-press-points-for…
Darren-Kelly-Unity May 15, 2026
332ee3b
Merge branch 'develop' into bugfix/uum-138143-button-press-points-for…
Darren-Kelly-Unity May 15, 2026
e9e5613
Update Packages/com.unity.inputsystem/Documentation~/RespondingToActi…
Darren-Kelly-Unity May 18, 2026
35097bb
Update Packages/com.unity.inputsystem/Documentation~/RespondingToActi…
Darren-Kelly-Unity May 18, 2026
00528c5
Update Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Ve…
Darren-Kelly-Unity May 18, 2026
5f5b474
Make press point property internal.
Darren-Kelly-Unity May 18, 2026
53e8efe
Fix compiler issues.
Darren-Kelly-Unity May 18, 2026
8881e3c
Formatting
Darren-Kelly-Unity May 19, 2026
ee70ced
Fix documentation formatting.
Darren-Kelly-Unity May 19, 2026
fdea0bc
Add code review changes Hakan requested.
Darren-Kelly-Unity May 19, 2026
ee0f8f5
Add doc changes and changelog entry.
Darren-Kelly-Unity May 19, 2026
b466193
Changes for code review with discussion with Hakan.
Darren-Kelly-Unity May 20, 2026
b9a2edf
Update documentation.
Darren-Kelly-Unity May 20, 2026
52279d1
Update documentation RespondingToActions.md
Darren-Kelly-Unity May 20, 2026
174397d
Update changelog.
Darren-Kelly-Unity May 20, 2026
6e1ab2d
Remove redundant performance tests added due to code change following…
Darren-Kelly-Unity May 20, 2026
2c731c2
Add performance test to be sure we aren't allocating memory on the ho…
Darren-Kelly-Unity May 20, 2026
e8aa7eb
Remove redundant category.
Darren-Kelly-Unity May 20, 2026
373877d
Remove empty folder after refactor.
Darren-Kelly-Unity May 20, 2026
fcb1c38
Fix missing crefs.
Darren-Kelly-Unity May 20, 2026
a73b5f5
Fix failing CI due to docs
Darren-Kelly-Unity May 20, 2026
82d6127
Fix duplicated comment for documentation and used a cref on IsPressed…
Darren-Kelly-Unity May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
358 changes: 358 additions & 0 deletions Assets/Tests/InputSystem/ActuationPressPointTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,358 @@
using NUnit.Framework;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;

// Covers IActuationPressPoint, defaultButtonPressPoint, InputAction.IsPressed, and InputControl.IsPressed().
[TestFixture]
[Category("ActuationPressPoint")]
internal class ActuationPressPointTests : CoreTestsFixture
{
#region InputAction.IsPressed (Vector2 + Press interaction / control pressPoint)

[Test]
[Category("Actions")]
public void Actions_Vector2IsPressed_UsesPressInteractionPressPoint()
{
InputSystem.settings.defaultButtonPressPoint = 0.5f;
InputSystem.settings.buttonReleaseThreshold = 0.8f;

var gamepad = InputSystem.AddDevice<Gamepad>();

Set(gamepad.leftStick, Vector2.zero);
InputSystem.Update();

var action = new InputAction(
type: InputActionType.Value,
expectedControlType: "Vector2",
binding: "<Gamepad>/leftStick",
interactions: "press(pressPoint=0.6)");
action.Enable();

Set(gamepad.leftStick, new Vector2(0.55f, 0f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.False);

Set(gamepad.leftStick, new Vector2(0f, 0.65f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.True);
}

[Test]
[Category("Actions")]
public void Actions_Vector2IsPressed_UsesVector2ControlPressPoint()
{
InputSystem.settings.defaultButtonPressPoint = 0.5f;
InputSystem.settings.buttonReleaseThreshold = 0.8f;

var gamepad = InputSystem.AddDevice<Gamepad>();

Set(gamepad.leftStick, Vector2.zero);
InputSystem.Update();

var action = new InputAction(
type: InputActionType.Value,
expectedControlType: "Vector2",
binding: "<Gamepad>/leftStick");
gamepad.leftStick.pressPoint = 0.7f;
action.Enable();

Set(gamepad.leftStick, new Vector2(0.65f, 0f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.False);

Set(gamepad.leftStick, new Vector2(0.75f, 0f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.True);

gamepad.leftStick.pressPoint = -1f;
}

[Test]
[Category("Actions")]
public void Actions_ButtonIsPressed_UsesPressInteractionWhenControlPressPointUnset()
{
InputSystem.settings.defaultButtonPressPoint = 0.5f;
InputSystem.settings.buttonReleaseThreshold = 0.8f;

var gamepad = InputSystem.AddDevice<Gamepad>();

var action = new InputAction(
type: InputActionType.Button,
binding: "<Gamepad>/leftTrigger",
interactions: "press(pressPoint=0.6)");
action.Enable();

Set(gamepad.leftTrigger, 0.55f);
InputSystem.Update();
Assert.That(action.IsPressed(), Is.False);

Set(gamepad.leftTrigger, 0.65f);
InputSystem.Update();
Assert.That(action.IsPressed(), Is.True);
}

[Test]
[Category("Actions")]
public void Actions_Vector2IsPressed_ControlPressPointOverridesPressInteraction()
{
InputSystem.settings.defaultButtonPressPoint = 0.5f;
InputSystem.settings.buttonReleaseThreshold = 0.8f;

var gamepad = InputSystem.AddDevice<Gamepad>();

Set(gamepad.leftStick, Vector2.zero);
InputSystem.Update();

var action = new InputAction(
type: InputActionType.Value,
expectedControlType: "Vector2",
binding: "<Gamepad>/leftStick",
interactions: "press(pressPoint=0.6)");
gamepad.leftStick.pressPoint = 0.85f;
action.Enable();

// Above interaction threshold (0.6) but below control threshold (0.85).
Set(gamepad.leftStick, new Vector2(0.7f, 0f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.False);

Set(gamepad.leftStick, new Vector2(0.9f, 0f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.True);

gamepad.leftStick.pressPoint = -1f;
}

[Test]
[Category("Actions")]
public void Actions_CompositeVector2IsPressed_UsesPressInteractionOnCompositeBinding()
{
// Interaction lives on the composite binding while state changes arrive on part bindings.
// Analog 2DVector + stick half-axes yields composite magnitudes between 0 and 1 so we can
// distinguish defaultButtonPressPoint (0.5) from press(pressPoint=0.6).
InputSystem.settings.defaultButtonPressPoint = 0.5f;
InputSystem.settings.buttonReleaseThreshold = 0.8f;
InputSystem.settings.defaultDeadzoneMin = 0;
InputSystem.settings.defaultDeadzoneMax = 1;

var gamepad = InputSystem.AddDevice<Gamepad>();

Set(gamepad.leftStick, Vector2.zero);
InputSystem.Update();

var action = new InputAction(type: InputActionType.Value, expectedControlType: "Vector2");
action.AddCompositeBinding("2DVector(mode=2)", interactions: "press(pressPoint=0.6)")
.With("Up", "<Gamepad>/leftStick/up")
.With("Down", "<Gamepad>/leftStick/down")
.With("Left", "<Gamepad>/leftStick/left")
.With("Right", "<Gamepad>/leftStick/right");
action.Enable();

Set(gamepad.leftStick, new Vector2(0f, 0.55f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.False);

Set(gamepad.leftStick, new Vector2(0f, 0.65f));
InputSystem.Update();
Assert.That(action.IsPressed(), Is.True);
}

[Test]
[Category("Actions")]
public void Actions_Vector2Composite_RespectsButtonPressurePoint()
{
// The stick has deadzones on the up/down/left/right buttons to get rid of stick
// noise. For this test, simplify things by getting rid of deadzones.
InputSystem.settings.defaultDeadzoneMin = 0;
InputSystem.settings.defaultDeadzoneMax = 1;

var gamepad = InputSystem.AddDevice<Gamepad>();

// Set up classic WASD control.
var action = new InputAction();
action.AddCompositeBinding("Dpad")
.With("Up", "<Gamepad>/leftstick/up")
.With("Down", "<Gamepad>/leftstick/down")
.With("Left", "<Gamepad>/leftstick/left")
.With("Right", "<Gamepad>/leftstick/right");
action.Enable();

Vector2? value = null;
action.performed += ctx => { value = ctx.ReadValue<Vector2>(); };
action.canceled += ctx => { value = ctx.ReadValue<Vector2>(); };

var pressPoint = gamepad.leftStick.up.pressPointOrDefault;

// Up.
value = null;
InputSystem.QueueStateEvent(gamepad, new GamepadState { leftStick = Vector2.up });
InputSystem.Update();

Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.up));

// Up (slightly above press point)
value = null;
InputSystem.QueueStateEvent(gamepad, new GamepadState { leftStick = Vector2.up * pressPoint * 1.01f });
InputSystem.Update();

Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.up));

// Up (slightly below press point)
value = null;
InputSystem.QueueStateEvent(gamepad, new GamepadState { leftStick = Vector2.up * pressPoint * 0.99f });
InputSystem.Update();

Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.zero));

// Up left.
value = null;
InputSystem.QueueStateEvent(gamepad, new GamepadState { leftStick = Vector2.up + Vector2.left });
InputSystem.Update();

Assert.That(value, Is.Not.Null);
Assert.That(value.Value.x, Is.EqualTo((Vector2.up + Vector2.left).normalized.x).Within(0.00001));
Assert.That(value.Value.y, Is.EqualTo((Vector2.up + Vector2.left).normalized.y).Within(0.00001));

// Up left (up slightly above press point)
value = null;
InputSystem.QueueStateEvent(gamepad,
new GamepadState { leftStick = Vector2.up * pressPoint * 1.01f + Vector2.left });
InputSystem.Update();

Assert.That(value, Is.Not.Null);
Assert.That(value.Value.x, Is.EqualTo((Vector2.up + Vector2.left).normalized.x).Within(0.00001));
Assert.That(value.Value.y, Is.EqualTo((Vector2.up + Vector2.left).normalized.y).Within(0.00001));

// Up left (up slightly below press point)
value = null;
InputSystem.QueueStateEvent(gamepad,
new GamepadState { leftStick = Vector2.up * pressPoint * 0.99f + Vector2.left });
InputSystem.Update();

Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.left));
}

#endregion

#region Control extension IsPressed + settings (IActuationPressPoint / default threshold)

[Test]
[Category("Controls")]
public void Controls_CanDetermineIfControlIsPressed()
{
InputSystem.settings.defaultButtonPressPoint = 0.5f;

var gamepad = InputSystem.AddDevice<Gamepad>();

Set(gamepad.leftStick, Vector2.one);
Set(gamepad.leftTrigger, 0.6f);
Press(gamepad.buttonSouth);

Assert.That(gamepad.leftTrigger.IsPressed(), Is.True);
Assert.That(gamepad.rightTrigger.IsPressed(), Is.False);
Assert.That(gamepad.buttonSouth.IsPressed(), Is.True);
Assert.That(gamepad.buttonNorth.IsPressed(), Is.False);
Assert.That(gamepad.leftStick.IsPressed(),
Is.True); // Note how this diverges from the actual meaning of "is the left stick pressed?"
Assert.That(gamepad.rightStick.IsPressed(), Is.False);

// https://fogbugz.unity3d.com/f/cases/1374024/
// Calling it on the entire device should be false.
Assert.That(gamepad.IsPressed(), Is.False);
}

[Test]
[Category("Controls")]
public void Controls_CanCustomizeDefaultButtonPressPoint()
{
var gamepad = InputSystem.AddDevice<Gamepad>();

InputSystem.settings.defaultButtonPressPoint = 0.4f;

Set(gamepad.leftTrigger, 0.39f);

Assert.That(gamepad.leftTrigger.isPressed, Is.False);

Set(gamepad.leftTrigger, 0.4f);

Assert.That(gamepad.leftTrigger.isPressed, Is.True);

InputSystem.settings.defaultButtonPressPoint = 0.5f;

Assert.That(gamepad.leftTrigger.isPressed, Is.False);

InputSystem.settings.defaultButtonPressPoint = 0;

Assert.That(gamepad.leftTrigger.isPressed, Is.True);

// Setting the trigger to 0 requires the system to be "smart" enough to
// figure out that 0 as a default button press point doesn't make sense
// and that instead the press point should clamp off at some low, non-zero value.
// https://fogbugz.unity3d.com/f/cases/1349002/
Set(gamepad.leftTrigger, 0f);

Assert.That(gamepad.leftTrigger.isPressed, Is.False);

Set(gamepad.leftTrigger, 0.001f);

Assert.That(gamepad.leftTrigger.isPressed, Is.True);

InputSystem.settings.defaultButtonPressPoint = -1;
Set(gamepad.leftTrigger, 0f);

Assert.That(gamepad.leftTrigger.isPressed, Is.False);
}

[Test]
[Category("Controls")]
public void Controls_CanCustomizePressPointOfGamepadTriggers()
{
var json = @"
{
""name"" : ""CustomGamepad"",
""extend"" : ""Gamepad"",
""controls"" : [
{
""name"" : ""rightTrigger"",
""parameters"" : ""pressPoint=0.2""
}
]
}
";

InputSystem.RegisterLayout(json);
var gamepad = InputDevice.Build<Gamepad>("CustomGamepad");

Assert.That(gamepad.rightTrigger.pressPoint, Is.EqualTo(0.2f).Within(0.0001f));
}

[Test]
[Category("Controls")]
public void Controls_Vector2ExtensionIsPressed_UsesPressPointOrDefault()
{
InputSystem.settings.defaultButtonPressPoint = 0.5f;

var gamepad = InputSystem.AddDevice<Gamepad>();

gamepad.leftStick.pressPoint = 0.75f;
Set(gamepad.leftStick, new Vector2(0.6f, 0f));
Assert.That(gamepad.leftStick.IsPressed(), Is.False);

Set(gamepad.leftStick, new Vector2(0.8f, 0f));
Assert.That(gamepad.leftStick.IsPressed(), Is.True);

gamepad.leftStick.pressPoint = -1f;
Set(gamepad.leftStick, new Vector2(0.4f, 0f));
Assert.That(gamepad.leftStick.IsPressed(), Is.False);

Set(gamepad.leftStick, new Vector2(0.55f, 0f));
Assert.That(gamepad.leftStick.IsPressed(), Is.True);
}

#endregion
}
11 changes: 11 additions & 0 deletions Assets/Tests/InputSystem/ActuationPressPointTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading