From c33fbfddf4d93e201d109528baf5a0317216da9b Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 7 May 2017 10:04:15 -0500 Subject: [PATCH] Colecovision - virtualpad support for new controller options --- .../tools/VirtualPads/schema/ColecoSchema.cs | 229 +++++++++++++++++- .../Consoles/Coleco/ColecoControllerDeck.cs | 20 +- .../Consoles/Coleco/ColecoControllers.cs | 12 +- .../Consoles/Coleco/ColecoVision.cs | 2 +- 4 files changed, 244 insertions(+), 19 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs index 9e0e2d2a28..d357201015 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs @@ -2,6 +2,7 @@ using System.Drawing; using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.ColecoVision; namespace BizHawk.Client.EmuHawk { @@ -10,8 +11,28 @@ namespace BizHawk.Client.EmuHawk { public IEnumerable GetPadSchemas(IEmulator core) { - yield return StandardController(1); - yield return StandardController(2); + var deck = ((ColecoVision)core).ControllerDeck; + var ports = new[] { deck.Port1.GetType(), deck.Port2.GetType() }; + + for (int i = 0; i < 2; i++) + { + if (ports[i] == typeof(UnpluggedController)) + { + break; + } + else if (ports[i] == typeof(StandardController)) + { + yield return StandardController(i + 1); + } + else if (ports[i] == typeof(ColecoTurboController)) + { + yield return TurboController(i + 1); + } + else if (ports[i] == typeof(ColecoSuperActionController)) + { + yield return SuperActionController(i + 1); + } + } } public static PadSchema StandardController(int controller) @@ -159,5 +180,209 @@ namespace BizHawk.Client.EmuHawk } }; } + + public static PadSchema TurboController(int controller) + { + return new PadSchema + { + IsConsole = false, + DefaultSize = new Size(275, 260), + Buttons = new[] + { + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Disc X", + MinValue = -127, + MidValue = 0, + MaxValue = 127, + MinValueSec = 127, + MidValueSec = 0, + MaxValueSec = -127, + DisplayName = "", + Location = new Point(6, 14), + Type = PadSchema.PadInputType.AnalogStick + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Pedal", + DisplayName = "Pedal", + Location = new Point(6, 224), + Type = PadSchema.PadInputType.Boolean + }, + } + }; + } + + public static PadSchema SuperActionController(int controller) + { + return new PadSchema + { + IsConsole = false, + DefaultSize = new Size(195, 260), + Buttons = new[] + { + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Up", + DisplayName = "", + Icon = Properties.Resources.BlueUp, + Location = new Point(50, 11), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Down", + DisplayName = "", + Icon = Properties.Resources.BlueDown, + Location = new Point(50, 32), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Left", + DisplayName = "", + Icon = Properties.Resources.Back, + Location = new Point(29, 22), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Right", + DisplayName = "", + Icon = Properties.Resources.Forward, + Location = new Point(71, 22), + Type = PadSchema.PadInputType.Boolean + }, + + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 1", + DisplayName = "1", + Location = new Point(27, 85), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 2", + DisplayName = "2", + Location = new Point(50, 85), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 3", + DisplayName = "3", + Location = new Point(73, 85), + Type = PadSchema.PadInputType.Boolean + }, + + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 4", + DisplayName = "4", + Location = new Point(27, 108), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 5", + DisplayName = "5", + Location = new Point(50, 108), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 6", + DisplayName = "6", + Location = new Point(73, 108), + Type = PadSchema.PadInputType.Boolean + }, + + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 7", + DisplayName = "7", + Location = new Point(27, 131), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 8", + DisplayName = "8", + Location = new Point(50, 131), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 9", + DisplayName = "9", + Location = new Point(73, 131), + Type = PadSchema.PadInputType.Boolean + }, + + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Star", + DisplayName = "*", + Location = new Point(27, 154), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Key 0", + DisplayName = "0", + Location = new Point(50, 154), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Pound", + DisplayName = "#", + Location = new Point(73, 154), + Type = PadSchema.PadInputType.Boolean + }, + + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Disc X", + DisplayName = "Disc", + Location = new Point(6, 200), + TargetSize = new Size(180, 55), + MinValue = -360, + MaxValue = 360, + Type = PadSchema.PadInputType.FloatSingle + }, + + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Yellow", + DisplayName = "Yellow", + Location = new Point(126, 15), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Red", + DisplayName = "Red", + Location = new Point(126, 40), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Purple", + DisplayName = "Purple", + Location = new Point(126, 65), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "P" + controller + " Blue", + DisplayName = "Blue", + Location = new Point(126, 90), + Type = PadSchema.PadInputType.Boolean + }, + } + }; + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs index 2b0ef0870f..2ad8b5cd5b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs @@ -43,24 +43,24 @@ namespace BizHawk.Emulation.Cores.ColecoVision private int wheel1; private int wheel2; - public byte ReadPort1(IController c, bool left_mode, bool update_wheel) + public byte ReadPort1(IController c, bool leftMode, bool updateWheel) { - if (update_wheel) + if (updateWheel) { - wheel1 = Port1.Update_Wheel(c, wheel1); + wheel1 = Port1.UpdateWheel(c, wheel1); } - return Port1.Read(c, left_mode, wheel1); + return Port1.Read(c, leftMode, wheel1); } - public byte ReadPort2(IController c, bool left_mode, bool update_wheel) + public byte ReadPort2(IController c, bool leftMode, bool updateWheel) { - if (update_wheel) + if (updateWheel) { - wheel2 = Port2.Update_Wheel(c, wheel2); + wheel2 = Port2.UpdateWheel(c, wheel2); } - return Port2.Read(c, left_mode, wheel2); + return Port2.Read(c, leftMode, wheel2); } public ControllerDefinition Definition { get; } @@ -78,8 +78,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision ser.EndSection(); } - private readonly IPort Port1; - private readonly IPort Port2; + public IPort Port1 { get; private set; } + public IPort Port2 { get; private set; } private static Dictionary _controllerTypes = null; diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs index 912954d76e..a44baeb679 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs @@ -13,9 +13,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision /// public interface IPort { - byte Read(IController c, bool left_mode, int wheel); + byte Read(IController c, bool leftMode, int wheel); - int Update_Wheel(IController c, int wheel); + int UpdateWheel(IController c, int wheel); ControllerDefinition Definition { get; } @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public int PortNum { get; } - public int Update_Wheel(IController c, int wheel) + public int UpdateWheel(IController c, int wheel) { return 0; } @@ -124,7 +124,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision "Key 6", "Key 7", "Key 8", "Key 9", "Pound", "Star" }; - public int Update_Wheel(IController c, int wheel) + public int UpdateWheel(IController c, int wheel) { return 0; } @@ -217,7 +217,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision return 0x1F; } - public int Update_Wheel(IController c, int wheel) + public int UpdateWheel(IController c, int wheel) { return 0; } @@ -328,7 +328,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision return retval; } - public int Update_Wheel(IController c, int wheel) + public int UpdateWheel(IController c, int wheel) { int x = (int)c.GetFloat(Definition.FloatControls[0]); diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 866bfc9835..1dc3124251 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public ControllerDefinition ControllerDefinition => ControllerDeck.Definition; - private readonly ColecoVisionControllerDeck ControllerDeck; + public ColecoVisionControllerDeck ControllerDeck { get; private set; } private const ushort RamSizeMask = 0x03FF;