CinemachineInputProvider not working

Hello.

I am using the following system

Input System
CinemachineInputProvider

I need to control Cinemachine with a second finger.

I have already set up the Input Action to operate it with RightStick, I have attached CinemachineInputProvider to Virtual Camera and Input Action to XYAxis for camera operation.

However, when built on IOS, the camera barely moves with the second finger.

In the editor, it works fine with the XBox controller.

Here is the source code for testing
I know this is strange English, but don’t give up on me.
Please let me know.

using UnityEngine.InputSystem.EnhancedTouch;
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
using TouchPhase = UnityEngine.InputSystem.TouchPhase;
using UnityEngine;
using System.Collections.Generic;
using System;
using UnityEngine.UI;
using UnityEngine.InputSystem.OnScreen;
using UnityEngine.InputSystem.Layouts;

public class Test : OnScreenControl
{
    private int touchId = -1;
    private int targetFingerIndex = 1;
    private Dictionary<TouchPhase, Action<Touch>> touchFunctions;

    [SerializeField] private float deathPoint = 0.1f;
    [SerializeField] private Graphic joystickBackGround;
    [SerializeField] private Graphic joyStickbutton;
    [InputControl(layout = "Stick"), SerializeField] private string m_ControlPath = "<Gamepad>/rightStick";

    private Vector2 deltaDrag;
    private Vector2 axisValue;

    public Vector2 AxisValue
    {
        get => this.axisValue; 
        private set
        {
            MonoBehaviour.print(this.axisValue); // (40.32, 15.08)
            this.axisValue = value;
            this.SendValueToControl(this.axisValue);
        }
    }

    protected override string controlPathInternal
    {
        get => this.m_ControlPath;
        set => this.m_ControlPath = value;
    }
   
    private void Awake()
    {
        EnhancedTouchSupport.Enable();

        this.touchFunctions = new Dictionary<TouchPhase, Action<Touch>>()
        {
            {TouchPhase.Began, this.OnDrag},
            {TouchPhase.Moved, this.OnDrag},
            {TouchPhase.Stationary, this.OnStationary},
            {TouchPhase.Canceled, this.OnPointerUp},
            {TouchPhase.Ended, this.OnPointerUp},
        };
    }
   
    private void Update()
    {
        this.GetTouch();
        this.InvokeFunction();
    }

    private void GetTouch()
    {
        if (this.touchId != -1) return;
        if (Touch.activeTouches.Count <= this.targetFingerIndex) return;

        this.touchId = Touch.activeTouches[this.targetFingerIndex].touchId;
    }

    private void InvokeFunction()
    {
        if (this.touchId == -1) return;
       
        for (int i = 0; i < Touch.activeTouches.Count; i++)
        {
            var targetTouch = Touch.activeTouches[i];
            if (targetTouch.touchId != this.touchId) continue;

            this.touchFunctions[targetTouch.phase].Invoke(targetTouch);
        }
    }
   
    public void OnDrag(Touch touch)
    {
        Vector2 targetAxis = Vector2.zero;

        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(this.joystickBackGround.rectTransform, touch.screenPosition, null, out Vector2 pos))
        {
            this.joyStickbutton.rectTransform.anchoredPosition = pos;
            var relative = pos - this.deltaDrag;

            targetAxis = new Vector3(
                relative.x * Screen.width * 0.001f,
                relative.y * 0.001f * Screen.height
            );
            this.deltaDrag = pos;
        }

        if (targetAxis.magnitude <= this.deathPoint)
        {
            this.AxisValue = Vector2.zero;
        }
        else
        {
            this.AxisValue = targetAxis;
        }
    }

    private void OnStationary(Touch touch)
    {
        this.AxisValue = Vector2.zero;
    }

    public void OnPointerUp(Touch _)
    {
        this.deltaDrag = this.AxisValue = Vector2.zero;
        this.touchId = -1;
    }
}

I planted a print in the CinemachineInputProvider.GetAxisValue method, but the value displayed was (0.00, 0.00).

It seems that the player index is not set properly, so I will look into this a bit more.

However, it is a mystery why there are still moments when the camera can be manipulated a bit.

Maybe it is a bug.

OnScreenControl.SendValueToControl is not working.

SendValueToControl in the Update method for testing, it works, but if you call SendValueToControl in another method, it does not work.

private void Update()
{
    this.SendValueToControl(new Vector2(0.5f, 0));
}

It may not be a problem with OnScreenControl.SendValueToControl.

OnValueToControl.SendValueToControl and use that value for other operations instead of Cinemachine, it works fine, so I suspect it is a CinemachineInputProvider issue.

But I don’t understand why it works if I call the SendValueToControl method directly within the Update method.

I have created another thread as the conversation has changed a lot.