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.