diff --git a/GUI.NET/Controls/ctrlRenderer.Designer.cs b/GUI.NET/Controls/ctrlRenderer.Designer.cs
index a2821421..e3b5be8a 100644
--- a/GUI.NET/Controls/ctrlRenderer.Designer.cs
+++ b/GUI.NET/Controls/ctrlRenderer.Designer.cs
@@ -27,15 +27,8 @@
///
private void InitializeComponent()
{
- this.components = new System.ComponentModel.Container();
- this.tmrMouse = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
- // tmrMouse
- //
- this.tmrMouse.Interval = 3000;
- this.tmrMouse.Tick += new System.EventHandler(this.tmrMouse_Tick);
- //
// ctrlRenderer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -48,7 +41,5 @@
}
#endregion
-
- private System.Windows.Forms.Timer tmrMouse;
}
}
diff --git a/GUI.NET/Controls/ctrlRenderer.cs b/GUI.NET/Controls/ctrlRenderer.cs
index c297b0ca..b9d05354 100644
--- a/GUI.NET/Controls/ctrlRenderer.cs
+++ b/GUI.NET/Controls/ctrlRenderer.cs
@@ -17,34 +17,11 @@ namespace Mesen.GUI.Controls
private const int RightMouseButtonKeyCode = 0x201;
private const int MiddleMouseButtonKeyCode = 0x202;
- private bool _cursorHidden = false;
-
public ctrlRenderer()
{
InitializeComponent();
}
- public bool NeedMouseIcon
- {
- get { return InteropEmu.GetExpansionDevice() == InteropEmu.ExpansionPortDevice.OekaKidsTablet || InteropEmu.HasZapper(); }
- }
-
- private void ShowMouse()
- {
- if(_cursorHidden) {
- Cursor.Show();
- _cursorHidden = false;
- }
- }
-
- private void HideMouse()
- {
- if(!_cursorHidden) {
- Cursor.Hide();
- _cursorHidden = true;
- }
- }
-
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
@@ -66,21 +43,10 @@ namespace Mesen.GUI.Controls
private void ctrlRenderer_MouseMove(object sender, MouseEventArgs e)
{
- if(!InteropEmu.IsRunning() || InteropEmu.IsPaused() || !InteropEmu.HasArkanoidPaddle()) {
- ShowMouse();
- } else if(InteropEmu.HasArkanoidPaddle() && !this.NeedMouseIcon) {
- HideMouse();
- }
+ CursorManager.OnMouseMove(this);
- tmrMouse.Stop();
-
- if(this.NeedMouseIcon) {
+ if(CursorManager.NeedMouseIcon) {
this.Cursor = Cursors.Cross;
- } else {
- this.Cursor = Cursors.Default;
-
- //Only hide mouse if no zapper (otherwise this could be pretty annoying)
- tmrMouse.Start();
}
double xPos = (double)e.X / this.Width;
@@ -91,16 +57,10 @@ namespace Mesen.GUI.Controls
InteropEmu.SetMousePosition(xPos, yPos);
}
-
- private void tmrMouse_Tick(object sender, EventArgs e)
- {
- HideMouse();
- }
private void ctrlRenderer_MouseLeave(object sender, EventArgs e)
{
- tmrMouse.Stop();
- ShowMouse();
+ CursorManager.OnMouseLeave();
InteropEmu.SetMousePosition(-1, -1);
}
}
diff --git a/GUI.NET/Controls/ctrlRenderer.resx b/GUI.NET/Controls/ctrlRenderer.resx
index 765789c8..1af7de15 100644
--- a/GUI.NET/Controls/ctrlRenderer.resx
+++ b/GUI.NET/Controls/ctrlRenderer.resx
@@ -117,7 +117,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 17, 17
-
\ No newline at end of file
diff --git a/GUI.NET/CursorManager.cs b/GUI.NET/CursorManager.cs
new file mode 100644
index 00000000..e2110819
--- /dev/null
+++ b/GUI.NET/CursorManager.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Mesen.GUI.Config;
+
+namespace Mesen.GUI
+{
+ public class CursorManager
+ {
+ private static bool _cursorHidden = false;
+ private static Timer _tmrMouse = new Timer();
+
+ static CursorManager()
+ {
+ _tmrMouse.Interval = 3000;
+ _tmrMouse.Tick += tmrMouse_Tick;
+ }
+
+ private static void tmrMouse_Tick(object sender, EventArgs e)
+ {
+ if(InteropEmu.IsRunning() && !InteropEmu.IsPaused()) {
+ HideMouse();
+ } else {
+ ShowMouse();
+ _tmrMouse.Stop();
+ }
+ }
+
+ private static void ShowMouse()
+ {
+ if(_cursorHidden) {
+ Cursor.Show();
+ _cursorHidden = false;
+ }
+ }
+
+ private static void HideMouse()
+ {
+ if(!_cursorHidden) {
+ Cursor.Hide();
+ _cursorHidden = true;
+ }
+ }
+
+ public static bool NeedMouseIcon
+ {
+ get { return InteropEmu.GetExpansionDevice() == InteropEmu.ExpansionPortDevice.OekaKidsTablet || InteropEmu.HasZapper(); }
+ }
+
+ public static void OnMouseMove(Control ctrl)
+ {
+ if(!InteropEmu.IsRunning() || InteropEmu.IsPaused() || !InteropEmu.HasArkanoidPaddle()) {
+ ShowMouse();
+ } else if(InteropEmu.HasArkanoidPaddle() && !CursorManager.NeedMouseIcon) {
+ HideMouse();
+ }
+
+ _tmrMouse.Stop();
+
+ if(!CursorManager.NeedMouseIcon) {
+ ctrl.Cursor = Cursors.Default;
+
+ //Only hide mouse if no zapper (otherwise this could be pretty annoying)
+ _tmrMouse.Start();
+ }
+ }
+
+ public static void OnMouseLeave()
+ {
+ _tmrMouse.Stop();
+ ShowMouse();
+ }
+ }
+}
diff --git a/GUI.NET/Forms/frmMain.Designer.cs b/GUI.NET/Forms/frmMain.Designer.cs
index a69f68e2..383589bc 100644
--- a/GUI.NET/Forms/frmMain.Designer.cs
+++ b/GUI.NET/Forms/frmMain.Designer.cs
@@ -211,6 +211,7 @@ namespace Mesen.GUI.Forms
this.panelRenderer.TabIndex = 2;
this.panelRenderer.Click += new System.EventHandler(this.panelRenderer_Click);
this.panelRenderer.DoubleClick += new System.EventHandler(this.ctrlRenderer_DoubleClick);
+ this.panelRenderer.MouseLeave += new System.EventHandler(this.panelRenderer_MouseLeave);
this.panelRenderer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove);
//
// ctrlLoading
@@ -265,8 +266,8 @@ namespace Mesen.GUI.Forms
this.ctrlRecentGames.Size = new System.Drawing.Size(430, 309);
this.ctrlRecentGames.TabIndex = 7;
this.ctrlRecentGames.Visible = false;
- this.ctrlRecentGames.DoubleClick += new System.EventHandler(this.ctrlRenderer_DoubleClick);
this.ctrlRecentGames.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove);
+ this.ctrlRecentGames.DoubleClick += new System.EventHandler(this.ctrlRenderer_DoubleClick);
//
// ctrlNsfPlayer
//
@@ -327,50 +328,50 @@ namespace Mesen.GUI.Forms
this.mnuOpen.Image = global::Mesen.GUI.Properties.Resources.FolderOpen;
this.mnuOpen.Name = "mnuOpen";
this.mnuOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
- this.mnuOpen.Size = new System.Drawing.Size(152, 22);
+ this.mnuOpen.Size = new System.Drawing.Size(146, 22);
this.mnuOpen.Text = "Open";
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
- this.toolStripMenuItem4.Size = new System.Drawing.Size(149, 6);
+ this.toolStripMenuItem4.Size = new System.Drawing.Size(143, 6);
//
// mnuSaveState
//
this.mnuSaveState.Name = "mnuSaveState";
- this.mnuSaveState.Size = new System.Drawing.Size(152, 22);
+ this.mnuSaveState.Size = new System.Drawing.Size(146, 22);
this.mnuSaveState.Text = "Save State";
this.mnuSaveState.DropDownOpening += new System.EventHandler(this.mnuSaveState_DropDownOpening);
//
// mnuLoadState
//
this.mnuLoadState.Name = "mnuLoadState";
- this.mnuLoadState.Size = new System.Drawing.Size(152, 22);
+ this.mnuLoadState.Size = new System.Drawing.Size(146, 22);
this.mnuLoadState.Text = "Load State";
this.mnuLoadState.DropDownOpening += new System.EventHandler(this.mnuLoadState_DropDownOpening);
//
// toolStripMenuItem7
//
this.toolStripMenuItem7.Name = "toolStripMenuItem7";
- this.toolStripMenuItem7.Size = new System.Drawing.Size(149, 6);
+ this.toolStripMenuItem7.Size = new System.Drawing.Size(143, 6);
//
// mnuRecentFiles
//
this.mnuRecentFiles.Name = "mnuRecentFiles";
- this.mnuRecentFiles.Size = new System.Drawing.Size(152, 22);
+ this.mnuRecentFiles.Size = new System.Drawing.Size(146, 22);
this.mnuRecentFiles.Text = "Recent Files";
//
// toolStripMenuItem6
//
this.toolStripMenuItem6.Name = "toolStripMenuItem6";
- this.toolStripMenuItem6.Size = new System.Drawing.Size(149, 6);
+ this.toolStripMenuItem6.Size = new System.Drawing.Size(143, 6);
//
// mnuExit
//
this.mnuExit.Image = global::Mesen.GUI.Properties.Resources.Exit;
this.mnuExit.Name = "mnuExit";
- this.mnuExit.Size = new System.Drawing.Size(152, 22);
+ this.mnuExit.Size = new System.Drawing.Size(146, 22);
this.mnuExit.Text = "Exit";
this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
//
@@ -532,7 +533,7 @@ namespace Mesen.GUI.Forms
this.mnuShowFPS});
this.mnuEmulationSpeed.Image = global::Mesen.GUI.Properties.Resources.Speed;
this.mnuEmulationSpeed.Name = "mnuEmulationSpeed";
- this.mnuEmulationSpeed.Size = new System.Drawing.Size(152, 22);
+ this.mnuEmulationSpeed.Size = new System.Drawing.Size(135, 22);
this.mnuEmulationSpeed.Text = "Speed";
this.mnuEmulationSpeed.DropDownOpening += new System.EventHandler(this.mnuEmulationSpeed_DropDownOpening);
//
@@ -634,7 +635,7 @@ namespace Mesen.GUI.Forms
this.mnuFullscreen});
this.mnuVideoScale.Image = global::Mesen.GUI.Properties.Resources.Fullscreen;
this.mnuVideoScale.Name = "mnuVideoScale";
- this.mnuVideoScale.Size = new System.Drawing.Size(152, 22);
+ this.mnuVideoScale.Size = new System.Drawing.Size(135, 22);
this.mnuVideoScale.Text = "Video Size";
//
// mnuScale1x
@@ -750,7 +751,7 @@ namespace Mesen.GUI.Forms
this.mnuBilinearInterpolation});
this.mnuVideoFilter.Image = global::Mesen.GUI.Properties.Resources.VideoFilter;
this.mnuVideoFilter.Name = "mnuVideoFilter";
- this.mnuVideoFilter.Size = new System.Drawing.Size(152, 22);
+ this.mnuVideoFilter.Size = new System.Drawing.Size(135, 22);
this.mnuVideoFilter.Text = "Video Filter";
//
// mnuNoneFilter
@@ -980,7 +981,7 @@ namespace Mesen.GUI.Forms
this.mnuRegionDendy});
this.mnuRegion.Image = global::Mesen.GUI.Properties.Resources.Globe;
this.mnuRegion.Name = "mnuRegion";
- this.mnuRegion.Size = new System.Drawing.Size(152, 22);
+ this.mnuRegion.Size = new System.Drawing.Size(135, 22);
this.mnuRegion.Text = "Region";
//
// mnuRegionAuto
@@ -1014,13 +1015,13 @@ namespace Mesen.GUI.Forms
// toolStripMenuItem10
//
this.toolStripMenuItem10.Name = "toolStripMenuItem10";
- this.toolStripMenuItem10.Size = new System.Drawing.Size(149, 6);
+ this.toolStripMenuItem10.Size = new System.Drawing.Size(132, 6);
//
// mnuAudioConfig
//
this.mnuAudioConfig.Image = global::Mesen.GUI.Properties.Resources.Audio;
this.mnuAudioConfig.Name = "mnuAudioConfig";
- this.mnuAudioConfig.Size = new System.Drawing.Size(152, 22);
+ this.mnuAudioConfig.Size = new System.Drawing.Size(135, 22);
this.mnuAudioConfig.Text = "Audio";
this.mnuAudioConfig.Click += new System.EventHandler(this.mnuAudioConfig_Click);
//
@@ -1028,7 +1029,7 @@ namespace Mesen.GUI.Forms
//
this.mnuInput.Image = global::Mesen.GUI.Properties.Resources.Controller;
this.mnuInput.Name = "mnuInput";
- this.mnuInput.Size = new System.Drawing.Size(152, 22);
+ this.mnuInput.Size = new System.Drawing.Size(135, 22);
this.mnuInput.Text = "Input";
this.mnuInput.Click += new System.EventHandler(this.mnuInput_Click);
//
@@ -1036,7 +1037,7 @@ namespace Mesen.GUI.Forms
//
this.mnuVideoConfig.Image = global::Mesen.GUI.Properties.Resources.Video;
this.mnuVideoConfig.Name = "mnuVideoConfig";
- this.mnuVideoConfig.Size = new System.Drawing.Size(152, 22);
+ this.mnuVideoConfig.Size = new System.Drawing.Size(135, 22);
this.mnuVideoConfig.Text = "Video";
this.mnuVideoConfig.Click += new System.EventHandler(this.mnuVideoConfig_Click);
//
@@ -1044,20 +1045,20 @@ namespace Mesen.GUI.Forms
//
this.mnuEmulationConfig.Image = global::Mesen.GUI.Properties.Resources.DipSwitches;
this.mnuEmulationConfig.Name = "mnuEmulationConfig";
- this.mnuEmulationConfig.Size = new System.Drawing.Size(152, 22);
+ this.mnuEmulationConfig.Size = new System.Drawing.Size(135, 22);
this.mnuEmulationConfig.Text = "Emulation";
this.mnuEmulationConfig.Click += new System.EventHandler(this.mnuEmulationConfig_Click);
//
// toolStripMenuItem11
//
this.toolStripMenuItem11.Name = "toolStripMenuItem11";
- this.toolStripMenuItem11.Size = new System.Drawing.Size(149, 6);
+ this.toolStripMenuItem11.Size = new System.Drawing.Size(132, 6);
//
// mnuPreferences
//
this.mnuPreferences.Image = global::Mesen.GUI.Properties.Resources.Cog;
this.mnuPreferences.Name = "mnuPreferences";
- this.mnuPreferences.Size = new System.Drawing.Size(152, 22);
+ this.mnuPreferences.Size = new System.Drawing.Size(135, 22);
this.mnuPreferences.Text = "Preferences";
this.mnuPreferences.Click += new System.EventHandler(this.mnuPreferences_Click);
//
diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs
index a0a30cda..b1355257 100644
--- a/GUI.NET/Forms/frmMain.cs
+++ b/GUI.NET/Forms/frmMain.cs
@@ -426,6 +426,10 @@ namespace Mesen.GUI.Forms
private void ctrlRenderer_MouseMove(object sender, MouseEventArgs e)
{
+ if(sender != this.ctrlRecentGames) {
+ CursorManager.OnMouseMove((Control)sender);
+ }
+
if(this.HideMenuStrip && !this.menuStrip.ContainsFocus) {
if(sender == ctrlRenderer) {
this.menuStrip.Visible = ctrlRenderer.Top + e.Y < 30;
@@ -1615,7 +1619,7 @@ namespace Mesen.GUI.Forms
private void ctrlRenderer_DoubleClick(object sender, EventArgs e)
{
- if(!ctrlRenderer.NeedMouseIcon && !InteropEmu.HasArkanoidPaddle()) {
+ if(!CursorManager.NeedMouseIcon && !InteropEmu.HasArkanoidPaddle()) {
//Disable double clicking (used to switch to fullscreen mode) when using zapper/arkanoid controller
SetFullscreenState(!_fullscreenMode);
}
@@ -1835,5 +1839,10 @@ namespace Mesen.GUI.Forms
frm.ShowDialog(sender, this);
}
}
+
+ private void panelRenderer_MouseLeave(object sender, EventArgs e)
+ {
+ CursorManager.OnMouseLeave();
+ }
}
}
diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj
index 9ee4fd43..f6657f02 100644
--- a/GUI.NET/GUI.NET.csproj
+++ b/GUI.NET/GUI.NET.csproj
@@ -253,6 +253,7 @@
ctrlRecentGames.cs
+
UserControl