Skip to content

Conversation

myss
Copy link

@myss myss commented Sep 25, 2025

The generic HID layout builder made a faulty assumption that the X and Y axes of a composite "Stick" control always used a simple bitfield format (SBIT/BIT).

This assumption is incorrect for many modern devices, most notably 6DoF controllers like the 3Dconnexion SpaceMouse, which report their axes as 16-bit shorts (SHRT). This bug caused the builder to apply the wrong data format, resulting in incorrect parsing and unusable stick input for these devices.

This commit resolves the issue by replacing the brittle, hardcoded format logic with a call to the element.DetermineFormat() helper method. This is the same robust method used by the general-purpose element processor later in the same function.

This change:

  • Fixes axis detection for 6DoF controllers and other HID devices that use SHRT or BYTE formats.
  • Makes the special-case "Stick" logic consistent with the rest of the HID parser.

Description

Fix HID handling for 3dconnexion SpaceMouse. Without the fix, the "/stick", "/stick/x" and "/stick/y" values contained garbage.

Testing status & QA

Only tested on a 3dconnexion SpaceMouse Wireless.

Overall Product Risks

Comments to reviewers

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.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • 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.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

…builder

The generic HID layout builder made a faulty assumption that the X and Y axes of a composite "Stick" control always used a simple bitfield format (`SBIT`/`BIT`).

This assumption is incorrect for many modern devices, most notably 6DoF controllers like the 3Dconnexion SpaceMouse, which report their axes as 16-bit shorts (`SHRT`). This bug caused the builder to apply the wrong data format, resulting in incorrect parsing and unusable stick input for these devices.

This commit resolves the issue by replacing the brittle, hardcoded format logic with a call to the `element.DetermineFormat()` helper method. This is the same robust method used by the general-purpose element processor later in the same function.

This change:
- Fixes axis detection for 6DoF controllers and other HID devices that use `SHRT` or `BYTE` formats.
- Makes the special-case "Stick" logic consistent with the rest of the HID parser.
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.

Thanks for finding this @myss , yes assuming the format specifier is just a format bit is definitely incorrect, good catch. I suggest we pick this PR up, complement it with a unit test with a HID descriptor using this format, e.g. 3D connexion space mouse, update the changeling to reflect the change and land this.c

@myss myss changed the title fix(HID): Use correct data format for composite stick axes in layout builder FIX: Use correct data format for composite stick axes in HID layout builder Sep 26, 2025
jfreire-unity added a commit that referenced this pull request Sep 26, 2025
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.

2 participants