Virtualpads - add a Readonly property to IVirtualPadControl, and some cleanup, readonly not wired up on any pad yet though
This commit is contained in:
parent
3c1ececb14
commit
9c601da269
|
@ -4,7 +4,20 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public interface IVirtualPadControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Clears the pad and resets it to a logical default
|
||||
/// </summary>
|
||||
void Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the state of the control based on the given controller state
|
||||
/// </summary>
|
||||
/// <param name="controller">The controller state that the control will be set to</param>
|
||||
void Set(IController controller);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether or not the user can change the state of the control
|
||||
/// </summary>
|
||||
bool ReadOnly { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,37 @@ namespace BizHawk.Client.EmuHawk
|
|||
private string _displayName = string.Empty;
|
||||
private int _maxValue = 0;
|
||||
private bool _programmaticallyChangingValue = false;
|
||||
|
||||
public VirtualPadAnalogButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region IVirtualPadControl Implementation
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
var newVal = (int)controller.GetFloat(Name);
|
||||
var changed = AnalogTrackBar.Value != newVal;
|
||||
if (changed)
|
||||
{
|
||||
CurrentValue = newVal;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
get;
|
||||
set; // TODO
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void VirtualPadAnalogButton_Load(object sender, EventArgs e)
|
||||
{
|
||||
DisplayNameLabel.Text = DisplayName;
|
||||
|
@ -75,21 +101,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
var newVal = (int)controller.GetFloat(Name);
|
||||
var changed = AnalogTrackBar.Value != newVal;
|
||||
if (changed)
|
||||
{
|
||||
CurrentValue = newVal;
|
||||
}
|
||||
}
|
||||
|
||||
private void AnalogTrackBar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_programmaticallyChangingValue)
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
MaxYNumeric.Value = 127; // Note: these trigger change events that change the analog stick too
|
||||
}
|
||||
|
||||
#region IVirtualPadControl Implementation
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
AnalogStick.Set(controller);
|
||||
|
@ -42,6 +44,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
ManualY.Value = 0;
|
||||
}
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
get;
|
||||
set; // TODO
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ManualX_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
SetAnalogControlFromNumerics();
|
||||
|
|
|
@ -22,6 +22,35 @@ namespace BizHawk.Client.EmuHawk
|
|||
ForeColor = SystemColors.ControlText;
|
||||
}
|
||||
|
||||
#region IVirtualPadControl Implementation
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
RightClicked = false;
|
||||
Checked = false;
|
||||
Global.AutofireStickyXORAdapter.SetSticky(Name, false);
|
||||
Global.StickyXORAdapter.SetSticky(Name, false);
|
||||
}
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
var newVal = controller.IsPressed(Name);
|
||||
var changed = newVal != Checked;
|
||||
|
||||
Checked = newVal;
|
||||
if (changed)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
get; set; // TODO
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
switch (m.Msg)
|
||||
|
@ -116,25 +145,5 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
base.OnMouseClick(e);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
RightClicked = false;
|
||||
Checked = false;
|
||||
Global.AutofireStickyXORAdapter.SetSticky(Name, false);
|
||||
Global.StickyXORAdapter.SetSticky(Name, false);
|
||||
}
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
var newVal = controller.IsPressed(Name);
|
||||
var changed = newVal != Checked;
|
||||
|
||||
Checked = newVal;
|
||||
if (changed)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
YNumeric.Maximum = TargetPanel.Height;
|
||||
}
|
||||
|
||||
#region IVirtualPadControl Implementation
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
get;
|
||||
set; // TODO
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public string XName { get; set; }
|
||||
public string YName { get; set; }
|
||||
public string FireButton { get; set; } // Fire, Press, etc
|
||||
|
@ -95,16 +115,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void Set(IController controller)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void UpdatePanelFromNumeric()
|
||||
{
|
||||
if (!_isProgrammicallyChangingNumerics)
|
||||
|
|
Loading…
Reference in New Issue