diff --git a/src/BizHawk.Client.Common/config/Binding.cs b/src/BizHawk.Client.Common/config/Binding.cs index 41df476792..3d2c72fbfa 100644 --- a/src/BizHawk.Client.Common/config/Binding.cs +++ b/src/BizHawk.Client.Common/config/Binding.cs @@ -66,6 +66,7 @@ namespace BizHawk.Client.Common Bind("General", "Toggle Messages"); Bind("General", "Toggle Display Nothing"); Bind("General", "Accept Background Input"); + Bind("General", "Capture Mouse"); Bind("Save States", "Save State 1", "Shift+F1"); Bind("Save States", "Save State 2", "Shift+F2"); diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index aeb9923a4d..3760945ece 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -170,6 +170,7 @@ namespace BizHawk.Client.Common public string UpdateLatestVersion { get; set; } = ""; public string UpdateIgnoreVersion { get; set; } = ""; public bool SkipOutdatedOsCheck { get; set; } + public bool CaptureMouse { get; set; } = false; public bool SkipSuperuserPrivsCheck { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index fe016b7309..c46ed09f40 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -149,6 +149,9 @@ namespace BizHawk.Client.EmuHawk case "Accept Background Input": ToggleBackgroundInput(); break; + case "Capture Mouse": + ToggleCaptureMouse(); + break; // Save States case "Save State 1": diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index d43a3671d7..093800461e 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -856,6 +856,8 @@ namespace BizHawk.Client.EmuHawk return _exitCode; } + LockMouse(Config.CaptureMouse); + // incantation required to get the program reliably on top of the console window // we might want it in ToggleFullscreen later, but here, it needs to happen regardless BringToFront(); @@ -2313,7 +2315,7 @@ namespace BizHawk.Client.EmuHawk || Math.Abs(_lastMouseAutoHidePos.X - mousePos.X) > 5 || Math.Abs(_lastMouseAutoHidePos.Y - mousePos.Y) > 5; - if (!shouldUpdateCursor) + if (!shouldUpdateCursor || Config.CaptureMouse) { return; } @@ -2803,6 +2805,13 @@ namespace BizHawk.Client.EmuHawk AddOnScreenMessage($"Background Input {(Config.AcceptBackgroundInput ? "enabled" : "disabled")}"); } + private void ToggleCaptureMouse() + { + Config.CaptureMouse = !Config.CaptureMouse; + LockMouse(Config.CaptureMouse); + AddOnScreenMessage($"Capture Mouse {(Config.CaptureMouse ? "enabled" : "disabled")}"); + } + private void VsyncMessage() { AddOnScreenMessage($"Display Vsync set to {(Config.VSync ? "on" : "off")}"); @@ -4826,10 +4835,16 @@ namespace BizHawk.Client.EmuHawk var fbLocation = Point.Subtract(Bounds.Location, new(PointToClient(Location))); fbLocation.Offset(_presentationPanel.Control.Location); Cursor.Clip = new(fbLocation, _presentationPanel.Control.Size); + Cursor.Hide(); + _presentationPanel.Control.Cursor = Properties.Resources.BlankCursor; + _cursorHidden = true; } else { Cursor.Clip = Rectangle.Empty; + Cursor.Show(); + _presentationPanel.Control.Cursor = Cursors.Default; + _cursorHidden = false; } // Cursor.Clip is a no-op on Linux, so we need this too