2013-04-28 13:56:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-05-04 13:37:20 +00:00
|
|
|
|
namespace BizHawk.MultiClient
|
2013-04-28 13:56:29 +00:00
|
|
|
|
{
|
2013-05-04 13:37:20 +00:00
|
|
|
|
public partial class VirtualPadN64 : UserControl, IVirtualPad
|
2013-04-28 13:56:29 +00:00
|
|
|
|
{
|
2013-05-04 13:37:20 +00:00
|
|
|
|
public string Controller = "P1";
|
|
|
|
|
|
2013-06-09 23:54:19 +00:00
|
|
|
|
private int old_X = 0;
|
|
|
|
|
private int old_Y = 0;
|
|
|
|
|
|
2013-04-28 13:56:29 +00:00
|
|
|
|
public VirtualPadN64()
|
|
|
|
|
{
|
2013-05-04 13:37:20 +00:00
|
|
|
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.UserPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.DoubleBuffer, true);
|
|
|
|
|
BorderStyle = BorderStyle.Fixed3D;
|
2013-04-28 13:56:29 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UserControl1_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2013-05-04 13:37:20 +00:00
|
|
|
|
|
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
if (keyData == Keys.Up)
|
|
|
|
|
{
|
|
|
|
|
//TODO: move to next logical key
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Down)
|
|
|
|
|
{
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Left)
|
|
|
|
|
{
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Right)
|
|
|
|
|
{
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Tab)
|
|
|
|
|
{
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
|
|
|
|
if (Global.Emulator.SystemId != "N64") return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false);
|
|
|
|
|
if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false);
|
|
|
|
|
if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false);
|
|
|
|
|
if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false);
|
|
|
|
|
|
|
|
|
|
if (BB.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false);
|
|
|
|
|
if (BA.Checked) Global.StickyXORAdapter.SetSticky(Controller + " A", false);
|
|
|
|
|
if (BZ.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Z", false);
|
|
|
|
|
if (BS.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Start", false);
|
|
|
|
|
|
|
|
|
|
if (BL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " L", false);
|
|
|
|
|
if (BR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " R", false);
|
|
|
|
|
|
|
|
|
|
if (CU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Up", false);
|
|
|
|
|
if (CD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Down", false);
|
|
|
|
|
if (CL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Left", false);
|
|
|
|
|
if (CR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Right", false);
|
|
|
|
|
|
|
|
|
|
PU.Checked = false;
|
|
|
|
|
PD.Checked = false;
|
|
|
|
|
PL.Checked = false;
|
|
|
|
|
PR.Checked = false;
|
|
|
|
|
|
|
|
|
|
BB.Checked = false;
|
|
|
|
|
BA.Checked = false;
|
|
|
|
|
BZ.Checked = false;
|
|
|
|
|
BS.Checked = false;
|
|
|
|
|
BL.Checked = false;
|
|
|
|
|
BR.Checked = false;
|
|
|
|
|
|
|
|
|
|
CU.Checked = false;
|
|
|
|
|
CD.Checked = false;
|
|
|
|
|
CL.Checked = false;
|
|
|
|
|
CR.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetButtons(string buttons)
|
|
|
|
|
{
|
|
|
|
|
if (buttons.Length < 14) return;
|
|
|
|
|
if (buttons[0] == '.') PU.Checked = false; else PU.Checked = true;
|
|
|
|
|
if (buttons[1] == '.') PD.Checked = false; else PD.Checked = true;
|
|
|
|
|
if (buttons[2] == '.') PL.Checked = false; else PL.Checked = true;
|
|
|
|
|
if (buttons[3] == '.') PR.Checked = false; else PR.Checked = true;
|
|
|
|
|
if (buttons[4] == '.') BB.Checked = false; else BB.Checked = true;
|
|
|
|
|
if (buttons[5] == '.') BA.Checked = false; else BA.Checked = true;
|
|
|
|
|
if (buttons[6] == '.') BZ.Checked = false; else BZ.Checked = true;
|
|
|
|
|
if (buttons[7] == '.') BS.Checked = false; else BS.Checked = true;
|
|
|
|
|
if (buttons[8] == '.') BL.Checked = false; else BL.Checked = true;
|
|
|
|
|
if (buttons[9] == '.') BR.Checked = false; else BR.Checked = true;
|
|
|
|
|
if (buttons[10] == '.') CU.Checked = false; else CU.Checked = true;
|
|
|
|
|
if (buttons[11] == '.') CD.Checked = false; else CD.Checked = true;
|
|
|
|
|
if (buttons[12] == '.') CL.Checked = false; else CL.Checked = true;
|
|
|
|
|
if (buttons[13] == '.') CR.Checked = false; else CR.Checked = true;
|
2013-05-20 01:53:02 +00:00
|
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
2013-08-05 02:38:45 +00:00
|
|
|
|
if (InputValidate.IsValidSignedNumber(buttons.Substring(14, 4)))
|
2013-05-20 01:53:02 +00:00
|
|
|
|
{
|
2013-08-05 02:38:45 +00:00
|
|
|
|
x = Int32.Parse(buttons.Substring(14, 4));
|
2013-05-20 01:53:02 +00:00
|
|
|
|
|
|
|
|
|
}
|
2013-08-05 02:38:45 +00:00
|
|
|
|
if (InputValidate.IsValidSignedNumber(buttons.Substring(19, 4)))
|
2013-05-20 01:53:02 +00:00
|
|
|
|
{
|
2013-08-05 02:38:45 +00:00
|
|
|
|
y = Int32.Parse(buttons.Substring(19, 4));
|
2013-05-20 01:53:02 +00:00
|
|
|
|
}
|
2013-08-05 02:38:45 +00:00
|
|
|
|
set_analog(x, y);
|
2013-05-04 13:37:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetMnemonic()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder input = new StringBuilder("");
|
|
|
|
|
input.Append(PU.Checked ? "U" : ".");
|
|
|
|
|
input.Append(PD.Checked ? "D" : ".");
|
|
|
|
|
input.Append(PL.Checked ? "L" : ".");
|
|
|
|
|
input.Append(PR.Checked ? "R" : ".");
|
|
|
|
|
|
|
|
|
|
input.Append(BB.Checked ? "B" : ".");
|
|
|
|
|
input.Append(BA.Checked ? "A" : ".");
|
|
|
|
|
input.Append(BZ.Checked ? "Z" : ".");
|
|
|
|
|
input.Append(BS.Checked ? "S" : ".");
|
|
|
|
|
|
|
|
|
|
input.Append(BL.Checked ? "L" : ".");
|
|
|
|
|
input.Append(BR.Checked ? "R" : ".");
|
|
|
|
|
|
|
|
|
|
input.Append(CU.Checked ? "u" : ".");
|
|
|
|
|
input.Append(CD.Checked ? "d" : ".");
|
|
|
|
|
input.Append(CL.Checked ? "l" : ".");
|
|
|
|
|
input.Append(CR.Checked ? "r" : ".");
|
2013-05-27 01:31:29 +00:00
|
|
|
|
input.Append(String.Format("{0:000}", AnalogControl1.X + 128));
|
|
|
|
|
input.Append(String.Format("{0:000}", AnalogControl1.Y + 128));
|
2013-05-04 13:37:20 +00:00
|
|
|
|
|
|
|
|
|
input.Append("|");
|
|
|
|
|
return input.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Buttons_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Global.Emulator.SystemId != "N64")
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (sender == PU)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " DPad U", PU.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == PD)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " DPad D", PD.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == PL)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " DPad L", PL.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == PR)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " DPad R", PR.Checked);
|
|
|
|
|
}
|
2013-05-11 20:21:29 +00:00
|
|
|
|
else if (sender == CR)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " C Right", CR.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == CL)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " C Left", CL.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == CU)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " C Up", CU.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == CD)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " C Down", CD.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == BR)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " R", BR.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == BL)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " L", BL.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == BS)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Start", BS.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == BA)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " A", BA.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == BB)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " B", BB.Checked);
|
|
|
|
|
}
|
|
|
|
|
else if (sender == BZ)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Z", BZ.Checked);
|
|
|
|
|
}
|
2013-05-04 13:37:20 +00:00
|
|
|
|
}
|
2013-05-10 23:29:14 +00:00
|
|
|
|
|
|
|
|
|
private void AnalogControl1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2013-06-09 23:54:19 +00:00
|
|
|
|
set_analog(AnalogControl1.X, AnalogControl1.Y);
|
2013-05-10 23:29:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AnalogControl1_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2013-06-09 23:54:19 +00:00
|
|
|
|
set_analog(AnalogControl1.X, AnalogControl1.Y);
|
2013-06-08 21:59:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ManualX_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-06-09 23:54:19 +00:00
|
|
|
|
if (ManualX.Value != old_X)
|
|
|
|
|
set_analog((int)ManualX.Value, old_Y);
|
2013-06-08 21:59:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ManualY_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-06-09 23:54:19 +00:00
|
|
|
|
if (ManualY.Value != old_Y)
|
|
|
|
|
set_analog(old_X, (int)ManualY.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void set_analog(int X, int Y)
|
|
|
|
|
{
|
|
|
|
|
Global.StickyXORAdapter.SetFloat(Controller + " X Axis", X);
|
|
|
|
|
Global.StickyXORAdapter.SetFloat(Controller + " Y Axis", Y);
|
|
|
|
|
|
|
|
|
|
AnalogControl1.X = X;
|
|
|
|
|
AnalogControl1.Y = Y;
|
2013-06-08 21:59:06 +00:00
|
|
|
|
AnalogControl1.Refresh();
|
2013-06-09 23:54:19 +00:00
|
|
|
|
|
|
|
|
|
old_X = X;
|
|
|
|
|
old_Y = Y;
|
|
|
|
|
ManualX.Value = X;
|
|
|
|
|
ManualY.Value = Y;
|
2013-05-10 23:29:14 +00:00
|
|
|
|
}
|
2013-08-03 13:22:54 +00:00
|
|
|
|
|
|
|
|
|
//TODO: multiplayer
|
|
|
|
|
public void FudgeAnalog(int? dx, int? dy)
|
|
|
|
|
{
|
|
|
|
|
int newx = AnalogControl1.X;
|
|
|
|
|
int newy = AnalogControl1.Y;
|
|
|
|
|
if (dx.HasValue)
|
|
|
|
|
{
|
|
|
|
|
newx = AnalogControl1.X + dx.Value;
|
|
|
|
|
if (newx > AnalogControlPanel.Max) newx = AnalogControlPanel.Max;
|
|
|
|
|
if (newx < AnalogControlPanel.Min) newx = AnalogControlPanel.Min;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dy.HasValue)
|
|
|
|
|
{
|
|
|
|
|
newy = AnalogControl1.Y + dy.Value;
|
|
|
|
|
if (newy > AnalogControlPanel.Max) newy = AnalogControlPanel.Max;
|
|
|
|
|
if (newy < AnalogControlPanel.Min) newy = AnalogControlPanel.Min;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnalogControl1.SetPosition(newx, newy);
|
|
|
|
|
ManualX.Value = newx;
|
|
|
|
|
ManualY.Value = newy;
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
2013-04-28 13:56:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|