コード例 #1
0
        public override void CalcOutputDelta(double delayInMs, Vector2 angVelocity, ref Vector2 outputDelta, ref Vector2 outputCarry)
        {
            double veloLen = angVelocity.Length;
            XYLinkedTrans transAlg = this.transFuncs[0];
            bool clearRest = false;
            foreach (XYLinkedTrans alg in this.transFuncs)
            {
                if (clearRest)
                {
                    alg.TimeInOrAboveTrans = 0;
                }
                else
                {
                    if (veloLen < alg.MinSpeed)
                    {
                        alg.TimeInOrAboveTrans = 0;
                        clearRest = true;
                        continue;
                    }

                    transAlg = alg;

                    alg.AddTimeInOrAboveTrans(delayInMs);

                    if (veloLen < alg.MaxSpeed)
                    {
                        clearRest = true;
                        continue;
                    }
                }
            }

            if (veloLen > transAlg.MaxSpeed)
            {
                Vector2 angCarry = new Vector2(angVelocity);
                angCarry.Normalize();
                angCarry.Scale(transAlg.MaxSpeed);
                outputCarry.X = angVelocity.X - angCarry.X;
                outputCarry.Y = angVelocity.Y - angCarry.Y;
                angVelocity = angCarry;
            }

            transAlg.CalcOutputDelta(angVelocity, ref outputDelta);
        }
コード例 #2
0
ファイル: BetaMouseMath.cs プロジェクト: InfInt/ximtranslator
        public void CalcAngularVelocity(Vector2 delta, out Vector2 angularVelocity)
        {
            double speed, accel, yaw, pitch, mouseDpi;

            GetUserSettings(out speed, out accel, out mouseDpi, out pitch, out yaw);

            double delay = (1000 / (1000 / (double)m_rate.Value));
            double revolutionsperinch = speed / 15;

            double userScale = revolutionsperinch * delay / mouseDpi;

            angularVelocity = new Vector2(delta.X, delta.Y);

            // Short circuit if we know we have no movement;
            if (angularVelocity.X != 0 || angularVelocity.Y != 0)
            {
                // Transform mouseDelta into Angular Velocity ( revolutions / time ) = delta^accel * sens * delay
                angularVelocity.Pow(accel);
                angularVelocity.Scale(userScale);

                // Factor in user Y:X ratio
                angularVelocity.X = angularVelocity.X * yaw;
                angularVelocity.Y = angularVelocity.Y * pitch;
            }

            InfoTextManager.Instance.WriteLine(highEndCarry.X.ToString());
            angularVelocity.Add(highEndCarry);
            highEndCarry.X = highEndCarry.Y = 0;

            angularVelocity.Add(lowEndCarry);
            lowEndCarry.X = lowEndCarry.Y = 0;
        }
コード例 #3
0
 public override void CalcOutputDelta(Vector2 angVelocity, ref Vector2 outputDelta)
 {
     Vector2 delta = new Vector2(angVelocity);
     delta.Pow(this.exponent);
     delta.Scale(this.coeff);
     delta.Scale(this.accel.GetAccelCoeff(this.TimeInOrAboveTrans));
     outputDelta = delta;
 }
コード例 #4
0
ファイル: BetaMouseMath.cs プロジェクト: InfInt/ximtranslator
        private void CalcDiag(Vector2 mouseDelta, BetaGamesManager.GameSettings gs)
        {
            if (gs.DiagonalCoeff != 0)
            {
                Vector2 absDelta = new Vector2(Math.Abs(mouseDelta.X), Math.Abs(mouseDelta.Y));
                absDelta.Cap(0, (double)Xim.Stick.Max);

                double association = 0;
                if (absDelta.X > absDelta.Y)
                {
                    association = absDelta.Y / absDelta.X;
                    if (association != 0 && !Double.IsNaN(association) && !Double.IsInfinity(association))
                    {
                        //mouseDelta.Y = mouseDelta.Y + mouseDelta.Y * (0.1 - association / 10) * gs.DiagonalCoeff;
                        mouseDelta.Scale(1 - association * gs.DiagonalCoeff);
                    }
                }
                else
                {
                    association = absDelta.X / absDelta.Y;
                    if (association != 0 && !Double.IsNaN(association) && !Double.IsInfinity(association))
                    {
                        //mouseDelta.X = mouseDelta.X + mouseDelta.X * (0.1 - association / 10) * gs.DiagonalCoeff;
                        mouseDelta.Scale(1 - association * gs.DiagonalCoeff);
                    }
                }
            }
        }
コード例 #5
0
ファイル: BetaMouseMath.cs プロジェクト: InfInt/ximtranslator
 private static Vector2 CalcDeadzone(Vector2 mouseDelta, BetaGamesManager.GameSettings gs)
 {
     Vector2 deadzone = null;
     if (gs.Circular)
     {
         deadzone = new Vector2(mouseDelta.X, mouseDelta.Y);
         deadzone.Normalize();
         deadzone.Scale(gs.Deadzone);
     }
     else
     {
         deadzone = new Vector2(gs.Deadzone * Math.Sign(mouseDelta.X), gs.Deadzone * Math.Sign(mouseDelta.Y));
     }
     return deadzone;
 }
コード例 #6
0
ファイル: MouseMath.cs プロジェクト: InfInt/ximtranslator
        public void XSoftMouseMovement(ref Xim.Input input, ref Xim.Input startState)
        {
            GamesManager.GameSettings gameSettings = gamesManager.GetGameSettings((GamesManager.Games)m_currentGame.Value);

            // User Values
            double speed, accel, yaw, pitch, mouseDpi;

            GetUserSettings(out speed, out accel, out mouseDpi, out pitch, out yaw);

            double delay = (1000 / (1000 / (double)m_rate.Value));
            double revolutionsperinch = speed / 15;

            double userScale = revolutionsperinch * delay / mouseDpi;

            Vector2 delta;
            GetMouseDelta(out delta);

            if (delta.X == 0 && delta.Y == 0)
                return;

            Vector2 mouseDelta = new Vector2(delta.X, delta.Y);

            // Transform mouseDelta into Angular Velocity ( revolutions / time ) = delta^accel * sens * delay
            mouseDelta.Pow(accel);
            mouseDelta.Scale(userScale);

            // Factor in game Y:X ratio
            mouseDelta.X = mouseDelta.X * yaw;
            mouseDelta.Y = mouseDelta.Y * pitch;

            CalcDelta(mouseDelta, gameSettings);

            CalcDiag(mouseDelta, gameSettings);

            CalcAveraging(mouseDelta, gameSettings);

            // Add deadzone
            Vector2 deadzoneVec = CalcDeadzone(mouseDelta, gameSettings);

            mouseDelta.Add(deadzoneVec);

            // pixelCap is the number of pixels per frame that can be processed by the current angular velocity formula.
            // Anything above this value is useless to translate but we can carry the leftover value to the next frame.

            if (gameSettings.XAxis.Cap != -1)
            {
                double pixelCapX = Math.Pow((gameSettings.XAxis.GetPixelCapValue(gameSettings.Deadzone) / (userScale * yaw)), (double)1 / accel);
                if (Math.Abs(delta.X) > pixelCapX)
                {
                    int sign = Math.Sign(delta.X);

                    highEndCarry.X = (Math.Abs(delta.X) - pixelCapX) * sign;
                    mouseDelta.X = (short)(gameSettings.XAxis.Cap * sign);
                }
            }

            if (gameSettings.YAxis.Cap != -1)
            {
                double pixelCapY = Math.Pow((gameSettings.YAxis.GetPixelCapValue(gameSettings.Deadzone) / (userScale * pitch)), (double)1 / accel);
                if (Math.Abs(delta.Y) > pixelCapY)
                {
                    int sign = Math.Sign(mouseDelta.Y);

                    highEndCarry.Y = (Math.Abs(delta.Y) - pixelCapY) * sign;
                    mouseDelta.Y = (short)(gameSettings.YAxis.Cap * sign);
                }
            }

            // pixelsAtMax is the number of pixels we can process when moving at Xim.Stick.Max, if we have moved more than
            // this number of pixels then we should carry the leftover and use Xim.Stick.Max for our output.
            if (gameSettings.XAxis.MaxSpeed != -1)
            {
                double pixelsAtMaxX = Math.Pow((gameSettings.XAxis.MaxSpeed) / (userScale * pitch), 1 / accel);

                if (Math.Abs(delta.X) > pixelsAtMaxX)
                {
                    InfoTextManager.Instance.WriteLineDebug("CarryX!" + delta.X);
                    int sign = Math.Sign(delta.X);
                    highEndCarry.X = (Math.Abs(delta.X) - pixelsAtMaxX) * sign;
                    mouseDelta.X = ((short)Xim.Stick.Max * sign);
                }
            }

            if (gameSettings.YAxis.MaxSpeed != -1)
            {
                double pixelsAtMaxY = Math.Pow((gameSettings.YAxis.MaxSpeed) / (userScale * yaw), 1 / accel);
                if (Math.Abs(delta.Y) > pixelsAtMaxY)
                {
                    InfoTextManager.Instance.WriteLineDebug("CarryY!" + delta.Y);
                    int sign = Math.Sign(delta.Y);
                    highEndCarry.Y = (Math.Abs(delta.Y) - pixelsAtMaxY) * sign;
                    mouseDelta.Y = ((short)Xim.Stick.Max * sign);
                }
            }

            // Some games ( like UT3 ) have a strange Y step function going on, account for that.
            if (gameSettings.XAxis.CarryZone != -1)
            {
                if (Math.Abs(mouseDelta.X) < gameSettings.XAxis.CarryZone)
                {
                    lowEndCarry.X = delta.X;
                    mouseDelta.X = 0;
                }
            }

            if (gameSettings.YAxis.CarryZone != -1)
            {
                if (Math.Abs(mouseDelta.Y) < gameSettings.YAxis.CarryZone)
                {
                    lowEndCarry.Y = delta.Y;
                    mouseDelta.Y = 0;
                }
            }

            mouseDelta.Cap(-(double)Xim.Stick.Max, (double)Xim.Stick.Max);

            SaveDrivingModeData(mouseDelta, delta);

            SetXboxInput(ref input, mouseDelta);
        }
コード例 #7
0
ファイル: MouseAlgs.cs プロジェクト: InfInt/ximtranslator
 public override double CalcOutputDelta(double inputDelta,double otherAxis)
 {
     Vector2 delta = new Vector2(inputDelta, otherAxis);
     delta.Pow(this.Exp);
     delta.Scale(this.Speed);
     return delta.X;
 }
コード例 #8
0
ファイル: MouseAlgs.cs プロジェクト: InfInt/ximtranslator
 public override double CalcOutputDelta(double inputDelta, double otherAxis)
 {
     Vector2 xsquared = new Vector2(inputDelta, otherAxis);
     xsquared.Pow(2);
     xsquared.Scale(this.x2Factor);
     return Math.Sign(inputDelta) * ( xsquared.X + this.xFactor * Math.Abs(inputDelta) + yIntercept ) ;
 }