Skip to content

Fixed GetHapticCapabilitiesCommand always failing to execute #1776

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

Merged
merged 13 commits into from
Nov 8, 2023

Conversation

chris-massie
Copy link
Collaborator

@chris-massie chris-massie commented Oct 18, 2023

Description

Fixed GetHapticCapabilitiesCommand always failing to execute.

Changes made

Added new fields to the command to make the payload size in bytes match the expected size.

I modified the names of the command fields to match the names in Unity core and the XR module, and created deprecated properties that map to the new fields. The naming makes it more clear they only apply for buffered haptics. Though this is technically a breaking change, since the command never worked at all, I think this is acceptable. EDIT: I kept the old names to avoid API breaking.

I also renamed the old properties in HapticCapabilities to match XR module with auto migration. This is not a breaking change. EDIT: Reverted since the API_MinorVersionsHaveNoBreakingChanges test isn't sophisticated enough to recognize this is allowed.

Notes

Starting with Unity 2018.3, the UnityXRHapticCapabilities struct was modified to add new properties, which adjusted the size of the struct. The XRInputSubsystem verifies that the size of the buffer passed to the command matches. It was previously always failing because 12 bytes != 20 bytes.

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.

Copy link
Collaborator

@vrdave-unity vrdave-unity left a comment

Choose a reason for hiding this comment

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

Good find.

The names won't match the UnityEngine.XR and IUnityXRInput.h names, but this is needed to avoid a breaking change. Renamed the optimal size field to more closely match the naming of maxBufferSize for consistency within Input System.
… API_MinorVersionsHaveNoBreakingChanges to fail. The value remains the same.

The test could be updated in the future to recognize the value is the same, but for now it's easier to just revert the change.
@chris-massie
Copy link
Collaborator Author

chris-massie commented Oct 19, 2023

Like @jamesmcgill I was getting failures of API_MinorVersionsHaveNoBreakingChanges when running locally on my computer, see #1763 (comment). I reverted the change of adding a redundant explicit field initialization to Vector2Composite to make the test pass.

I also updated the branch to revert the obsolete and renaming I did previously. The names won't match the UnityEngine.XR namespace, but it seems we can't really do so without doing a breaking change.

# Conflicts:
#	Packages/com.unity.inputsystem/CHANGELOG.md
# Conflicts:
#	Packages/com.unity.inputsystem/CHANGELOG.md
@jamesmcgill
Copy link
Collaborator

@chris-massie There is another PR about to land, so it's going to need another update soon I'm afraid. 😄
I can do that and make sure it's merged next, if you are okay with that?

@jamesmcgill jamesmcgill merged commit 317d7cc into develop Nov 8, 2023
@jamesmcgill jamesmcgill deleted the fix-xr-haptic-capabilities branch November 8, 2023 14:54
jamesmcgill added a commit that referenced this pull request Nov 8, 2023
* Fixed GetHapticCapabilitiesCommand always failing to execute and added missing haptic capabilities properties

* Added setter to make migration better if the user was setting the old field

* Fixed API_MinorVersionsHaveNoBreakingChanges by reverting renames

The names won't match the UnityEngine.XR and IUnityXRInput.h names, but this is needed to avoid a breaking change. Renamed the optimal size field to more closely match the naming of maxBufferSize for consistency within Input System.

* Reverted redundant explicit field initialization since it was causing API_MinorVersionsHaveNoBreakingChanges to fail. The value remains the same.

The test could be updated in the future to recognize the value is the same, but for now it's easier to just revert the change.

* Added xml-doc to public fields and methods

---------

Co-authored-by: James McGill <jamesmcgill@users.noreply.github.com>
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.

5 participants