Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling/Enabling an InputAction doesn't reset it's state. #261

Closed
Wahooney opened this issue Sep 26, 2018 · 10 comments
Closed

Disabling/Enabling an InputAction doesn't reset it's state. #261

Wahooney opened this issue Sep 26, 2018 · 10 comments
Assignees
Labels
bug Issues where existsing functionality misbehaves
Milestone

Comments

@Wahooney
Copy link

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):

  1. Press the key
  2. Disable the InputAction
  3. Release the key
  4. Enable the InputAction
  5. 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).
@Wahooney Wahooney changed the title Disabling an InputAction doesn't reset it's state. Disabling/Enabling an InputAction doesn't reset it's state. Sep 26, 2018
@Rene-Damm Rene-Damm self-assigned this Sep 26, 2018
@Rene-Damm Rene-Damm added the bug Issues where existsing functionality misbehaves label Sep 26, 2018
@Rene-Damm Rene-Damm added this to the 2018.2 milestone Sep 26, 2018
@Wahooney
Copy link
Author

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.

@douglas-piconi
Copy link
Contributor

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

@Wahooney
Copy link
Author

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!

@douglas-piconi
Copy link
Contributor

@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));

@douglas-piconi
Copy link
Contributor

@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));

@Wahooney
Copy link
Author

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.

@Rene-Damm
Copy link
Contributor

@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.

@douglas-piconi
Copy link
Contributor

@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.

@JiaUnity
Copy link
Contributor

@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.

@douglas-piconi
Copy link
Contributor

ok great thank you @JiaUnity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues where existsing functionality misbehaves
Projects
None yet
Development

No branches or pull requests

4 participants