From e41659e237f7f9327452058b72babbf6933569ad Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 14 Jun 2020 12:02:05 -0500 Subject: [PATCH] rough in for gamepad or none virtualpad support for Turbo and Hyper Nyma cores, only 2 button currently supported, support some uppercase button names in mnemonics --- BizHawk.sln.DotSettings | 1 + .../movie/bk2/Bk2MnemonicLookup.cs | 3 + .../VirtualPads/schema/PadSchemaControl.cs | 13 ++++ .../tools/VirtualPads/schema/PceSchema.cs | 77 +++++++++++++++---- 4 files changed, 77 insertions(+), 17 deletions(-) diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 903737f6e3..18ef13547e 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -427,6 +427,7 @@ True True True + True True True True diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2MnemonicLookup.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2MnemonicLookup.cs index e8707611fa..a0a4d8a60b 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2MnemonicLookup.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2MnemonicLookup.cs @@ -92,8 +92,11 @@ namespace BizHawk.Client.Common ["Z"] = 'Z', ["Select"] = 's', + ["SELECT"] = 's', ["Start"] = 'S', + ["START"] = 'S', ["Run"] = 'R', + ["RUN"] = 'R', ["Left Shoulder"] = 'l', ["Right Shoulder"] = 'r', diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchemaControl.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchemaControl.cs index 6c06972718..dbceab1594 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchemaControl.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchemaControl.cs @@ -59,6 +59,19 @@ namespace BizHawk.Client.EmuHawk public static ButtonSchema Right(int x, int y, int controller) => new ButtonSchema(x, y, controller, "Right") { Icon = Resources.Forward }; + + // Nyma has its own conventions + public static ButtonSchema NymaUp(int x, int y, int controller) + => new ButtonSchema(x, y, controller, "UP ↑") { Icon = Resources.BlueUp }; + + public static ButtonSchema NymaDown(int x, int y, int controller) + => new ButtonSchema(x, y, controller, "DOWN ↓") { Icon = Resources.BlueDown }; + + public static ButtonSchema NymaLeft(int x, int y, int controller) + => new ButtonSchema(x, y, controller, "LEFT ←") { Icon = Resources.Back }; + + public static ButtonSchema NymaRight(int x, int y, int controller) + => new ButtonSchema(x, y, controller, "RIGHT →") { Icon = Resources.Forward }; } /// A single analog control (e.g. pressure sensitive button) diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PceSchema.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PceSchema.cs index 583a14f47d..26b277c57f 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PceSchema.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PceSchema.cs @@ -4,7 +4,9 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Consoles.NEC.PCE; using BizHawk.Emulation.Cores.PCEngine; +using BizHawk.Emulation.Cores.Waterbox; namespace BizHawk.Client.EmuHawk { @@ -17,29 +19,34 @@ namespace BizHawk.Client.EmuHawk { public IEnumerable GetPadSchemas(IEmulator core) { - if (!(core is PCEngine)) + return core switch { - return Enumerable.Empty(); - } + PCEngine pce => PceHawkSchemas(pce), + NymaCore hyper => NymaSchemas(hyper), + _ => Enumerable.Empty() + }; + } - var ss = ((PCEngine)core).GetSyncSettings(); + private static IEnumerable PceHawkSchemas(PCEngine core) + { + var ss = core.GetSyncSettings(); var padSchemas = new[] - { - ss.Port1, - ss.Port2, - ss.Port3, - ss.Port4, - ss.Port5 - } - .Where(p => p != PceControllerType.Unplugged) - .Select((p, i) => GenerateSchemaForPort(p, i + 1)) - .Where(s => s != null); + { + ss.Port1, + ss.Port2, + ss.Port3, + ss.Port4, + ss.Port5 + } + .Where(p => p != PceControllerType.Unplugged) + .Select((p, i) => PceHawkGenerateSchemaForPort(p, i + 1)) + .Where(s => s != null); return padSchemas; } - private static PadSchema GenerateSchemaForPort(PceControllerType type, int controller) + private static PadSchema PceHawkGenerateSchemaForPort(PceControllerType type, int controller) { switch (type) { @@ -49,11 +56,11 @@ namespace BizHawk.Client.EmuHawk case PceControllerType.Unplugged: return null; case PceControllerType.GamePad: - return StandardController(controller); + return StandardHawkController(controller); } } - private static PadSchema StandardController(int controller) + private static PadSchema StandardHawkController(int controller) { return new PadSchema { @@ -83,5 +90,41 @@ namespace BizHawk.Client.EmuHawk } }; } + + private static IEnumerable NymaSchemas(NymaCore nyma) + { + foreach (NymaCore.PortResult result in nyma.ActualPortData) + { + var num = int.Parse(result.Port.ShortName.Last().ToString()); + var device = result.Device.ShortName; + if (device == "gamepad") + { + yield return StandardController(num); + } + else if (device != "none") + { + MessageBox.Show($"Controller type {device} not supported yet."); + } + } + } + + private static PadSchema StandardController(int controller) + { + return new PadSchema + { + Size = new Size(174, 90), + Buttons = new[] + { + ButtonSchema.NymaUp(14, 12, controller), + ButtonSchema.NymaDown(14, 56, controller), + ButtonSchema.NymaLeft(2, 34, controller), + ButtonSchema.NymaRight(24, 34, controller), + new ButtonSchema(122, 34, controller, "I"), + new ButtonSchema(146, 34, controller, "II"), + new ButtonSchema(52, 34, controller, "SELECT") { DisplayName = "s" }, + new ButtonSchema(74, 34, controller, "RUN") { DisplayName = "R" } + } + }; + } } }