Detecting Pinch Zoom Via Interactions or Processors

I am using the new Input System to abstract away the specific details behind the devices used, and I really love that aspect of the new system. I am having a big issue trying to lump the mouse wheel and pinch to zoom into a single “zoom” action.

I do know a solution, but I don’t like it. I can make an action specifically for touch devices alone that does a zoom specifically with actual knowledge of two touches… but that breaks my design because it makes assumptions about technologies used to cause actions.

So, I find myself trying to somehow compose the Vector2 for the “zoom” action by making a composite control made up of touches. This doesn’t seem to work since the composite parts are expected to be up, down, left, and right. I don’t see a way I can make this happen and wanted to reach out and see if anyone had ideas for me to try out.

1 Like

I might be making progress here:

#if UNITY_EDITOR
    [InitializeOnLoad]
#endif
    public class test : InputProcessor<Vector2>
    {
       
#if UNITY_EDITOR
        static test()
        {
            Initialize();
        }
#endif

        [RuntimeInitializeOnLoadMethod]
        static void Initialize()
        {
            InputSystem.RegisterProcessor<test>();
        }

        public override Vector2 Process(Vector2 value, InputControl control)
        {
            //$ snag both positions and then produce your vector2 here
            var potentialControl0 = control.device.TryGetChildControl<Vector2Control>("/touch0/position");
            var potentialControl1 = control.device.TryGetChildControl<Vector2Control>("/touch1/position");
            return value;
        }

    }
1 Like

Have you came up with something? Can you share processor final code?
I have a trouble with checking InputControl state. It seems like for /touch0/position there is no way to get propert IsActuated() (probably because it doesn’t support magnitude evaluation). So how you handle case, when input system detect touch0 without touch1?

UPD0: Figured out that for such purposes modifiers suits better

UPD1: finally got it to work ( described in this thread )