Unity-Technologies / InputSystem

An efficient and versatile input system for Unity.
Other
1.43k stars 310 forks source link

NEW: Add Hinge Angle sensor for Android #1979

Closed todi1856 closed 2 months ago

todi1856 commented 2 months ago

Description

Add AndroidHingeAngle sensor, which basically tells how much Android device is unfolded with values ranging from 0 to 180.

Note: There's no foldable Apple phones currently, thus this change is for Android only.

See foldable phone here - https://media.wired.com/photos/6453efc6daed59ebbf4608a7/master/pass/Google-Pixel-Fold-News-Gear.jpg

This change contributes to Unity better supporting large screen & foldable Android devices, as part of contractual obligation with Google - https://jira.unity3d.com/browse/PLAT-9014

Child ticket for tracking https://jira.unity3d.com/browse/PLAT-10298

The change is pretty isolated and doesn't require any change on Android platform backend, since backend always reports both existing and future sensors. So only C# side on input system package was missing.

Changes made

Added public AndroidHingeAngle class, which user can use to access hinge angle sensor and thus get data how much phone is folded.

Testing

Risk

Very low risk, since change is isolated

Checklist

Before review:

During merge:

After merge:

Pauliusd01 commented 2 months ago

Added @IGuscin to help since I don't have access to a folding phone. Also, I see there's some CI failures with it (you can ignore the tvOS ones though)

todi1856 commented 2 months ago

Hey @ekcoh , any ideas what to do about this one https://unity-ci.cds.internal.unity3d.com/job/40124614?utm_source=github ?

Should I bump minor version ?

ekcoh commented 2 months ago

@todi1856 Yes version should be bumped (minor) on the branch/PR like this that requires it to change.

ekcoh commented 2 months ago

@IGuscin @todi1856 Maybe this indicates that there is need to know device dependent resolution of the sensor value? Maybe we should state in the sensor API docs that the resolution of the sensor value is device/implementation dependent at least?

todi1856 commented 2 months ago

@IGuscin @todi1856 Maybe this indicates that there is need to know device dependent resolution of the sensor value? Maybe we should state in the sensor API docs that the resolution of the sensor value is device/implementation dependent at least?

I expanded the sample to show to get sensor resolution - https://github.com/Unity-Technologies/InputSystem/pull/1979/commits/510c6a1cc52c27b6580e6ed9a37b2490d133c1a2