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); }
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); }
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); }