internal void UpdateState(StateMapping mapping) { _controller.ResetReport(); _controller.SetButtonState(Xbox360Button.A, mapping.A); _controller.SetButtonState(Xbox360Button.B, mapping.B); _controller.SetButtonState(Xbox360Button.X, mapping.X); _controller.SetButtonState(Xbox360Button.Y, mapping.Y); _controller.SetButtonState(Xbox360Button.Back, mapping.Back); _controller.SetButtonState(Xbox360Button.Start, mapping.Start); _controller.SetButtonState(Xbox360Button.Guide, mapping.Guide); _controller.SetButtonState(Xbox360Button.LeftShoulder, mapping.LeftShoulder); _controller.SetButtonState(Xbox360Button.RightShoulder, mapping.RightShoulder); _controller.SetButtonState(Xbox360Button.LeftThumb, mapping.LeftThumb); _controller.SetButtonState(Xbox360Button.RightThumb, mapping.RightThumb); _controller.SetAxisValue(Xbox360Axis.LeftThumbX, mapping.LeftThumbX); _controller.SetAxisValue(Xbox360Axis.LeftThumbY, mapping.LeftThumbY); _controller.SetAxisValue(Xbox360Axis.RightThumbX, mapping.RightThumbX); _controller.SetAxisValue(Xbox360Axis.RightThumbY, mapping.RightThumbY); _controller.SetSliderValue(Xbox360Slider.LeftTrigger, mapping.LeftTrigger); _controller.SetSliderValue(Xbox360Slider.RightTrigger, mapping.RightTrigger); _controller.SetButtonState(Xbox360Button.Up, mapping.Up); _controller.SetButtonState(Xbox360Button.Down, mapping.Down); _controller.SetButtonState(Xbox360Button.Left, mapping.Left); _controller.SetButtonState(Xbox360Button.Right, mapping.Right); _controller.SubmitReport(); }
internal async Task Run() { _featureEnforcer.Start(); while (true) { var report = await _device.ReadAsync(); var controllerState = ControllerStateFactory.FromHidRawData(report.Data); if (controllerState.Equals(_previousState)) { continue; } var mapping = _mapper.MapState(controllerState); if (mapping.Equals(_previousMapping)) { continue; } _previousState = controllerState; _previousMapping = mapping; _controllerAdapter.UpdateState(mapping); } // ReSharper disable once FunctionNeverReturns }
public bool Equals(StateMapping other) { return(A == other.A && B == other.B && X == other.X && Y == other.Y && Back == other.Back && Start == other.Start && Guide == other.Guide && LeftShoulder == other.LeftShoulder && RightShoulder == other.RightShoulder && LeftThumbX == other.LeftThumbX && LeftThumbY == other.LeftThumbY && LeftThumb == other.LeftThumb && RightThumbX == other.RightThumbX && RightThumbY == other.RightThumbY && RightThumb == other.RightThumb && LeftTrigger == other.LeftTrigger && RightTrigger == other.RightTrigger && Up == other.Up && Down == other.Down && Left == other.Left && Right == other.Right); }