Disabling/Enabling an InputAction doesn't reset it's state.
There is an issue in 0.0.7/8 when you have a Press and Release InputAction (in my case a member, not an asset):
- Press the key
- Disable the InputAction
- Release the key
- Enable the InputAction
- The next press of that key doesn't fire the InputAction::started event (presumably because it's being held in some sort of buffer of pressed buttons).
Has there been any movement on this issue? I'm on 0.1.2 and it's still a problem. Any work arounds?
BTW the SetCallbacks() with the and Generate Interfaces is pretty sweet.
Has there been any movement on this issue? I'm on 0.1.2 and it's still a problem. Any work arounds?
I'll take a look, and try to get a fix in for next release
Has there been any movement on this issue? I'm on 0.1.2 and it's still a problem. Any work arounds?
I'll take a look, and try to get a fix in for next release
Fantastic! Thank you!
@Wahooney I'm going to talk over with a few other engineers. When I wrote up a test to repro your issue, I'm starting to think it might be as designed. But I could be wrong, I'm gonna get a second opinion. Here is a test without any disabling. Press the key, action gets fired, release the key, different action gets fired. Press the key, action gets fired. If you comment out releasing that key, the action wont get fired twice. I'm wandering if the key is also released while action is disabled, is that as if it never happened, as in below if that code was not there to release. I'll get back to you, this one I'm not 100% clear on what should actually happen.
var keyboard = InputSystem.AddDevice<Keyboard>();
var action = new InputAction();
action.AddCompositeBinding("Dpad")
.With("Up", "/<Keyboard>/w");
action.Enable();
Vector2? value = null;
action.performed += ctx => { value = ctx.ReadValue<Vector2>(); };
// Press the Key
Assert.That(keyboard.wKey.isPressed, Is.False);
InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.W));
InputSystem.Update();
Assert.That(keyboard.wKey.isPressed, Is.True);
Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.up));
// Release the Key
value = null;
InputSystem.QueueStateEvent(keyboard, new KeyboardState());
InputSystem.Update();
Assert.That(keyboard.wKey.isPressed, Is.False);
Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.zero));
// Press the Key Again
value = null;
InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.W));
InputSystem.Update();
Assert.That(keyboard.wKey.isPressed, Is.True);
Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.up));
@Wahooney This test is what I interpret your issue, but this passes. Is there anything I'm missing here on what you are running into?
var keyboard = InputSystem.AddDevice<Keyboard>();
var action = new InputAction();
action.AddCompositeBinding("Dpad")
.With("Up", "/<Keyboard>/w");
action.Enable();
Vector2? value = null;
action.performed += ctx => { value = ctx.ReadValue<Vector2>(); };
// Press the Key
Assert.That(keyboard.wKey.isPressed, Is.False);
InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.W));
InputSystem.Update();
Assert.That(keyboard.wKey.isPressed, Is.True);
Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.up));
action.Disable();
// Release the Key
InputSystem.QueueStateEvent(keyboard, new KeyboardState());
InputSystem.Update();
Assert.That(keyboard.wKey.isPressed, Is.False);
action.Enable();
// Press the Key Again
value = null;
InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.W));
InputSystem.Update();
Assert.That(keyboard.wKey.isPressed, Is.True);
Assert.That(value, Is.Not.Null);
Assert.That(value.Value, Is.EqualTo(Vector2.up));
If I'm reading that right that does seem to be the process. I'll start a new project and make a minimal example, I'll let you know what I find.
@Wahooney There's a stack of changes that landed yesterday and among them, I think the issues around this should be resolved.
One of the key changes is that actions will now properly cancel ongoing interactions when calling Disable (see here).
When reenabled, there is also now an initial sync to the current state of the control. And subsequent control changes should lead to proper triggering.
Please let us know if you still see issues around this.
@Wahooney , with 0.2.0-preview now available. You should be good now with this issue being fixed. I'll keep bug open until you can confirm.
@douglas-piconi This issue is fixed somewhere in the past and does not happen anymore. I closed the FB side and think it is good to close it here as well.
ok great thank you @JiaUnity