N64 - hook up virtual pad, currently only 1 player and only the digital buttons

This commit is contained in:
adelikat 2013-05-04 13:37:20 +00:00
parent 27c21db9b6
commit a638ea6f41
4 changed files with 295 additions and 138 deletions

View File

@ -180,7 +180,7 @@ namespace BizHawk.MultiClient
"Nintento 64 Controller", new Dictionary<string, string>()
{
{"DPad U", "U"}, {"DPad D", "D"}, {"DPad L", "L"}, {"DPad R", "R"},
{"A", "A"}, {"B", "B"}, {"Z", "Z"}, {"Start", "S"}, {"L", "L"}, {"R", "R"},
{"B", "B"}, {"A", "A"}, {"Z", "Z"}, {"Start", "S"}, {"L", "L"}, {"R", "R"},
{"C Up", "u"}, {"C Down", "d"}, {"C Left", "l"}, {"C Right", "r"}
}
},

View File

@ -173,6 +173,14 @@ namespace BizHawk.MultiClient
ControllerBox.Controls.Add(_ataripad1);
ControllerBox.Controls.Add(_ataripad2);
break;
case "N64":
VirtualPadN64 n64k = new VirtualPadN64
{
Location = new Point(8, 19)
};
Pads.Add(n64k);
ControllerBox.Controls.Add(n64k);
break;
}
//Hack for now

View File

@ -1,4 +1,4 @@
namespace BizHawk.MultiClient.tools
namespace BizHawk.MultiClient
{
partial class VirtualPadN64
{
@ -28,30 +28,23 @@
/// </summary>
private void InitializeComponent()
{
this.AnalogControl1 = new AnalogControlPanel();
this.PL = new System.Windows.Forms.CheckBox();
this.PD = new System.Windows.Forms.CheckBox();
this.PR = new System.Windows.Forms.CheckBox();
this.PU = new System.Windows.Forms.CheckBox();
this.KeyLeft = new System.Windows.Forms.CheckBox();
this.KeyRight = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.checkBox6 = new System.Windows.Forms.CheckBox();
this.checkBox7 = new System.Windows.Forms.CheckBox();
this.checkBox8 = new System.Windows.Forms.CheckBox();
this.BL = new System.Windows.Forms.CheckBox();
this.BR = new System.Windows.Forms.CheckBox();
this.BS = new System.Windows.Forms.CheckBox();
this.BZ = new System.Windows.Forms.CheckBox();
this.BB = new System.Windows.Forms.CheckBox();
this.BA = new System.Windows.Forms.CheckBox();
this.CU = new System.Windows.Forms.CheckBox();
this.CL = new System.Windows.Forms.CheckBox();
this.CR = new System.Windows.Forms.CheckBox();
this.CD = new System.Windows.Forms.CheckBox();
this.AnalogControl1 = new BizHawk.MultiClient.AnalogControlPanel();
this.SuspendLayout();
//
// AnalogControl1
//
this.AnalogControl1.Location = new System.Drawing.Point(14, 27);
this.AnalogControl1.Name = "AnalogControl1";
this.AnalogControl1.Size = new System.Drawing.Size(205, 147);
this.AnalogControl1.TabIndex = 0;
//
// PL
//
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
@ -62,6 +55,7 @@
this.PL.Size = new System.Drawing.Size(22, 22);
this.PL.TabIndex = 7;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PD
//
@ -73,6 +67,7 @@
this.PD.Size = new System.Drawing.Size(22, 22);
this.PD.TabIndex = 6;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PR
//
@ -84,6 +79,7 @@
this.PR.Size = new System.Drawing.Size(22, 22);
this.PR.TabIndex = 5;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PU
//
@ -95,131 +91,149 @@
this.PU.Size = new System.Drawing.Size(22, 22);
this.PU.TabIndex = 4;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// KeyLeft
// BL
//
this.KeyLeft.Appearance = System.Windows.Forms.Appearance.Button;
this.KeyLeft.AutoSize = true;
this.KeyLeft.Location = new System.Drawing.Point(14, 180);
this.KeyLeft.Name = "KeyLeft";
this.KeyLeft.Size = new System.Drawing.Size(23, 23);
this.KeyLeft.TabIndex = 8;
this.KeyLeft.Text = "L";
this.KeyLeft.UseVisualStyleBackColor = true;
this.BL.Appearance = System.Windows.Forms.Appearance.Button;
this.BL.AutoSize = true;
this.BL.Location = new System.Drawing.Point(14, 180);
this.BL.Name = "BL";
this.BL.Size = new System.Drawing.Size(23, 23);
this.BL.TabIndex = 8;
this.BL.Text = "L";
this.BL.UseVisualStyleBackColor = true;
this.BL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// KeyRight
// BR
//
this.KeyRight.Appearance = System.Windows.Forms.Appearance.Button;
this.KeyRight.AutoSize = true;
this.KeyRight.Location = new System.Drawing.Point(177, 180);
this.KeyRight.Name = "KeyRight";
this.KeyRight.Size = new System.Drawing.Size(25, 23);
this.KeyRight.TabIndex = 9;
this.KeyRight.Text = "R";
this.KeyRight.UseVisualStyleBackColor = true;
this.BR.Appearance = System.Windows.Forms.Appearance.Button;
this.BR.AutoSize = true;
this.BR.Location = new System.Drawing.Point(177, 180);
this.BR.Name = "BR";
this.BR.Size = new System.Drawing.Size(25, 23);
this.BR.TabIndex = 9;
this.BR.Text = "R";
this.BR.UseVisualStyleBackColor = true;
this.BR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox1
// BS
//
this.checkBox1.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(98, 191);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(24, 23);
this.checkBox1.TabIndex = 10;
this.checkBox1.Text = "S";
this.checkBox1.UseVisualStyleBackColor = true;
this.BS.Appearance = System.Windows.Forms.Appearance.Button;
this.BS.AutoSize = true;
this.BS.Location = new System.Drawing.Point(98, 191);
this.BS.Name = "BS";
this.BS.Size = new System.Drawing.Size(24, 23);
this.BS.TabIndex = 10;
this.BS.Text = "S";
this.BS.UseVisualStyleBackColor = true;
this.BS.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox2
// BZ
//
this.checkBox2.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(98, 270);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(24, 23);
this.checkBox2.TabIndex = 11;
this.checkBox2.Text = "Z";
this.checkBox2.UseVisualStyleBackColor = true;
this.BZ.Appearance = System.Windows.Forms.Appearance.Button;
this.BZ.AutoSize = true;
this.BZ.Location = new System.Drawing.Point(98, 270);
this.BZ.Name = "BZ";
this.BZ.Size = new System.Drawing.Size(24, 23);
this.BZ.TabIndex = 11;
this.BZ.Text = "Z";
this.BZ.UseVisualStyleBackColor = true;
//
// checkBox3
// BB
//
this.checkBox3.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox3.AutoSize = true;
this.checkBox3.Location = new System.Drawing.Point(98, 220);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(24, 23);
this.checkBox3.TabIndex = 12;
this.checkBox3.Text = "B";
this.checkBox3.UseVisualStyleBackColor = true;
this.BB.Appearance = System.Windows.Forms.Appearance.Button;
this.BB.AutoSize = true;
this.BB.Location = new System.Drawing.Point(98, 220);
this.BB.Name = "BB";
this.BB.Size = new System.Drawing.Size(24, 23);
this.BB.TabIndex = 12;
this.BB.Text = "B";
this.BB.UseVisualStyleBackColor = true;
this.BB.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox4
// BA
//
this.checkBox4.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox4.AutoSize = true;
this.checkBox4.Location = new System.Drawing.Point(128, 229);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(24, 23);
this.checkBox4.TabIndex = 13;
this.checkBox4.Text = "A";
this.checkBox4.UseVisualStyleBackColor = true;
this.BA.Appearance = System.Windows.Forms.Appearance.Button;
this.BA.AutoSize = true;
this.BA.Location = new System.Drawing.Point(128, 229);
this.BA.Name = "BA";
this.BA.Size = new System.Drawing.Size(24, 23);
this.BA.TabIndex = 13;
this.BA.Text = "A";
this.BA.UseVisualStyleBackColor = true;
this.BA.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox5
// CU
//
this.checkBox5.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox5.AutoSize = true;
this.checkBox5.Location = new System.Drawing.Point(212, 216);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(31, 23);
this.checkBox5.TabIndex = 14;
this.checkBox5.Text = "cU";
this.checkBox5.UseVisualStyleBackColor = true;
this.CU.Appearance = System.Windows.Forms.Appearance.Button;
this.CU.AutoSize = true;
this.CU.Location = new System.Drawing.Point(212, 216);
this.CU.Name = "CU";
this.CU.Size = new System.Drawing.Size(31, 23);
this.CU.TabIndex = 14;
this.CU.Text = "cU";
this.CU.UseVisualStyleBackColor = true;
this.CU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox6
// CL
//
this.checkBox6.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox6.AutoSize = true;
this.checkBox6.Location = new System.Drawing.Point(190, 245);
this.checkBox6.Name = "checkBox6";
this.checkBox6.Size = new System.Drawing.Size(29, 23);
this.checkBox6.TabIndex = 15;
this.checkBox6.Text = "cL";
this.checkBox6.UseVisualStyleBackColor = true;
this.CL.Appearance = System.Windows.Forms.Appearance.Button;
this.CL.AutoSize = true;
this.CL.Location = new System.Drawing.Point(190, 245);
this.CL.Name = "CL";
this.CL.Size = new System.Drawing.Size(29, 23);
this.CL.TabIndex = 15;
this.CL.Text = "cL";
this.CL.UseVisualStyleBackColor = true;
this.CL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox7
// CR
//
this.checkBox7.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox7.AutoSize = true;
this.checkBox7.Location = new System.Drawing.Point(225, 245);
this.checkBox7.Name = "checkBox7";
this.checkBox7.Size = new System.Drawing.Size(31, 23);
this.checkBox7.TabIndex = 16;
this.checkBox7.Text = "cR";
this.checkBox7.UseVisualStyleBackColor = true;
this.CR.Appearance = System.Windows.Forms.Appearance.Button;
this.CR.AutoSize = true;
this.CR.Location = new System.Drawing.Point(225, 245);
this.CR.Name = "CR";
this.CR.Size = new System.Drawing.Size(31, 23);
this.CR.TabIndex = 16;
this.CR.Text = "cR";
this.CR.UseVisualStyleBackColor = true;
this.CR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// checkBox8
// CD
//
this.checkBox8.Appearance = System.Windows.Forms.Appearance.Button;
this.checkBox8.AutoSize = true;
this.checkBox8.Location = new System.Drawing.Point(212, 274);
this.checkBox8.Name = "checkBox8";
this.checkBox8.Size = new System.Drawing.Size(31, 23);
this.checkBox8.TabIndex = 17;
this.checkBox8.Text = "cD";
this.checkBox8.UseVisualStyleBackColor = true;
this.CD.Appearance = System.Windows.Forms.Appearance.Button;
this.CD.AutoSize = true;
this.CD.Location = new System.Drawing.Point(212, 274);
this.CD.Name = "CD";
this.CD.Size = new System.Drawing.Size(31, 23);
this.CD.TabIndex = 17;
this.CD.Text = "cD";
this.CD.UseVisualStyleBackColor = true;
this.CD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// AnalogControl1
//
this.AnalogControl1.BackColor = System.Drawing.Color.Transparent;
this.AnalogControl1.Location = new System.Drawing.Point(14, 27);
this.AnalogControl1.Name = "AnalogControl1";
this.AnalogControl1.Size = new System.Drawing.Size(205, 147);
this.AnalogControl1.TabIndex = 0;
//
// VirtualPadN64
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.checkBox8);
this.Controls.Add(this.checkBox7);
this.Controls.Add(this.checkBox6);
this.Controls.Add(this.checkBox5);
this.Controls.Add(this.checkBox4);
this.Controls.Add(this.checkBox3);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.KeyRight);
this.Controls.Add(this.KeyLeft);
this.Controls.Add(this.CD);
this.Controls.Add(this.CR);
this.Controls.Add(this.CL);
this.Controls.Add(this.CU);
this.Controls.Add(this.BA);
this.Controls.Add(this.BB);
this.Controls.Add(this.BZ);
this.Controls.Add(this.BS);
this.Controls.Add(this.BR);
this.Controls.Add(this.BL);
this.Controls.Add(this.PL);
this.Controls.Add(this.PD);
this.Controls.Add(this.PR);
@ -240,15 +254,15 @@
private System.Windows.Forms.CheckBox PD;
private System.Windows.Forms.CheckBox PR;
private System.Windows.Forms.CheckBox PU;
private System.Windows.Forms.CheckBox KeyLeft;
private System.Windows.Forms.CheckBox KeyRight;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.CheckBox checkBox5;
private System.Windows.Forms.CheckBox checkBox6;
private System.Windows.Forms.CheckBox checkBox7;
private System.Windows.Forms.CheckBox checkBox8;
private System.Windows.Forms.CheckBox BL;
private System.Windows.Forms.CheckBox BR;
private System.Windows.Forms.CheckBox BS;
private System.Windows.Forms.CheckBox BZ;
private System.Windows.Forms.CheckBox BB;
private System.Windows.Forms.CheckBox BA;
private System.Windows.Forms.CheckBox CU;
private System.Windows.Forms.CheckBox CL;
private System.Windows.Forms.CheckBox CR;
private System.Windows.Forms.CheckBox CD;
}
}

View File

@ -1,19 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BizHawk.MultiClient.tools
namespace BizHawk.MultiClient
{
public partial class VirtualPadN64 : UserControl
public partial class VirtualPadN64 : UserControl, IVirtualPad
{
public string Controller = "P1";
public VirtualPadN64()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
BorderStyle = BorderStyle.Fixed3D;
InitializeComponent();
}
@ -21,5 +21,140 @@ namespace BizHawk.MultiClient.tools
{
}
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;
}
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" : ".");
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);
}
}
}
}