public void Update(ref InputState previous, ref InputState current) { PreviousState = CurrentState; var mouseState = CurrentState = Mouse.GetState(); if (!HasState) { PreviousState = CurrentState; } current.Buttons |= ((mouseState.LeftButton == ButtonState.Pressed) ? MouseButtons.Left : MouseButtons.None); current.Buttons |= ((mouseState.MiddleButton == ButtonState.Pressed) ? MouseButtons.Middle : MouseButtons.None); current.Buttons |= ((mouseState.RightButton == ButtonState.Pressed) ? MouseButtons.Right : MouseButtons.None); current.Buttons |= ((mouseState.XButton1 == ButtonState.Pressed) ? MouseButtons.X1 : MouseButtons.None); current.Buttons |= ((mouseState.XButton2 == ButtonState.Pressed) ? MouseButtons.X2 : MouseButtons.None); var prevPosition = new Vector2(PreviousState.X, PreviousState.Y) * Scale + Offset; var newPosition = new Vector2(mouseState.X, mouseState.Y) * Scale + Offset; if (PreviousState.ScrollWheelValue != CurrentState.ScrollWheelValue) { current.WheelValue = mouseState.ScrollWheelValue * MouseWheelScale; } if (!HasState) { HasState = true; return; } var isPriority = Context.IsPriorityInputSource(this); var insideWindow = Context.CanvasRect.Contains(newPosition); if ((CurrentState.X != PreviousState.X) || (CurrentState.Y != PreviousState.Y)) { if (insideWindow || isPriority) { current.CursorPosition = newPosition; current.KeyboardNavigationEnded = true; if (!isPriority) { Context.PromoteInputSource(this); } } } }