Virtual Pad - get analog button working on movie replay
This commit is contained in:
parent
22dc432199
commit
7fa551708f
|
@ -41,6 +41,20 @@ namespace BizHawk.Client.Common
|
|||
return adapter;
|
||||
}
|
||||
|
||||
// Convenience property that gets the controller state from the movie for the most recent frame
|
||||
public IController CurrentInput
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished)
|
||||
{
|
||||
return Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Output(string message)
|
||||
{
|
||||
if (MessageCallback != null)
|
||||
|
|
|
@ -120,9 +120,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
if (Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished)
|
||||
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished)
|
||||
{
|
||||
Pads.ForEach(p => p.Set(Global.MovieOutputHardpoint));
|
||||
Pads.ForEach(p => p.Set(Global.MovieSession.CurrentInput));
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
private string _displayName = string.Empty;
|
||||
private int _maxValue = 0;
|
||||
|
||||
private bool _programmaticallyChangingValue = false;
|
||||
public VirtualPadAnalogButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -59,6 +59,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public int CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return AnalogTrackBar.Value;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_programmaticallyChangingValue = true;
|
||||
AnalogTrackBar.Value = value;
|
||||
ValueLabel.Text = AnalogTrackBar.Value.ToString();
|
||||
_programmaticallyChangingValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
// Nothing to do
|
||||
|
@ -66,20 +82,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
// TODO
|
||||
var newVal = (int)controller.GetFloat(Name);
|
||||
var changed = AnalogTrackBar.Value != newVal;
|
||||
if (changed)
|
||||
{
|
||||
CurrentValue = newVal;
|
||||
}
|
||||
}
|
||||
|
||||
private void AnalogTrackBar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
ValueLabel.Text = AnalogTrackBar.Value.ToString();
|
||||
Refresh();
|
||||
Global.StickyXORAdapter.SetFloat(Name, AnalogTrackBar.Value);
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
{
|
||||
AnalogTrackBar.Value = (int)Global.StickyXORAdapter.GetFloat(Name);
|
||||
base.Update();
|
||||
if (!_programmaticallyChangingValue)
|
||||
{
|
||||
CurrentValue = AnalogTrackBar.Value;
|
||||
Global.StickyXORAdapter.SetFloat(Name, AnalogTrackBar.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue