示例#1
0
文件: MainForm.cs 项目: xuxiandi/XJoy
        private void ParseConfigMapping(string From, string To)
        {
            ComboBox inputControl = GetControlForInput(From);

            if (inputControl != null)
            {
                ComboBox.ObjectCollection items = inputControl.Items;
                HID_USAGES axis;
                bool       isAxis = TryGetAxisFromString(To, out axis);

                if (isAxis)
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        vJoyManager.AnalogInput inputData = items[i] as vJoyManager.AnalogInput;
                        if (inputData != null)
                        {
                            if (inputData.Axis == axis)
                            {
                                inputControl.SelectedIndex = i;
                                return;
                            }
                        }
                    }
                }
                else
                {
                    int  buttonIndex;
                    bool s = Int32.TryParse(To, out buttonIndex);
                    if (s)
                    {
                        for (int i = 0; i < items.Count; i++)
                        {
                            vJoyManager.DigitalInput inputData = items[i] as vJoyManager.DigitalInput;
                            if (inputData != null)
                            {
                                if (inputData.ButtonIndex == buttonIndex)
                                {
                                    inputControl.SelectedIndex = i;
                                    return;
                                }
                            }
                        }
                        Console.WriteLine("Couldn't match button index #" + buttonIndex);
                        return;
                    }
                }
                Console.WriteLine("Failed to find input mapping for '" + To + "'");
                return;
            }
            else
            {
                Console.WriteLine("Failed to find input control for '" + From + "'");
                return;
            }
        }
示例#2
0
文件: MainForm.cs 项目: xuxiandi/XJoy
 private void AddInputMappingFromBox(object SelectedItem, XInputManager.Inputs From)
 {
     if (SelectedItem != null)
     {
         vJoyManager.AnalogInput InputDataAnalog = SelectedItem as vJoyManager.AnalogInput;
         if (InputDataAnalog != null)
         {
             InputMappings.Add(new InputMapping(From, 0, InputDataAnalog.Axis, InputMapping.MappingType.Axis));
         }
         else
         {
             vJoyManager.DigitalInput InputDataDigital = SelectedItem as vJoyManager.DigitalInput;
             if (InputDataDigital != null)
             {
                 InputMappings.Add(new InputMapping(From, InputDataDigital.ButtonIndex, HID_USAGES.HID_USAGE_X, InputMapping.MappingType.Button));
             }
         }
     }
 }
示例#3
0
文件: MainForm.cs 项目: xuxiandi/XJoy
        private void WriteInputLineToSaveFile(ref StreamWriter Writer, ComboBox Control, string XInputName)
        {
            if (Control.SelectedIndex != 0 && Control.SelectedItem != null)
            {
                vJoyManager.AnalogInput analog = Control.SelectedItem as vJoyManager.AnalogInput;
                if (analog != null)
                {
                    string vJoyName = "";
                    switch (analog.Axis)
                    {
                    case HID_USAGES.HID_USAGE_X:
                        vJoyName = "X";
                        break;

                    case HID_USAGES.HID_USAGE_Y:
                        vJoyName = "Y";
                        break;

                    case HID_USAGES.HID_USAGE_Z:
                        vJoyName = "Z";
                        break;

                    case HID_USAGES.HID_USAGE_RX:
                        vJoyName = "RX";
                        break;

                    case HID_USAGES.HID_USAGE_RY:
                        vJoyName = "RY";
                        break;

                    case HID_USAGES.HID_USAGE_RZ:
                        vJoyName = "RZ";
                        break;

                    case HID_USAGES.HID_USAGE_SL0:
                        vJoyName = "SL0";
                        break;

                    case HID_USAGES.HID_USAGE_SL1:
                        vJoyName = "SL1";
                        break;

                    case HID_USAGES.HID_USAGE_WHL:
                        vJoyName = "WHL";
                        break;

                    case HID_USAGES.HID_USAGE_POV:
                        vJoyName = "POV";
                        break;

                    default:
                        return;
                    }

                    Writer.WriteLine(XInputName + "=" + vJoyName);
                }
                else
                {
                    vJoyManager.DigitalInput digital = Control.SelectedItem as vJoyManager.DigitalInput;
                    if (digital != null)
                    {
                        Writer.WriteLine(XInputName + "=" + digital.ButtonIndex.ToString());
                    }
                }
            }
        }