private void UpdateFromState(GamePadState gamepadState, TimeSpan elapsed) { this.LeftShoulder = this.LeftShoulder.NextState(gamepadState.Buttons.LeftShoulder == ButtonState.Pressed, elapsed); this.RightShoulder = this.RightShoulder.NextState(gamepadState.Buttons.RightShoulder == ButtonState.Pressed, elapsed); this.LeftTrigger = this.LeftTrigger.NextState(gamepadState.Triggers.Left, elapsed); this.RightTrigger = this.RightTrigger.NextState(gamepadState.Triggers.Right, elapsed); this.Start = FezButtonStateExtensions.NextState(this.Start, gamepadState.Buttons.Start == ButtonState.Pressed); this.Back = FezButtonStateExtensions.NextState(this.Back, gamepadState.Buttons.Back == ButtonState.Pressed); this.A = this.A.NextState(gamepadState.Buttons.A == ButtonState.Pressed, elapsed); this.B = this.B.NextState(gamepadState.Buttons.B == ButtonState.Pressed, elapsed); this.X = this.X.NextState(gamepadState.Buttons.X == ButtonState.Pressed, elapsed); this.Y = this.Y.NextState(gamepadState.Buttons.Y == ButtonState.Pressed, elapsed); this.DPad = this.DPad.NextState(gamepadState.DPad.Up == ButtonState.Pressed, gamepadState.DPad.Down == ButtonState.Pressed, gamepadState.DPad.Left == ButtonState.Pressed, gamepadState.DPad.Right == ButtonState.Pressed, elapsed); this.LeftStick = this.LeftStick.NextState(gamepadState.ThumbSticks.Left, gamepadState.Buttons.LeftStick == ButtonState.Pressed, elapsed); this.RightStick = this.RightStick.NextState(gamepadState.ThumbSticks.Right, gamepadState.Buttons.RightStick == ButtonState.Pressed, elapsed); this.ExactUp = FezButtonStateExtensions.NextState(this.ExactUp, (double)this.LeftStick.Position.Y > 0.899999976158142 || FezButtonStateExtensions.IsDown(this.DPad.Up.State) && this.DPad.Left.State == FezButtonState.Up && this.DPad.Right.State == FezButtonState.Up); }
internal TimedButtonState NextState(bool down, TimeSpan elapsed) { return(new TimedButtonState(FezButtonStateExtensions.NextState(this.State, down), down ? this.TimePressed + elapsed : TimeSpan.Zero)); }
internal TimedAnalogButtonState NextState(float value, TimeSpan elapsed) { bool pressed = (double)value > 0.5; return(new TimedAnalogButtonState(value, FezButtonStateExtensions.NextState(this.State, pressed), pressed ? this.TimePressed + elapsed : TimeSpan.Zero)); }