Example #1
0
        private void SetupAxisGesture(AxisGesture ag, Panel panel)
        {
            VirtualController.Axis
                stick       = Util.StickFromGesture(ag),
                axis        = Util.AxisFromGesture(ag);
            bool      pos   = Util.PoleFromGesture(ag);
            SlotShape shape = SlotShape.Rounded;

            if (panel.Tag is string)
            {
                try {
                    shape = (SlotShape)Enum.Parse(typeof(SlotShape), panel.Tag as string);
                } catch (FormatException) { }
            }

            AxisActions.Gestures axisGesture = pos ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative;
            RegisterOverlay(axis, pos, panel.Bounds, panel.BackColor, shape);

            panel.Hide();
            panel.Tag = ag;
        }
Example #2
0
        private void SetupAxisGesture(AxisGesture ag)
        {
            string   name = "";
            TreeNode root = null;

            VirtualController.Axis
                stick = Util.StickFromGesture(ag),
                axis  = Util.AxisFromGesture(ag);
            bool pos  = Util.PoleFromGesture(ag);

            AxisActions.Gestures axisGesture = pos ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative;

            EventHandler press = delegate(object sender, EventArgs e)
            {
                padView.SetOverlay(axis, pos, true);

                if (padView.AutoSelectInput)
                {
                    string idx  = Util.GetAxisGestureID(axis, axisGesture);
                    var    node = buttonMapNodes[idx];
                    currentMappings.SelectedNode = node;
                    if (node != null)
                    {
                        node.Expand();
                    }
                }
            };

            EventHandler release = delegate(object sender, EventArgs e)
            {
                padView.SetOverlay(axis, pos, false);
            };

            switch (ag)
            {
            case AxisGesture.LeftXNeg:
                controller.Virtual.LeftXAxis.NegativePress   += press;
                controller.Virtual.LeftXAxis.NegativeRelease += release;
                break;

            case AxisGesture.LeftXPos:
                controller.Virtual.LeftXAxis.PositivePress   += press;
                controller.Virtual.LeftXAxis.PositiveRelease += release;
                break;

            case AxisGesture.LeftYNeg:
                controller.Virtual.LeftYAxis.NegativePress   += press;
                controller.Virtual.LeftYAxis.NegativeRelease += release;
                break;

            case AxisGesture.LeftYPos:
                controller.Virtual.LeftYAxis.PositivePress   += press;
                controller.Virtual.LeftYAxis.PositiveRelease += release;
                break;

            case AxisGesture.RightXNeg:
                controller.Virtual.RightXAxis.NegativePress   += press;
                controller.Virtual.RightXAxis.NegativeRelease += release;
                break;

            case AxisGesture.RightXPos:
                controller.Virtual.RightXAxis.PositivePress   += press;
                controller.Virtual.RightXAxis.PositiveRelease += release;
                break;

            case AxisGesture.RightYNeg:
                controller.Virtual.RightYAxis.NegativePress   += press;
                controller.Virtual.RightYAxis.NegativeRelease += release;
                break;

            case AxisGesture.RightYPos:
                controller.Virtual.RightYAxis.PositivePress   += press;
                controller.Virtual.RightYAxis.PositiveRelease += release;
                break;

            case AxisGesture.DigitalXNeg:
                controller.Virtual.DigitalXAxis.NegativePress   += press;
                controller.Virtual.DigitalXAxis.NegativeRelease += release;
                break;

            case AxisGesture.DigitalXPos:
                controller.Virtual.DigitalXAxis.PositivePress   += press;
                controller.Virtual.DigitalXAxis.PositiveRelease += release;
                break;

            case AxisGesture.DigitalYNeg:
                controller.Virtual.DigitalYAxis.NegativePress   += press;
                controller.Virtual.DigitalYAxis.NegativeRelease += release;
                break;

            case AxisGesture.DigitalYPos:
                controller.Virtual.DigitalYAxis.PositivePress   += press;
                controller.Virtual.DigitalYAxis.PositiveRelease += release;
                break;

            case AxisGesture.TriggerNeg:
                controller.Virtual.Trigger.NegativePress   += press;
                controller.Virtual.Trigger.NegativeRelease += release;
                break;

            case AxisGesture.TriggerPos:
                controller.Virtual.Trigger.PositivePress   += press;
                controller.Virtual.Trigger.PositiveRelease += release;
                break;
            }

            if (stick == VirtualController.Axis.RightX)
            {
                if (axisPortNodes.ContainsKey(stick))
                {
                    root = axisPortNodes[stick];
                }
                else
                {
                    root = axisPortNodes[stick] = buttonMapNodes["right-analog"] = currentMappings.Nodes.Add("Right Analog");
                    buttonMapNodes["right-analog/analog"] = root.Nodes.Add("Analog");
                }
            }
            else if (stick == VirtualController.Axis.LeftX)
            {
                if (axisPortNodes.ContainsKey(stick))
                {
                    root = axisPortNodes[stick];
                }
                else
                {
                    root = axisPortNodes[stick] = buttonMapNodes["left-analog"] = currentMappings.Nodes.Add("Left Analog");
                    buttonMapNodes["left-analog/analog"] = root.Nodes.Add("Analog");
                }
            }
            else if (stick == VirtualController.Axis.DigitalX)
            {
                if (axisPortNodes.ContainsKey(stick))
                {
                    root = axisPortNodes[stick];
                }
                else
                {
                    root = axisPortNodes[stick] = buttonMapNodes["digital"] = currentMappings.Nodes.Add("Digital Pad");
                    buttonMapNodes["digital/analog"] = root.Nodes.Add("Raw");                     // Hardee har!
                }
            }
            else if (stick == VirtualController.Axis.Trigger)
            {
                if (axisPortNodes.ContainsKey(stick))
                {
                    root = axisPortNodes[stick];
                }
                else
                {
                    root = axisPortNodes[stick] = buttonMapNodes["trigger"] = currentMappings.Nodes.Add("Trigger");
                    buttonMapNodes["trigger/analog"] = root.Nodes.Add("Analog");
                }
            }

            switch (ag)
            {
            case AxisGesture.LeftXNeg:
            case AxisGesture.RightXNeg:
            case AxisGesture.DigitalXNeg:
            case AxisGesture.TriggerPos:
                name = "Left";
                break;

            case AxisGesture.LeftXPos:
            case AxisGesture.RightXPos:
            case AxisGesture.DigitalXPos:
            case AxisGesture.TriggerNeg:
                name = "Right";
                break;

            case AxisGesture.LeftYNeg:
            case AxisGesture.RightYNeg:
            case AxisGesture.DigitalYNeg:
                name = "Up";
                break;

            case AxisGesture.LeftYPos:
            case AxisGesture.RightYPos:
            case AxisGesture.DigitalYPos:
                name = "Down";
                break;
            }
            var n = root.Nodes.Add(name.ToString());

            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture)]           = n;
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/link"] = n.Nodes.Add("Link");
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/tap"]  = n.Nodes.Add("Tap");
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/dtap"] = n.Nodes.Add("Double Tap");
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/hold"] = n.Nodes.Add("Hold");
        }
Example #3
0
        private void SetupAxisGesture(AxisGesture ag, Panel panel)
        {
            VirtualController.Axis
                stick = Util.StickFromGesture(ag),
                axis = Util.AxisFromGesture(ag);
            bool pos = Util.PoleFromGesture(ag);
            SlotShape shape = SlotShape.Rounded;

            if (panel.Tag is string) try {
                    shape = (SlotShape)Enum.Parse(typeof(SlotShape), panel.Tag as string);
                } catch (FormatException) { }

            AxisActions.Gestures axisGesture = pos ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative;
            RegisterOverlay(axis, pos, panel.Bounds, panel.BackColor, shape);

            panel.Hide();
            panel.Tag = ag;
        }
Example #4
0
        private void SetupAxisGesture(AxisGesture ag)
        {
            string name = "";
            TreeNode root = null;
            VirtualController.Axis
                stick = Util.StickFromGesture(ag),
                axis = Util.AxisFromGesture(ag);
            bool pos = Util.PoleFromGesture(ag);
            AxisActions.Gestures axisGesture = pos ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative;

            EventHandler press = delegate(object sender, EventArgs e)
            {
                padView.SetOverlay(axis, pos, true);

                if (padView.AutoSelectInput) {
                    string idx = Util.GetAxisGestureID(axis, axisGesture);
                    var node = buttonMapNodes[idx];
                    currentMappings.SelectedNode = node;
                    if (node != null)
                        node.Expand();
                }
            };

            EventHandler release = delegate(object sender, EventArgs e)
            {
                padView.SetOverlay(axis, pos, false);
            };

            switch (ag) {
                case AxisGesture.LeftXNeg:
                    controller.Virtual.LeftXAxis.NegativePress += press;
                    controller.Virtual.LeftXAxis.NegativeRelease += release;
                    break;
                case AxisGesture.LeftXPos:
                    controller.Virtual.LeftXAxis.PositivePress += press;
                    controller.Virtual.LeftXAxis.PositiveRelease += release;
                    break;
                case AxisGesture.LeftYNeg:
                    controller.Virtual.LeftYAxis.NegativePress += press;
                    controller.Virtual.LeftYAxis.NegativeRelease += release;
                    break;
                case AxisGesture.LeftYPos:
                    controller.Virtual.LeftYAxis.PositivePress += press;
                    controller.Virtual.LeftYAxis.PositiveRelease += release;
                    break;
                case AxisGesture.RightXNeg:
                    controller.Virtual.RightXAxis.NegativePress += press;
                    controller.Virtual.RightXAxis.NegativeRelease += release;
                    break;
                case AxisGesture.RightXPos:
                    controller.Virtual.RightXAxis.PositivePress += press;
                    controller.Virtual.RightXAxis.PositiveRelease += release;
                    break;
                case AxisGesture.RightYNeg:
                    controller.Virtual.RightYAxis.NegativePress += press;
                    controller.Virtual.RightYAxis.NegativeRelease += release;
                    break;
                case AxisGesture.RightYPos:
                    controller.Virtual.RightYAxis.PositivePress += press;
                    controller.Virtual.RightYAxis.PositiveRelease += release;
                    break;
                case AxisGesture.DigitalXNeg:
                    controller.Virtual.DigitalXAxis.NegativePress += press;
                    controller.Virtual.DigitalXAxis.NegativeRelease += release;
                    break;
                case AxisGesture.DigitalXPos:
                    controller.Virtual.DigitalXAxis.PositivePress += press;
                    controller.Virtual.DigitalXAxis.PositiveRelease += release;
                    break;
                case AxisGesture.DigitalYNeg:
                    controller.Virtual.DigitalYAxis.NegativePress += press;
                    controller.Virtual.DigitalYAxis.NegativeRelease += release;
                    break;
                case AxisGesture.DigitalYPos:
                    controller.Virtual.DigitalYAxis.PositivePress += press;
                    controller.Virtual.DigitalYAxis.PositiveRelease += release;
                    break;
                case AxisGesture.TriggerNeg:
                    controller.Virtual.Trigger.NegativePress += press;
                    controller.Virtual.Trigger.NegativeRelease += release;
                    break;
                case AxisGesture.TriggerPos:
                    controller.Virtual.Trigger.PositivePress += press;
                    controller.Virtual.Trigger.PositiveRelease += release;
                    break;
            }

            if (stick == VirtualController.Axis.RightX) {
                if (axisPortNodes.ContainsKey(stick)) {
                    root = axisPortNodes[stick];
                } else {
                    root = axisPortNodes[stick] = buttonMapNodes["right-analog"] = currentMappings.Nodes.Add("Right Analog");
                    buttonMapNodes["right-analog/analog"] = root.Nodes.Add("Analog");
                }
            } else if (stick == VirtualController.Axis.LeftX) {
                if (axisPortNodes.ContainsKey(stick)) {
                    root = axisPortNodes[stick];
                } else {
                    root = axisPortNodes[stick] = buttonMapNodes["left-analog"] = currentMappings.Nodes.Add("Left Analog");
                    buttonMapNodes["left-analog/analog"] = root.Nodes.Add("Analog");
                }
            } else if (stick == VirtualController.Axis.DigitalX) {
                if (axisPortNodes.ContainsKey(stick)) {
                    root = axisPortNodes[stick];
                } else {
                    root = axisPortNodes[stick] = buttonMapNodes["digital"] = currentMappings.Nodes.Add("Digital Pad");
                    buttonMapNodes["digital/analog"] = root.Nodes.Add("Raw"); // Hardee har!
                }
            } else if (stick == VirtualController.Axis.Trigger) {
                if (axisPortNodes.ContainsKey(stick)) {
                    root = axisPortNodes[stick];
                } else {
                    root = axisPortNodes[stick] = buttonMapNodes["trigger"] = currentMappings.Nodes.Add("Trigger");
                    buttonMapNodes["trigger/analog"] = root.Nodes.Add("Analog");
                }
            }

            switch (ag) {
                case AxisGesture.LeftXNeg:
                case AxisGesture.RightXNeg:
                case AxisGesture.DigitalXNeg:
                case AxisGesture.TriggerPos:
                    name = "Left";
                    break;
                case AxisGesture.LeftXPos:
                case AxisGesture.RightXPos:
                case AxisGesture.DigitalXPos:
                case AxisGesture.TriggerNeg:
                    name = "Right";
                    break;
                case AxisGesture.LeftYNeg:
                case AxisGesture.RightYNeg:
                case AxisGesture.DigitalYNeg:
                    name = "Up";
                    break;
                case AxisGesture.LeftYPos:
                case AxisGesture.RightYPos:
                case AxisGesture.DigitalYPos:
                    name = "Down";
                    break;
            }
            var n = root.Nodes.Add(name.ToString());
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture)] = n;
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/link"] = n.Nodes.Add("Link");
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/tap"] = n.Nodes.Add("Tap");
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/dtap"] = n.Nodes.Add("Double Tap");
            buttonMapNodes[Util.GetAxisGestureID(axis, axisGesture) + "/hold"] = n.Nodes.Add("Hold");
        }