VirtualPad support for Wonderswan

This commit is contained in:
adelikat 2014-06-01 20:44:13 +00:00
parent f02448b769
commit f146875452
5 changed files with 567 additions and 0 deletions

View File

@ -959,6 +959,12 @@
<Compile Include="tools\VirtualPads\VirtualPadSNESControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="tools\VirtualPads\VirtualPadWonderSawn.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="tools\VirtualPads\VirtualPadWonderSawn.Designer.cs">
<DependentUpon>VirtualPadWonderSawn.cs</DependentUpon>
</Compile>
<Compile Include="tools\Watch\RamPoke.cs">
<SubType>Form</SubType>
</Compile>
@ -1294,6 +1300,9 @@
<EmbeddedResource Include="tools\VirtualPads\VirtualPadSaturnControl.resx">
<DependentUpon>VirtualPadSaturnControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\VirtualPads\VirtualPadWonderSawn.resx">
<DependentUpon>VirtualPadWonderSawn.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\Watch\RamPoke.resx">
<DependentUpon>RamPoke.cs</DependentUpon>
</EmbeddedResource>

View File

@ -225,6 +225,9 @@ namespace BizHawk.Client.EmuHawk
ControllerBox.Controls.Add(new VirtualPadSaturnControl { Location = new Point(8, 125) });
ControllerBox.Controls.Add(new VirtualPadSaturn { Location = new Point(8, 19), Controller = "P1" });
break;
case "WSWAN":
ControllerBox.Controls.Add(new VirtualPadWonderSawn { Location = new Point(8, 19) });
break;
}
// Hack for now

View File

@ -0,0 +1,229 @@
namespace BizHawk.Client.EmuHawk
{
partial class VirtualPadWonderSawn
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
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.PL2 = new System.Windows.Forms.CheckBox();
this.PD2 = new System.Windows.Forms.CheckBox();
this.PR2 = new System.Windows.Forms.CheckBox();
this.PU2 = new System.Windows.Forms.CheckBox();
this.BStart = new System.Windows.Forms.CheckBox();
this.BA = new System.Windows.Forms.CheckBox();
this.BB = new System.Windows.Forms.CheckBox();
this.BPower = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// PL
//
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Back;
this.PL.Location = new System.Drawing.Point(1, 15);
this.PL.Name = "PL";
this.PL.Size = new System.Drawing.Size(22, 22);
this.PL.TabIndex = 11;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PD
//
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.BlueDown;
this.PD.Location = new System.Drawing.Point(22, 24);
this.PD.Name = "PD";
this.PD.Size = new System.Drawing.Size(22, 22);
this.PD.TabIndex = 10;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PR
//
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Forward;
this.PR.Location = new System.Drawing.Point(43, 15);
this.PR.Name = "PR";
this.PR.Size = new System.Drawing.Size(22, 22);
this.PR.TabIndex = 9;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PU
//
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.BlueUp;
this.PU.Location = new System.Drawing.Point(22, 3);
this.PU.Name = "PU";
this.PU.Size = new System.Drawing.Size(22, 22);
this.PU.TabIndex = 8;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PL2
//
this.PL2.Appearance = System.Windows.Forms.Appearance.Button;
this.PL2.AutoSize = true;
this.PL2.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Back;
this.PL2.Location = new System.Drawing.Point(1, 79);
this.PL2.Name = "PL2";
this.PL2.Size = new System.Drawing.Size(22, 22);
this.PL2.TabIndex = 15;
this.PL2.UseVisualStyleBackColor = true;
this.PL2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PD2
//
this.PD2.Appearance = System.Windows.Forms.Appearance.Button;
this.PD2.AutoSize = true;
this.PD2.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.BlueDown;
this.PD2.Location = new System.Drawing.Point(22, 88);
this.PD2.Name = "PD2";
this.PD2.Size = new System.Drawing.Size(22, 22);
this.PD2.TabIndex = 14;
this.PD2.UseVisualStyleBackColor = true;
this.PD2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PR2
//
this.PR2.Appearance = System.Windows.Forms.Appearance.Button;
this.PR2.AutoSize = true;
this.PR2.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Forward;
this.PR2.Location = new System.Drawing.Point(43, 79);
this.PR2.Name = "PR2";
this.PR2.Size = new System.Drawing.Size(22, 22);
this.PR2.TabIndex = 13;
this.PR2.UseVisualStyleBackColor = true;
this.PR2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// PU2
//
this.PU2.Appearance = System.Windows.Forms.Appearance.Button;
this.PU2.AutoSize = true;
this.PU2.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.BlueUp;
this.PU2.Location = new System.Drawing.Point(22, 67);
this.PU2.Name = "PU2";
this.PU2.Size = new System.Drawing.Size(22, 22);
this.PU2.TabIndex = 12;
this.PU2.UseVisualStyleBackColor = true;
this.PU2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BStart
//
this.BStart.Appearance = System.Windows.Forms.Appearance.Button;
this.BStart.AutoSize = true;
this.BStart.Location = new System.Drawing.Point(79, 78);
this.BStart.Name = "BStart";
this.BStart.Size = new System.Drawing.Size(24, 23);
this.BStart.TabIndex = 21;
this.BStart.Text = "S";
this.BStart.UseVisualStyleBackColor = true;
this.BStart.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BA
//
this.BA.Appearance = System.Windows.Forms.Appearance.Button;
this.BA.AutoSize = true;
this.BA.Location = new System.Drawing.Point(145, 30);
this.BA.Name = "BA";
this.BA.Size = new System.Drawing.Size(24, 23);
this.BA.TabIndex = 23;
this.BA.Text = "A";
this.BA.UseVisualStyleBackColor = true;
this.BA.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BB
//
this.BB.Appearance = System.Windows.Forms.Appearance.Button;
this.BB.AutoSize = true;
this.BB.Location = new System.Drawing.Point(122, 35);
this.BB.Name = "BB";
this.BB.Size = new System.Drawing.Size(24, 23);
this.BB.TabIndex = 22;
this.BB.Text = "B";
this.BB.UseVisualStyleBackColor = true;
this.BB.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BPower
//
this.BPower.Appearance = System.Windows.Forms.Appearance.Button;
this.BPower.AutoSize = true;
this.BPower.ForeColor = System.Drawing.Color.Red;
this.BPower.Location = new System.Drawing.Point(108, 78);
this.BPower.Name = "BPower";
this.BPower.Size = new System.Drawing.Size(47, 23);
this.BPower.TabIndex = 24;
this.BPower.Text = "Power";
this.BPower.UseVisualStyleBackColor = true;
this.BPower.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// VirtualPadWonderSawn
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.BPower);
this.Controls.Add(this.BA);
this.Controls.Add(this.BB);
this.Controls.Add(this.BStart);
this.Controls.Add(this.PL2);
this.Controls.Add(this.PD2);
this.Controls.Add(this.PR2);
this.Controls.Add(this.PU2);
this.Controls.Add(this.PL);
this.Controls.Add(this.PD);
this.Controls.Add(this.PR);
this.Controls.Add(this.PU);
this.Name = "VirtualPadWonderSawn";
this.Size = new System.Drawing.Size(179, 119);
this.Load += new System.EventHandler(this.VirtualPadWonderSawn_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox PL;
private System.Windows.Forms.CheckBox PD;
private System.Windows.Forms.CheckBox PR;
private System.Windows.Forms.CheckBox PU;
private System.Windows.Forms.CheckBox PL2;
private System.Windows.Forms.CheckBox PD2;
private System.Windows.Forms.CheckBox PR2;
private System.Windows.Forms.CheckBox PU2;
private System.Windows.Forms.CheckBox BStart;
private System.Windows.Forms.CheckBox BA;
private System.Windows.Forms.CheckBox BB;
private System.Windows.Forms.CheckBox BPower;
}
}

View File

@ -0,0 +1,206 @@
using System;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class VirtualPadWonderSawn : UserControl, IVirtualPad
{
public string Controller { get; set; }
public VirtualPadWonderSawn()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
InitializeComponent();
Controller = "";
}
private void VirtualPadWonderSawn_Load(object sender, EventArgs e)
{
}
private void VirtualPad_Paint(object sender, PaintEventArgs e)
{
}
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 string GetMnemonic()
{
StringBuilder input = new StringBuilder("");
input.Append(PU.Checked ? "Up X" : ".");
input.Append(PD.Checked ? "Down X" : ".");
input.Append(PL.Checked ? "Left X" : ".");
input.Append(PR.Checked ? "Right X" : ".");
input.Append("|");
input.Append(PU2.Checked ? "Up Y" : ".");
input.Append(PD2.Checked ? "Down Y" : ".");
input.Append(PL2.Checked ? "Left Y" : ".");
input.Append(PR2.Checked ? "Right Y" : ".");
input.Append("|");
input.Append(BStart.Checked ? "Start" : ".");
input.Append(BB.Checked ? "B" : ".");
input.Append(BA.Checked ? "A" : ".");
input.Append(BPower.Checked ? "P" : ".");
input.Append("|");
return input.ToString();
}
public void Clear()
{
if (Global.Emulator.SystemId != "WSWAN")
{
return;
}
if (PU.Checked) Global.StickyXORAdapter.SetSticky("Up X", false);
if (PD.Checked) Global.StickyXORAdapter.SetSticky("Down X", false);
if (PL.Checked) Global.StickyXORAdapter.SetSticky("Left X", false);
if (PR.Checked) Global.StickyXORAdapter.SetSticky("Right X", false);
if (PU2.Checked) Global.StickyXORAdapter.SetSticky("Up Y", false);
if (PD2.Checked) Global.StickyXORAdapter.SetSticky("Down Y", false);
if (PL2.Checked) Global.StickyXORAdapter.SetSticky("Left Y", false);
if (PR2.Checked) Global.StickyXORAdapter.SetSticky("Right Y", false);
if (BStart.Checked) Global.StickyXORAdapter.SetSticky("Start", false);
if (BB.Checked) Global.StickyXORAdapter.SetSticky("B", false);
if (BA.Checked) Global.StickyXORAdapter.SetSticky("A", false);
if (BPower.Checked) Global.StickyXORAdapter.SetSticky("Power", false);
PU.Checked = false;
PD.Checked = false;
PL.Checked = false;
PR.Checked = false;
PU2.Checked = false;
PD2.Checked = false;
PL2.Checked = false;
PR2.Checked = false;
BStart.Checked = false;
BA.Checked = false;
BB.Checked = false;
BPower.Checked = false;
}
public void SetButtons(string buttons)
{
if (buttons.Length < 15) 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[5] == '.') PU2.Checked = false; else PU2.Checked = true;
if (buttons[6] == '.') PD2.Checked = false; else PD2.Checked = true;
if (buttons[7] == '.') PL2.Checked = false; else PL2.Checked = true;
if (buttons[8] == '.') PR2.Checked = false; else PR2.Checked = true;
if (buttons[10] == '.') BStart.Checked = false; else BStart.Checked = true;
if (buttons[11] == '.') BB.Checked = false; else BB.Checked = true;
if (buttons[12] == '.') BA.Checked = false; else BA.Checked = true;
if (buttons[13] == '.') BPower.Checked = false; else BPower.Checked = true;
}
private void Buttons_CheckedChanged(object sender, EventArgs e)
{
if (Global.Emulator.SystemId != "WSWAN")
{
return;
}
else if (sender == PU)
{
Global.StickyXORAdapter.SetSticky("Up X", PU.Checked);
}
else if (sender == PD)
{
Global.StickyXORAdapter.SetSticky("Down X", PD.Checked);
}
else if (sender == PL)
{
Global.StickyXORAdapter.SetSticky("Left X", PL.Checked);
}
else if (sender == PR)
{
Global.StickyXORAdapter.SetSticky("Right X", PR.Checked);
}
else if (sender == PU2)
{
Global.StickyXORAdapter.SetSticky("Up Y", PU2.Checked);
}
else if (sender == PD2)
{
Global.StickyXORAdapter.SetSticky("Down Y", PD2.Checked);
}
else if (sender == PL2)
{
Global.StickyXORAdapter.SetSticky("Left Y", PL2.Checked);
}
else if (sender == PR2)
{
Global.StickyXORAdapter.SetSticky("Right Y", PR2.Checked);
}
else if (sender == BStart)
{
Global.StickyXORAdapter.SetSticky("Start", BStart.Checked);
}
else if (sender == BB)
{
Global.StickyXORAdapter.SetSticky("B", BB.Checked);
}
else if (sender == BA)
{
Global.StickyXORAdapter.SetSticky("A", BA.Checked);
}
else if (sender == BPower)
{
Global.StickyXORAdapter.SetSticky("Power", BPower.Checked);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>