I was making a prototype with input system v1.1.1 on Unity 2021.2.0f11 beta, and ran into this problem that I am unsure if Input System is the culprit or not.
What I observe is that event TEXT on macOS is sometimes not followed by a STAT event, and the high-level Input System consider the key is never released, so the Control value remain at 1 forever.
Here is a simple repro video:
jshx90
Notice the control for “r” key remain at 1, even when my hands are off keyboard; it only fires STAT event when I interaction with the touchpad (and I didn’t touch the keyboard).
Notes:
I was able to reproduce this on both my MBP 2020 and MBP 2015, both with macOS Catalina; but I was unable to reproduce it on a Windows machine.
I wasn’t reading these events myself, I was using the high level API, through Player Input and its Unity Events.
My setup for the action is like this, which I believe is fairly normal.
My callback handles it like following, basically Input System never fired canceled callback as promised, not until I press another key or use touchpad.
public void ReadCameraFocusRotation(InputAction.CallbackContext context)
{
if (context.canceled)
{
m_CameraFocusRotationTimeout = m_InputConfig.CameraMovementTimeout;
}
else if (context.performed)
{
m_CameraFocusRotation = context.ReadValue<Vector2>();
m_CameraFocusRotationTimeout = MAX_TIMEOUT_VALUE;
}
}
I cannot upload my code due to various factors, but I believe I have given enough information for a repro.
Receive no reply so far, I am guessing unless someone use the latest beta and spend their time to provide a full repro project upload, this case won’t get solved.
I have this exact issue. I see a keyboard button down TEXT, not followed by a key-up STAT until some other input happens. It’s pretty easy to reproduce by simply starting play mode and tapping left/right repeatedly. Attached find a screenshot from the input system debugger, where I have circled a STAT that follows more than 5 seconds after TEXT, achieved by simply tapping the keyboard.
It doesn’t always happen, it is intermittent / random, feels like an update slipping in between frames or something.
I’m running Mac OS monterey 12.0.1
Unity:
2021.2.0b16.3733 Personal
Revision: 2021.2/staging edbc0738c91b
Built: Fri, 08 Oct 2021 00:41:40 GMT
It happens on Intel and M1 and on 2021.2 and the new 2022.1.
We noticed we would get ActionStarted and ActionPerformed. But sometimes ActionCanceled will not occur until you move the mouse or press another key.
I tried a few other approaches and even wrote a simple test:
using UnityEngine;
using UnityEngine.InputSystem;
public class KeyboardTest : MonoBehaviour
{
public InputAction _action;
// Start is called before the first frame update
void Start()
{
_action = new InputAction(
type: InputActionType.Button,
binding: "<Keyboard>/W");
_action.Enable();
}
// Update is called once per frame
void Update()
{
if (_action != null)
{
if (_action.WasPressedThisFrame())
{
Debug.Log("PRESS");
}
if (_action.WasReleasedThisFrame())
{
Debug.Log("RELEASE");
Debug.Log("----");
}
}
}
}
Keep pressing W, and occasionally you won’t get RELEASE.
We are building a pinball engine, and this is definitely a huge issue as it causes our flippers to stay up!
If you want to know when a Button has been pressed and released, you either use ActionType value or passthrough. In your example, if you switch to ActionType.Value it should work as expected.
Long time ago, I opened an issue regarding this and it’s by design. Unfortunately, most people understand “Button” as a different concept than Unity’s implementation.