Virtualpads - some code cleanup
This commit is contained in:
parent
9e73db3daa
commit
ee6d73aac7
|
@ -1,21 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class VirtualPad : UserControl
|
||||
{
|
||||
private PadSchema _schema;
|
||||
private bool _readOnly = false;
|
||||
private readonly PadSchema _schema;
|
||||
private bool _readOnly;
|
||||
|
||||
private List<IVirtualPadControl> PadControls
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
private int _defaultWidth;
|
||||
private int _defaultHeight;
|
||||
private bool _readOnly = false;
|
||||
private bool _readOnly;
|
||||
|
||||
private List<VirtualPad> Pads
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -10,9 +9,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class VirtualPadAnalogButton : UserControl, IVirtualPadControl
|
||||
{
|
||||
private string _displayName = string.Empty;
|
||||
private int _maxValue = 0;
|
||||
private bool _programmaticallyChangingValue = false;
|
||||
private bool _readonly = false;
|
||||
private int _maxValue;
|
||||
private bool _programmaticallyChangingValue;
|
||||
private bool _readonly;
|
||||
|
||||
public VirtualPadAnalogButton()
|
||||
{
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -13,8 +7,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadAnalogStick : UserControl, IVirtualPadControl
|
||||
{
|
||||
private bool _programmaticallyUpdatingNumerics = false;
|
||||
private bool _readonly = false;
|
||||
private bool _programmaticallyUpdatingNumerics;
|
||||
private bool _readonly;
|
||||
|
||||
public VirtualPadAnalogStick()
|
||||
{
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public class VirtualPadButton : CheckBox, IVirtualPadControl
|
||||
{
|
||||
private bool _rightClicked = false;
|
||||
private bool _readonly = false;
|
||||
private bool _rightClicked;
|
||||
private bool _readonly;
|
||||
|
||||
public VirtualPadButton()
|
||||
{
|
||||
|
@ -126,14 +126,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (!ReadOnly)
|
||||
{
|
||||
_rightClicked = value;
|
||||
if (_rightClicked)
|
||||
{
|
||||
ForeColor = SystemColors.HotTrack;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForeColor = SystemColors.ControlText;
|
||||
}
|
||||
ForeColor = _rightClicked ? SystemColors.HotTrack : SystemColors.ControlText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -18,9 +13,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
private readonly Pen WhitePen = new Pen(Brushes.White, 2);
|
||||
private readonly Pen GrayPen = new Pen(Brushes.Gray, 2);
|
||||
|
||||
private bool _isProgrammicallyChangingNumerics = false;
|
||||
private bool _isDragging = false;
|
||||
private bool _readonly = false;
|
||||
private bool _isProgrammicallyChangingNumerics;
|
||||
private bool _isDragging;
|
||||
private bool _readonly;
|
||||
|
||||
public VirtualPadTargetScreen()
|
||||
{
|
||||
|
|
|
@ -43,16 +43,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
private int MinY { get { return 0 - MaxY; } }
|
||||
|
||||
private readonly Brush WhiteBrush = Brushes.White;
|
||||
private readonly Brush BlackBrush = Brushes.Black;
|
||||
private readonly Brush GrayBrush = Brushes.LightGray;
|
||||
private readonly Brush RedBrush = Brushes.Red;
|
||||
private readonly Brush BlueBrush = Brushes.DarkBlue;
|
||||
private readonly Brush OffWhiteBrush = Brushes.Beige;
|
||||
|
||||
private readonly Pen BlackPen = new Pen(Brushes.Black);
|
||||
private readonly Pen BluePen = new Pen(Brushes.Blue, 2);
|
||||
private readonly Pen GrayPen = new Pen(Brushes.LightGray);
|
||||
private readonly Pen OffWhite = new Pen(Brushes.Beige);
|
||||
|
||||
private readonly Bitmap Dot = new Bitmap(7, 7);
|
||||
private readonly Bitmap GrayDot = new Bitmap(7, 7);
|
||||
|
@ -70,30 +66,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
BorderStyle = BorderStyle.Fixed3D;
|
||||
|
||||
// Draw the dot into a bitmap
|
||||
Graphics g = Graphics.FromImage(Dot);
|
||||
var g = Graphics.FromImage(Dot);
|
||||
g.Clear(Color.Transparent);
|
||||
g.FillRectangle(RedBrush, 2, 0, 3, 7);
|
||||
g.FillRectangle(RedBrush, 1, 1, 5, 5);
|
||||
g.FillRectangle(RedBrush, 0, 2, 7, 3);
|
||||
|
||||
Graphics gg = Graphics.FromImage(GrayDot);
|
||||
var gg = Graphics.FromImage(GrayDot);
|
||||
gg.Clear(Color.Transparent);
|
||||
gg.FillRectangle(Brushes.Gray, 2, 0, 3, 7);
|
||||
gg.FillRectangle(Brushes.Gray, 1, 1, 5, 5);
|
||||
gg.FillRectangle(Brushes.Gray, 0, 2, 7, 3);
|
||||
}
|
||||
|
||||
private int RealToGFX(int val)
|
||||
private static int RealToGfx(int val)
|
||||
{
|
||||
return (val + 128) / 2;
|
||||
}
|
||||
|
||||
private int GFXToReal(int val, bool isX) // isX is a hack
|
||||
private int GfxToReal(int val, bool isX) // isX is a hack
|
||||
{
|
||||
var max = isX ? MaxX : MaxY;
|
||||
var min = isX ? MinX : MinY;
|
||||
|
||||
int ret = (val * 2);
|
||||
var ret = (val * 2);
|
||||
if (ret > max)
|
||||
{
|
||||
ret = max;
|
||||
|
@ -114,8 +110,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetAnalog()
|
||||
{
|
||||
int? xn = HasValue ? X : (int?)null;
|
||||
int? yn = HasValue ? Y : (int?)null;
|
||||
var xn = HasValue ? X : (int?)null;
|
||||
var yn = HasValue ? Y : (int?)null;
|
||||
Global.StickyXORAdapter.SetFloat(XName, xn);
|
||||
Global.StickyXORAdapter.SetFloat(YName, yn);
|
||||
|
||||
|
@ -136,8 +132,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
//Line
|
||||
if (HasValue)
|
||||
{
|
||||
e.Graphics.DrawLine(BluePen, 64, 63, RealToGFX(X), 127 - RealToGFX(Y));
|
||||
e.Graphics.DrawImage(ReadOnly ? GrayDot : Dot, RealToGFX(X) - 3, 127 - RealToGFX(Y) - 3);
|
||||
e.Graphics.DrawLine(BluePen, 64, 63, RealToGfx(X), 127 - RealToGfx(Y));
|
||||
e.Graphics.DrawImage(ReadOnly ? GrayDot : Dot, RealToGfx(X) - 3, 127 - RealToGfx(Y) - 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,8 +144,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
X = GFXToReal(e.X - 64, true);
|
||||
Y = GFXToReal(-(e.Y - 63), false);
|
||||
X = GfxToReal(e.X - 64, true);
|
||||
Y = GfxToReal(-(e.Y - 63), false);
|
||||
HasValue = true;
|
||||
SetAnalog();
|
||||
}
|
||||
|
@ -171,9 +167,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == 0x007B) //WM_CONTEXTMENU
|
||||
if (m.Msg == 0x007B) // WM_CONTEXTMENU
|
||||
{
|
||||
//dont let parent controls get this.. we handle the right mouse button ourselves
|
||||
// Don't let parent controls get this. We handle the right mouse button ourselves
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -186,8 +182,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
X = GFXToReal(e.X - 64, true);
|
||||
Y = GFXToReal(-(e.Y - 63), false);
|
||||
X = GfxToReal(e.X - 64, true);
|
||||
Y = GfxToReal(-(e.Y - 63), false);
|
||||
HasValue = true;
|
||||
}
|
||||
if (e.Button == MouseButtons.Right)
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Atari.Atari2600;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Atari.Atari7800;
|
||||
|
@ -21,8 +18,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
yield return JoystickController(2);
|
||||
break;
|
||||
case "Atari 7800 Paddle Controller":
|
||||
PaddleController(1);
|
||||
PaddleController(2);
|
||||
yield return PaddleController(1);
|
||||
yield return PaddleController(2);
|
||||
break;
|
||||
case "Atari 7800 Keypad Controller":
|
||||
break;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Computers.Commodore64;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[SchemaAttributes("C64")]
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[SchemaAttributes("Coleco")]
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[SchemaAttributes("GBA")]
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[SchemaAttributes("GB")]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -228,7 +227,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
SecondaryNames = new []
|
||||
{
|
||||
"P" + controller + " Lightgun Y",
|
||||
"P" + controller + " Lightgun Trigger",
|
||||
"P" + controller + " Lightgun Trigger"
|
||||
}
|
||||
},
|
||||
new PadSchema.ButtonScema
|
||||
|
@ -267,7 +266,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
SecondaryNames = new []
|
||||
{
|
||||
"P" + controller + " Mouse Y",
|
||||
"P" + controller + " Mouse Left",
|
||||
"P" + controller + " Mouse Left"
|
||||
}
|
||||
},
|
||||
new PadSchema.ButtonScema
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -13,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public IEnumerable<PadSchema> GetPadSchemas()
|
||||
{
|
||||
var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings();
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
if (ss.Controllers[i].IsConnected)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
|
@ -50,7 +48,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
int currentControlerNo = 1;
|
||||
var currentControlerNo = 1;
|
||||
switch (ss.Controls.NesLeftPort)
|
||||
{
|
||||
default:
|
||||
|
@ -155,7 +153,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema FdsConsoleButtons(int diskSize)
|
||||
{
|
||||
List<PadSchema.ButtonScema> buttons = new List<PadSchema.ButtonScema>
|
||||
var buttons = new List<PadSchema.ButtonScema>
|
||||
{
|
||||
new PadSchema.ButtonScema
|
||||
{
|
||||
|
@ -180,7 +178,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < diskSize; i++)
|
||||
for (var i = 0; i < diskSize; i++)
|
||||
{
|
||||
buttons.Add(new PadSchema.ButtonScema
|
||||
{
|
||||
|
@ -282,7 +280,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema Famicom2ndController()
|
||||
{
|
||||
int controller = 2;
|
||||
var controller = 2;
|
||||
return new PadSchema
|
||||
{
|
||||
DisplayName = "Player 2",
|
||||
|
@ -367,7 +365,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
SecondaryNames = new []
|
||||
{
|
||||
"P" + controller + " Zapper Y",
|
||||
"P" + controller + " Fire",
|
||||
"P" + controller + " Fire"
|
||||
}
|
||||
},
|
||||
new PadSchema.ButtonScema
|
||||
|
@ -528,7 +526,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
SecondaryNames = new []
|
||||
{
|
||||
"P" + controller + " Pen Y",
|
||||
"P" + controller + " Click",
|
||||
"P" + controller + " Click"
|
||||
}
|
||||
},
|
||||
new PadSchema.ButtonScema
|
||||
|
@ -564,7 +562,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DisplayName = " F1 ",
|
||||
Location = new Point(23, 15),
|
||||
Type = PadSchema.PadInputType.Boolean
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
|
@ -12,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public IEnumerable<PadSchema> GetPadSchemas()
|
||||
{
|
||||
for (int i = 0; i < Global.Emulator.ControllerDefinition.PlayerCount; i++)
|
||||
for (var i = 0; i < Global.Emulator.ControllerDefinition.PlayerCount; i++)
|
||||
{
|
||||
yield return StandardController(i);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[SchemaAttributes("SAT")]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -11,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public IEnumerable<PadSchema> GetPadSchemas()
|
||||
{
|
||||
for (int i = 0; i < Global.Emulator.ControllerDefinition.PlayerCount; i++)
|
||||
for (var i = 0; i < Global.Emulator.ControllerDefinition.PlayerCount; i++)
|
||||
{
|
||||
yield return StandardController(i);
|
||||
}
|
||||
|
@ -117,7 +116,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DisplayName = "A",
|
||||
Location = new Point(146, 25),
|
||||
Type = PadSchema.PadInputType.Boolean
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.WonderSwan;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[SchemaAttributes("WSWAN")]
|
||||
|
@ -106,7 +102,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DisplayName = "A",
|
||||
Location = new Point(133, 103),
|
||||
Type = PadSchema.PadInputType.Boolean
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -199,9 +195,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DisplayName = "X4",
|
||||
Location = new Point(103, 156),
|
||||
Type = PadSchema.PadInputType.Boolean
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue