-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: ISXB-704 scroll wheel support windows raw input value #1946
FIX: ISXB-704 scroll wheel support windows raw input value #1946
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting for now until aligned on potential graceful version handling.
get => NativeInputSystem.normalizeScrollWheelDelta; | ||
set => NativeInputSystem.normalizeScrollWheelDelta = value; | ||
#else | ||
get; set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I see what role these getter setters play when earlier Unity version? Wouldn't it make sense to remove the property completely instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or would have expected hard coded behavior, but the answer is - it depends)
public float scrollWheelDeltaPerTick | ||
{ | ||
#if UNITY_6000_0_OR_NEWER | ||
get { return NativeInputSystem.GetScrollWheelDeltaPerTick(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend being consistent with getter below and use the short-hand version with =>
var scrollDelta = ctx.ReadValue<Vector2>(); | ||
if (scrollDelta.sqrMagnitude < k_SmallestReportedMovementSqrDist) | ||
// ISXB-704: convert input value to uniform ticks before sending them to UI. | ||
var scrollTicks = ctx.ReadValue<Vector2>() / InputSystem.scrollWheelDeltaPerTick; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is InputSystem.scrollWheelDeltaPerTick guaranteed to never be zero (to make sure we never can run into division by zero)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an Assert on the native side in the trunk PR, is that enough? I'm not a fan of adding more asserts on all the stages where we propagate that value, do you recommend adding one here too? Only here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If trunk version guarantees that its never zero I believe its fine to not check it in package. Agree that its better to define the API contract on lower level.
if (scrollDelta.sqrMagnitude < k_SmallestReportedMovementSqrDist) | ||
// ISXB-704: convert input value to uniform ticks before sending them to UI. | ||
var scrollTicks = ctx.ReadValue<Vector2>() / InputSystem.scrollWheelDeltaPerTick; | ||
if (scrollTicks.sqrMagnitude < k_SmallestReportedMovementSqrDist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to avoid the sqr root
@@ -281,6 +281,25 @@ private void OnFocusChanged(bool focus) | |||
public Vector2 screenSize => new Vector2(Screen.width, Screen.height); | |||
public ScreenOrientation screenOrientation => Screen.orientation; | |||
|
|||
public bool normalizeScrollWheelDelta | |||
{ | |||
#if UNITY_6000_0_OR_NEWER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we run into issues with UNITY 6 revision prior to trunk change landing but maybe ok if/when that revision is current or is there opportunity for a even more specific define in the asmdef to detect the exact expected version once the trunk change lands maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the general solution to this problem is. There are other places in the Input System package code where we have a similar problem, so if we find a solution for this we should apply it everywhere (at once) probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was after above was whether UNITY_6000_0_OR_NEWER was specific enough or whether to define a custom asmdef symbol based on version value to define a symbol more specifically reflecting the change as introduced into UNITY_6000 version. There are other examples here https://github.com/Unity-Technologies/InputSystem/blob/develop/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef but I noticed they very not specific on a "sub-version" level so probably ok.
[Category(kTestCategory)] | ||
[TestCase(1.0f)] | ||
[TestCase(120.0f)] | ||
public void UIActionScroll_ReceivesNormalizedScrollWheelDelta(float scrollWheelDeltaPerTick) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these tests to cover scaling.
Looks like a branch update and CI rerun might be in order. |
50f03a1
to
8bb47fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this now, I saw some minor comments remain but ok with me to leave them as-is if you consider it to be preferable to have it as it currently is.
@@ -281,6 +281,25 @@ private void OnFocusChanged(bool focus) | |||
public Vector2 screenSize => new Vector2(Screen.width, Screen.height); | |||
public ScreenOrientation screenOrientation => Screen.orientation; | |||
|
|||
public bool normalizeScrollWheelDelta | |||
{ | |||
#if UNITY_6000_0_OR_NEWER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was after above was whether UNITY_6000_0_OR_NEWER was specific enough or whether to define a custom asmdef symbol based on version value to define a symbol more specifically reflecting the change as introduced into UNITY_6000 version. There are other examples here https://github.com/Unity-Technologies/InputSystem/blob/develop/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef but I noticed they very not specific on a "sub-version" level so probably ok.
var scrollDelta = ctx.ReadValue<Vector2>(); | ||
if (scrollDelta.sqrMagnitude < k_SmallestReportedMovementSqrDist) | ||
// ISXB-704: convert input value to uniform ticks before sending them to UI. | ||
var scrollTicks = ctx.ReadValue<Vector2>() / InputSystem.scrollWheelDeltaPerTick; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If trunk version guarantees that its never zero I believe its fine to not check it in package. Agree that its better to define the API contract on lower level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with amendments to tooltip and API docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of concerns from me:
- I did not need these changes to fix the issue, simply opening the Editor version that has your latest changes is enough to fix it
- The ifdefs for the code are not granular enough and I still get errors about missing Editor code on 6.0.6f1 Editor, should that be changed?
Also, please take a look at the slack discussion about this change in our input channel
You say you only need the Editor changes, are you sure there's no copy of my package fixes that survived in your Library folder? Otherwise I can't see how the InputSystemUIInputModule fixes could come from the Editor only... makes no sense :-( About the ifdefs not being granular enough, I'll comment in the slack discussion but I'm not sure there's a clean solution. |
It's the user project from ISXB-704 with no library and 1.8.2 input system |
Hi! I've updated the PR description to emphasize the changes that this PR contains. It's not observable scroll range fixes in any of the UI systems, but just the option to allow InputSystem actions returning values in the -120 to 120 range. |
…om:Unity-Technologies/InputSystem into isxb-704-scrollwheelwindowsrawvaluesupport # Conflicts: # Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the extra info, lgtm. Do check the CI failures though, there's more than the usual culprit ones
Description
Fixes ISXB-704. Based on recently landed trunk PR.
Details of what was changed and the thought process can be found in this Google Document:
https://docs.google.com/document/d/1XCC6GqaWzKf1M1jm-UmKRn6sIlmvF7rvF1C8Ws5Yxa4/edit?usp=sharing
This PR introduces a new Settings option for the InputSystem package. See screenshot:
When the "Keep Platform Specific Input Range" option is selected, InputSystem actions that result from a Scroll Wheel hardware input will be expressed in the OS native range when retrieved with the
InputAction.CallbackContext.ReadValue<Vector2>()
method. On Windows, the values should range between -120 to 120, whereas on other platforms it will remain between -1 and 1 in general.The new setting's default option is "Uniform Across All Platforms". When that option is selected, InputSystem actions that result from a Scroll Wheel will always be expressed in the -1 to 1 range, regardless of platform.
Changes made
Please write down a short description of what changes were made.
Notes
Please write down any additional notes, remove the section if not applicable.
Checklist
Before review:
Changed
,Fixed
,Added
sections.([case %number%](https://issuetracker.unity3d.com/issues/...))
.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: