Skip to content

Commit 66f7ee8

Browse files
authored
fix(HID): Use correct data format for composite stick axes in layout 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.
1 parent d0e00c1 commit 66f7ee8

File tree

1 file changed

+2
-2
lines changed
  • Packages/com.unity.inputsystem/InputSystem/Plugins/HID

1 file changed

+2
-2
lines changed

Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HID.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public InputControlLayout Build()
385385
var yElementParameters = yElement.DetermineParameters();
386386

387387
builder.AddControl(stickName + "/x")
388-
.WithFormat(xElement.isSigned ? InputStateBlock.FormatSBit : InputStateBlock.FormatBit)
388+
.WithFormat(xElement.DetermineFormat())
389389
.WithByteOffset((uint)(xElement.reportOffsetInBits / 8 - byteOffset))
390390
.WithBitOffset((uint)(xElement.reportOffsetInBits % 8))
391391
.WithSizeInBits((uint)xElement.reportSizeInBits)
@@ -394,7 +394,7 @@ public InputControlLayout Build()
394394
.WithProcessors(xElement.DetermineProcessors());
395395

396396
builder.AddControl(stickName + "/y")
397-
.WithFormat(yElement.isSigned ? InputStateBlock.FormatSBit : InputStateBlock.FormatBit)
397+
.WithFormat(yElement.DetermineFormat())
398398
.WithByteOffset((uint)(yElement.reportOffsetInBits / 8 - byteOffset))
399399
.WithBitOffset((uint)(yElement.reportOffsetInBits % 8))
400400
.WithSizeInBits((uint)yElement.reportSizeInBits)

0 commit comments

Comments
 (0)