Skip to content
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

NEW: Add Android backButtonLeavesApp to New Input #1914

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

manugildev
Copy link
Collaborator

@manugildev manugildev commented Apr 24, 2024

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:

  • 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.
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • 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:

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

@unity-cla-assistant
Copy link

unity-cla-assistant commented Apr 24, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manugildev Thanks for submitting this PR. Would you mind filling in the PR template to aid the review process for this new functionality and API surface being proposed? Instructions for filling in the PR template are available in the PR itself but also here: https://github.com/Unity-Technologies/InputSystem/blob/develop/.github/pull_request_template.md
Clearly describing the purpose of the PR and motivating the changes made makes it simpler to understand and review.

In addition som initial questions:

  • This is adding a new type of device, AndroidDevice that communicates with the native backend/run-time via IOCTL command GCC. However I do not see any Unity version dependent #ifdef checks present. Is this IOCTL command available back to Unity 2019 which the Input System package is still compliant with? If not, please guard the availability of this feature under appropriate compile-time version checks if intended to just return default if runtime is not implementing the IOCTL command and document from which Unity version this is expected to work, or guard the API under a certain UNITY version to control availability.
  • Noted that CHANGELOG.md do not contain an addition under ADD section describing the addition, would it be possible to get that added?

@todi1856
Copy link
Member

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

@manugildev manugildev force-pushed the platform/android/add-back-button-leaves-app-new-input branch from 971e6e3 to ab07662 Compare April 30, 2024 13:14
@manugildev manugildev force-pushed the platform/android/add-back-button-leaves-app-new-input branch from a28f01d to 04e1db1 Compare April 30, 2024 14:31
@manugildev manugildev force-pushed the platform/android/add-back-button-leaves-app-new-input branch 3 times, most recently from 37c9174 to 6f93df2 Compare April 30, 2024 14:50
@manugildev manugildev force-pushed the platform/android/add-back-button-leaves-app-new-input branch from 6f93df2 to 2dc6312 Compare April 30, 2024 16:10
@manugildev manugildev marked this pull request as ready for review April 30, 2024 17:05
@manugildev manugildev requested a review from ekcoh April 30, 2024 17:05
public class AndroidDevice : InputDevice
{
[InputControl(synthetic = true)]
public ButtonControl button { get; protected set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this? I see it's a public API, how would user use it ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to get rid of this ButtonControl. InputDevices need to have AT LEAST one control. If not they throw an exception. In our case, this controls is not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants