Got same issue and this the only place on Internet where the subject is raised so I will try to answer the question for other people who encounter the same issue.
This error messages is triggered from this condition:
if (control.stateBlock.bitOffset != 0)
throw new InvalidOperationException($"Cannot send delta state events against bitfield controls: {control}");
So, you just cannot use InputSystem.QueueDeltaStateEvent
on a InputControl
that use bitfields (that was the case in your example with bit = 0 and bit = 1.
In my own case, it was due to UnityEngine.InputSystem.TrackedDevice
.
[InputControl(synthetic = true)]
public ButtonControl isTracked { get; private set; }
The message appeared when trying to set the delta state event on this InputControl
. However there is no bit field manipulation so I do not understand why. When debugging, its stateBlock.bitOffset
is 5.
My own code is based on Unity.XR.Hands.XRHandDevice
and they use InputSystem.InputSystem.QueueDeltaStateEvent(isTracked, false);
with no problem, but I cannot.
Well, a workaround is to get ride of InputSystem.QueueDeltaStateEvent
and use StateEvent.From
and InputControl.WriteValueIntoEvent
.
Here is an example:
using (StateEvent.From(this, out InputEventPtr eventPtr))
{
...
devicePosition.WriteValueIntoEvent(position, eventPtr);
deviceRotation.WriteValueIntoEvent(rotation, eventPtr);
isTracked.WriteValueIntoEvent(isDeviceTracked ? 1.0f : 0.0f, eventPtr);
...
}
Be really careful on the type you use when using WriteValueIntoEvent
. For example, the ButtonControl
use a float internally so you may want to set:
buttonControl.WriteValueIntoEvent(isPressed ? 1.0f : 0.0f);
instead of buttonControl.WriteValueIntoEvent(isPressed);