I’m building a custom device to process DirectInput (input + ffb). I could get Input Debugger to show button arrays by following code:
[InputControl(name = "dpad", layout = "Dpad", displayName = "D-Pad", sizeInBits = 4, bit = 0)]
[InputControl(name = "button", layout = "Button", arraySize = 28, bit = 4)]
public uint buttons;
While looking at Input Debugger I can tell this creates 28 buttons with increasing offset and bit 4 on all of the buttons in the array. It appears though that the input system doesn’t actually map the buttons properly this way. When I press the button on my device, it DOES change the “buttons” variable properly (no issues there) but neither input system or input debugger detects these button presses beyond first button on the array.
If I however do this:
[InputControl(name = "dpad", layout = "Dpad", displayName = "D-Pad", sizeInBits = 4, bit = 0)]
[InputControl(name = "button1", layout = "Button", bit = 4)]
[InputControl(name = "button2", layout = "Button", bit = 5)]
..
[InputControl(name = "button27", layout = "Button", bit = 30)]
[InputControl(name = "button28", layout = "Button", bit = 31)]
public uint buttons;
it does let me set all buttons just fine.
I’m using the following code to set the bits:
void SetButton(int index, bool value, ref DirectInputControllerState state)
{
var bit = (uint)1 << index;
if (value)
{
state.buttons |= bit;
}
else
{
state.buttons &= ~bit;
}
}
Is there any way to go with the array approach? Declaring each button separately (one extra LOC per button) is just ugly when you can have potentially 128 buttons + d-pad on a DirectInput device
Additionally in ideal case, I could set the button amount per detected DirectInput device but current Custom Device structure doesn’t seem to support this. I need to register the button amount ahead of time with IInputStateTypeInfo - well before the device gets detected.