N64 VirtualPads - right-click sets autofire, this is done with a new VirtualPadButtons component that could be easily ported to other virtualpads as well

This commit is contained in:
adelikat 2013-08-28 18:01:34 +00:00
parent 160c76c531
commit eaf94ebda3
5 changed files with 170 additions and 155 deletions

View File

@ -576,6 +576,9 @@
<Compile Include="tools\VirtualPads\VirtualPadA78Control.Designer.cs">
<DependentUpon>VirtualPadA78Control.cs</DependentUpon>
</Compile>
<Compile Include="tools\VirtualPads\VirtualPadButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="tools\VirtualPads\VirtualPadC64Keyboard.cs">
<SubType>UserControl</SubType>
</Compile>

View File

@ -572,6 +572,7 @@
<Compile Include="tools\VirtualPads\VirtualPadA78Control.Designer.cs">
<DependentUpon>VirtualPadA78Control.cs</DependentUpon>
</Compile>
<Compile Include="tools\VirtualPads\VirtualPadButton.cs" />
<Compile Include="tools\VirtualPads\VirtualPadC64Keyboard.cs">
<SubType>UserControl</SubType>
</Compile>

View File

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace BizHawk.MultiClient
{
public class VirtualPadButton : CheckBox
{
public string ControllerButton = "";
private bool _rightClicked = false;
public VirtualPadButton()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
Appearance = System.Windows.Forms.Appearance.Button;
ForeColor = Color.Black;
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0204://WM_RBUTTONDOWN
_rightClicked = true;
ForeColor = Color.Red;
Checked ^= true;
return;
case 0x0205://WM_RBUTTONUP
return;
case 0x0206://WM_RBUTTONDBLCLK
return;
}
base.WndProc(ref m);
}
protected void SetSticky()
{
Global.StickyXORAdapter.SetSticky(ControllerButton, Checked);
if (Checked == false)
{
Clear();
}
}
protected void SetAutofireSticky()
{
Global.AutofireStickyXORAdapter.SetSticky(ControllerButton, Checked);
if (Checked == false)
{
Clear();
}
}
protected override void OnCheckedChanged(EventArgs e)
{
if (_rightClicked)
{
SetAutofireSticky();
}
else
{
SetSticky();
}
base.OnCheckedChanged(e);
}
protected override void OnMouseClick(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
_rightClicked = false;
ForeColor = Color.Black;
}
base.OnMouseClick(e);
}
public void Clear()
{
_rightClicked = false;
ForeColor = Color.Black;
Checked = false;
Global.AutofireStickyXORAdapter.SetSticky(ControllerButton, false);
Global.StickyXORAdapter.SetSticky(ControllerButton, false);
}
}
}

View File

@ -28,20 +28,20 @@
/// </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.BL = new System.Windows.Forms.CheckBox();
this.BR = new System.Windows.Forms.CheckBox();
this.BS = new System.Windows.Forms.CheckBox();
this.BZ = new System.Windows.Forms.CheckBox();
this.BB = new System.Windows.Forms.CheckBox();
this.BA = new System.Windows.Forms.CheckBox();
this.CU = new System.Windows.Forms.CheckBox();
this.CL = new System.Windows.Forms.CheckBox();
this.CR = new System.Windows.Forms.CheckBox();
this.CD = new System.Windows.Forms.CheckBox();
this.PL = new VirtualPadButton();
this.PD = new VirtualPadButton();
this.PR = new VirtualPadButton();
this.PU = new VirtualPadButton();
this.BL = new VirtualPadButton();
this.BR = new VirtualPadButton();
this.BS = new VirtualPadButton();
this.BZ = new VirtualPadButton();
this.BB = new VirtualPadButton();
this.BA = new VirtualPadButton();
this.CU = new VirtualPadButton();
this.CL = new VirtualPadButton();
this.CR = new VirtualPadButton();
this.CD = new VirtualPadButton();
this.ManualX = new System.Windows.Forms.NumericUpDown();
this.ManualY = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
@ -53,7 +53,6 @@
//
// PL
//
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.Location = new System.Drawing.Point(3, 207);
@ -61,11 +60,9 @@
this.PL.Size = new System.Drawing.Size(22, 22);
this.PL.TabIndex = 7;
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.MultiClient.Properties.Resources.BlueDown;
this.PD.Location = new System.Drawing.Point(24, 216);
@ -73,11 +70,9 @@
this.PD.Size = new System.Drawing.Size(22, 22);
this.PD.TabIndex = 6;
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.MultiClient.Properties.Resources.Forward;
this.PR.Location = new System.Drawing.Point(45, 207);
@ -85,11 +80,9 @@
this.PR.Size = new System.Drawing.Size(22, 22);
this.PR.TabIndex = 5;
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.MultiClient.Properties.Resources.BlueUp;
this.PU.Location = new System.Drawing.Point(24, 195);
@ -97,11 +90,9 @@
this.PU.Size = new System.Drawing.Size(22, 22);
this.PU.TabIndex = 4;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BL
//
this.BL.Appearance = System.Windows.Forms.Appearance.Button;
this.BL.AutoSize = true;
this.BL.Location = new System.Drawing.Point(3, 148);
this.BL.Name = "BL";
@ -109,11 +100,9 @@
this.BL.TabIndex = 8;
this.BL.Text = "L";
this.BL.UseVisualStyleBackColor = true;
this.BL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BR
//
this.BR.Appearance = System.Windows.Forms.Appearance.Button;
this.BR.AutoSize = true;
this.BR.Location = new System.Drawing.Point(172, 148);
this.BR.Name = "BR";
@ -121,11 +110,9 @@
this.BR.TabIndex = 9;
this.BR.Text = "R";
this.BR.UseVisualStyleBackColor = true;
this.BR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BS
//
this.BS.Appearance = System.Windows.Forms.Appearance.Button;
this.BS.AutoSize = true;
this.BS.Location = new System.Drawing.Point(87, 157);
this.BS.Name = "BS";
@ -133,11 +120,9 @@
this.BS.TabIndex = 10;
this.BS.Text = "S";
this.BS.UseVisualStyleBackColor = true;
this.BS.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// BZ
//
this.BZ.Appearance = System.Windows.Forms.Appearance.Button;
this.BZ.AutoSize = true;
this.BZ.Location = new System.Drawing.Point(74, 245);
this.BZ.Name = "BZ";
@ -145,11 +130,9 @@
this.BZ.TabIndex = 11;
this.BZ.Text = "Z";
this.BZ.UseVisualStyleBackColor = true;
this.BZ.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(83, 195);
this.BB.Name = "BB";
@ -157,11 +140,9 @@
this.BB.TabIndex = 12;
this.BB.Text = "B";
this.BB.UseVisualStyleBackColor = true;
this.BB.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(113, 206);
this.BA.Name = "BA";
@ -169,11 +150,9 @@
this.BA.TabIndex = 13;
this.BA.Text = "A";
this.BA.UseVisualStyleBackColor = true;
this.BA.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// CU
//
this.CU.Appearance = System.Windows.Forms.Appearance.Button;
this.CU.AutoSize = true;
this.CU.Location = new System.Drawing.Point(147, 235);
this.CU.Name = "CU";
@ -181,11 +160,9 @@
this.CU.TabIndex = 14;
this.CU.Text = "cU";
this.CU.UseVisualStyleBackColor = true;
this.CU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// CL
//
this.CL.Appearance = System.Windows.Forms.Appearance.Button;
this.CL.AutoSize = true;
this.CL.Location = new System.Drawing.Point(129, 258);
this.CL.Name = "CL";
@ -193,11 +170,9 @@
this.CL.TabIndex = 15;
this.CL.Text = "cL";
this.CL.UseVisualStyleBackColor = true;
this.CL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// CR
//
this.CR.Appearance = System.Windows.Forms.Appearance.Button;
this.CR.AutoSize = true;
this.CR.Location = new System.Drawing.Point(164, 258);
this.CR.Name = "CR";
@ -205,11 +180,9 @@
this.CR.TabIndex = 16;
this.CR.Text = "cR";
this.CR.UseVisualStyleBackColor = true;
this.CR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// CD
//
this.CD.Appearance = System.Windows.Forms.Appearance.Button;
this.CD.AutoSize = true;
this.CD.Location = new System.Drawing.Point(147, 281);
this.CD.Name = "CD";
@ -217,7 +190,6 @@
this.CD.TabIndex = 17;
this.CD.Text = "cD";
this.CD.UseVisualStyleBackColor = true;
this.CD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
//
// ManualX
//
@ -321,20 +293,20 @@
#endregion
private AnalogControlPanel AnalogControl1;
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 BL;
private System.Windows.Forms.CheckBox BR;
private System.Windows.Forms.CheckBox BS;
private System.Windows.Forms.CheckBox BZ;
private System.Windows.Forms.CheckBox BB;
private System.Windows.Forms.CheckBox BA;
private System.Windows.Forms.CheckBox CU;
private System.Windows.Forms.CheckBox CL;
private System.Windows.Forms.CheckBox CR;
private System.Windows.Forms.CheckBox CD;
private VirtualPadButton PL;
private VirtualPadButton PD;
private VirtualPadButton PR;
private VirtualPadButton PU;
private VirtualPadButton BL;
private VirtualPadButton BR;
private VirtualPadButton BS;
private VirtualPadButton BZ;
private VirtualPadButton BB;
private VirtualPadButton BA;
private VirtualPadButton CU;
private VirtualPadButton CL;
private VirtualPadButton CR;
private VirtualPadButton CD;
private System.Windows.Forms.NumericUpDown ManualY;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;

View File

@ -1,6 +1,8 @@
using System;
using System.Text;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
namespace BizHawk.MultiClient
{
@ -22,7 +24,24 @@ namespace BizHawk.MultiClient
private void UserControl1_Load(object sender, EventArgs e)
{
PU.ControllerButton = Controller + " Up";
PD.ControllerButton = Controller + " Down";
PL.ControllerButton = Controller + " Left";
PR.ControllerButton = Controller + " Right";
BA.ControllerButton = Controller + " A";
BB.ControllerButton = Controller + " B";
BZ.ControllerButton = Controller + " Z";
BS.ControllerButton = Controller + " Start";
BL.ControllerButton = Controller + " L";
BR.ControllerButton = Controller + " R";
CU.ControllerButton = Controller + " C Up";
CD.ControllerButton = Controller + " C Down";
CL.ControllerButton = Controller + " C Left";
CR.ControllerButton = Controller + " C Right";
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -55,41 +74,10 @@ namespace BizHawk.MultiClient
{
if (Global.Emulator.SystemId != "N64") return;
if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false);
if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false);
if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false);
if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false);
if (BB.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false);
if (BA.Checked) Global.StickyXORAdapter.SetSticky(Controller + " A", false);
if (BZ.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Z", false);
if (BS.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Start", false);
if (BL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " L", false);
if (BR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " R", false);
if (CU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Up", false);
if (CD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Down", false);
if (CL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Left", false);
if (CR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C Right", false);
PU.Checked = false;
PD.Checked = false;
PL.Checked = false;
PR.Checked = false;
BB.Checked = false;
BA.Checked = false;
BZ.Checked = false;
BS.Checked = false;
BL.Checked = false;
BR.Checked = false;
CU.Checked = false;
CD.Checked = false;
CL.Checked = false;
CR.Checked = false;
foreach (var button in Buttons)
{
button.Clear();
}
}
public void SetButtons(string buttons)
@ -151,70 +139,6 @@ namespace BizHawk.MultiClient
return input.ToString();
}
private void Buttons_CheckedChanged(object sender, EventArgs e)
{
if (Global.Emulator.SystemId != "N64")
{
return;
}
else if (sender == PU)
{
Global.StickyXORAdapter.SetSticky(Controller + " DPad U", PU.Checked);
}
else if (sender == PD)
{
Global.StickyXORAdapter.SetSticky(Controller + " DPad D", PD.Checked);
}
else if (sender == PL)
{
Global.StickyXORAdapter.SetSticky(Controller + " DPad L", PL.Checked);
}
else if (sender == PR)
{
Global.StickyXORAdapter.SetSticky(Controller + " DPad R", PR.Checked);
}
else if (sender == CR)
{
Global.StickyXORAdapter.SetSticky(Controller + " C Right", CR.Checked);
}
else if (sender == CL)
{
Global.StickyXORAdapter.SetSticky(Controller + " C Left", CL.Checked);
}
else if (sender == CU)
{
Global.StickyXORAdapter.SetSticky(Controller + " C Up", CU.Checked);
}
else if (sender == CD)
{
Global.StickyXORAdapter.SetSticky(Controller + " C Down", CD.Checked);
}
else if (sender == BR)
{
Global.StickyXORAdapter.SetSticky(Controller + " R", BR.Checked);
}
else if (sender == BL)
{
Global.StickyXORAdapter.SetSticky(Controller + " L", BL.Checked);
}
else if (sender == BS)
{
Global.StickyXORAdapter.SetSticky(Controller + " Start", BS.Checked);
}
else if (sender == BA)
{
Global.StickyXORAdapter.SetSticky(Controller + " A", BA.Checked);
}
else if (sender == BB)
{
Global.StickyXORAdapter.SetSticky(Controller + " B", BB.Checked);
}
else if (sender == BZ)
{
Global.StickyXORAdapter.SetSticky(Controller + " Z", BZ.Checked);
}
}
private void AnalogControl1_MouseClick(object sender, MouseEventArgs e)
{
set_analog(AnalogControl1.HasValue, AnalogControl1.X, AnalogControl1.Y);
@ -280,5 +204,21 @@ namespace BizHawk.MultiClient
ManualY.Value = newy;
Refresh();
}
public List<VirtualPadButton> Buttons
{
get
{
List<VirtualPadButton> _list = new List<VirtualPadButton>();
foreach(Control c in this.Controls)
{
if (c is VirtualPadButton)
{
_list.Add((c as VirtualPadButton));
}
}
return _list;
}
}
}
}