TAStudio - atari virtualpads

This commit is contained in:
adelikat 2012-04-01 18:53:06 +00:00
parent 4c817b20c8
commit 59f92b4c81
4 changed files with 324 additions and 0 deletions

View File

@ -462,6 +462,12 @@
<Compile Include="tools\ToolBox.Designer.cs">
<DependentUpon>ToolBox.cs</DependentUpon>
</Compile>
<Compile Include="tools\VirtualPadA26.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="tools\VirtualPadA26Control.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="tools\VirtualPadNES.cs">
<SubType>Component</SubType>
</Compile>

View File

@ -150,6 +150,22 @@ namespace BizHawk.MultiClient
case "NULL":
default:
break;
case "A26":
VirtualPadA26 ataripad1 = new VirtualPadA26();
ataripad1.Location = new Point(8, 19);
ataripad1.Controller = "P1";
VirtualPadA26 ataripad2 = new VirtualPadA26();
ataripad2.Location = new Point(188, 19);
ataripad2.Controller = "P2";
Pads.Add(ataripad1);
Pads.Add(ataripad2);
ControllerBox.Controls.Add(Pads[0]);
ControllerBox.Controls.Add(Pads[1]);
VirtualPadA26Control ataricontrols = new VirtualPadA26Control();
ataricontrols.Location = new Point(8, 109);
Pads.Add(ataricontrols);
ControllerBox.Controls.Add(Pads[2]);
break;
case "NES":
VirtualPadNES nespad1 = new VirtualPadNES();
nespad1.Location = new Point(8, 19);

View File

@ -0,0 +1,171 @@
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
{
class VirtualPadA26 : VirtualPad
{
public VirtualPadA26()
{
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(122, 24);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Size = new Size(174, 74);
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;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
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;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
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;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
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;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "B";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
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;
}
public override string GetMnemonic()
{
StringBuilder input = new StringBuilder("");
input.Append(PR.Checked ? "U" : ".");
input.Append(PL.Checked ? "D" : ".");
input.Append(PD.Checked ? "L" : ".");
input.Append(PU.Checked ? "R" : ".");
input.Append(B1.Checked ? "B" : ".");
input.Append("|");
return input.ToString();
}
public override void SetButtons(string buttons)
{
if (buttons.Length < 5) 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] == '.') B1.Checked = false; else B1.Checked = true;
}
private void Buttons_CheckedChanged(object sender, EventArgs e)
{
if (Global.Emulator.SystemId != "A26") return;
if (sender == PU)
Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked);
else if (sender == PD)
Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked);
else if (sender == PL)
Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked);
else if (sender == PR)
Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked);
else if (sender == B1)
Global.StickyXORAdapter.SetSticky(Controller + " Button", B1.Checked);
}
public override void Clear()
{
if (Global.Emulator.SystemId != "A26") return;
PU.Checked = false;
PD.Checked = false;
PL.Checked = false;
PR.Checked = false;
B1.Checked = false;
Global.StickyXORAdapter.SetSticky(Controller + " Up", false);
Global.StickyXORAdapter.SetSticky(Controller + " Down", false);
Global.StickyXORAdapter.SetSticky(Controller + " Left", false);
Global.StickyXORAdapter.SetSticky(Controller + " Right", false);
Global.StickyXORAdapter.SetSticky(Controller + " Select", false);
Global.StickyXORAdapter.SetSticky(Controller + " Start", false);
Global.StickyXORAdapter.SetSticky(Controller + " B", false);
}
}
}

View File

@ -0,0 +1,131 @@
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
{
class VirtualPadA26Control : VirtualPad
{
public VirtualPadA26Control()
{
ButtonPoints[0] = new Point(2, 2);
ButtonPoints[1] = new Point(56, 2);
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);
this.Size = new Size(108, 34);
Point n = new Point(this.Size);
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[0];
this.B1.TabIndex = 5;
this.B1.Text = "Reset";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1.ForeColor = Color.Red;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[1];
this.B2.TabIndex = 6;
this.B2.Text = "Select";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B2.ForeColor = Color.Red;
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
}
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)
{
}
public override string GetMnemonic()
{
StringBuilder input = new StringBuilder("");
input.Append(B1.Checked ? "r" : ".");
input.Append(B2.Checked ? "s" : ".");
input.Append("|");
return input.ToString();
}
public override void SetButtons(string buttons)
{
if (buttons.Length < 2) return;
if (buttons[0] == '.') B1.Checked = false; else B1.Checked = true;
if (buttons[1] == '.') B2.Checked = false; else B2.Checked = true;
}
private void Buttons_CheckedChanged(object sender, EventArgs e)
{
if (Global.Emulator.SystemId != "A26") return;
else if (sender == B1)
{
Global.StickyXORAdapter.SetSticky("Reset", B1.Checked);
if (B1.Checked == true)
B1.BackColor = Color.Pink;
else
B1.BackColor = SystemColors.Control;
}
else if (sender == B2)
{
Global.StickyXORAdapter.SetSticky("Select", B2.Checked);
if (B2.Checked == true)
B2.BackColor = Color.Pink;
else
B2.BackColor = SystemColors.Control;
}
}
public override void Clear()
{
if (Global.Emulator.SystemId != "A26") return;
B1.Checked = false;
B2.Checked = false;
Global.StickyXORAdapter.SetSticky("Reset", false);
Global.StickyXORAdapter.SetSticky("Pause", false);
}
}
}