Example #1
0
    /// <summary>
    /// Data transformation, encapsulating key values as apis
    /// </summary>
    private void TransformData(ControllerHand hand, int handId, int[] data)
    {
        var offset = handId == 1 ? 67 : 0;

        hand.TouchPadPosition.x = data[0 + offset];
        hand.TouchPadPosition.y = data[5 + offset];

        TransSingleKey(hand.Home, 10 + offset, data);
        TransSingleKey(hand.App, 15 + offset, data);
        TransSingleKey(hand.Touch, 20 + offset, data);
        TransSingleKey(hand.VolumeUp, 25 + offset, data);
        TransSingleKey(hand.VolumeDown, 30 + offset, data);
        TransSingleKey(hand.Trigger, 35 + offset, data);

        if (controllerlink.goblinserviceStarted && !controllerlink.neoserviceStarted)
        {
            hand.TriggerNum = controllerlink.GetHBKeyValue();
        }

        if (!controllerlink.goblinserviceStarted && controllerlink.neoserviceStarted)
        {
            hand.TriggerNum = controllerlink.GetCVTriggerValue(handId);
        }

        hand.Battery = data[40 + offset];

        if (data.Length == 47)
        {
            hand.SwipeDirection = (SwipeDirection)data[45];
            hand.TouchPadClick  = (TouchPadClick)data[46];
        }
        else
        {
            switch (handId)
            {
            case 0:
                TransSingleKey(hand.X, 45 + offset, data);
                TransSingleKey(hand.Y, 50 + offset, data);
                TransSingleKey(hand.Left, 60 + offset, data);
                break;

            case 1:
                TransSingleKey(hand.A, 45 + offset, data);
                TransSingleKey(hand.B, 50 + offset, data);
                TransSingleKey(hand.Right, 55 + offset, data);
                break;
            }

            hand.SwipeDirection = (SwipeDirection)data[65 + offset];
            hand.TouchPadClick  = (TouchPadClick)data[66 + offset];
        }

        hand.GripValue = controllerlink.GetNeo3GripValue(handId);

        var touchData = controllerlink.GetNeo3TouchData(handId);

        TransformTouchData(hand, handId, touchData);
    }