コード例 #1
0
ファイル: CursorManager.cs プロジェクト: sdefkk/Mesen
        public static void OnMouseMove(Control ctrl)
        {
            if (_mouseCaptured && AllowMouseCapture)
            {
                HideMouse();
                _tmrHideMouse.Stop();
                Form  frm       = Application.OpenForms[0];
                Point centerPos = frm.PointToScreen(new Point(frm.Width / 2, frm.Height / 2));
                Point diff      = new Point(Cursor.Position.X - centerPos.X, Cursor.Position.Y - centerPos.Y);
                if (diff.X != 0 || diff.Y != 0)
                {
                    InteropEmu.SetMouseMovement((Int16)diff.X, (Int16)diff.Y);
                    Cursor.Position = centerPos;
                }
            }
            else
            {
                _mouseCaptured = false;

                if (!InteropEmu.IsRunning() || InteropEmu.IsPaused())
                {
                    ShowMouse();
                }
                else if (ConfigManager.Config.InputInfo.HideMousePointerForZapper && CursorManager.IsLightGun)
                {
                    //Keep mouse hidden when using zapper if option to hide mouse is enabled
                    HideMouse();
                    return;
                }

                _tmrHideMouse.Stop();

                if (!CursorManager.NeedMouseIcon)
                {
                    //Only hide mouse if no zapper (otherwise this could be pretty annoying)
                    ctrl.Cursor = Cursors.Default;

                    if (InteropEmu.IsRunning() && !InteropEmu.IsPaused())
                    {
                        _tmrHideMouse.Start();
                    }
                }
            }
        }