Script says it cannot find custom processor but still works after reloading

Hey, I wrote a custom HID layout for the Logitech G920 steering wheel. The raw input from the wheel itself is represented by two bytes with little endian. The problem I face now is that with the solution I found in another forum post:

[InputControl(name = "wheel", layout = "Axis", displayName = "Wheel", format = "USHT", processors = "wheelInputProcessor", defaultState = 128)]
    [FieldOffset(4)] public short wheel;

My input ranges from 0 to +1 with 0.5 being the neutral. Since I’d much rather have it to range from -1 to +1 with neutral at 0 I wrote the following custom processor:

#if UNITY_EDITOR
[InitializeOnLoad]
#endif
public class WheelInputProcessor : InputProcessor<float>
{
#if UNITY_EDITOR
    static WheelInputProcessor()
    {
        Initialize();
    }
#endif

    [RuntimeInitializeOnLoadMethod]
    static void Initialize()
    {
        InputSystem.RegisterProcessor<WheelInputProcessor>("wheelInputProcessor");
    }

    /// <summary>
    /// The current input from the wheel in format "USHT" (unsigned short) ranges from 0 to +1 with neutral at 0.5.
    /// This method maps it to range from -1 to +1 with neutral at 0.
    /// </summary>
    public override float Process(float value, InputControl control)
    {
        return 2 * value - 1;
    }
}

Now when I first compile the script I get an InvalidOperationException saying “Cannot find processor ‘wheelInputProcessor’ referenced by control ‘wheel’ in layout ‘LogitechG920’” and the Wheel is located in the unsupported devices section in the Input Debug View.

But if I then recompile the script again without changing anything (e.g. by adding an empty comment somewhere) I get the same errors but this time the wheel is detected correctly as “LogitechG920” and everything works as expected and wanted.

Is this a bug with Unity or did I do something wrong/understood something completely wrong?

On a side note: I use another processor that flips the range of the pedals from [1 → 0] to [0 → 1] and use the same processor and just changed the name and the Process() calculations and that works on three pedals without a problem.

I tried it out a bit further and the error occurs every seconds recompiling. Say, I recompile and it doesn’t work. I add an empty comment, recompile: it works. I delete the empty comment, recompile: doesn’t work anymore. That’s a reliable reproduction lol

bump?

Alright, I tried it out in both Unity 2020.3.7 and Unity 2021.1.7 and it doesn’t work in either. Furthermore I removed the “WheelProcessor” and turns out the “FlipProcessors” for the pedals also cause the same error. I’ll file in a bug report on this one now.

If anyone should ever stumble across this: I solved it eventually without processors!

[InputControl(name = "wheel", layout = "Axis", displayName = "Wheel", format = "USHT", sizeInBits = 16,
        parameters = "normalize,normalizeMin=0,normalizeMax=1,normalizeZero=0.5")]
    [FieldOffset(4)] public short wheel;

That does the trick and gives us a fine wheel input from -1 to 1 with 0 being neutral. Perfect!