예제 #1
0
        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;
        }
예제 #2
0
        public void XSoftMouseMovement(double delayInMs, ref Xim.Input input, ref Xim.Input startState)
        {
            BetaGamesManager.GameSettings gameSettings = gamesManager.GetGameSettings((GamesManager.Games)m_currentGame.Value);

            // Get the user input
            Vector2 rawDelta;
            InputManager.Instance.GetAndResetMouseDelta(out rawDelta);
            rawDelta.Y = -rawDelta.Y;

            Vector2 angVelocity;
            CalcAngularVelocity(rawDelta, out angVelocity);

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

            //angVelocity = new Vector2(spot);
            //spot.Rotate(Math.PI / 45);

            Vector2 outputDelta = new Vector2(angVelocity);

            CalcDelta(delayInMs, angVelocity, ref outputDelta, gameSettings);

            /*if(outputDelta.X != 0 && outputDelta.Y != 0)
            {
                double association = 0;
                double xy = 0;
                if (Math.Abs(outputDelta.X) > Math.Abs(outputDelta.Y))
                {
                    association = Math.Abs(outputDelta.Y / outputDelta.X);
                    xy = outputDelta.X;
                }
                else
                {
                    association = Math.Abs(outputDelta.X / outputDelta.Y);
                    xy = outputDelta.Y;
                }

                xy = Math.Sqrt(2 * xy * xy);

                double newLen = outputDelta.Length *( 1.0 - association * .30  );

                outputDelta.Normalize();
                outputDelta.Scale(newLen);
            }*/

            outputDelta.Add(CalcDeadzone(outputDelta, gameSettings));

            SetXboxInput(ref input, outputDelta);
        }
예제 #3
0
        private void GetMouseDelta(out Vector2 delta)
        {
            if ((bool)this.m_drivingMode.Value)
            {
                this.inputManager.GetMouseDelta(out delta);
            }
            else
                this.inputManager.GetAndResetMouseDelta(out delta);

            if ((bool)this.m_drivingMode.Value)
            {
                if (Math.Sign(this.lastFrameMaxVals.X) == Math.Sign(delta.X))
                {
                    if (Math.Abs(this.lastFrameMaxVals.X) < Math.Abs(delta.X))
                        delta.X = lastFrameMaxVals.X;
                }

                if (Math.Sign(this.lastFrameMaxVals.Y) == Math.Sign(delta.Y))
                {
                    if (Math.Abs(this.lastFrameMaxVals.Y) < Math.Abs(delta.Y))
                        delta.Y = lastFrameMaxVals.Y;
                }

                this.inputManager.SetMouseDelta(delta);
            }
            else
            {
                delta.Add(highEndCarry);
                highEndCarry.X = highEndCarry.Y = 0;

                delta.Add(lowEndCarry);
                lowEndCarry.X = lowEndCarry.Y = 0;
            }
        }
예제 #4
0
 public static Vector2 operator +(Vector2 first, Vector2 other )
 {
     Vector2 v = new Vector2(other.X, other.Y);
     v.Add(first);
     return v;
 }
예제 #5
0
        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);
        }