add system for controlling which forms can generate mouse input
This commit is contained in:
parent
b364b5c48f
commit
140aec6a4d
|
@ -62,6 +62,29 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public class Input
|
public class Input
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum InputFocus
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Mouse = 1,
|
||||||
|
Keyboard = 2,
|
||||||
|
Pad = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If your form needs this kind of input focus, be sure to say so.
|
||||||
|
/// Really, this only makes sense for mouse, but I've started building it out for other things
|
||||||
|
/// Why is this receiving a control, but actually using it as a Form (where the WantingMouseFocus is checked?)
|
||||||
|
/// Because later we might change it to work off the control, specifically, if a control is supplied (normally actually a Form will be supplied)
|
||||||
|
/// </summary>
|
||||||
|
public void ControlInputFocus(System.Windows.Forms.Control c, InputFocus types, bool wants)
|
||||||
|
{
|
||||||
|
if (types.HasFlag(InputFocus.Mouse) && wants) WantingMouseFocus.Add(c);
|
||||||
|
if (types.HasFlag(InputFocus.Mouse) && !wants) WantingMouseFocus.Remove(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<System.Windows.Forms.Control> WantingMouseFocus = new HashSet<System.Windows.Forms.Control>();
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum ModifierKey
|
public enum ModifierKey
|
||||||
{
|
{
|
||||||
|
@ -352,6 +375,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
// analyse moose
|
// analyse moose
|
||||||
// other sorts of mouse api (raw input) could easily be added as a separate listing under a different class
|
// other sorts of mouse api (raw input) could easily be added as a separate listing under a different class
|
||||||
|
if (WantingMouseFocus.Contains(System.Windows.Forms.Form.ActiveForm))
|
||||||
{
|
{
|
||||||
var P = System.Windows.Forms.Control.MousePosition;
|
var P = System.Windows.Forms.Control.MousePosition;
|
||||||
if (trackdeltas)
|
if (trackdeltas)
|
||||||
|
@ -366,11 +390,20 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
var B = System.Windows.Forms.Control.MouseButtons;
|
var B = System.Windows.Forms.Control.MouseButtons;
|
||||||
HandleButton("WMouse L", (B & System.Windows.Forms.MouseButtons.Left) != 0);
|
HandleButton("WMouse L", (B & System.Windows.Forms.MouseButtons.Left) != 0);
|
||||||
HandleButton("WMouse M", (B & System.Windows.Forms.MouseButtons.Middle) != 0);
|
HandleButton("WMouse C", (B & System.Windows.Forms.MouseButtons.Middle) != 0);
|
||||||
HandleButton("WMouse R", (B & System.Windows.Forms.MouseButtons.Right) != 0);
|
HandleButton("WMouse R", (B & System.Windows.Forms.MouseButtons.Right) != 0);
|
||||||
HandleButton("WMouse 1", (B & System.Windows.Forms.MouseButtons.XButton1) != 0);
|
HandleButton("WMouse 1", (B & System.Windows.Forms.MouseButtons.XButton1) != 0);
|
||||||
HandleButton("WMouse 2", (B & System.Windows.Forms.MouseButtons.XButton2) != 0);
|
HandleButton("WMouse 2", (B & System.Windows.Forms.MouseButtons.XButton2) != 0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//unpress all buttons
|
||||||
|
HandleButton("WMouse L", false);
|
||||||
|
HandleButton("WMouse C", false);
|
||||||
|
HandleButton("WMouse R", false);
|
||||||
|
HandleButton("WMouse 1", false);
|
||||||
|
HandleButton("WMouse 2", false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -623,6 +623,20 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override void OnActivated(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnActivated(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDeactivate(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void ProcessInput()
|
public void ProcessInput()
|
||||||
{
|
{
|
||||||
ControllerInputCoalescer conInput = Global.ControllerInputCoalescer as ControllerInputCoalescer;
|
ControllerInputCoalescer conInput = Global.ControllerInputCoalescer as ControllerInputCoalescer;
|
||||||
|
|
|
@ -42,6 +42,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
ControllerImages.Add("WonderSwan Controller", Properties.Resources.WonderSwanColor);
|
ControllerImages.Add("WonderSwan Controller", Properties.Resources.WonderSwanColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivated(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnActivated(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDeactivate(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, false);
|
||||||
|
}
|
||||||
|
|
||||||
private ControllerConfig()
|
private ControllerConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
|
@ -18,6 +18,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
IDB_SAVE.Focus(); // A very dirty hack to avoid https://code.google.com/p/bizhawk/issues/detail?id=161
|
IDB_SAVE.Focus(); // A very dirty hack to avoid https://code.google.com/p/bizhawk/issues/detail?id=161
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnActivated(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnActivated(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDeactivate(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewHotkeyWindow_Load(object sender, EventArgs e)
|
private void NewHotkeyWindow_Load(object sender, EventArgs e)
|
||||||
|
|
|
@ -30,6 +30,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
TopMost = Global.Config.VirtualPadSettings.TopMost;
|
TopMost = Global.Config.VirtualPadSettings.TopMost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivated(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnActivated(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDeactivate(e);
|
||||||
|
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, false);
|
||||||
|
}
|
||||||
|
|
||||||
private void VirtualpadTool_Load(object sender, EventArgs e)
|
private void VirtualpadTool_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_defaultWidth = Size.Width;
|
_defaultWidth = Size.Width;
|
||||||
|
|
Loading…
Reference in New Issue