Esempio n. 1
0
        private void changeBtn_Click(object sender, EventArgs e)
        {
            if (buttonMappings.SelectedItem == null)
            {
                return;
            }

            var item = buttonMappings.SelectedItem as DeviceMappingItem;
            var cmf  = new ChangeMappingDialog(mainForm, item.Mapping.Pad, item.Mapping.Source, item.Mapping.Gesture, item.Mapping.Destination);

            cmf.ShowDialog(this);

            if (cmf.DialogResult == DialogResult.OK)
            {
                bool isButton = item.Mapping.Source.StartsWith("button:");

                item.Mapping.Destination = cmf.Destination;
                if (isButton)
                {
                    item.Mapping.Gesture = cmf.Gesture;
                }
                else
                {
                    item.Mapping.Gesture = "";
                }

                if (isButton)
                {
                    int btn = int.Parse(item.Mapping.Source.Substring("button:".Length));
                    VirtualController.Button b = (VirtualController.Button)Enum.Parse(typeof(VirtualController.Button), cmf.Destination);
                    var ba = new VirtualController.ButtonAction(controller.Virtual, b);

                    if (cmf.Gesture != "Link" && cmf.Gesture != "" && cmf.Gesture != null)
                    {
                        // We need to enable gesture support at the device level for this button
                        controller.Device.Buttons[btn].EnableGestures = true;
                    }

                    switch (cmf.Gesture)
                    {
                    case "Link":
                    case null:
                    case "":
                        controller.Device.Buttons[btn].Link = ba;
                        break;

                    case "Tap":
                        controller.Device.Buttons[btn].Tap = ba;
                        break;

                    case "DoubleTap":
                        controller.Device.Buttons[btn].DoubleTap = ba;
                        break;

                    case "Hold":
                        controller.Device.Buttons[btn].Hold = ba;
                        break;
                    }
                }
                else
                {
                    int axis = int.Parse(item.Mapping.Source.Substring("axis:".Length));
                    VirtualController.Axis a = (VirtualController.Axis)Enum.Parse(typeof(VirtualController.Axis), cmf.Destination);
                    controller.Device.Axes[axis].Analog = new VirtualController.AxisAction(controller.Virtual, a);
                }

                mainForm.GlobalConfig.Save();
                RefreshDeviceMappings();
            }
        }
Esempio n. 2
0
        private void changeBtn_Click(object sender, EventArgs e)
        {
            if (buttonMappings.SelectedItem == null)
                return;

            var item = buttonMappings.SelectedItem as DeviceMappingItem;
            var cmf = new ChangeMappingDialog(mainForm, item.Mapping.Pad, item.Mapping.Source, item.Mapping.Gesture, item.Mapping.Destination);
            cmf.ShowDialog(this);

            if (cmf.DialogResult == DialogResult.OK) {
                bool isButton = item.Mapping.Source.StartsWith("button:");

                item.Mapping.Destination = cmf.Destination;
                if (isButton) item.Mapping.Gesture = cmf.Gesture;
                else item.Mapping.Gesture = "";

                if (isButton) {
                    int btn = int.Parse(item.Mapping.Source.Substring("button:".Length));
                    VirtualController.Button b = (VirtualController.Button)Enum.Parse(typeof(VirtualController.Button), cmf.Destination);
                    var ba = new VirtualController.ButtonAction(controller.Virtual, b);

                    if (cmf.Gesture != "Link" && cmf.Gesture != "" && cmf.Gesture != null) {
                        // We need to enable gesture support at the device level for this button
                        controller.Device.Buttons[btn].EnableGestures = true;
                    }

                    switch (cmf.Gesture) {
                        case "Link":
                        case null:
                        case "":
                            controller.Device.Buttons[btn].Link = ba;
                            break;
                        case "Tap":
                            controller.Device.Buttons[btn].Tap = ba;
                            break;
                        case "DoubleTap":
                            controller.Device.Buttons[btn].DoubleTap = ba;
                            break;
                        case "Hold":
                            controller.Device.Buttons[btn].Hold = ba;
                            break;
                    }
                } else {
                    int axis = int.Parse(item.Mapping.Source.Substring("axis:".Length));
                    VirtualController.Axis a = (VirtualController.Axis)Enum.Parse(typeof(VirtualController.Axis), cmf.Destination);
                    controller.Device.Axes[axis].Analog = new VirtualController.AxisAction(controller.Virtual, a);
                }

                mainForm.GlobalConfig.Save();
                RefreshDeviceMappings();
            }
        }