The new Input System documentation says:
How do I enable polling for gamepads on all platforms? I’m having bugs in Linux (Kubuntu) with a wireless Bluetooth controller (8bitdo, I think it should be XInput, but it’s recognized as a generic Gamepad, not as Xbox Controller).
The problem happens when I push the analog stick forward and back to zero. Sometimes it drifts - that is, although the stick value should be back to (0.0, 0.0), it doesn’t update, so the character keeps walking on its own on the last received value forever. This bug is quite annoying to test, since it happens randomly. Here’s a piece of the code I used to detect it:
public class Player : MonoBehaviour {
public InputActionReference moveAction;
//...
Vector2 hangInput;
float hangSince;
void Update() {
var movement = moveAction.action.ReadValue<Vector2>();
if (movement == Vector2.zero || movement != hangInput) {
hangInput = movement;
hangSince = Time.time;
} else if (Time.time - hangSince > 1) {
// gets here when drift is happening; try many calls to test if something
// can trigger a refresh of input without user interaction; nothing works
// except that old Input.GetAxis("Horizontal|Vertical") gets right value
// but it doesn't trigger a refresh on new Input System
}
//...
}
}
The thing is, I’m sure it’s a problem with the Input System, since Input.GetAxis returns the correct value. Also it refreshes it to the correct value when I press any button, key or move the mouse (even if I don’t touch the controller). So this has to be a bug in Input System itself, not on the driver for Linux.
I tried many things to work around it (from calling many properties on Gamepad, to writing stuff on event queue; even InputSystem.Update) to see if it would somehow refresh the Input values via code (so I could do it periodically) but nothing works.
Can I enable some setting or do some workaround to enable active polling for all gamepads on any platform, instead of this passive mode?
Since this bug might happen, I think developers should have the option to choose to be safe instead of efficient. Controller drift is just unacceptable to players, so this would force me to use the old system and I really don’t want to because the new system’s structure is FAR superior.