ExtendRealityLtd / Tilia.Input.UnityInputSystem

Input wrappers for the Unity Input system
MIT License
3 stars 2 forks source link

Inputs do not zero out when used with New Input System #19

Closed jorgeolothar closed 2 years ago

jorgeolothar commented 3 years ago

Environment

Steps to reproduce

  1. Set up Tilia with Unity's New Input system as per this issue.
  2. Add Tilia.SDK.SteamVR.Unity and SteamVR package from Unity Asset Store
  3. Setup SteamVR default inputs per package instructions
  4. Replace UnityXRPluginFramework with CameraRigs.SteamVR in the farm scene
  5. Update Left/right controller references under Generic Actions and Locomotors to use SteamVR default input mappings accordingly
  6. Set locomotion to any teleport, teleport pointers to axis control
  7. Teleport around with both controllers

Expected behavior

Teleport pointer appears when thumbstick is off center, disappears when thumbstick is released to neutral.

Current behavior

Teleport pointer appears, but very often will fail to disappear as if the axis 2D coordinates were not zero. This is also true to other 1D axis actions like grabbing (index controller) and trigger axis.

I believe this is related to providing a deadzone value for float as per this fix in Tilia.Input.UnityInputSystem. Not sure if it belongs there since it only occurs when using Tilia.SDK.SteamVR.Unity

jorgeolothar commented 2 years ago

This can also be recreated with the latest Tilia Farm project, without the use of SteamVR, so this issue might need to moved.

Steps to reproduce

  1. Download Tilia Farm example for New Input System (627344c)
  2. Open in Unity 2020.3.24f1 (Tested in Android platform)
  3. XR Plugin: OpenXR (PC), OpenXR (Android)
  4. Connect Oculus Quest to PC via Oculus link cable
  5. Hit Play.
  6. Build and deploy to Oculus Quest standalone android
  7. Detach cable
  8. Run in Quest

Current behavior Near zero float values seem to not register correctly, causing pointers to not disappear, and movement axes to keep moving when joystick is at rest, and triggers to not reset.

thestonefox commented 2 years ago

just to confirm, you can only recreate when building for quest? you cannot recreate in the editor?

thestonefox commented 2 years ago

I think this issue is still part of the Tilia.Input.UnityInputSystem package and the sample mappings don't actually contain a better deadzone value and the callback to context for vector2 and vector3 also need a deadzone setting

thestonefox commented 2 years ago

Also, the existing float deadzone fix needs updating too i think

https://github.com/ExtendRealityLtd/Tilia.Input.UnityInputSystem/blob/6e7c7de31c7669c4c4b9df9ea2070d33e9d491f7/Runtime/SharedResources/Scripts/Transformation/Conversion/CallbackContextToFloat.cs#L35

return value >= DeadZoneValue ? value : 0f; only matters if the float value is a positive value.

If the value is negative but not 0, then it will fail to return any value at all.

the DeadZoneValue for now can be a positive and negative bound instead of having a separate deadzone for positive and negative approaches to zero.

so:

return Math.Abs(value) >= Math.Abs(DeadZoneValue) ? value : 0f;

This should assure the value is always checked against the positive version of the value against the positive version of the deadzone, but the actual value even if negative will still be returned.

jorgeolothar commented 2 years ago

I can recreate in the editor with the Quest acting as an Oculus Rift PC

thestonefox commented 2 years ago

It seems that in fact the Unity Input System has its own built in mechanism for handling axis deadzones using the Processors.

image

I'll look to just use that instead of adding any custom stuff, that makes more sense I think

thestonefox commented 2 years ago

I can recreate in the editor with the Quest acting as an Oculus Rift PC

I cannot recreate at all in the unity editor, works fine every time for me. but built for quest i can recreate it.

thestonefox commented 2 years ago

Ok I think I know the issue.

The Vector2 Context callback (and the float one as well) have the context to process set to Performed

This should mean that when the input context is performed then the value is passed to the zinnia action.

But it seems that the input context doesn't register as performed on the quest when you quickly let go of the control (e.g. release the thumbstick for it to snap back to the center)

in this instance it does register a Canceled context though.

So my proposal for the fix is to just make sure that on axis values (vector and float) the Callback Context -> Context To Process is just set to Everything

This will mean the value is registered upon it first being touched, then registered for every subsequent performed and will also register on the final Canceled.

It may mean that the Value Changed event on the zinnia action could report the same value 3 times for the same frame. I think I'll just chance that and see if anyone finds that to be an issue first.

thestonefox commented 2 years ago

This PR https://github.com/ExtendRealityLtd/Tilia.Input.UnityInputSystem/pull/20 should fix the issue, it will need to be updated in the farm scene too

ExtendReality-Bot commented 2 years ago

:tada: This issue has been resolved in version 1.1.11 :tada:

The release is available on:

Your semantic-release bot :package::rocket: