From 1ff7385b8844f1413615d9fc6d03e5c9fbbee3af Mon Sep 17 00:00:00 2001 From: Rita Merkl Date: Wed, 1 Oct 2025 17:20:55 +0200 Subject: [PATCH 1/3] sort out controls which are not contained in event --- .../InputSystem/Controls/InputControlExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlExtensions.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlExtensions.cs index e43dc6cec8..3e308d86e1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlExtensions.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlExtensions.cs @@ -1114,6 +1114,8 @@ public static InputControl GetFirstButtonPressOrNull(this InputEventPtr eventPtr foreach (var control in eventPtr.EnumerateControls(Enumerate.IgnoreControlsInDefaultState, magnitudeThreshold: magnitude)) { + if (!control.HasValueChangeInEvent(eventPtr)) + continue; if (buttonControlsOnly && !control.isButton) continue; return control; From 449c3f0a6844ba71d968074d96fa244be2b7f02b Mon Sep 17 00:00:00 2001 From: Rita Merkl Date: Wed, 1 Oct 2025 17:45:09 +0200 Subject: [PATCH 2/3] added changelog --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index ce6fe06286..0f13753b95 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -28,6 +28,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed the compilation warnings when used with Unity 6.4 (ISX-2349). - Fixed an issue where `InputSystemUIInputModule.localMultiPlayerRoot` could not be set to `null` when using `MultiplayerEventSystem`. [ISXB-1610](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1610) - Fixed an issue in `Keyboard` where the sub-script operator would return a `null` key control for the deprecated key `Key.IMESelected`. Now, an aliased `KeyControl`mapping to the IMESelected bit is returned for compability reasons. It is still strongly advised to not rely on this key since `IMESelected` bit isn't strictly a key and will be removed from the `Key` enumeration type in a future major revision. [ISXB-1541](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1541). +- Fixed an issue where the onAnyButtonPress callback would be triggered multiple times during unrelated events when a button is held down. See [ISXB-1005](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1005). ## [1.14.2] - 2025-08-05 From 2ad3a3c9baec4c66e643574f8efc4a4ef2ebb5a1 Mon Sep 17 00:00:00 2001 From: Rita Merkl Date: Thu, 2 Oct 2025 08:29:07 +0200 Subject: [PATCH 3/3] added test to filter out other controls --- Assets/Tests/InputSystem/CoreTests_Events.cs | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Assets/Tests/InputSystem/CoreTests_Events.cs b/Assets/Tests/InputSystem/CoreTests_Events.cs index bf504f2274..c3dc4c7cfd 100644 --- a/Assets/Tests/InputSystem/CoreTests_Events.cs +++ b/Assets/Tests/InputSystem/CoreTests_Events.cs @@ -179,6 +179,45 @@ public void Events_CanListenForButtonPresses() InputSystem.Update(); } + [Test] + [Category("Events")] + public void Events_OnAnyButtonPressed_FiltersOutOtherControls() + { + InputSystem.settings.defaultButtonPressPoint = 0.5f; + + var mouse = InputSystem.AddDevice(); + + var callCount = 0; + + InputSystem.onAnyButtonPress + .Call(ctrl => + { + Assert.That(ctrl, Is.SameAs(mouse.leftButton)); + ++callCount; + }); + + Assert.That(callCount, Is.Zero); + + InputSystem.Update(); + + InputSystem.QueueStateEvent(mouse, new MouseState().WithButton(MouseButton.Left)); + InputSystem.Update(); + + Assert.That(callCount, Is.EqualTo(1)); + + var mouseState = new MouseState(); + mouseState.position.x = 3f; + InputSystem.QueueStateEvent(mouse, mouseState.WithButton(MouseButton.Left)); + InputSystem.Update(); + + Assert.That(callCount, Is.EqualTo(1)); + + InputSystem.QueueStateEvent(mouse, new MouseState().WithButton(MouseButton.Left, false)); + InputSystem.Update(); + + Assert.That(callCount, Is.EqualTo(1)); + } + [Test] [Category("Events")] public void Events_OnAnyButtonPressed_FiltersOutNonStateEvents()