Exemple #1
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     if (status == Status.WaitInput)
     {
         AxAssgn axisInfo = new AxAssgn();
         axisAssign = new InGameAxAssgn(-1, -1, axisInfo);
         if (whoCalledWindow == "Throttle" | whoCalledWindow == "Throttle_Right")
         {
             MainWindow.deviceControl.throttlePos = new ThrottlePosition();
         }
     }
     if (status == Status.ShowAxisStatus)
     {
         AxAssgn axisInfo = new AxAssgn();
         axisAssign = new InGameAxAssgn(
             devNumTmp,
             phyAxNumTmp,
             (bool)Invert.IsChecked,
             (AxCurve)DeadZone.SelectedIndex,
             (AxCurve)Saturation.SelectedIndex
             );
         if (whoCalledWindow == "Throttle" | whoCalledWindow == "Throttle_Right")
         {
             MainWindow.deviceControl.throttlePos = new ThrottlePosition(AB, IDLE);
         }
     }
     AxisDetectionTimer.Stop();
     sw.Stop();
     Close();
 }
Exemple #2
0
        public static InGameAxAssgn ShowAxisAssignWindow(InGameAxAssgn axisAssign, object sender)
        {
            AxisAssignWindow ownWindow = new AxisAssignWindow(axisAssign, sender);

            ownWindow.ShowDialog();
            axisAssign = ownWindow.axisAssign;
            return(axisAssign);
        }
Exemple #3
0
 public AxAssgn(String axisName, InGameAxAssgn axisassign)
 {
     this.axisName   = axisName;
     this.assgnDate  = DateTime.Now;
     this.invert     = axisassign.GetInvert();
     this.saturation = axisassign.GetSaturation();
     this.deadzone   = axisassign.GetDeadzone();
 }
Exemple #4
0
        public AxisAssignWindow(InGameAxAssgn axisAssign, object sender)
        {
            InitializeComponent();

            this.axisAssign = axisAssign;
            whoCalledWindow = ((System.Windows.Controls.Button)sender).Name;

            devNumTmp   = axisAssign.GetDeviceNumber();
            phyAxNumTmp = axisAssign.GetPhysicalNumber();

            MouseWheel += Detect_MouseWheel;
        }
Exemple #5
0
        /// <summary>
        /// Callback When clicked "Assign" Button. Opens AxisAssignWindow.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Assign_Click(object sender, RoutedEventArgs e)
        {
            AxisMovingTimer.Stop();

            string whocalledwindow = ((System.Windows.Controls.Button)sender).Name;

            InGameAxAssgn axisAssign = new InGameAxAssgn();

            axisAssign = AxisAssignWindow.ShowMiniWindow((InGameAxAssgn)inGameAxis[whocalledwindow], sender);

            // Reset PhysicalAxis previously assigned to same axis
            // In case of axis has been unassigned and saved.
            for (int i = 0; i < deviceControl.devList.Count; i++)
            {
                deviceControl.joyAssign[i].ResetPreviousAxis(whocalledwindow);
            }
            if (deviceControl.mouseWheelAssign.GetAxisName() == whocalledwindow)
            {
                deviceControl.mouseWheelAssign = new JoyAssgn.AxAssgn();
            }

            // When axis has been assigned.
            if (axisAssign.GetDeviceNumber() > -1)
            {
                deviceControl.joyAssign[axisAssign.GetDeviceNumber()].axis[axisAssign.GetPhysicalNumber()]
                    = new JoyAssgn.AxAssgn(whocalledwindow, axisAssign);
            }
            if (axisAssign.GetDeviceNumber() == -2)
            {
                wheelValue = 0;
                deviceControl.mouseWheelAssign = new JoyAssgn.AxAssgn(whocalledwindow, axisAssign);
            }

            joyAssign_2_inGameAxis();
            ResetAssgnWindow();

            AxisMovingTimer.Start();
        }
Exemple #6
0
        /// <summary>
        /// Make new instance.
        /// </summary>
        public void ImportStockSetup(AppRegInfo appReg, int devcount, int povnum, int joynum)
        {
            Invoke    invokeStatus    = Invoke.UI;
            Behaviour behaviourStatus = Behaviour.Press;

            string deviceSorting = appReg.GetInstallDir() + "/User/Config/DeviceSorting.txt";

            if (System.IO.Path.GetFileName(deviceSorting) != "DeviceSorting.txt")
            {
                return;
            }
            if (System.IO.File.Exists(deviceSorting) == false)
            {
                return;
            }
            string[] lines     = System.IO.File.ReadAllLines(deviceSorting, Encoding.UTF8);
            int      currentID = -1;

            for (int i = 0; i < lines.Count(); i++)
            {
                if (lines[i] == this.GetDeviceSortingLine().Replace("\r\n", ""))
                {
                    currentID = i;
                }
            }
            if (currentID == -1)
            {
                return;
            }
            string keyfile = appReg.GetInstallDir() + "/User/Config/" + appReg.getKeyFileName();

            string[] Klines = System.IO.File.ReadAllLines(keyfile, Encoding.UTF8);
            foreach (string stBuffer in Klines)
            {
                string[] stArrayData = stBuffer.Split(' ');
                if (stArrayData.Length < 7)
                {
                    continue;
                }
                if (stBuffer.Substring(0, 1) == "#")
                {
                    continue;
                }
                if (stArrayData[3] == "-2" | stArrayData[3] == "-3")
                {
                    if ((string)stArrayData[2] == "-1")
                    {
                        invokeStatus = Invoke.Default;
                    }
                    if ((string)stArrayData[2] == "-2")
                    {
                        invokeStatus = Invoke.Down;
                    }
                    if ((string)stArrayData[2] == "-4")
                    {
                        invokeStatus = Invoke.Up;
                    }
                    if ((string)stArrayData[2] == "8")
                    {
                        invokeStatus = Invoke.UI;
                    }
                    if ((string)stArrayData[3] == "0")
                    {
                        behaviourStatus = Behaviour.Press;
                    }
                    if ((string)stArrayData[3] == "0x42")
                    {
                        behaviourStatus = Behaviour.Release;
                    }
                }
                // Import DX Setup
                if (stArrayData[3] == "-2")
                {
                    for (int i = 0; i < 32; i++)
                    {
                        if (Int32.Parse(stArrayData[1]) == i + currentID * 32)
                        {
                            this.dx[i].Assign((string)stArrayData[0], Pinky.UnShift, behaviourStatus, invokeStatus, 0);
                        }
                        if (Int32.Parse(stArrayData[1]) == i + currentID * 32 + devcount * 32) // Okay This has to be the problem. I have to read FalconBMS.cfg for
                        {
                            this.dx[i].Assign((string)stArrayData[0], Pinky.Shift, behaviourStatus, invokeStatus, 0);
                        }
                    }
                }
                // Import POV Setup
                if (stArrayData[3] == "-3")
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (Int32.Parse(stArrayData[1]) != i)
                        {
                            continue;
                        }
                        if (povnum < 3)
                        {
                            if (i == 0 | i == 1)
                            {
                                this.pov[i].direction[Int32.Parse(stArrayData[4])].Assign((string)stArrayData[0], Pinky.UnShift, 0);
                            }
                            if (i == 2 | i == 3)
                            {
                                this.pov[i - 2].direction[Int32.Parse(stArrayData[4])].Assign((string)stArrayData[0], Pinky.Shift, 0);
                            }
                            continue;
                        }
                        this.pov[i].direction[Int32.Parse(stArrayData[4])].Assign((string)stArrayData[0], Pinky.UnShift, 0);
                    }
                }
                // Import Axis Setup
                string filename = appReg.GetInstallDir() + "/User/Config/axismapping.dat";
                if (!System.IO.File.Exists(filename))
                {
                    return;
                }
                System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                byte[] ad = new byte[fs.Length];
                fs.Read(ad, 0, ad.Length);
                fs.Close();

                filename = appReg.GetInstallDir() + "/User/Config/joystick.cal";
                if (!System.IO.File.Exists(filename))
                {
                    return;
                }
                fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                byte[] jc = new byte[fs.Length];
                fs.Read(jc, 0, jc.Length);
                fs.Close();

                AxisName[] axisMappingList = appReg.getOverrideWriter().getAxisMappingList();
                AxisName[] joystickCalList = appReg.getOverrideWriter().getJoystickCalList();
                for (int i = 0; i < axisMappingList.Count(); i++)
                {
                    for (int ii = 0; ii < devcount; ii++)
                    {
                        if ((int)ad[24 + i * 16] == currentID + 2)
                        {
                            int     axisNum  = (int)ad[24 + i * 16 + 4];
                            AxCurve deadzone = AxCurve.None;
                            if ((int)ad[24 + i * 16 + 8] == 0x64)
                            {
                                deadzone = AxCurve.Small;
                            }
                            if ((int)ad[24 + i * 16 + 8] == 0xF4)
                            {
                                deadzone = AxCurve.Medium;
                            }
                            if ((int)ad[24 + i * 16 + 8] == 0xE8)
                            {
                                deadzone = AxCurve.Large;
                            }
                            AxCurve saturation = AxCurve.None;
                            if ((int)ad[24 + i * 16 + 12] == 0x1C)
                            {
                                saturation = AxCurve.Small;
                            }
                            if ((int)ad[24 + i * 16 + 12] == 0x28)
                            {
                                saturation = AxCurve.Medium;
                            }
                            if ((int)ad[24 + i * 16 + 12] == 0x34)
                            {
                                saturation = AxCurve.Large;
                            }
                            bool invert = false;

                            for (int iii = 0; iii < joystickCalList.Count(); iii++)
                            {
                                // read joystick.cal
                                if (axisMappingList[i] != joystickCalList[iii])
                                {
                                    continue;
                                }
                                int invertnum = (int)jc[iii * 28 + 20];
                                if (invertnum == 1)
                                {
                                    invert = true;
                                }
                            }

                            InGameAxAssgn inGameAxAssgn = new InGameAxAssgn(currentID, axisNum, invert, deadzone, saturation);
                            this.axis[axisNum] = new AxAssgn(axisMappingList[i].ToString(), inGameAxAssgn);
                        }
                    }
                }
            }
        }