diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 06ddde4554..5aeadbc718 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -653,6 +653,9 @@ VirtualPadN64.cs + + Component + Component diff --git a/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj b/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj index 342ff9ff01..b57467b34a 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj @@ -655,6 +655,9 @@ VirtualPadN64.cs + + Component + Component diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs index 515d402631..d69442b706 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs @@ -90,6 +90,23 @@ namespace BizHawk.MultiClient Pads.Add(controlpad1); ControllerBox.Controls.Add(controlpad1); break; + case "N64": + VirtualPadN64 n64pad1 = new VirtualPadN64 { Location = new Point(8, 19), Controller = "P1" }; + VirtualPadN64 n64pad2 = new VirtualPadN64 { Location = new Point(208, 19), Controller = "P2" }; + VirtualPadN64 n64pad3 = new VirtualPadN64 { Location = new Point(408, 19), Controller = "P3" }; + VirtualPadN64 n64pad4 = new VirtualPadN64 { Location = new Point(608, 19), Controller = "P4" }; + Pads.Add(n64pad1); + Pads.Add(n64pad2); + Pads.Add(n64pad3); + Pads.Add(n64pad4); + ControllerBox.Controls.Add(n64pad1); + ControllerBox.Controls.Add(n64pad2); + ControllerBox.Controls.Add(n64pad3); + ControllerBox.Controls.Add(n64pad4); + VirtualPadN64Control n64controlpad1 = new VirtualPadN64Control { Location = new Point(8, 350) }; + Pads.Add(n64controlpad1); + ControllerBox.Controls.Add(n64controlpad1); + break; case "SMS": case "SG": case "GG": @@ -174,20 +191,7 @@ namespace BizHawk.MultiClient ControllerBox.Controls.Add(_ataripad1); ControllerBox.Controls.Add(_ataripad2); break; - case "N64": - VirtualPadN64 n64pad1 = new VirtualPadN64 { Location = new Point(8, 19), Controller = "P1" }; - VirtualPadN64 n64pad2 = new VirtualPadN64 { Location = new Point(208, 19), Controller = "P2" }; - VirtualPadN64 n64pad3 = new VirtualPadN64 { Location = new Point(408, 19), Controller = "P3" }; - VirtualPadN64 n64pad4 = new VirtualPadN64 { Location = new Point(608, 19), Controller = "P4" }; - Pads.Add(n64pad1); - Pads.Add(n64pad2); - Pads.Add(n64pad3); - Pads.Add(n64pad4); - ControllerBox.Controls.Add(n64pad1); - ControllerBox.Controls.Add(n64pad2); - ControllerBox.Controls.Add(n64pad3); - ControllerBox.Controls.Add(n64pad4); - break; + case "SAT": VirtualPadSaturn saturnpad1 = new VirtualPadSaturn { Location = new Point(8, 19), Controller = "P1" }; VirtualPadSaturn saturnpad2 = new VirtualPadSaturn { Location = new Point(213, 19), Controller = "P2" }; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs new file mode 100644 index 0000000000..aae6868bac --- /dev/null +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs @@ -0,0 +1,145 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using System.Text; + +namespace BizHawk.MultiClient +{ + public class VirtualPadN64Control : VirtualPad + { + public VirtualPadN64Control() + { + ButtonPoints[0] = new Point(2, 2); + ButtonPoints[1] = new Point(56, 2); + + SetStyle(ControlStyles.AllPaintingInWmPaint, true); + SetStyle(ControlStyles.UserPaint, true); + SetStyle(ControlStyles.DoubleBuffer, true); + BorderStyle = BorderStyle.Fixed3D; + Paint += VirtualPad_Paint; + Size = new Size(108, 34); + + B1 = new CheckBox + { + Appearance = Appearance.Button, + AutoSize = true, + Location = ButtonPoints[0], + TabIndex = 5, + Text = "Power", + TextAlign = ContentAlignment.BottomCenter, + UseVisualStyleBackColor = true + }; + B1.CheckedChanged += Buttons_CheckedChanged; + B1.ForeColor = Color.Red; + + B2 = new CheckBox + { + Appearance = Appearance.Button, + AutoSize = true, + Location = ButtonPoints[1], + TabIndex = 6, + Text = "Reset", + TextAlign = ContentAlignment.BottomCenter, + UseVisualStyleBackColor = true + }; + B2.CheckedChanged += Buttons_CheckedChanged; + B2.ForeColor = Color.Red; + + Controls.Add(B1); + Controls.Add(B2); + } + + 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; + } + + private void VirtualPad_Paint(object sender, PaintEventArgs e) + { + + } + + public override string GetMnemonic() + { + StringBuilder input = new StringBuilder(""); + input.Append(B2.Checked ? "r" : "."); + input.Append("|"); + return input.ToString(); + } + + public override void SetButtons(string buttons) + { + if (buttons.Length < 1) + { + return; + } + else if (buttons[0] == 'P') + { + B1.Checked = true; + } + else if (buttons[0] == '.' || buttons[0] == 'l' || buttons[0] == '0') + { + B2.Checked = false; + } + else + { + B2.Checked = true; + } + } + + private void Buttons_CheckedChanged(object sender, EventArgs e) + { + if (Global.Emulator.SystemId != "N64") + { + return; + } + else if (sender == B1) + { + Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + if (B1.Checked) + B1.BackColor = Color.Pink; + else + B1.BackColor = SystemColors.Control; + } + else if (sender == B2) + { + Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + if (B2.Checked) + B2.BackColor = Color.Pink; + else + B2.BackColor = SystemColors.Control; + } + } + + public override void Clear() + { + if (Global.Emulator.SystemId != "N64") return; + + B1.Checked = false; + B2.Checked = false; + + Global.StickyXORAdapter.SetSticky("Reset", false); + } + } +} diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs index a2ca03a3b0..9bab96025e 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs @@ -99,13 +99,13 @@ namespace BizHawk.MultiClient B1.Checked = true; } else if (buttons[0] == '.' || buttons[0] == 'l' || buttons[0] == '0') - { - B2.Checked = false; - } - else - { - B2.Checked = true; - } + { + B2.Checked = false; + } + else + { + B2.Checked = true; + } } private void Buttons_CheckedChanged(object sender, EventArgs e)