From e7f3abdfc360eafa3d48ae80dae21146c01f3c16 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 6 Nov 2012 03:27:24 +0000 Subject: [PATCH] Add NES Reset and Power as remappable controller buttons, remapping not hooked up to old config dialog, new config dialog - start console button remapping still has some bugs --- .../BizHawk.MultiClient.csproj | 3 ++ BizHawk.MultiClient/Config.cs | 6 ++- BizHawk.MultiClient/MainForm.cs | 5 ++- .../config/ControllerConfig.Designer.cs | 12 ++++++ .../ControllerConfig/NESConsoleButtons.cs | 40 +++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 BizHawk.MultiClient/config/ControllerConfig/NESConsoleButtons.cs diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 2e46e42621..2037154cfa 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -172,6 +172,9 @@ Component + + Component + Component diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index 3a8a372e5f..73ffcd601a 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -627,6 +627,7 @@ namespace BizHawk.MultiClient public string SmsReset = "C"; public string SmsPause = "V, X1 Start"; + public SMSControllerTemplate[] SMSController = new SMSControllerTemplate[2]; public SMSControllerTemplate[] SMSAutoController = new SMSControllerTemplate[2]; @@ -653,7 +654,6 @@ namespace BizHawk.MultiClient public ColecoVisionControllerTemplate ColecoController = new ColecoVisionControllerTemplate(true); //NES settings - //public string NESReset = "Backspace"; public NESControllerTemplate[] NESController = new NESControllerTemplate[4]; public NESControllerTemplate[] NESAutoController = new NESControllerTemplate[4]; @@ -709,6 +709,10 @@ namespace BizHawk.MultiClient public bool Atari2600_ShowMissle2 = true; public bool Atari2600_ShowBall = true; public bool Atari2600_ShowPlayfield = true; + + //NES Console buttons + public string NESReset = ""; + public string NESPower = ""; } public class SMSControllerTemplate diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 477235691e..01ae771872 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -829,7 +829,6 @@ namespace BizHawk.MultiClient } Global.AutofireSNESControls = asnesControls; - var nesControls = new Controller(NES.NESController); for (int i = 0; i < 2 /*TODO*/; i++) { @@ -842,6 +841,10 @@ namespace BizHawk.MultiClient nesControls.BindMulti("P" + (i + 1) + " Select", Global.Config.NESController[i].Select); nesControls.BindMulti("P" + (i + 1) + " Start", Global.Config.NESController[i].Start); } + + nesControls.BindMulti("Reset", Global.Config.NESReset); + nesControls.BindMulti("Power", Global.Config.NESPower); + Global.NESControls = nesControls; var anesControls = new AutofireController(NES.NESController); diff --git a/BizHawk.MultiClient/config/ControllerConfig.Designer.cs b/BizHawk.MultiClient/config/ControllerConfig.Designer.cs index 4961f8e74a..dce757b091 100644 --- a/BizHawk.MultiClient/config/ControllerConfig.Designer.cs +++ b/BizHawk.MultiClient/config/ControllerConfig.Designer.cs @@ -103,6 +103,7 @@ this.NESAutofire2Panel = new BizHawk.MultiClient.NESGamePad(); this.NESAutofire3Panel = new BizHawk.MultiClient.NESGamePad(); this.NESAutofire4Panel = new BizHawk.MultiClient.NESGamePad(); + this.NESConsolePad = new BizHawk.MultiClient.NESConsoleButtons(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabControl2.SuspendLayout(); @@ -110,6 +111,7 @@ this.tabPage14.SuspendLayout(); this.tabPage15.SuspendLayout(); this.tabPage16.SuspendLayout(); + this.tabPage17.SuspendLayout(); this.tabPage18.SuspendLayout(); this.tabPage19.SuspendLayout(); this.tabPage20.SuspendLayout(); @@ -224,6 +226,7 @@ // // tabPage17 // + this.tabPage17.Controls.Add(this.NESConsolePad); this.tabPage17.Location = new System.Drawing.Point(4, 22); this.tabPage17.Name = "tabPage17"; this.tabPage17.Size = new System.Drawing.Size(445, 378); @@ -891,6 +894,13 @@ this.NESAutofire4Panel.Size = new System.Drawing.Size(392, 332); this.NESAutofire4Panel.TabIndex = 0; // + // NESConsolePad + // + this.NESConsolePad.Location = new System.Drawing.Point(14, 13); + this.NESConsolePad.Name = "NESConsolePad"; + this.NESConsolePad.Size = new System.Drawing.Size(392, 332); + this.NESConsolePad.TabIndex = 1; + // // ControllerConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -911,6 +921,7 @@ this.tabPage14.ResumeLayout(false); this.tabPage15.ResumeLayout(false); this.tabPage16.ResumeLayout(false); + this.tabPage17.ResumeLayout(false); this.tabPage18.ResumeLayout(false); this.tabPage19.ResumeLayout(false); this.tabPage20.ResumeLayout(false); @@ -1010,5 +1021,6 @@ private NESGamePad NESAutofire2Panel; private NESGamePad NESAutofire3Panel; private NESGamePad NESAutofire4Panel; + private NESConsoleButtons NESConsolePad; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/config/ControllerConfig/NESConsoleButtons.cs b/BizHawk.MultiClient/config/ControllerConfig/NESConsoleButtons.cs new file mode 100644 index 0000000000..b08a50bd34 --- /dev/null +++ b/BizHawk.MultiClient/config/ControllerConfig/NESConsoleButtons.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Drawing; +using System.Reflection; + +namespace BizHawk.MultiClient +{ + class NESConsoleButtons : GamepadConfigPanel + { + public NESConsoleButtons() + { + buttons = new List { "Power", "Reset"}; + Startup(); + } + + public override void Save() + { + for (int button = 0; button < buttons.Count; button++) + { + NESControllerTemplate o = Global.Config.NESController[ControllerNumber - 1]; + FieldInfo buttonF = o.GetType().GetField(buttons[button]); + buttonF.SetValue(o, Inputs[button].Text); + } + } + + public void Load() + { + for (int button = 0; button < buttons.Count; button++) + { + NESControllerTemplate o = Global.Config.NESController[ControllerNumber - 1]; + FieldInfo buttonF = o.GetType().GetField(buttons[button]); + object field = o.GetType().GetField(buttons[button]).GetValue(o); + Inputs[button].Text = field.ToString(); + } + } + } +}