2013-07-24 01:38:52 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class AnalogBindControl : UserControl
|
|
|
|
|
{
|
|
|
|
|
private AnalogBindControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 13:10:09 +00:00
|
|
|
|
public AnalogBindControl(string buttonName, Config.AnalogBind bind)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
: this()
|
|
|
|
|
{
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_bind = bind;
|
|
|
|
|
ButtonName = buttonName;
|
|
|
|
|
labelButtonName.Text = buttonName;
|
|
|
|
|
trackBarSensitivity.Value = (int)(bind.Mult * 10.0f);
|
|
|
|
|
trackBarDeadzone.Value = (int)(bind.Deadzone * 20.0f);
|
|
|
|
|
TrackBarSensitivity_ValueChanged(null, null);
|
|
|
|
|
TrackBarDeadzone_ValueChanged(null, null);
|
|
|
|
|
textBox1.Text = bind.Value;
|
2013-07-24 01:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 13:10:09 +00:00
|
|
|
|
public string ButtonName { get; private set; }
|
|
|
|
|
public Config.AnalogBind Bind => _bind;
|
|
|
|
|
|
|
|
|
|
private Config.AnalogBind _bind;
|
|
|
|
|
private bool _listening;
|
|
|
|
|
|
|
|
|
|
private void Timer1_Tick(object sender, EventArgs e)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
|
|
|
|
string bindval = Input.Instance.GetNextFloatEvent();
|
|
|
|
|
if (bindval != null)
|
|
|
|
|
{
|
|
|
|
|
timer1.Stop();
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_listening = false;
|
|
|
|
|
_bind.Value = bindval;
|
2013-07-24 01:38:52 +00:00
|
|
|
|
textBox1.Text = Bind.Value;
|
|
|
|
|
buttonBind.Text = "Bind!";
|
2013-07-24 02:19:38 +00:00
|
|
|
|
Input.Instance.StopListeningForFloatEvents();
|
2013-07-24 01:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 13:10:09 +00:00
|
|
|
|
private void ButtonBind_Click(object sender, EventArgs e)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
2017-05-31 13:10:09 +00:00
|
|
|
|
if (_listening)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
|
|
|
|
timer1.Stop();
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_listening = false;
|
2013-07-24 01:38:52 +00:00
|
|
|
|
buttonBind.Text = "Bind!";
|
2013-07-24 02:19:38 +00:00
|
|
|
|
Input.Instance.StopListeningForFloatEvents();
|
2013-07-24 01:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Input.Instance.StartListeningForFloatEvents();
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_listening = true;
|
2013-07-24 01:38:52 +00:00
|
|
|
|
buttonBind.Text = "Cancel!";
|
|
|
|
|
timer1.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 13:10:09 +00:00
|
|
|
|
private void TrackBarSensitivity_ValueChanged(object sender, EventArgs e)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_bind.Mult = trackBarSensitivity.Value / 10.0f;
|
|
|
|
|
labelSensitivity.Text = $"Sensitivity: {(Bind.Mult * 100)}" + "%";
|
2013-07-24 01:38:52 +00:00
|
|
|
|
}
|
2013-07-29 23:39:37 +00:00
|
|
|
|
|
2017-05-31 13:10:09 +00:00
|
|
|
|
private void TrackBarDeadzone_ValueChanged(object sender, EventArgs e)
|
2013-07-29 23:39:37 +00:00
|
|
|
|
{
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_bind.Deadzone = trackBarDeadzone.Value / 20.0f;
|
|
|
|
|
labelDeadzone.Text = $"Deadzone: {(Bind.Deadzone * 100)}" + "%";
|
2013-07-29 23:39:37 +00:00
|
|
|
|
}
|
2014-01-11 15:11:49 +00:00
|
|
|
|
|
2017-05-31 13:10:09 +00:00
|
|
|
|
private void ButtonFlip_Click(object sender, EventArgs e)
|
2014-01-11 15:11:49 +00:00
|
|
|
|
{
|
|
|
|
|
trackBarSensitivity.Value *= -1;
|
|
|
|
|
}
|
2014-02-09 23:18:42 +00:00
|
|
|
|
|
2014-06-04 15:00:53 +00:00
|
|
|
|
public void Unbind_Click(object sender, EventArgs e)
|
2014-02-09 23:18:42 +00:00
|
|
|
|
{
|
2017-05-31 13:10:09 +00:00
|
|
|
|
_bind.Value = "";
|
2014-02-09 23:18:42 +00:00
|
|
|
|
textBox1.Text = "";
|
|
|
|
|
}
|
2013-07-24 01:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|