Пример #1
0
        void ProcessRightStick(ulong updateTick, float deltaTime)
        {
            var x = Utility.ValueFromSides(RightStickLeft.NextRawValue, RightStickRight.NextRawValue);
            var y = Utility.ValueFromSides(RightStickDown.NextRawValue, RightStickUp.NextRawValue, InputManager.InvertYAxis);

            Vector2 v;

            if (RawSticks || RightStickLeft.Raw || RightStickRight.Raw || RightStickUp.Raw || RightStickDown.Raw)
            {
                v = new Vector2(x, y);
            }
            else
            {
                var lowerDeadZone = Utility.Max(RightStickLeft.LowerDeadZone, RightStickRight.LowerDeadZone, RightStickUp.LowerDeadZone, RightStickDown.LowerDeadZone);
                var upperDeadZone = Utility.Min(RightStickLeft.UpperDeadZone, RightStickRight.UpperDeadZone, RightStickUp.UpperDeadZone, RightStickDown.UpperDeadZone);
                v = Utility.ApplyCircularDeadZone(x, y, lowerDeadZone, upperDeadZone);
            }

            RightStick.Raw = true;
            RightStick.UpdateWithAxes(v.x, v.y, updateTick, deltaTime);

            RightStickX.Raw = true;
            RightStickX.CommitWithValue(v.x, updateTick, deltaTime);

            RightStickY.Raw = true;
            RightStickY.CommitWithValue(v.y, updateTick, deltaTime);

            RightStickLeft.SetValue(RightStick.Left.Value, updateTick);
            RightStickRight.SetValue(RightStick.Right.Value, updateTick);
            RightStickUp.SetValue(RightStick.Up.Value, updateTick);
            RightStickDown.SetValue(RightStick.Down.Value, updateTick);
        }
Пример #2
0
        internal void ProcessRightStick()
        {
            var x = Utility.ValueFromSides(RightStickLeft.NextRawValue, RightStickRight.NextRawValue);
            var y = Utility.ValueFromSides(RightStickDown.NextRawValue, RightStickUp.NextRawValue, InputManager.InvertYAxis);

            Vector2 v;

            if (RawSticks)
            {
                v = new Vector2(x, y);
            }
            else
            {
                var lowerDeadZone = Utility.Max(RightStickLeft.LowerDeadZone, RightStickRight.LowerDeadZone, RightStickUp.LowerDeadZone, RightStickDown.LowerDeadZone);
                var upperDeadZone = Utility.Min(RightStickLeft.UpperDeadZone, RightStickRight.UpperDeadZone, RightStickUp.UpperDeadZone, RightStickDown.UpperDeadZone);
                v = Utility.ApplyCircularDeadZone(x, y, lowerDeadZone, upperDeadZone);
            }

            RightStick.Raw = true;
            RightStick.UpdateWithAxes(v.X, v.Y);

            RightStickX.Raw = true;
            RightStickX.CommitWithValue(v.X);

            RightStickY.Raw = true;
            RightStickY.CommitWithValue(v.Y);

            RightStickLeft.SetValue(RightStick.Left.Value);
            RightStickRight.SetValue(RightStick.Right.Value);
            RightStickUp.SetValue(RightStick.Up.Value);
            RightStickDown.SetValue(RightStick.Down.Value);
        }