Virtual Pad - some analog stick tweaks

This commit is contained in:
adelikat 2014-06-24 17:30:14 +00:00
parent 7fa551708f
commit 7e8f0f74bc
3 changed files with 20 additions and 8 deletions

View File

@ -120,7 +120,7 @@ namespace BizHawk.Client.EmuHawk
return;
}
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished)
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished && Global.Emulator.Frame > 0)
{
Pads.ForEach(p => p.Set(Global.MovieSession.CurrentInput));
}

View File

@ -2,6 +2,7 @@
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
@ -61,10 +62,7 @@ namespace BizHawk.Client.EmuHawk
SetStyle(ControlStyles.Opaque, true);
BackColor = Color.Gray;
Paint += AnalogControlPanel_Paint;
new Pen(_whiteBrush);
_blackPen = new Pen(_blackBrush);
new Pen(_grayBrush);
new Pen(_redBrush);
_bluePen = new Pen(_blueBrush);
BorderStyle = BorderStyle.Fixed3D;
@ -133,9 +131,10 @@ namespace BizHawk.Client.EmuHawk
e.Graphics.DrawLine(_blackPen, 0, 63, 127, 63);
if (Global.MovieSession != null && Global.MovieSession.Movie != null && // For the desinger
Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished)
Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished &&
Global.Emulator.Frame > 1)
{
var input = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1);
var input = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 2);
var x = input.GetFloat(XName);
var y = input.GetFloat(YName);
@ -180,7 +179,6 @@ namespace BizHawk.Client.EmuHawk
Capture = false;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x007B) //WM_CONTEXTMENU
@ -216,6 +214,17 @@ namespace BizHawk.Client.EmuHawk
Refresh();
}
public void Set(IController controller)
{
var newX = (int)controller.GetFloat(XName);
var newY = (int)controller.GetFloat(YName);
var changed = newX != X || newY != Y;
if (changed)
{
SetPosition(newX, newY);
}
}
public void SetPosition(int xval, int yval)
{
X = xval;

View File

@ -23,13 +23,16 @@ namespace BizHawk.Client.EmuHawk
private void VirtualPadAnalogStick_Load(object sender, EventArgs e)
{
AnalogStick.Name = Name;
AnalogStick.Name = Name.Replace("X", "Y"); // TODO: allow schema to dictate this but this is a convenient default
AnalogStick.XName = Name;
AnalogStick.YName = Name.Replace("X", "Y"); // TODO: allow schema to dictate this but this is a convenient default
MaxXNumeric.Value = 127;
MaxYNumeric.Value = 127; // Note: these trigger change events that change the analog stick too
}
public void Set(IController controller)
{
AnalogStick.Set(controller);
SetNumericsFromAnalog();
}
public void Clear()