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
jfreire-unity added a commit that referenced this pull request Oct 17, 2025
@unity-cla-assistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ekcoh
❌ myss
You have signed the CLA already but the status is still pending? Let us recheck it.

@ekcoh
Copy link
Collaborator

ekcoh commented Oct 21, 2025

Merged develop into this branch to get critical CI fix from #2260. Hope this doesn't caused any inconvenience for you.

jfreire-unity added a commit that referenced this pull request Oct 21, 2025
@myss
Copy link
Author

myss commented Oct 21, 2025

No, not a problem. This is a simple change, which is now being handled in #2246. Feel free to close this PR.

@myss
Copy link
Author

myss commented Oct 21, 2025

Or feel free to reopen if needed.

@myss myss closed this Oct 21, 2025
@jfreire-unity
Copy link
Collaborator

Thanks a lot for the contribution @myss

Needle-Mirror-Bot pushed a commit to needle-mirror/com.unity.inputsystem that referenced this pull request Nov 12, 2025
## [1.16.0] - 2025-11-10

### Changed
- Replaced "Look" rebinding button for "Keyboard" control scheme with a mouse sensitivity slider in `RebindingUISample` to illustrate how to support customizing scaling of mouse deltas and how to reapply the persisted setting between runs.
- Changed: Input System no longer depends the obsolete com.unity.modules.vr package.
- Removed code that had to do with Unity versions older than Unity 2021.3 LTS.

### Added
- Added an example of how to swap two similar controls to the `RebindingUISample`. This is accessible via a button with two arrows at the right hand-side of the screen. Pressing the button allows swapping the current bindings of the "Move" and "Look" gamepad bindings via the new `RebindActionUI.SwapBinding(RebindActionUI other)` method.
- Added support for (MonoBehavior OnMouse events) [https://docs.unity3d.com/ScriptReference/MonoBehaviour.html] when running the Input System on Unity 6000.4 or newer.
- Added tests and a sample for MonoBehavior OnMouse events using the InputSystem package.
- Added support for all the existing InputControl types in InputTestFixture.Trigger [ISXB-1716]

### Fixed
- Fixed warnings being generated on Unity 6.3 (beta). (ISXB-1718).
- Fixed an issue in `DeltaStateEvent.From` where unsafe code would throw exception or crash if internal pointer `currentStatePtr` was `null`. [ISXB-1637](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1637).
- Fixed an issue in `InputTestFixture.Set` where attempting to change state of a device not belonging to the test fixture context would result in null pointer exception or crash. [ISXB-1637](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1637).
- Fixed an issue where input action parameter overrides applied via `InputActionRebindingExtensions.ApplyParameterOverride` would not be applied if the associated binding has the empty string as `InputBinding.name`and the binding mask also has the empty string as name. (ISXB-1721).
- Fixed an issue in `InputActionReference` where `Set` was not updating the cached action leading to incorrect evaluation of `InputActionReference.action` after first being cached, then set, then read again. This could lead to reference not being reset if set programmatically during play-mode. [ISXB-1584](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1584).
- Fixed an issue where `InputActionSetupExtensions.Remove` will result in `NullReferenceException` if the action being removed has no bindings. (ISXB-1688).
- Fixed an issue where assigning a ``MonoBehaviour` field of type `InputActionReference` to an instance stored in `.inputactions` asset via `InputActionReference.Set` in playmode corrupts the originally referenced asset. (ISXB-1692).
- Fixed an issue where `InputActionReference.Create(null)` returns `null` instead "of a reference object to the given action" as documented behaviour for the API. (ISXB-1693)
- Fixed an issue where `InputActionReference.Set(null)` does not update the cached input action reference nor the `ScriptableObject.name` leading to incorrect action being returned and reference showing up as the path to the previously assigned action in Inspector. (ISXB-1694)
- Fixed an issue where Inspector field of type `InputActionReference` isn't reflecting broken reference in case action is deleted from asset, action map is deleted from asset, or the asset itself is deleted. (ISXB-1701)
- Fixed HID parsing not handling logical minimum and maximum values correctly when they are negative. This applies for platforms that parse HID descriptors in the package, e.g. macOS at the moment.
- Fix usage of correct data format for stick axes in HID Layout Builder ([User contribution](Unity-Technologies/InputSystem#2245))
- Fixed InputSystemUIInputModule calling pointer events on parent objects even when the "Send Pointer Hover To Parent" is off on 2022.3.XX. This was  was previously only available on Unity 6 versions since 1.11.0. [ISXB-1296]
- Limited the Add Control Scheme popup window max size to be its parent window, so that it won't resize beyond the visible area. [ISXB-1733](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1733)
- Fixed an issue where the action icon would shrink or disappear from UI when an action has a very long name. [ISXB-1650](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1650).
- Fixed upgrading input actions containing multiple processors [ISXB-1674](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1674).
- Fixed an issue that led to non-deterministic behaviour during `.inputaction` asset imports that could lead to corrupted assets or Unity hanging during asset import when "Generate C# Scripts" was active in importer settings. [ISXB-1746](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1746)
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.

4 participants