Skip to content

Commit eda7c63

Browse files
authored
FIX: controls excluded from rebinding could be still suppressed during interactive rebinding (#1620)
* FIX: controls excluded from rebinding could be still suppressed during interactive rebinding. * move changelog to correct location
1 parent c8f99d5 commit eda7c63

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Assets/Tests/InputSystem/CoreTests_Actions_Rebinding.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,13 +1152,23 @@ public void Actions_InteractiveRebinding_CanSuppressEventsWhileListening()
11521152
using (new InputActionRebindingExtensions.RebindingOperation()
11531153
.WithAction(action)
11541154
.WithControlsExcluding("<Pointer>/position")
1155-
.WithMatchingEventsBeingSuppressed().Start())
1155+
.WithControlsExcluding("<Pointer>/press")
1156+
.WithControlsExcluding("<Mouse>/leftButton")
1157+
.WithControlsExcluding("<Gamepad>/buttonEast")
1158+
.WithMatchingEventsBeingSuppressed()
1159+
.Start()
1160+
)
11561161
{
1162+
// Non-bindable controls should not be suppressed and continue working as normal
11571163
Set(mouse.position, new Vector2(123, 234));
1158-
Press(gamepad.buttonSouth);
1164+
Press(mouse.leftButton);
1165+
Press(gamepad.buttonEast);
11591166

1167+
Press(gamepad.buttonSouth);
11601168
Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/buttonSouth"));
1169+
Assert.That(mouse.leftButton.isPressed, Is.True);
11611170
Assert.That(gamepad.buttonSouth.isPressed, Is.False);
1171+
Assert.That(gamepad.buttonEast.isPressed, Is.True);
11621172
Assert.That(mouse.position.ReadValue(), Is.EqualTo(new Vector2(123, 234)).Using(Vector2EqualityComparer.Instance));
11631173
}
11641174
}

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ however, it has to be formatted properly to pass verification tests.
2121
- Fixed an issue on PS5 where device disconnected events that happen while the app is in the background are missed causing orphaned devices to hang around forever and exceptions when the same device is added again ([case UUM-7842](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-6744)).
2222
- Fixed Switch Pro, DualShock 4, DualSense gamepads becoming current on PC/macOS when no controls are changing ([case ISXB-223](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-223))).
2323
- Fixed an issue that made OnScreenStick unusable when used in conjunction with PlayerInput in Auto-Switch devices mode, or with any code that changes user/device pairing on unsued device activity being detected ([case ISXB-48](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-48)).
24+
- Fixed issue where input events were being suppressed during interactive action rebinding even when when their controls were excluded ([case ISXB-367](https://issuetracker.unity3d.com/issues/mouse-position-and-mouse-click-input-not-recognized-when-rebinding-is-active)).
2425

2526
### Actions
2627
- Extended input action code generator (`InputActionCodeGenerator.cs`) to support optional registration and unregistration of callbacks for multiple callback instances via `AddCallbacks(...)` and `RemoveCallbacks(...)` part of the generated code. Contribution by [Ramobo](https://github.com/Ramobo) in [#889](https://github.com/Unity-Technologies/InputSystem/pull/889).

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionRebindingExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,9 +2304,6 @@ private unsafe void OnEvent(InputEventPtr eventPtr, InputDevice device)
23042304
if (m_ExcludePathCount > 0 && HavePathMatch(control, m_ExcludePaths, m_ExcludePathCount))
23052305
continue;
23062306

2307-
// The control is not explicitly excluded so we suppress the event, if that's enabled.
2308-
suppressEvent = true;
2309-
23102307
// If controls have to match a certain path, check if this one does.
23112308
if (m_IncludePathCount > 0 && !HavePathMatch(control, m_IncludePaths, m_IncludePathCount))
23122309
continue;
@@ -2347,6 +2344,9 @@ private unsafe void OnEvent(InputEventPtr eventPtr, InputDevice device)
23472344
continue;
23482345
}
23492346

2347+
// At this point the control is a potential candidate for rebinding and therefore the event may need to be suppressed, if that's enabled.
2348+
suppressEvent = true;
2349+
23502350
var magnitude = control.EvaluateMagnitude(statePtr);
23512351
if (magnitude >= 0)
23522352
{

0 commit comments

Comments
 (0)