Exemplo n.º 1
0
        void ProcessDPad(ulong updateTick, float deltaTime)
        {
            var x = Utility.ValueFromSides(DPadLeft.NextRawValue, DPadRight.NextRawValue);
            var y = Utility.ValueFromSides(DPadDown.NextRawValue, DPadUp.NextRawValue, InputManager.InvertYAxis);

            Vector2 v;

            if (RawSticks || DPadLeft.Raw || DPadRight.Raw || DPadUp.Raw || DPadDown.Raw)
            {
                v = new Vector2(x, y);
            }
            else
            {
                var lowerDeadZone = Utility.Max(DPadLeft.LowerDeadZone, DPadRight.LowerDeadZone, DPadUp.LowerDeadZone, DPadDown.LowerDeadZone);
                var upperDeadZone = Utility.Min(DPadLeft.UpperDeadZone, DPadRight.UpperDeadZone, DPadUp.UpperDeadZone, DPadDown.UpperDeadZone);
                v = Utility.ApplySeparateDeadZone(x, y, lowerDeadZone, upperDeadZone);
            }

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

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

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

            DPadLeft.SetValue(DPad.Left.Value, updateTick);
            DPadRight.SetValue(DPad.Right.Value, updateTick);
            DPadUp.SetValue(DPad.Up.Value, updateTick);
            DPadDown.SetValue(DPad.Down.Value, updateTick);
        }
Exemplo n.º 2
0
        internal void ProcessDPad()
        {
            var lowerDeadZone = Utility.Max(DPadLeft.LowerDeadZone, DPadRight.LowerDeadZone, DPadUp.LowerDeadZone, DPadDown.LowerDeadZone);
            var upperDeadZone = Utility.Min(DPadLeft.UpperDeadZone, DPadRight.UpperDeadZone, DPadUp.UpperDeadZone, DPadDown.UpperDeadZone);

            var x = Utility.ValueFromSides(DPadLeft.NextRawValue, DPadRight.NextRawValue);
            var y = Utility.ValueFromSides(DPadDown.NextRawValue, DPadUp.NextRawValue, InputManager.InvertYAxis);
            var v = Utility.ApplyCircularDeadZone(x, y, lowerDeadZone, upperDeadZone);

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

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

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

            DPadLeft.SetValue(DPad.Left.Value);
            DPadRight.SetValue(DPad.Right.Value);
            DPadUp.SetValue(DPad.Up.Value);
            DPadDown.SetValue(DPad.Down.Value);
        }