Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
28 changes: 28 additions & 0 deletions Assets/Tests/InputSystem/CoreTests_Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,34 @@ public void Events_OnAnyButtonPressed_FiltersOutOtherControls()

Assert.That(callCount, Is.EqualTo(1));
}

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

var touch = InputSystem.AddDevice<Touchscreen>();

var callCount = 0;

InputSystem.onAnyButtonPress
.Call(ctrl =>
{
Assert.That(ctrl, Is.SameAs(touch.touches[0].press));
++callCount;
});

Assert.That(callCount, Is.Zero);

InputSystem.Update();

SetTouch(0,TouchPhase.Began, new Vector2(12,12));

InputSystem.Update();

Assert.That(callCount, Is.EqualTo(1));
}

[Test]
[Category("Events")]
Expand Down
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed `buttonSouth` returning the state of the east button (and so on for all the compass named buttons) when using a Nintendo Switch Pro Controller on iOS [ISXB-1632](issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1632)
- Fixed `aButton` returning the state of the east button (and so on for all the letter named buttons) when using a Nintendo Switch Pro Controller on Standalone & iOS [ISXB-1632](issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1632)
- 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).
- Fixed InputSystem.onAnyButtonPress fails to trigger when the device receives a touch [UUM-137930](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-137930).

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ public static InputControl GetFirstButtonPressOrNull(this InputEventPtr eventPtr

foreach (var control in eventPtr.EnumerateControls(Enumerate.IgnoreControlsInDefaultState, magnitudeThreshold: magnitude))
{
if (!control.HasValueChangeInEvent(eventPtr))
if (!control.HasValueChangeInEvent(eventPtr) && !(control.device is Touchscreen)) // touches can happen to not have a previous state to compare to after the touch started
Comment thread
ritamerkl marked this conversation as resolved.
Outdated
Comment thread
ritamerkl marked this conversation as resolved.
Outdated
Comment thread
ritamerkl marked this conversation as resolved.
Outdated
Comment thread
ritamerkl marked this conversation as resolved.
Outdated
continue;
if (buttonControlsOnly && !control.isButton)
continue;
Expand Down
Loading