Example #1
0
        public void Commit(ulong updateTick, float deltaTime)
        {
            int controlCount = Controls.Length;

            for (int i = 0; i < controlCount; i++)
            {
                var control = Controls[i];
                if (control != null)
                {
                    control.Commit();

                    if (control.HasChanged)
                    {
                        LastChangeTick = updateTick;
                    }
                }
            }

            if (IsKnown)
            {
                GetControl(InputControlType.Command).CommitWithState(AnyCommandControlIsPressed(), updateTick, deltaTime);
            }

            LeftStickX.CommitWithSides(LeftStickLeft, LeftStickRight, updateTick, deltaTime);
            LeftStickY.CommitWithSides(LeftStickDown, LeftStickUp, updateTick, deltaTime, InputManager.InvertYAxis);
            LeftStick.UpdateWithAxes(LeftStickX, LeftStickY, updateTick, deltaTime);

            RightStickX.CommitWithSides(RightStickLeft, RightStickRight, updateTick, deltaTime);
            RightStickY.CommitWithSides(RightStickDown, RightStickUp, updateTick, deltaTime, InputManager.InvertYAxis);
            RightStick.UpdateWithAxes(RightStickX, RightStickY, updateTick, deltaTime);

            DPadX.CommitWithSides(DPadLeft, DPadRight, updateTick, deltaTime);
            DPadY.CommitWithSides(DPadDown, DPadUp, updateTick, deltaTime, InputManager.InvertYAxis);
            DPad.UpdateWithAxes(DPadX, DPadY, updateTick, deltaTime);
        }
Example #2
0
        void ProcessLeftStick(ulong updateTick, float deltaTime)
        {
            var x = Utility.ValueFromSides(LeftStickLeft.NextRawValue, LeftStickRight.NextRawValue);
            var y = Utility.ValueFromSides(LeftStickDown.NextRawValue, LeftStickUp.NextRawValue, InputManager.InvertYAxis);

            Vector2 v;

            if (RawSticks || LeftStickLeft.Raw || LeftStickRight.Raw || LeftStickUp.Raw || LeftStickDown.Raw)
            {
                v = new Vector2(x, y);
            }
            else
            {
                var lowerDeadZone = Utility.Max(LeftStickLeft.LowerDeadZone, LeftStickRight.LowerDeadZone, LeftStickUp.LowerDeadZone, LeftStickDown.LowerDeadZone);
                var upperDeadZone = Utility.Min(LeftStickLeft.UpperDeadZone, LeftStickRight.UpperDeadZone, LeftStickUp.UpperDeadZone, LeftStickDown.UpperDeadZone);
                v = Utility.ApplyCircularDeadZone(x, y, lowerDeadZone, upperDeadZone);
            }

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

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

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

            LeftStickLeft.SetValue(LeftStick.Left.Value, updateTick);
            LeftStickRight.SetValue(LeftStick.Right.Value, updateTick);
            LeftStickUp.SetValue(LeftStick.Up.Value, updateTick);
            LeftStickDown.SetValue(LeftStick.Down.Value, updateTick);
        }
Example #3
0
        internal void ProcessLeftStick()
        {
            var x = Utility.ValueFromSides(LeftStickLeft.NextRawValue, LeftStickRight.NextRawValue);
            var y = Utility.ValueFromSides(LeftStickDown.NextRawValue, LeftStickUp.NextRawValue, InputManager.InvertYAxis);

            Vector2 v;

            if (RawSticks)
            {
                v = new Vector2(x, y);
            }
            else
            {
                var lowerDeadZone = Utility.Max(LeftStickLeft.LowerDeadZone, LeftStickRight.LowerDeadZone, LeftStickUp.LowerDeadZone, LeftStickDown.LowerDeadZone);
                var upperDeadZone = Utility.Min(LeftStickLeft.UpperDeadZone, LeftStickRight.UpperDeadZone, LeftStickUp.UpperDeadZone, LeftStickDown.UpperDeadZone);
                v = Utility.ApplyCircularDeadZone(x, y, lowerDeadZone, upperDeadZone);
            }

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

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

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

            LeftStickLeft.SetValue(LeftStick.Left.Value);
            LeftStickRight.SetValue(LeftStick.Right.Value);
            LeftStickUp.SetValue(LeftStick.Up.Value);
            LeftStickDown.SetValue(LeftStick.Down.Value);
        }
Example #4
0
        public void ClearInputState()
        {
            LeftStickX.ClearInputState();
            LeftStickY.ClearInputState();
            LeftStick.ClearInputState();

            RightStickX.ClearInputState();
            RightStickY.ClearInputState();
            RightStick.ClearInputState();

            DPadX.ClearInputState();
            DPadY.ClearInputState();
            DPad.ClearInputState();

            var controlCount = Controls.Length;

            for (int i = 0; i < controlCount; i++)
            {
                var control = Controls[i];
                if (control != null)
                {
                    control.ClearInputState();
                }
            }
        }
Example #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = A.GetHashCode();
         hashCode = (hashCode * 397) ^ B.GetHashCode();
         hashCode = (hashCode * 397) ^ X.GetHashCode();
         hashCode = (hashCode * 397) ^ Y.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftGrip.GetHashCode();
         hashCode = (hashCode * 397) ^ RightGrip.GetHashCode();
         hashCode = (hashCode * 397) ^ Select.GetHashCode();
         hashCode = (hashCode * 397) ^ Start.GetHashCode();
         hashCode = (hashCode * 397) ^ Steam.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftBumper.GetHashCode();
         hashCode = (hashCode * 397) ^ RightBumper.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftStickX.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftStickY.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftStickClick.GetHashCode();
         hashCode = (hashCode * 397) ^ RightPadX.GetHashCode();
         hashCode = (hashCode * 397) ^ RightPadY.GetHashCode();
         hashCode = (hashCode * 397) ^ RightPadClick.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftPadClick.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftTrigger.GetHashCode();
         hashCode = (hashCode * 397) ^ RightTrigger.GetHashCode();
         hashCode = (hashCode * 397) ^ LeftPadTouched.GetHashCode();
         return(hashCode);
     }
 }
Example #6
0
    void ProcessLeftStick(ulong updateTick, float deltaTime)
    {
        var x = Utility.ValueFromSides(LeftStickLeft.NextRawValue, LeftStickRight.NextRawValue);
        var y = Utility.ValueFromSides(LeftStickDown.NextRawValue, LeftStickUp.NextRawValue, InputManager.InvertYAxis);

        Vector2 v;

        //if (RawSticks)
        //{
        v = new Vector2(x, y);
        //}


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

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

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

        LeftStickLeft.SetValue(LeftStick.Left.Value, updateTick);
        LeftStickRight.SetValue(LeftStick.Right.Value, updateTick);
        LeftStickUp.SetValue(LeftStick.Up.Value, updateTick);
        LeftStickDown.SetValue(LeftStick.Down.Value, updateTick);
    }