Skip to content

Commit 502e854

Browse files
Apply the same scale factor as InputForUI InputManager provider for scroll delta (#1690)
* Apply same scale factor for mouse scroll delta as IM * Update scroll test to match new value * Disable tests failing on 2022.3.3f1 * Ignore one more UI test and fix define conditionals
1 parent d3ff56a commit 502e854

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

Assets/Tests/InputSystem/Plugins/InputForUITests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ public void NavigationMoveWorks()
118118
[Category("InputForUI")]
119119
public void SendWheelEvent()
120120
{
121-
var kScrollUGUIScaleFactor = 40f; // See InputSystemProvider OnScrollWheelPerformed() callback
121+
var kScrollUGUIScaleFactor = 3.0f; // See InputSystemProvider OnScrollWheelPerformed() callback
122122
var mouse = InputSystem.AddDevice<Mouse>();
123123
Update();
124-
Set(mouse.scroll.y, -1f * kScrollUGUIScaleFactor);
124+
// Make the minimum step of scroll delta to be ±1.0f
125+
Set(mouse.scroll.y, -1f / kScrollUGUIScaleFactor);
125126
Update();
126127
Assert.IsTrue(m_InputForUIEvents.Count == 1);
127128
Assert.That(m_InputForUIEvents[0].asPointerEvent.scroll, Is.EqualTo(new Vector2(0, 1)));

Assets/Tests/InputSystem/Plugins/OnScreenTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ public IEnumerator Devices_CanHaveOnScreenJoystickControls()
467467
}
468468

469469
[UnityTest]
470+
[Ignore("Failing on 2023.3.3f1 https://jira.unity3d.com/browse/ISX-1462")]
470471
[Category("Devices")]
471472
public IEnumerator Devices_OnScreenStickDoesNotReceivePointerUpEventsInIsolatedMode()
472473
{

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,8 @@ public IEnumerator UI_DisplayIndexMatchesDisplayWithTouchscreenOnScreenSpaceCanv
38853885
[UnityTest]
38863886
#if UNITY_TVOS
38873887
[Ignore("Failing on tvOS https://jira.unity3d.com/browse/ISX-448")]
3888+
#else
3889+
[Ignore("Failing on 2023.3.3f1 https://jira.unity3d.com/browse/ISX-1462")]
38883890
#endif
38893891
public IEnumerator UI_DisplayIndexMatchesDisplayWithTouchscreenOnOverlayCanvas()
38903892
{
@@ -3987,6 +3989,7 @@ public IEnumerator UI_DisplayIndexMatchesDisplayWithMouseOnScreenSpaceCanvas()
39873989
}
39883990

39893991
[UnityTest]
3992+
[Ignore("Failing on 2023.3.3f1 https://jira.unity3d.com/browse/ISX-1462")]
39903993
public IEnumerator UI_DisplayIndexMatchesDisplayWithMouseOnOverlayCanvas()
39913994
{
39923995
// Setup the Test Scene

Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ internal class InputSystemProvider : IEventProviderImpl
4343
NavigationEventRepeatHelper m_RepeatHelper = new();
4444
bool m_ResetSeenEventsOnUpdate;
4545

46+
const float kScrollUGUIScaleFactor = 3.0f;
47+
4648
static InputSystemProvider()
4749
{
4850
// Only if InputSystem is enabled in the PlayerSettings do we set it as the provider.
@@ -518,9 +520,8 @@ void OnScrollWheelPerformed(InputAction.CallbackContext ctx)
518520
}
519521

520522
// Make it look similar to IMGUI event scroll values.
521-
// TODO check how it behaves on macOS
522-
scrollDelta.x /= 40.0f;
523-
scrollDelta.y /= -40.0f;
523+
scrollDelta.x *= kScrollUGUIScaleFactor;
524+
scrollDelta.y *= -kScrollUGUIScaleFactor;
524525

525526
DispatchFromCallback(Event.From(new PointerEvent
526527
{

0 commit comments

Comments
 (0)