예제 #1
0
        internal override void UpdateInput(bool isActive)
        {
            Point nativeMousePosition = MouseManager.GetNativePosition();

            if (!isActive)
            {
                wasActive   = false;
                position.X += nativeMousePosition.X - previousNativeMousePosition.X;
                position.Y += nativeMousePosition.Y - previousNativeMousePosition.Y;

                previousNativeMousePosition = nativeMousePosition;
                return;
            }

            previousNativeMousePosition = nativeMousePosition;

            if (!wasActive)
            {
                if (GameBase.TotalFramesRendered == 0 || !MouseManager.PosInWindow(nativeMousePosition))
                {
                    position.X = nativeMousePosition.X;
                    position.Y = nativeMousePosition.Y;
                }
                else
                {
                    Point pixelPosition = new Point((int)Math.Round(position.X), (int)Math.Round(position.Y));

                    MouseManager.SetNativePosition(pixelPosition, true);
                    nativeMousePosition = MouseManager.GetNativePosition();
                }
            }

            wasActive = true;

            if (ConfigManager.sMouseSpeed != 1 && !MouseManager.showMouse && !ConfigManager.sRawInput)
            {
                Point pixelPosition = new Point((int)Math.Round(position.X), (int)Math.Round(position.Y));

                if (MouseManager.PosInWindow(new Point(nativeMousePosition.X, nativeMousePosition.Y)))
                {
                    position.X += (nativeMousePosition.X - pixelPosition.X) * (float)ConfigManager.sMouseSpeed;
                    position.Y += (nativeMousePosition.Y - pixelPosition.Y) * (float)ConfigManager.sMouseSpeed;

                    pixelPosition = new Point((int)Math.Round(position.X), (int)Math.Round(position.Y));
                }
                else
                {
                    position.X = nativeMousePosition.X;
                    position.Y = nativeMousePosition.Y;

                    //the input stream is sometimes hooked by crappy mouse drivers. so we want to equalize
                    //both changes and non changes in sensitivity mode.
                    pixelPosition = new Point(nativeMousePosition.X, nativeMousePosition.Y);
                }

                MouseManager.SetNativePosition(pixelPosition);
                nativeMousePosition = MouseManager.GetNativePosition();

                // Windows might restrict our mouse cursor's movement. In this case we adjust to windows' position.
                // (This is relevant for cursor clamping at monitor boundaries in full-screen and clamping to the osu! window in windowed mode)
                if (pixelPosition.X != nativeMousePosition.X)
                {
                    Debug.Print("X position disparity detected.");
                    position.X += nativeMousePosition.X - pixelPosition.X;
                }

                if (pixelPosition.Y != nativeMousePosition.Y)
                {
                    Debug.Print("Y position disparity detected.");
                    position.Y += nativeMousePosition.Y - pixelPosition.Y;
                }
            }
            else
            {
                position.X = nativeMousePosition.X;
                position.Y = nativeMousePosition.Y;
            }
        }
예제 #2
0
 internal override bool Initialize()
 {
     previousNativeMousePosition = MouseManager.GetNativePosition();
     return(true);
 }