Use TouchScript for Desktop Input (And Ofcourse Tablet Input)

Hello

Does anyone use TouchScript to handle both Touch and Desktop (Mouse) input? If you do; how do you manage or implement this?

On Desktop:
TouchScript ‘straight out of the box’ can handle panning with the mouse - you can hold down ‘Left Mouse Button’ and drag around. But for Rotation and Scaling; you need to hold down ‘Alt’ then click twice. Is there a way to make TouchScript detect ‘Right Mouse Button’ dragging as Rotation Gestures? Maybe we need to make our own Gesture? Or is there a simple setting? Similarly, is there a way to make the ‘Mouse Scroll Wheel’ trigger Scale Gestures?

Whats the best way to achieve this functionality in TouchScript? Is it by making our own Gestures? For example we make the Gesture ‘Right Click’ that relays mouse positions as Rotation gestures?

I have the same requirement and the easiest solution was just modifying the MouseHandler used by the Standard Input:

public void Update()
        {
            // If mouse button was pressed and released during the same frame,
            // we need to figure out what happened first.
            var upHandled = false;
            if (GetMouseButtonUp())
            {
                // Release happened first?
                if (mousePointId != -1)
                {
                    endTouch(mousePointId);
                    mousePointId = -1;
                    upHandled = true;
                }
            }

            // Need to end fake pointer
            if (fakeMousePointId > -1 && !(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)))
            {
                endTouch(fakeMousePointId);
                fakeMousePointId = -1;
            }

            if (GetMouseButtonDown())
            {
                var pos = Input.mousePosition;
                if ((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) && fakeMousePointId == -1)
                    fakeMousePointId = beginTouch(new Vector2(pos.x, pos.y), tags, true).Id;
                else if (mousePointId == -1) mousePointId = beginTouch(new Vector2(pos.x, pos.y), tags, true).Id;
            }
            else if (GetMouseButton())
            {
                var pos = Input.mousePosition;
                if (mousePointPos != pos)
                {
                    mousePointPos = pos;
                    if (fakeMousePointId != -1)
                    {
                        if (mousePointId == -1) moveTouch(fakeMousePointId, new Vector2(pos.x, pos.y));
                        else moveTouch(mousePointId, new Vector2(pos.x, pos.y));
                    }
                    else if (mousePointId != -1) moveTouch(mousePointId, new Vector2(pos.x, pos.y));
                }
            }

            // Release mouse if we haven't done it yet
            if (GetMouseButtonUp() && !upHandled && mousePointId != -1)
            {
                endTouch(mousePointId);
                mousePointId = -1;
            }
        }

        private bool GetMouseButton(){
            return Input.GetMouseButton(0) || Input.GetMouseButton(1);
        }

        private bool GetMouseButtonUp(){
            return Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1);
        }

        private bool GetMouseButtonDown(){
            return Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1);
        }

Then on the gesture handler I can just check:

public void OnPanChanged(object sender, EventArgs e) {
        if(Input.GetMouseButton(1)){
            var rotation = transform.eulerAngles;
            rotation.y += oneFinger.DeltaPosition.x;
            transform.eulerAngles = rotation;
        }else{
            transform.position = transform.position - oneFinger.DeltaPosition;
        }
    }