2012-12-16 19:07:45 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2012-12-16 19:07:45 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class VirtualPadA78 : UserControl, IVirtualPad
|
|
|
|
|
{
|
|
|
|
|
public string Controller = "P1";
|
|
|
|
|
|
|
|
|
|
public VirtualPadA78()
|
|
|
|
|
{
|
|
|
|
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.UserPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.DoubleBuffer, true);
|
2013-04-14 23:56:45 +00:00
|
|
|
|
BorderStyle = BorderStyle.Fixed3D;
|
2012-12-16 19:07:45 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
if (keyData == Keys.Up)
|
|
|
|
|
{
|
|
|
|
|
//TODO: move to next logical key
|
2013-04-14 23:56:45 +00:00
|
|
|
|
Refresh();
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Down)
|
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
Refresh();
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Left)
|
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
Refresh();
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Right)
|
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
Refresh();
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (keyData == Keys.Tab)
|
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
Refresh();
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetMnemonic()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder input = new StringBuilder("");
|
|
|
|
|
input.Append(PU.Checked ? "U" : ".");
|
|
|
|
|
input.Append(PD.Checked ? "D" : ".");
|
|
|
|
|
input.Append(PL.Checked ? "L" : ".");
|
|
|
|
|
input.Append(PR.Checked ? "R" : ".");
|
|
|
|
|
|
|
|
|
|
input.Append(B1.Checked ? "1" : ".");
|
|
|
|
|
input.Append(B2.Checked ? "2" : ".");
|
|
|
|
|
input.Append("|");
|
|
|
|
|
return input.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetButtons(string buttons)
|
|
|
|
|
{
|
|
|
|
|
if (buttons.Length < 6) 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;
|
|
|
|
|
if (buttons[5] == '.') B2.Checked = false; else B2.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Buttons_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-10-20 18:02:43 +00:00
|
|
|
|
if (Global.Emulator.SystemId != "A78")
|
2012-12-16 19:07:45 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (sender == PU)
|
|
|
|
|
{
|
2013-11-01 22:56:55 +00:00
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sender == PD)
|
|
|
|
|
{
|
2013-11-01 22:56:55 +00:00
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sender == PL)
|
|
|
|
|
{
|
2013-11-01 22:56:55 +00:00
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sender == PR)
|
|
|
|
|
{
|
2013-11-01 22:56:55 +00:00
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sender == B1)
|
|
|
|
|
{
|
2013-11-01 22:56:55 +00:00
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Trigger", B1.Checked);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sender == B2)
|
|
|
|
|
{
|
2013-11-01 22:56:55 +00:00
|
|
|
|
Global.StickyXORAdapter.SetSticky(Controller + " Trigger 2", B2.Checked);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
2013-10-20 18:02:43 +00:00
|
|
|
|
if (Global.Emulator.SystemId != "A78") return;
|
2012-12-16 19:07:45 +00:00
|
|
|
|
|
|
|
|
|
|
2013-11-01 22:56:55 +00:00
|
|
|
|
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 (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Trigger", false);
|
|
|
|
|
if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Trigger 2", false);
|
2012-12-16 19:07:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PU.Checked = false;
|
|
|
|
|
PD.Checked = false;
|
|
|
|
|
PL.Checked = false;
|
|
|
|
|
PR.Checked = false;
|
|
|
|
|
B1.Checked = false;
|
|
|
|
|
B2.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|