InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

NEW: Add Android backButtonLeavesApp to New Input

Open manugildev opened this issue 10 months ago • 6 comments

Description

Add backButtonLeavesApp support for New Input System.

Changes made

This PR creates a new AndroidDevice that is registered during initialization. This AndroidDevice represents a handheld device, and can be use to store device specific input functions that are not part of other input devices such as the keyboard, gamepad or sensors.

We also added SetCustomCommand and GetCustomCommand used to be able to set and get respectively a payload between the InputSystem package and runtime. This is then used to set and get backButtonLeavesApp to the native runtime. This two new commands are general purpose commands, and can be used for any other input device.

backButtonLeavesApp, is just a boolean flag needed for Predictive Back Gesture (PBG) support to work on Android. This allows users to preview the destination or other result of a back gesture before fully completing it, allowing them to decide whether to continue or stay in the current view.

Notes

This new API can be used as such:

InputSystem.settings.android.backButtonLeavesApp = true;

Checklist

Before review:

  • [x] Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • [x] Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • [x] Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • [x] Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

manugildev avatar Apr 24 '24 08:04 manugildev

CLA assistant check
All committers have signed the CLA.

unity-cla-assistant avatar Apr 24 '24 08:04 unity-cla-assistant

P.S you probably need to some tests to validate SetCustomCommand/GetCustomCommand works fine

todi1856 avatar Apr 29 '24 09:04 todi1856

Add/change deprecation message to Input.bindings backButtonLeavesApp once ready to land.

ritamerkl avatar May 28 '24 13:05 ritamerkl

(force push the only contains auto formatter changes)

manugildev avatar Jun 21 '24 15:06 manugildev

@ekcoh I did some new changes based on the code review. Let me know if this is ready so I can proceed with landing the unity/unity PR first.

manugildev avatar Jun 24 '24 09:06 manugildev

Sorry for providing this feedback at this stage, but I would suggest we do not land this PR for the following reasons:

  • This API (backButtonLeavesApp), is a poor fit for a device representation. Only adds overhead and contains no streaming data and isn't tightly related to input.
  • A corresponding API backButtonLeavesApp already exists in UnityEngine.Input and seems (in native implementation) to not be tied to InputManager at all so I see no reason to have two versions of the same API?

Please let me know or DM me if there is some value you see with this additional API in addition to what already exists in Unity.Input?

ekcoh avatar Jun 25 '24 10:06 ekcoh

@ekcoh Hello I stumbled upon this thread as I was searching for the Input System's equivalent to backButtonLeavesApp. Because it is recommended to only have the new Input System enabled in the Unity project, backButtonLeavesApp in UnityEngine.Input doesn't work anymore.

It is very confusing to say "No corresponding API yet." in the Input System doc without providing a workaround to handle back button on Android, especially considering back button behavior is required by Google Play Store.

If Unity is not supporting backButtonLeavesApp in the Input System for engineering reasons, can you at least provide a work around of handling back button in the Input System in the documentation?

seeyam-q avatar Aug 02 '24 15:08 seeyam-q

@seeyam-q thanks for bringing this up! Actually, last friday we merged a change to make Input.backButtonLeavesApp work on the new Input System on Android.

We are expecting these changes to land in 6000.0.14f1, 2022.3.42f1 and 2021.3.43f1.

Issue Tracker Link UUM-41638

manugildev avatar Aug 05 '24 08:08 manugildev