public InGameAxAssgn(int devNum, int phyAxNum, bool invert, AxCurve deadzone, AxCurve saturation)
 {
     this.devNum     = devNum;
     this.phyAxNum   = phyAxNum;
     this.invert     = invert;
     this.deadzone   = deadzone;
     this.saturation = saturation;
 }
示例#2
0
 public AxAssgn(String axisName, DateTime assgnDate, bool invert, AxCurve saturation, AxCurve deadzone)
 {
     this.axisName   = axisName;
     this.assgnDate  = assgnDate;
     this.invert     = invert;
     this.saturation = saturation;
     this.deadzone   = deadzone;
 }
示例#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();
 }
示例#4
0
 public InGameAxAssgn(JoyAssgn joy, int phyAxNum, bool invert, AxCurve deadzone, AxCurve saturation)
 {
     this.joy        = joy;
     this.phyAxNum   = phyAxNum;
     this.invert     = invert;
     this.deadzone   = deadzone;
     this.saturation = saturation;
 }
 public InGameAxAssgn(int devNum, int phyAxNum, AxAssgn axis)
 {
     this.devNum   = devNum;
     this.phyAxNum = phyAxNum;
     invert        = axis.GetInvert();
     saturation    = axis.GetSaturation();
     deadzone      = axis.GetDeadZone();
     assgnDate     = axis.GetAssignDate();
 }
示例#6
0
 public InGameAxAssgn(JoyAssgn joy, int phyAxNum, AxAssgn axis)
 {
     this.joy      = joy;
     this.phyAxNum = phyAxNum;
     invert        = axis.GetInvert();
     saturation    = axis.GetSaturation();
     deadzone      = axis.GetDeadZone();
     assgnDate     = axis.GetAssignDate();
 }
示例#7
0
        /// <summary>
        /// Shows axis output with DEADZONE and SATURATION enabled in BMS
        /// </summary>
        /// <param name="input"></param>
        /// <param name="deadzone"></param>
        /// <param name="saturation"></param>
        /// <returns></returns>
        public static int ApplyDeadZone(int input, AxCurve deadzone, AxCurve saturation)
        {
            double x = (double)input, y = 0;
            double x1 = 0, x2 = 0, x3 = 0, x4 = 0, a1 = 0, a2 = 0, b1 = 0, b2 = 0;

            switch (deadzone)
            {
            case AxCurve.None:
                x2 = MAXIN / 2;
                x3 = MAXIN / 2;
                break;

            case AxCurve.Small:
                x2 = (MAXIN / 2) - ((MAXIN / 2) * 0.01);
                x3 = (MAXIN / 2) + ((MAXIN / 2) * 0.01);
                break;

            case AxCurve.Medium:
                x2 = (MAXIN / 2) - ((MAXIN / 2) * 0.05);
                x3 = (MAXIN / 2) + ((MAXIN / 2) * 0.05);
                break;

            case AxCurve.Large:
                x2 = (MAXIN / 2) - ((MAXIN / 2) * 0.1);
                x3 = (MAXIN / 2) + ((MAXIN / 2) * 0.1);
                break;
            }
            switch (saturation)
            {
            case AxCurve.None:
                x1 = 0;
                x4 = MAXIN;
                break;

            case AxCurve.Small:
                x1 = 0 + ((MAXIN / 2) * 0.01);
                x4 = MAXIN - ((MAXIN / 2) * 0.01);
                break;

            case AxCurve.Medium:
                x1 = 0 + ((MAXIN / 2) * 0.05);
                x4 = MAXIN - ((MAXIN / 2) * 0.05);
                break;

            case AxCurve.Large:
                x1 = 0 + ((MAXIN / 2) * 0.1);
                x4 = MAXIN - ((MAXIN / 2) * 0.1);
                break;
            }

            a1 = (MAXIN / 2) / (x2 - x1);
            b1 = -a1 * x1;
            a2 = (MAXIN / 2) / (x4 - x3);
            b2 = (MAXIN / 2) - a2 * x3;

            if (input < (MAXIN / 2))
            {
                y = a1 * x + b1;
                if (y < 0)
                {
                    y = 0;
                }
                if (y > (MAXIN / 2))
                {
                    y = (MAXIN / 2);
                }
            }
            if (input >= (MAXIN / 2))
            {
                y = a2 * x + b2;
                if (y < (MAXIN / 2))
                {
                    y = (MAXIN / 2);
                }
                if (y > MAXIN)
                {
                    y = MAXIN;
                }
            }

            int output = (int)y;

            return(output);
        }
示例#8
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);
                        }
                    }
                }
            }
        }
示例#9
0
        /// <summary>
        /// Shows axis output with DEADZONE and SATURATION enabled in BMS
        /// </summary>
        /// <param name="input"></param>
        /// <param name="deadzone"></param>
        /// <param name="saturation"></param>
        /// <returns></returns>
        public static int ApplyDeadZone(int input, AxCurve deadzone, AxCurve saturation)
        {
            double x = input, y = 0;
            double x1 = 0, x2 = 0, x3 = 0, x4 = 0, a1 = 0, a2 = 0, b1 = 0, b2 = 0;

            switch (deadzone)
            {
            case AxCurve.None:
                x2 = CommonConstants.AXISMAX / 2;
                x3 = CommonConstants.AXISMAX / 2;
                break;

            case AxCurve.Small:
                x2 = CommonConstants.AXISMAX / 2 - CommonConstants.AXISMAX / 2 * 0.01;
                x3 = CommonConstants.AXISMAX / 2 + CommonConstants.AXISMAX / 2 * 0.01;
                break;

            case AxCurve.Medium:
                x2 = CommonConstants.AXISMAX / 2 - CommonConstants.AXISMAX / 2 * 0.05;
                x3 = CommonConstants.AXISMAX / 2 + CommonConstants.AXISMAX / 2 * 0.05;
                break;

            case AxCurve.Large:
                x2 = CommonConstants.AXISMAX / 2 - CommonConstants.AXISMAX / 2 * 0.1;
                x3 = CommonConstants.AXISMAX / 2 + CommonConstants.AXISMAX / 2 * 0.1;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(deadzone), deadzone, null);     // TODO: Add error message to pass to console/logs here.
            }
            switch (saturation)
            {
            case AxCurve.None:
                x1 = CommonConstants.AXISMIN;
                x4 = CommonConstants.AXISMAX;
                break;

            case AxCurve.Small:
                x1 = CommonConstants.AXISMIN + CommonConstants.AXISMAX / 2 * 0.01;
                x4 = CommonConstants.AXISMAX - CommonConstants.AXISMAX / 2 * 0.01;
                break;

            case AxCurve.Medium:
                x1 = CommonConstants.AXISMIN + CommonConstants.AXISMAX / 2 * 0.05;
                x4 = CommonConstants.AXISMAX - CommonConstants.AXISMAX / 2 * 0.05;
                break;

            case AxCurve.Large:
                x1 = CommonConstants.AXISMIN + CommonConstants.AXISMAX / 2 * 0.1;
                x4 = CommonConstants.AXISMAX - CommonConstants.AXISMAX / 2 * 0.1;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(saturation), saturation, null);     // TODO: Add error message to pass to console/logs here.
            }

            a1 = CommonConstants.AXISMAX / 2 / (x2 - x1);
            b1 = -a1 * x1;
            a2 = CommonConstants.AXISMAX / 2 / (x4 - x3);
            b2 = CommonConstants.AXISMAX / 2 - a2 * x3;

            if (input < CommonConstants.AXISMAX / 2)
            {
                y = a1 * x + b1;
                if (y < CommonConstants.AXISMIN)
                {
                    y = CommonConstants.AXISMIN;
                }
                if (y > CommonConstants.AXISMAX / 2)
                {
                    y = CommonConstants.AXISMAX / 2;
                }
            }
            if (input >= CommonConstants.AXISMAX / 2)
            {
                y = a2 * x + b2;
                if (y < CommonConstants.AXISMAX / 2)
                {
                    y = CommonConstants.AXISMAX / 2;
                }
                if (y > CommonConstants.AXISMAX)
                {
                    y = CommonConstants.AXISMAX;
                }
            }

            int output = (int)y;

            return(output);
        }