VirtualPads - fix issue 225 - properly clear the analog stick when right-clicking

This commit is contained in:
adelikat 2014-07-26 13:59:06 +00:00
parent 3fbbfde343
commit b69b141a05
2 changed files with 18 additions and 5 deletions

View File

@ -15,6 +15,7 @@ namespace BizHawk.Client.EmuHawk
public VirtualPadAnalogStick()
{
InitializeComponent();
AnalogStick.ClearCallback = SetNumericsFromAnalog;
RangeX = 127;
RangeY = 127;
}
@ -150,6 +151,11 @@ namespace BizHawk.Client.EmuHawk
ManualX.Value = AnalogStick.X;
ManualY.Value = AnalogStick.Y;
}
else
{
ManualX.Value = 0;
ManualY.Value = 0;
}
}
private void AnalogStick_MouseDown(object sender, MouseEventArgs e)

View File

@ -3,6 +3,7 @@ using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using System;
namespace BizHawk.Client.EmuHawk
{
@ -85,6 +86,16 @@ namespace BizHawk.Client.EmuHawk
private readonly Bitmap Dot = new Bitmap(7, 7);
private readonly Bitmap GrayDot = new Bitmap(7, 7);
public Action ClearCallback { get; set; }
private void DoClearCallback()
{
if (ClearCallback != null)
{
ClearCallback();
}
}
public AnalogStickPanel()
{
Size = new Size(MaxX + 1, MaxY + 1);
@ -135,11 +146,6 @@ namespace BizHawk.Client.EmuHawk
return ret;
}
protected override void OnMouseClick(MouseEventArgs e)
{
SetAnalog();
}
private void SetAnalog()
{
var xn = HasValue ? X : (int?)null;
@ -243,6 +249,7 @@ namespace BizHawk.Client.EmuHawk
{
X = Y = 0;
HasValue = false;
DoClearCallback();
Refresh();
}