2011-06-12 01:50:08 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
|
|
|
|
{
|
2011-06-12 18:58:30 +00:00
|
|
|
|
public class VirtualPadNES : VirtualPad
|
2011-06-12 01:50:08 +00:00
|
|
|
|
{
|
2011-06-12 18:58:30 +00:00
|
|
|
|
|
|
|
|
|
public VirtualPadNES()
|
2011-06-12 01:50:08 +00:00
|
|
|
|
{
|
2011-06-12 18:58:30 +00:00
|
|
|
|
ButtonPoints[0] = new Point(14, 2);
|
|
|
|
|
ButtonPoints[1] = new Point(14, 46);
|
|
|
|
|
ButtonPoints[2] = new Point(2, 24);
|
|
|
|
|
ButtonPoints[3] = new Point(24, 24);
|
|
|
|
|
ButtonPoints[4] = new Point(52, 24);
|
|
|
|
|
ButtonPoints[5] = new Point(74, 24);
|
|
|
|
|
ButtonPoints[6] = new Point(122, 24);
|
|
|
|
|
ButtonPoints[7] = new Point(146, 24);
|
2011-06-12 14:42:50 +00:00
|
|
|
|
|
2011-06-12 01:50:08 +00:00
|
|
|
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.UserPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.DoubleBuffer, true);
|
|
|
|
|
this.BorderStyle = BorderStyle.Fixed3D;
|
|
|
|
|
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.Size = new Size(174, 74);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
Point n = new Point(this.Size);
|
|
|
|
|
|
|
|
|
|
this.PU = new CheckBox();
|
|
|
|
|
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.PU.AutoSize = true;
|
|
|
|
|
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
|
|
|
|
|
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.PU.Location = ButtonPoints[0];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.PU.TabIndex = 1;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.PU.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.PD = new CheckBox();
|
|
|
|
|
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.PD.AutoSize = true;
|
|
|
|
|
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
|
|
|
|
|
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.PD.Location = ButtonPoints[1];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.PD.TabIndex = 4;
|
|
|
|
|
this.PD.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.PR = new CheckBox();
|
|
|
|
|
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.PR.AutoSize = true;
|
|
|
|
|
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
|
|
|
|
|
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.PR.Location = ButtonPoints[3];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.PR.TabIndex = 3;
|
|
|
|
|
this.PR.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.PL = new CheckBox();
|
|
|
|
|
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.PL.AutoSize = true;
|
|
|
|
|
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
|
|
|
|
|
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.PL.Location = ButtonPoints[2];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.PL.TabIndex = 2;
|
|
|
|
|
this.PL.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.B1 = new CheckBox();
|
|
|
|
|
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.B1.AutoSize = true;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.B1.Location = ButtonPoints[4];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.B1.TabIndex = 5;
|
|
|
|
|
this.B1.Text = "s";
|
|
|
|
|
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
|
|
|
|
|
this.B1.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.B2 = new CheckBox();
|
|
|
|
|
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.B2.AutoSize = true;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.B2.Location = ButtonPoints[5];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.B2.TabIndex = 6;
|
|
|
|
|
this.B2.Text = "S";
|
|
|
|
|
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
|
|
|
|
|
this.B2.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.B3 = new CheckBox();
|
|
|
|
|
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.B3.AutoSize = true;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.B3.Location = ButtonPoints[6];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.B3.TabIndex = 7;
|
|
|
|
|
this.B3.Text = "B";
|
|
|
|
|
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
|
|
|
|
|
this.B3.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.B4 = new CheckBox();
|
|
|
|
|
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
|
|
|
|
|
this.B4.AutoSize = true;
|
2011-06-12 18:58:30 +00:00
|
|
|
|
this.B4.Location = ButtonPoints[7];
|
2011-06-12 01:50:08 +00:00
|
|
|
|
this.B4.TabIndex = 8;
|
|
|
|
|
this.B4.Text = "A";
|
|
|
|
|
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
|
|
|
|
|
this.B4.UseVisualStyleBackColor = true;
|
2011-06-12 19:31:06 +00:00
|
|
|
|
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
|
2011-06-12 01:50:08 +00:00
|
|
|
|
|
|
|
|
|
this.Controls.Add(this.PU);
|
|
|
|
|
this.Controls.Add(this.PD);
|
|
|
|
|
this.Controls.Add(this.PL);
|
|
|
|
|
this.Controls.Add(this.PR);
|
|
|
|
|
this.Controls.Add(this.B1);
|
|
|
|
|
this.Controls.Add(this.B2);
|
|
|
|
|
this.Controls.Add(this.B3);
|
|
|
|
|
this.Controls.Add(this.B4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
if (keyData == Keys.Up)
|
|
|
|
|
{
|
|
|
|
|
//TODO: move to next logical key
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Down)
|
|
|
|
|
{
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Left)
|
|
|
|
|
{
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Right)
|
|
|
|
|
{
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Tab)
|
|
|
|
|
{
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void VirtualPad_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2011-06-12 14:42:50 +00:00
|
|
|
|
|
2011-06-12 18:58:30 +00:00
|
|
|
|
public override string GetMnemonic()
|
2011-06-12 14:42:50 +00:00
|
|
|
|
{
|
|
|
|
|
StringBuilder input = new StringBuilder("|0|"); //TODO: Reset button
|
|
|
|
|
input.Append(PR.Checked ? "R" : ".");
|
|
|
|
|
input.Append(PL.Checked ? "L" : ".");
|
|
|
|
|
input.Append(PD.Checked ? "D" : ".");
|
|
|
|
|
input.Append(PU.Checked ? "U" : ".");
|
|
|
|
|
|
|
|
|
|
input.Append(B2.Checked ? "S" : ".");
|
|
|
|
|
input.Append(B1.Checked ? "s" : ".");
|
|
|
|
|
input.Append(B3.Checked ? "B" : ".");
|
|
|
|
|
input.Append(B4.Checked ? "A" : ".");
|
|
|
|
|
input.Append("|");
|
|
|
|
|
return input.ToString();
|
|
|
|
|
}
|
2011-06-12 19:31:06 +00:00
|
|
|
|
|
|
|
|
|
private void Buttons_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Global.Emulator.SystemId != "NES") return;
|
|
|
|
|
if (sender == PU)
|
|
|
|
|
Global.ActiveController.SetSticky("Up", PU.Checked);
|
|
|
|
|
else if (sender == PD)
|
|
|
|
|
Global.ActiveController.SetSticky("Down", PD.Checked);
|
|
|
|
|
else if (sender == PL)
|
|
|
|
|
Global.ActiveController.SetSticky("Left", PL.Checked);
|
|
|
|
|
else if (sender == PR)
|
|
|
|
|
Global.ActiveController.SetSticky("Right", PR.Checked);
|
|
|
|
|
else if (sender == B1)
|
|
|
|
|
Global.ActiveController.SetSticky("Select", B1.Checked);
|
|
|
|
|
else if (sender == B2)
|
|
|
|
|
Global.ActiveController.SetSticky("Start", B2.Checked);
|
|
|
|
|
else if (sender == B3)
|
|
|
|
|
Global.ActiveController.SetSticky("B", B3.Checked);
|
|
|
|
|
else if (sender == B4)
|
|
|
|
|
Global.ActiveController.SetSticky("A", B4.Checked);
|
|
|
|
|
|
|
|
|
|
}
|
2011-06-12 01:50:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|