示例#1
0
        private void HandlePointerMotion(MouseDevice mouse, PointerEvent e)
        {
            Vector2 delta = new Vector2((float)e.DeltaX, (float)e.DeltaY);

            if (mouse != null)
            {
                mouse.State.SetIsConnected(true);
                mouse.State.Position += delta;
            }

            CursorPosition = new Vector2(
                MathHelper.Clamp(CursorPosition.X + delta.X, bounds.Left, bounds.Right - 1),
                MathHelper.Clamp(CursorPosition.Y + delta.Y, bounds.Top, bounds.Bottom - 1));
            UpdateCursor();
        }
示例#2
0
        private void HandlePointerAxis(MouseDevice mouse, PointerEvent e)
        {
            if (mouse != null)
            {
                mouse.State.SetIsConnected(true);

                if (e.HasAxis(PointerAxis.HorizontalScroll))
                {
                    mouse.State.SetScrollRelative((float)e.AxisValue(PointerAxis.HorizontalScroll), 0);
                }
                if (e.HasAxis(PointerAxis.VerticalScroll))
                {
                    mouse.State.SetScrollRelative(0, (float)e.AxisValue(PointerAxis.VerticalScroll));
                }
            }
        }