From 59a7b24df90ca7a66870367d9df06b8c84b257a8 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 22 Mar 2020 17:31:44 -0500 Subject: [PATCH] a7800 virtualpads - cleanup, support unplugged and lightgun options, remove unimplemented paddle controller logic --- .../tools/VirtualPads/schema/A78Schema.cs | 104 ++++++++---------- 1 file changed, 43 insertions(+), 61 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs index 48834ed355..db1a010f50 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Drawing; - using BizHawk.Emulation.Common; using BizHawk.Common.ReflectionExtensions; @@ -11,44 +10,65 @@ namespace BizHawk.Client.EmuHawk [Schema("A78")] // ReSharper disable once UnusedMember.Global public class A78Schema : IVirtualPadSchema - { - public IEnumerable GetPadSchemas(IEmulator core) - { - return Atari7800HawkSchema.GetPadSchemas((A7800Hawk)core); - } - } - - internal static class Atari7800HawkSchema { private static string StandardControllerName => typeof(StandardController).DisplayName(); private static string ProLineControllerName => typeof(ProLineController).DisplayName(); + private static string LightGunControllerName => typeof(LightGunController).DisplayName(); - public static IEnumerable GetPadSchemas(A7800Hawk core) + public IEnumerable GetPadSchemas(IEmulator core) { - var a78SyncSettings = core.GetSyncSettings().Clone(); - var port1 = a78SyncSettings.Port1; - var port2 = a78SyncSettings.Port2; + var ss = ((A7800Hawk)core).GetSyncSettings().Clone(); - if (port1 == StandardControllerName) + var port1 = SchemaFor(ss.Port1, 1); + if (port1 != null) { - yield return JoystickController(1); + yield return port1; } - if (port2 == StandardControllerName) + var port2 = SchemaFor(ss.Port2, 2); + if (port2 != null) { - yield return JoystickController(2); + yield return port2; } - if (port1 == ProLineControllerName) + yield return ConsoleButtons(); + } + + private static PadSchema SchemaFor(string controllerName, int portNum) + { + if (controllerName == StandardControllerName) { - yield return ProLineController(1); + return JoystickController(portNum); } - if (port2 == ProLineControllerName) + if (controllerName == ProLineControllerName) { - yield return ProLineController(2); + return ProLineController(portNum); } + if (controllerName == LightGunControllerName) + { + return LightGunController(portNum); + } + + return null; + } + + private static PadSchema JoystickController(int controller) + { + return new PadSchema + { + DisplayName = $"Player {controller}", + Size = new Size(174, 74), + Buttons = new [] + { + ButtonSchema.Up(23, 15, controller), + ButtonSchema.Down(23, 36, controller), + ButtonSchema.Left(2, 24, controller), + ButtonSchema.Right(44, 24, controller), + new ButtonSchema(120, 24, controller, "Button") { DisplayName = "1" } + } + }; } private static PadSchema ProLineController(int controller) @@ -69,40 +89,6 @@ namespace BizHawk.Client.EmuHawk }; } - private static PadSchema JoystickController(int controller) - { - return new PadSchema - { - DisplayName = $"Player {controller}", - Size = new Size(174, 74), - Buttons = new[] - { - ButtonSchema.Up(23, 15, controller), - ButtonSchema.Down(23, 36, controller), - ButtonSchema.Left(2, 24, controller), - ButtonSchema.Right(54, 24, controller), - new ButtonSchema(120, 24, controller, "Button") - { - DisplayName = "1" - } - } - }; - } - - private static PadSchema PaddleController(int controller) - { - return new PadSchema - { - DisplayName = $"Player {controller}", - Size = new Size(250, 74), - Buttons = new[] - { - new SingleFloatSchema(23, 15, controller, "Paddle"), - new ButtonSchema(12, 90, controller, "Trigger") { DisplayName = "1" } - } - }; - } - private static PadSchema LightGunController(int controller) { return new PadSchema @@ -111,13 +97,9 @@ namespace BizHawk.Client.EmuHawk Size = new Size(356, 290), Buttons = new[] { - new TargetedPairSchema(14, 17, $"P{controller} VPos") + new TargetedPairSchema(14, 17, $"P{controller} X") { - TargetSize = new Size(256, 240), - SecondaryNames = new[] - { - $"P{controller} HPos" - } + TargetSize = new Size(256, 240) }, new ButtonSchema(284, 17, controller, "Trigger") }