Virtualpads - re-implement the "bump" hotkeys

This commit is contained in:
adelikat 2014-06-29 23:43:31 +00:00
parent 3a011ad788
commit 8cf0f3b379
5 changed files with 75 additions and 3 deletions

View File

@ -113,5 +113,23 @@ namespace BizHawk.Client.EmuHawk
.ToList()
.ForEach(c => c.SetPrevious(previous));
}
public void BumpAnalog(int? x, int? y)
{
PadControls
.OfType<VirtualPadAnalogStick>()
.ToList()
.ForEach(a => a.Bump(x, y));
PadControls
.OfType<VirtualPadAnalogButton>()
.ToList()
.ForEach(a => a.Bump(x));
PadControls
.OfType<VirtualPadTargetScreen>()
.ToList()
.ForEach(a => a.Bump(x, y));
}
}
}

View File

@ -70,9 +70,9 @@ namespace BizHawk.Client.EmuHawk
Pads.ForEach(pad => pad.Clear());
}
public void BumpAnalogValue(int? dx, int? dy) // TODO: multi-player
public void BumpAnalogValue(int? x, int? y) // TODO: multi-player
{
Pads.ForEach(pad => pad.BumpAnalog(x, y));
}
private void CreatePads()

View File

@ -59,6 +59,14 @@ namespace BizHawk.Client.EmuHawk
#endregion
public void Bump(int? x)
{
if (x.HasValue)
{
CurrentValue = CurrentValue + x.Value;
}
}
private void VirtualPadAnalogButton_Load(object sender, EventArgs e)
{
DisplayNameLabel.Text = DisplayName;
@ -110,8 +118,22 @@ namespace BizHawk.Client.EmuHawk
set
{
int val;
if (value > AnalogTrackBar.Maximum)
{
val = AnalogTrackBar.Maximum;
}
else if (value < AnalogTrackBar.Minimum)
{
val = AnalogTrackBar.Minimum;
}
else
{
val = value;
}
_programmaticallyChangingValue = true;
AnalogTrackBar.Value = value;
AnalogTrackBar.Value = val;
ValueLabel.Text = AnalogTrackBar.Value.ToString();
_programmaticallyChangingValue = false;
}

View File

@ -77,6 +77,23 @@ namespace BizHawk.Client.EmuHawk
#endregion
public void Bump(int? x, int? y)
{
if (x.HasValue)
{
AnalogStick.HasValue = true;
AnalogStick.X += x.Value;
}
if (y.HasValue)
{
AnalogStick.HasValue = true;
AnalogStick.Y += y.Value;
}
SetNumericsFromAnalog();
}
public void SetPrevious(IController previous)
{
AnalogStick.SetPrevious(previous);

View File

@ -76,6 +76,21 @@ namespace BizHawk.Client.EmuHawk
#endregion
public void Bump(int? x, int? y)
{
if (x.HasValue)
{
X = X + x.Value;
}
if (y.HasValue)
{
Y = Y + y.Value;
}
Refresh();
}
public string XName { get; set; }
public string YName { get; set; }
public string FireButton { get; set; } // Fire, Press, etc