Input not working on build (custom HID)

Hey everyone,

We’ve set up a custom HID layout (flightstick) and it works in the editor. However, there is no response when we test with a build, though other automatically generated input (keyboard/xbox controller) do work.

The code is taken from the documentation and filled out to match the device information:

using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Layouts;

[InputControlLayout(stateType = typeof(ThrustmasterHIDInputReport))]
#if UNITY_EDITOR
[InitializeOnLoad]
#endif

public class ThrustmasterJoystrickHID : Joystick
{
    static ThrustmasterJoystrickHID()
    {
        InputSystem.RegisterLayout<ThrustmasterJoystrickHID>(
            matches: new InputDeviceMatcher()
                .WithInterface("HID")
                .WithCapability("vendorId", 1973)
                .WithCapability("productId", 790));
    }

    [RuntimeInitializeOnLoadMethod]
    static void Init() { }
}
using System.Runtime.InteropServices;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Utilities;

[StructLayout(LayoutKind.Explicit, Size = 32)]
struct ThrustmasterHIDInputReport : IInputStateTypeInfo
{
     public FourCC format => new FourCC('H', 'I', 'D');

    [FieldOffset(0)] public byte reportId;

    [InputControl(name = "stick", layout = "Stick", format = "VEC2")]
    [InputControl(name = "stick/x", offset = 0, format = "BYTE",
        parameters = "normalize,normalizeMin=0,normalizeMax=1,normalizeZero=0.5,invert")]
    [InputControl(name = "stick/y", offset = 1, format = "BYTE",
        parameters = "normalize,normalizeMin=0,normalizeMax=1,normalizeZero=0.5")]
    [FieldOffset(1)] public byte stickX;
    [FieldOffset(2)] public byte stickY;

    [InputControl(name = "trigger", layout = "Button", offset = 5, bit = 4)]
    [FieldOffset(3)] public byte trigger;
}

What’s the build target? There’s a known bug in il2cpp which causes the static class constructor to not be invoked when Init() runs.

Thanks Rene!

So checking, and it was still set to default Mono. However, it made me think to try building it out on x86_64, and that seems to have worked.