From 15a03a26e8c0b76bd774ea55af143a1dac5dd2f7 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 5 Dec 2021 17:16:58 +1000 Subject: [PATCH] Require `ControllerDefinition.Name` to be set (via ctor) src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllers.cs src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllers.cs --- .../movie/import/DsmImport.cs | 18 +++++----- .../movie/import/VbmImport.cs | 2 +- .../movie/import/YmvImport.cs | 3 +- .../movie/import/bkm/BkmControllerAdapter.cs | 5 ++- src/BizHawk.Client.EmuHawk/MainForm.cs | 10 +++--- .../tools/Macros/MovieZone.cs | 4 +-- .../ControllerDefinition.cs | 23 ++++++------- .../Base Implementations/NullController.cs | 5 +-- .../ControllerDefinitionMerger.cs | 7 ++-- .../Arcades/MAME/MAME.IInputPollable.cs | 6 +--- .../Calculator/TI83.cs | 28 +++++++-------- .../AmstradCPC/AmstradCPC.Controllers.cs | 5 +-- .../Computers/AppleII/AppleII.cs | 2 +- .../Computers/Commodore64/C64.cs | 3 +- .../Computers/MSX/MSX.Input.cs | 6 ++-- .../ZXSpectrum.Controllers.cs | 5 +-- .../Atari/2600/Atari2600ControllerDeck.cs | 3 +- .../Atari/2600/Atari2600Controllers.cs | 16 ++++----- .../A7800Hawk/A7800HawkControllerDeck.cs | 3 +- .../Atari/A7800Hawk/A7800HawkControllers.cs | 12 +++---- .../Consoles/Atari/lynx/Lynx.cs | 3 +- .../Consoles/Belogic/Uzem.cs | 6 ++-- .../Consoles/Coleco/ColecoControllerDeck.cs | 3 +- .../Consoles/Coleco/ColecoControllers.cs | 12 +++---- .../ChannelF/ChannelF.Controllers.cs | 5 +-- .../GCE/Vectrex/VectrexHawkControllerDeck.cs | 3 +- .../GCE/Vectrex/VectrexHawkControllers.cs | 6 ++-- .../IntellivisionControllerDeck.cs | 3 +- .../Controllers/IntellivisionControllers.cs | 10 ++---- .../Magnavox/Odyssey2/O2HawkControllerDeck.cs | 6 ++-- .../Magnavox/Odyssey2/O2HawkControllers.cs | 3 +- .../Nintendo/BSNES/BsnesControllers.cs | 22 ++++++------ .../Consoles/Nintendo/GBA/MGBAHawk.cs | 3 +- .../Nintendo/GBHawk/GBHawkControllerDeck.cs | 3 +- .../Nintendo/GBHawk/GBHawkControllers.cs | 6 ++-- .../GBHawkLink/GBHawkLinkControllerDeck.cs | 3 +- .../GBHawkLink3xControllerDeck.cs | 3 +- .../GBHawkLink4xControllerDeck.cs | 3 +- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 4 +-- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 2 +- .../Consoles/Nintendo/N64/N64.cs | 2 +- .../Consoles/Nintendo/NDS/MelonDS.cs | 3 +- .../Consoles/Nintendo/NES/NES.cs | 3 +- .../Consoles/Nintendo/NES/NESControllers.cs | 34 +++++++++---------- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 3 +- .../Nintendo/SNES/LibsnesControllerDeck.cs | 20 ++++++----- .../Consoles/Nintendo/SNES9X/Snes9x.cs | 13 +++---- .../Consoles/Nintendo/VB/VirtualBoyee.cs | 3 +- .../Consoles/PC Engine/PceControllerDeck.cs | 11 ++---- .../GGHawkLink/GGHawkLinkControllerDeck.cs | 3 +- .../Sega/GGHawkLink/GGHawkLinkControllers.cs | 3 +- .../Consoles/Sega/PicoDrive/PicoDrive.cs | 3 +- .../Consoles/Sega/SMS/SMSControllerDeck.cs | 12 ++----- .../Consoles/Sega/SMS/SMSControllers.cs | 15 +++----- .../Sega/gpgx64/GPGXControlConverter.cs | 4 +-- .../Consoles/Sony/PS2/DobieStation.cs | 3 +- .../Consoles/Sony/PSX/Octoshock.cs | 2 +- .../WonderSwan/WonderSwan.Controller.cs | 3 +- .../Libretro/LibretroCore.cs | 3 +- .../Waterbox/NymaCore.Controller.cs | 3 +- .../Display/InputDisplayTests.cs | 4 +-- .../Client.Common/Movie/LogGeneratorTests.cs | 6 ++-- 62 files changed, 172 insertions(+), 259 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/import/DsmImport.cs b/src/BizHawk.Client.Common/movie/import/DsmImport.cs index 6899048257..a409bd32f5 100644 --- a/src/BizHawk.Client.Common/movie/import/DsmImport.cs +++ b/src/BizHawk.Client.Common/movie/import/DsmImport.cs @@ -11,6 +11,13 @@ namespace BizHawk.Client.Common [ImporterFor("DeSmuME", ".dsm")] internal class DsmImport : MovieImporter { + private static readonly ControllerDefinition DeSmuMEControllerDef = new ControllerDefinition("NDS Controller") + { + BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "Y", "X", "L", "R", "LidOpen", "LidClose", "Touch", "Power" }, + }.AddXYPair("Touch {0}", AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(191), 96) //TODO verify direction against hardware + .AddAxis("Mic Input", 0.RangeTo(2047), 0) + .AddAxis("GBA Light Sensor", 0.RangeTo(10), 0); + protected override void RunImport() { Result.Movie.HeaderEntries[HeaderKeys.Platform] = VSystemID.Raw.NDS; @@ -84,16 +91,7 @@ namespace BizHawk.Client.Common private void ImportInputFrame(string line) { - SimpleController controller = new( - new ControllerDefinition - { - BoolButtons = - { - "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "Y", "X", "L", "R", "LidOpen", "LidClose", "Touch", "Power" - } - }.AddXYPair("Touch {0}", AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(191), 96) //TODO verify direction against hardware - .AddAxis("Mic Input", 0.RangeTo(2047), 0) - .AddAxis("GBA Light Sensor", 0.RangeTo(10), 0)); + SimpleController controller = new(DeSmuMEControllerDef); controller["LidOpen"] = false; controller["LidClose"] = false; diff --git a/src/BizHawk.Client.Common/movie/import/VbmImport.cs b/src/BizHawk.Client.Common/movie/import/VbmImport.cs index 4abdbe129a..c407c9fd34 100644 --- a/src/BizHawk.Client.Common/movie/import/VbmImport.cs +++ b/src/BizHawk.Client.Common/movie/import/VbmImport.cs @@ -296,7 +296,7 @@ namespace BizHawk.Client.Common.movie.import } private static SimpleController GbController() - => new(new ControllerDefinition + => new(new ControllerDefinition("Gameboy Controller") { BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "Power" } }); diff --git a/src/BizHawk.Client.Common/movie/import/YmvImport.cs b/src/BizHawk.Client.Common/movie/import/YmvImport.cs index 499f509384..f69a2f8f86 100644 --- a/src/BizHawk.Client.Common/movie/import/YmvImport.cs +++ b/src/BizHawk.Client.Common/movie/import/YmvImport.cs @@ -100,9 +100,8 @@ namespace BizHawk.Client.Common.movie.import private void ImportTextFrame(string line) { // Yabause only supported 1 controller - SimpleController controllers = new(new ControllerDefinition + SimpleController controllers = new(new ControllerDefinition("Saturn Controller") { - Name = "Saturn Controller", BoolButtons = new List { "Reset", "Power", "Previous Disk", "Next Disk", "P1 Left", "P1 Right", "P1 Up", "P1 Down", "P1 Start", "P1 A", "P1 B", "P1 C", "P1 X", "P1 Y", "P1 Z", "P1 L", "P1 R" diff --git a/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs b/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs index ff0e4adceb..0235bd8261 100644 --- a/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs +++ b/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs @@ -10,11 +10,9 @@ namespace BizHawk.Client.Common { public BkmControllerAdapter(ControllerDefinition definition, string systemId) { - Definition = definition; - // We do need to map the definition name to the legacy // controller names that were used back in the bkm days - Definition.Name = systemId switch + var name = systemId switch { "Lynx" => "Lynx Controller", "SNES" => "SNES Controller", @@ -34,6 +32,7 @@ namespace BizHawk.Client.Common "SMS Controller" => "SMS", _ => "Null Controller", }; + Definition = new(copyFrom: definition, withName: name); } public ControllerDefinition Definition { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index de87dbc590..596a58f8f1 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -2101,12 +2101,10 @@ namespace BizHawk.Client.EmuHawk private void InitControls() { - var controls = new Controller( - new ControllerDefinition - { - Name = "Emulator Frontend Controls", - BoolButtons = Config.HotkeyBindings.Select(x => x.DisplayName).ToList() - }); + Controller controls = new(new ControllerDefinition("Emulator Frontend Controls") + { + BoolButtons = Config.HotkeyBindings.Select(static x => x.DisplayName).ToList(), + }); foreach (var b in Config.HotkeyBindings) { diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs index a262b27789..ef7d27ac1d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs @@ -72,7 +72,7 @@ namespace BizHawk.Client.EmuHawk private void InitController(string key) { string[] keys = key.Split('|'); - var d = new ControllerDefinition(); + ControllerDefinition d = new(_emulator.ControllerDefinition.Name); foreach (var k in keys) { if (_emulator.ControllerDefinition.BoolButtons.Contains(k)) @@ -105,7 +105,7 @@ namespace BizHawk.Client.EmuHawk { // Get a IController that only contains buttons in key. string[] keys = _inputKey.Split('|'); - var d = new ControllerDefinition(); + ControllerDefinition d = new(_emulator.ControllerDefinition.Name); foreach (var key in keys) { if (_emulator.ControllerDefinition.BoolButtons.Contains(key)) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index 89d197a48d..9271d369ff 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -14,23 +14,20 @@ namespace BizHawk.Emulation.Common /// public class ControllerDefinition { - public ControllerDefinition() {} + public readonly string Name; - public ControllerDefinition(ControllerDefinition source) - : this() + public ControllerDefinition(string name) + => Name = name; + + public ControllerDefinition(ControllerDefinition copyFrom, string withName = null) + : this(withName ?? copyFrom.Name) { - Name = source.Name; - BoolButtons.AddRange(source.BoolButtons); - foreach (var kvp in source.Axes) Axes.Add(kvp); - HapticsChannels.AddRange(source.HapticsChannels); - CategoryLabels = source.CategoryLabels; + BoolButtons.AddRange(copyFrom.BoolButtons); + foreach (var kvp in copyFrom.Axes) Axes.Add(kvp); + HapticsChannels.AddRange(copyFrom.HapticsChannels); + CategoryLabels = copyFrom.CategoryLabels; } - /// - /// Gets or sets the name of the controller definition - /// - public string Name { get; set; } - /// /// Gets or sets a list of all button types that have a boolean (on/off) value /// diff --git a/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs b/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs index 002e5b87c0..bd51b68c11 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs @@ -12,10 +12,7 @@ namespace BizHawk.Emulation.Common /// public class NullController : IController { - public ControllerDefinition Definition => new ControllerDefinition - { - Name = "Null Controller" - }; + public ControllerDefinition Definition { get; } = new ControllerDefinition("Null Controller"); public bool IsPressed(string button) => false; diff --git a/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs b/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs index 98b763ccf0..683be0ed51 100644 --- a/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs +++ b/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs @@ -27,9 +27,12 @@ namespace BizHawk.Emulation.Common /// /// merge some controller definitions for different ports, and such. i promise to fully document this tomorrow /// - public static ControllerDefinition GetMerged(IEnumerable controllers, out List unmergers) + public static ControllerDefinition GetMerged( + string mergedName, + IEnumerable controllers, + out List unmergers) { - ControllerDefinition ret = new ControllerDefinition(); + ControllerDefinition ret = new(mergedName); unmergers = new List(); int plr = 1; int playerNext = 1; diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IInputPollable.cs index 19d0783fb5..6974e168c6 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IInputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IInputPollable.cs @@ -13,11 +13,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME [FeatureNotImplemented] public IInputCallbackSystem InputCallbacks => throw new NotImplementedException(); - public static ControllerDefinition MAMEController = new ControllerDefinition - { - Name = "MAME Controller", - BoolButtons = new List() - }; + public static ControllerDefinition MAMEController = new("MAME Controller"); private IController _controller = NullController.Instance; private readonly SortedDictionary _fieldsPorts = new SortedDictionary(); diff --git a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs index 26d052fd71..b071d55630 100644 --- a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -77,22 +77,20 @@ namespace BizHawk.Emulation.Cores.Calculators internal int LinkState => (_linkOutput | LinkInput) ^ 3; - private static readonly ControllerDefinition TI83Controller = - new ControllerDefinition + private static readonly ControllerDefinition TI83Controller = new ControllerDefinition("TI83 Controller") + { + BoolButtons = { - Name = "TI83 Controller", - BoolButtons = - { - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "DOT", - "ON", "ENTER", - "DOWN", "LEFT", "UP", "RIGHT", - "PLUS", "MINUS", "MULTIPLY", "DIVIDE", - "CLEAR", "EXP", "DASH", "PARACLOSE", "TAN", "VARS", "PARAOPEN", - "COS", "PRGM", "STAT", "COMMA", "SIN", "MATRIX", "X", - "STO", "LN", "LOG", "SQUARED", "NEG1", "MATH", "ALPHA", - "GRAPH", "TRACE", "ZOOM", "WINDOW", "Y", "2ND", "MODE", "DEL" - } - }; + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "DOT", + "ON", "ENTER", + "DOWN", "LEFT", "UP", "RIGHT", + "PLUS", "MINUS", "MULTIPLY", "DIVIDE", + "CLEAR", "EXP", "DASH", "PARACLOSE", "TAN", "VARS", "PARAOPEN", + "COS", "PRGM", "STAT", "COMMA", "SIN", "MATRIX", "X", + "STO", "LN", "LOG", "SQUARED", "NEG1", "MATH", "ALPHA", + "GRAPH", "TRACE", "ZOOM", "WINDOW", "Y", "2ND", "MODE", "DEL", + }, + }; private byte ReadMemory(ushort addr) { diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs index dfceefa720..40e959f68f 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs @@ -16,10 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { get { - var definition = new ControllerDefinition - { - Name = "AmstradCPC Controller" - }; + ControllerDefinition definition = new("AmstradCPC Controller"); // joysticks var joys1 = new List diff --git a/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index 91bd264141..8e6b40c515 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII { static AppleII() { - AppleIIController = new ControllerDefinition { Name = "Apple IIe Keyboard" }; + AppleIIController = new("Apple IIe Keyboard"); AppleIIController.BoolButtons.AddRange(RealButtons); AppleIIController.BoolButtons.AddRange(ExtraButtons); } diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 3bc7f764c4..7844a564f4 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -135,9 +135,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 private readonly List _roms; - private static readonly ControllerDefinition C64ControllerDefinition = new ControllerDefinition + private static readonly ControllerDefinition C64ControllerDefinition = new ControllerDefinition("Commodore 64 Controller") { - Name = "Commodore 64 Controller", BoolButtons = { "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button", diff --git a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs index 32d52901c5..98ed54af15 100644 --- a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs +++ b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs @@ -5,9 +5,8 @@ namespace BizHawk.Emulation.Cores.Computers.MSX public partial class MSX { - public static readonly ControllerDefinition MSXControllerKB = new ControllerDefinition + public static readonly ControllerDefinition MSXControllerKB = new ControllerDefinition("MSX Controller Keyboard") { - Name = "MSX Controller Keyboard", BoolButtons = { "Reset", @@ -25,9 +24,8 @@ namespace BizHawk.Emulation.Cores.Computers.MSX } }; - public static readonly ControllerDefinition MSXControllerJS = new ControllerDefinition + public static readonly ControllerDefinition MSXControllerJS = new ControllerDefinition("MSX Controller Joystick") { - Name = "MSX Controller Joystick", BoolButtons = { "Reset", diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs index e4f06906b1..958a429d8e 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs @@ -16,10 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { get { - var definition = new ControllerDefinition - { - Name = "ZXSpectrum Controller" - }; + ControllerDefinition definition = new("ZXSpectrum Controller"); // joysticks var joys1 = new List diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs index eefb5a17af..414b42047e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs @@ -15,9 +15,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 Port1 = ControllerCtors[controller1](1); Port2 = ControllerCtors[controller2](2); - Definition = new ControllerDefinition + Definition = new("Atari 2600 Basic Controller") { - Name = "Atari 2600 Basic Controller", BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs index 98728babc9..359d8d6038 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using BizHawk.Common; @@ -38,10 +37,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public UnpluggedController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition - { - BoolButtons = new List() - }; + Definition = new("(Atari 2600 Basic Controller fragment)"); } public byte Read(IController c) @@ -69,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public StandardController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("(Atari 2600 Basic Controller fragment)") { BoolButtons = BaseDefinition .Select(b => $"P{PortNum} " + b) @@ -115,7 +111,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public PaddleController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("(Atari 2600 Basic Controller fragment)") { BoolButtons = BaseDefinition .Select(b => $"P{PortNum} " + b) @@ -167,7 +163,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public BoostGripController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("(Atari 2600 Basic Controller fragment)") { BoolButtons = BaseDefinition .Select(b => $"P{PortNum} " + b) @@ -231,7 +227,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public DrivingController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("(Atari 2600 Basic Controller fragment)") { BoolButtons = BaseDefinition .Select(b => $"P{PortNum} " + b) @@ -325,7 +321,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public KeyboardController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("(Atari 2600 Basic Controller fragment)") { BoolButtons = BaseDefinition .Select(b => $"P{PortNum} " + b) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs index 7735d6cf71..920b4e5ce1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs @@ -19,9 +19,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk ? ctor2(2) : throw new InvalidOperationException($"Invalid controller type: {controller2Name}"); - Definition = new ControllerDefinition + Definition = new(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs index f78d9bbb72..d1d63cc1ba 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs @@ -34,9 +34,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public UnpluggedController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("Unplugged Controller") { - Name = "Unplugged Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() @@ -98,9 +97,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public StandardController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("Atari 7800 Basic Controller") { - Name = "Atari 7800 Basic Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() @@ -182,9 +180,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public ProLineController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("Atari 7800 ProLine Joystick Controller") { - Name = "Atari 7800 ProLine Joystick Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() @@ -276,9 +273,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public LightGunController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("Light Gun Controller") { - Name = "Light Gun Controller", BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList() }.AddXYPair($"P{PortNum} {{0}}", AxisPairOrientation.RightAndUp, 1.RangeTo(320), 160, 1.RangeTo(242), 121); //TODO verify direction against hardware } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index 15c7dd616a..c7160665fc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -161,9 +161,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx } } - private static readonly ControllerDefinition LynxTroller = new ControllerDefinition + private static readonly ControllerDefinition LynxTroller = new ControllerDefinition("Lynx Controller") { - Name = "Lynx Controller", BoolButtons = { "Up", "Down", "Left", "Right", "A", "B", "Option 1", "Option 2", "Pause", "Power" }, }; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs b/src/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs index 709f77306c..2a110319a9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs @@ -47,9 +47,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic PostInit(); } - private static readonly ControllerDefinition TwoPads = new ControllerDefinition + private static readonly ControllerDefinition TwoPads = new ControllerDefinition("SNES Controller") { - Name = "SNES Controller", BoolButtons = { "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Select", "P1 Start", "P1 X", "P1 A", "P1 B", "P1 Y", "P1 L", "P1 R", @@ -58,9 +57,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic } }; - private static readonly ControllerDefinition Mouse = new ControllerDefinition + private static readonly ControllerDefinition Mouse = new ControllerDefinition("SNES Controller") { - Name = "SNES Controller", BoolButtons = { "P1 Mouse Left", "P1 Mouse Right", "Power" } }.AddXYPair("P1 Mouse {0}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware diff --git a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs index a741fbf74d..adbe0607bc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs @@ -19,9 +19,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision ? ctor2(2) : throw new InvalidOperationException($"Invalid controller type: {controller2Name}"); - Definition = new ControllerDefinition + Definition = new("ColecoVision Basic Controller") { - Name = "ColecoVision Basic Controller", BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs index 6fab94fce7..62e4b40ba6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllers.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -30,10 +29,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public UnpluggedController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition - { - BoolButtons = new List() - }; + Definition = new("(ColecoVision Basic Controller fragment)"); } public byte Read(IController c, bool leftMode, bool updateWheel, float wheelAngle) @@ -59,7 +55,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public StandardController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("(ColecoVision Basic Controller fragment)") { BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) @@ -130,7 +126,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public ColecoTurboController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() } + Definition = new ControllerDefinition("(ColecoVision Basic Controller fragment)") { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() } .AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware } @@ -229,7 +225,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public ColecoSuperActionController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() } + Definition = new ControllerDefinition("(ColecoVision Basic Controller fragment)") { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() } .AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs index 4d4f979442..9b15714ead 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs @@ -9,10 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF { get { - ControllerDefinition definition = new ControllerDefinition - { - Name = "ChannelF Controller" - }; + ControllerDefinition definition = new("ChannelF Controller"); string pre = "P1 "; diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs index 3bc7554143..c3e257b48b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs @@ -19,9 +19,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex ? ctor2(2) : throw new InvalidOperationException($"Invalid controller type: {controller2Name}"); - Definition = new ControllerDefinition + Definition = new(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs index e8f13b4942..4a08278142 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs @@ -26,9 +26,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public StandardControls(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("Vectrex Digital Controller") { - Name = "Vectrex Digital Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList(), @@ -75,9 +74,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public AnalogControls(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("Vectrex Analog Controller") { - Name = "Vectrex Analog Controller", BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList() }.AddXYPair($"P{PortNum} Stick {{0}}", AxisPairOrientation.RightAndUp, (-128).RangeTo(127), 0); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs index 6c0494b0ef..0cb7a252a2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs @@ -19,9 +19,8 @@ namespace BizHawk.Emulation.Cores.Intellivision ? ctor2(2) : throw new InvalidOperationException($"Invalid controller type: {controller2Name}"); - Definition = new ControllerDefinition + Definition = new("Intellivision Controller") { - Name = "Intellivision Controller", BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllers.cs index 46e1b2ea96..7bd0304508 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllers.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -28,10 +27,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public UnpluggedController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition - { - BoolButtons = new List() - }; + Definition = new("(Intellivision Controller fragment)"); } public byte Read(IController c) @@ -55,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public StandardController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("(Intellivision Controller fragment)") { BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) @@ -139,7 +135,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public FakeAnalogController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() } + Definition = new ControllerDefinition("(Intellivision Controller fragment)") { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() } .AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs index 72e218e338..352cc787f0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs @@ -21,9 +21,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk if (is_G7400) { - Definition = new ControllerDefinition + Definition = new(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] @@ -42,9 +41,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk } else { - Definition = new ControllerDefinition + Definition = new(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs index ff9c879e90..977d5d9339 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs @@ -26,9 +26,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public StandardControls(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("O2 Joystick") { - Name = "O2 Joystick", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs index da78f5bba2..463a02ac9a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs @@ -43,13 +43,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES GetController(ss.RightPort, ss) }; - Definition = ControllerDefinitionMerger.GetMerged(_ports.Select(p => p.Definition), out var tmp); + Definition = ControllerDefinitionMerger.GetMerged( + "SNES Controller", + _ports.Select(p => p.Definition), + out var tmp); _mergers = tmp.ToArray(); // add buttons that the core itself will handle Definition.BoolButtons.Add("Reset"); Definition.BoolButtons.Add("Power"); - Definition.Name = "SNES Controller"; } public void CoreInputPoll(IController controller) @@ -84,7 +86,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES internal class BsnesUnpluggedController : IBsnesController { - private static readonly ControllerDefinition _definition = new(); + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)"); public ControllerDefinition Definition => _definition; @@ -118,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES ["0R"] = 11 }; - private static readonly ControllerDefinition _definition = new() + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Buttons.OrderBy(b => ButtonsOrder[b]).ToList() }; @@ -146,7 +148,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES { private readonly short[] _state = new short[4]; - private static readonly ControllerDefinition _definition = new ControllerDefinition + private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Mouse Left", "0Mouse Right" } } .AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndDown, (-127).RangeTo(127), 0); //TODO verify direction against hardware, R+D inferred from behaviour in Mario Paint @@ -207,7 +209,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES ["L"] = 11 }; - private static readonly ControllerDefinition _definition = new() + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Enumerable.Range(0, 4) .SelectMany(i => Buttons.OrderBy(b => ButtonsOrder[b]) @@ -241,7 +243,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES private readonly int[] _buttonsOrder = {4, 5, 6, 7, 0, 8, 1, 9, 10, 11, 2, 3, 12, 13, 14, 15}; - private static readonly ControllerDefinition _definition = new() + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Enumerable.Range(0, 32).Select(i => $"0B{i}").ToList() }; @@ -270,7 +272,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES { private readonly short[] _state = new short[6]; - private static readonly ControllerDefinition _definition = new ControllerDefinition + private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } } .AddLightGun("0Scope {0}"); @@ -300,11 +302,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES public BsnesJustifierController(bool chained) { Definition = chained - ? new ControllerDefinition + ? new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start", "1Trigger", "1Start" } } .AddLightGun("0Justifier {0}") .AddLightGun("1Justifier {0}") - : new ControllerDefinition + : new ControllerDefinition("(SNES Controller fragment)") {BoolButtons = { "0Trigger", "0Start"} } .AddLightGun("0Justifier {0}"); _state = new short[chained ? 8 : 4]; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index 9c2e97ca46..a0cee68915 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -261,9 +261,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA return baseTime + increment; } - public static readonly ControllerDefinition GBAController = new ControllerDefinition + public static readonly ControllerDefinition GBAController = new ControllerDefinition("GBA Controller") { - Name = "GBA Controller", BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power" } }.AddXYZTriple("Tilt {0}", (-32767).RangeTo(32767), 0) .AddAxis("Light Sensor", 0.RangeTo(255), 0); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs index 9844452c2d..4cbedf5479 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs @@ -16,9 +16,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk ? ctor1(1) : throw new InvalidOperationException($"Invalid controller type: {controller1Name}"); - Definition = new ControllerDefinition + Definition = new(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .ToList() }; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs index cc54331265..cb11d4de95 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs @@ -29,9 +29,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public StandardControls(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("Gameboy Controller H") { - Name = "Gameboy Controller H", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() @@ -102,9 +101,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public StandardTilt(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("Gameboy Controller + Tilt") { - Name = "Gameboy Controller + Tilt", BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList() }.AddXYPair($"P{PortNum} Tilt {{0}}", AxisPairOrientation.RightAndUp, (-90).RangeTo(90), 0); //TODO verify direction against hardware } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs index f271887cfc..82058d78a8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs @@ -18,9 +18,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink ? ctor2(2) : throw new InvalidOperationException($"Invalid controller type: {controller2Name}"); - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] { "Toggle Cable" } ) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllerDeck.cs index d9d3ebbf58..f18bb4795e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllerDeck.cs @@ -21,9 +21,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x ? ctor3(3) : throw new InvalidOperationException($"Invalid controller type: {controller3Name}"); - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(Port3.Definition.BoolButtons) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllerDeck.cs index 8a7370140e..24fd59a096 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllerDeck.cs @@ -24,9 +24,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x ? ctor4(4) : throw new InvalidOperationException($"Invalid controller type: {controller4Name}"); - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(Port3.Definition.BoolButtons) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index dfbf7972dc..6d4daf0a77 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -265,8 +265,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public static ControllerDefinition CreateControllerDefinition(bool sgb, bool sub) { var ret = sub - ? new ControllerDefinition { Name = "Subframe Gameboy Controller" }.AddAxis("Input Length", 0.RangeTo(35112), 35112) - : new ControllerDefinition { Name = "Gameboy Controller" }; + ? new ControllerDefinition("Subframe Gameboy Controller").AddAxis("Input Length", 0.RangeTo(35112), 35112) + : new ControllerDefinition("Gameboy Controller"); if (sgb) { for (int i = 0; i < 4; i++) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index 2e6f57528f..d7a45c3189 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -140,7 +140,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy private ControllerDefinition CreateControllerDefinition() { - var ret = new ControllerDefinition { Name = $"GB Link {_numCores}x Controller" }; + ControllerDefinition ret = new($"GB Link {_numCores}x Controller"); for (int i = 0; i < _numCores; i++) { ret.BoolButtons.AddRange( diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 0d2dcea9ca..0600e1b235 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -246,7 +246,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public DisplayType Region => _display_type; - public ControllerDefinition ControllerDefinition { get; } = new ControllerDefinition { Name = "Nintendo 64 Controller" }; + public ControllerDefinition ControllerDefinition { get; } = new("Nintendo 64 Controller"); public void ResetCounters() { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index 6901a827fd..94d2215e79 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -181,9 +181,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS public override ControllerDefinition ControllerDefinition => NDSController; - public static readonly ControllerDefinition NDSController = new ControllerDefinition + public static readonly ControllerDefinition NDSController = new ControllerDefinition("NDS Controller") { - Name = "NDS Controller", BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "Y", "X", "L", "R", "LidOpen", "LidClose", "Touch", "Power" diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 185745b102..05aaa91b5a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -250,9 +250,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES [Obsolete] // with the changes to both nes and quicknes cores, nothing uses this anymore public static readonly ControllerDefinition NESController = - new ControllerDefinition + new ControllerDefinition("NES Controller") { - Name = "NES Controller", BoolButtons = { "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Start", "P1 Select", "P1 B", "P1 A", "Reset", "Power", "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Start", "P2 Select", "P2 B", "P2 A" diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs index 7c373759d7..1a6870de56 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs @@ -146,9 +146,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES _left = left; _right = right; ControllerDef = ControllerDefinitionMerger.GetMerged( + "NES Controller", new[] { left.ControllerDefFragment, right.ControllerDefFragment }, out var cdum); - ControllerDef.Name = "NES Controller"; _leftU = cdum[0]; _rightU = cdum[1]; @@ -194,7 +194,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public class UnpluggedNES : INesPort { - public ControllerDefinition ControllerDefFragment { get; } = new(); + public ControllerDefinition ControllerDefFragment { get; } = new("(NES Controller fragment)"); public void Strobe(StrobeInfo s, IController c) { @@ -234,7 +234,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public ControllerNES() { - ControllerDefFragment = new() { BoolButtons = Buttons.OrderBy(x => _buttonOrdinals[x]).ToList() }; + ControllerDefFragment = new("(NES Controller fragment)") { BoolButtons = Buttons.OrderBy(x => _buttonOrdinals[x]).ToList() }; } @@ -254,11 +254,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (famicomP2) { - ControllerDefFragment = new() { BoolButtons = FamicomP2Buttons.Where(static s => s is not null).OrderBy(x => _buttonOrdinals[x]).ToList() }; + ControllerDefFragment = new("(NES Controller fragment)") { BoolButtons = FamicomP2Buttons.Where(static s => s is not null).OrderBy(x => _buttonOrdinals[x]).ToList() }; } else { - ControllerDefFragment = new() { BoolButtons = Buttons.OrderBy(x => _buttonOrdinals[x]).ToList() }; + ControllerDefFragment = new("(NES Controller fragment)") { BoolButtons = Buttons.OrderBy(x => _buttonOrdinals[x]).ToList() }; } _famicomP2Hack = famicomP2; @@ -313,7 +313,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES }; public ControllerDefinition ControllerDefFragment { get; } - = new() { BoolButtons = Buttons.Where(static s => s is not null).ToList() }; + = new("(NES Controller fragment)") { BoolButtons = Buttons.Where(static s => s is not null).ToList() }; // reset is not edge triggered; so long as it's high, the latch is continuously reloading // so we need to latch in two places: @@ -359,7 +359,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private byte _latchedValue = 0x54 ^ 0xff; public ControllerDefinition ControllerDefFragment { get; } - = new ControllerDefinition { BoolButtons = { "0Fire" } } + = new ControllerDefinition("(NES Controller fragment)") { BoolButtons = { "0Fire" } } .AddAxis("0Paddle", 0.RangeTo(160), 80); public void Strobe(StrobeInfo s, IController c) @@ -409,7 +409,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES }; public ControllerDefinition ControllerDefFragment { get; } - = new() { BoolButtons = Buttons.ToList() }; + = new("(NES Controller fragment)") { BoolButtons = Buttons.ToList() }; private bool _resetting; private int _latchedValue; @@ -455,7 +455,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private static readonly string[] D4Buttons = { "0PP4", "0PP3", "0PP12", "0PP8" }; public ControllerDefinition ControllerDefFragment { get; } - = new() { BoolButtons = D3Buttons.Concat(D4Buttons).ToList() }; + = new("(NES Controller fragment)") { BoolButtons = D3Buttons.Concat(D4Buttons).ToList() }; private bool _resetting; private int _latched3; @@ -516,7 +516,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public LightgunDelegate PPUCallback { get; set; } public ControllerDefinition ControllerDefFragment { get; } - = new ControllerDefinition { BoolButtons = { "0Fire" } } + = new ControllerDefinition("(NES Controller fragment)") { BoolButtons = { "0Fire" } } .AddZapper("0Zapper {0}"); public void Strobe(StrobeInfo s, IController c) @@ -561,7 +561,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private uint _latchedValue; public ControllerDefinition ControllerDefFragment { get; } - = new ControllerDefinition { BoolButtons = { "0Fire" } } + = new ControllerDefinition("(NES Controller fragment)") { BoolButtons = { "0Fire" } } .AddZapper("0Zapper {0}"); private void Latch(IController c) @@ -630,10 +630,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { _player3 = expSlot; ControllerDef = ControllerDefinitionMerger.GetMerged( + "NES Controller", new[] { _player1.ControllerDefFragment, _player2.ControllerDefFragment, _player3.ControllerDefFragment }, out var cdum); ControllerDef.BoolButtons.Add("P2 Microphone"); - ControllerDef.Name = "NES Controller"; _player1U = cdum[0]; _player2U = cdum[1]; _player3U = cdum[2]; @@ -692,7 +692,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private byte _latchedValue = 0x54 ^ 0xff; public ControllerDefinition ControllerDefFragment { get; } - = new ControllerDefinition { BoolButtons = { "0Fire" } } + = new ControllerDefinition("(NES Controller fragment)") { BoolButtons = { "0Fire" } } .AddAxis("0Paddle", 0.RangeTo(160), 80); public void Strobe(StrobeInfo s, IController c) @@ -821,7 +821,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES }; public ControllerDefinition ControllerDefFragment { get; } - = new() { BoolButtons = Buttons.ToList() }; + = new("(NES Controller fragment)") { BoolButtons = Buttons.ToList() }; private bool _active; private int _column; @@ -886,7 +886,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES }; public ControllerDefinition ControllerDefFragment { get; } - = new() { BoolButtons = P1Buttons.Concat(P2Buttons).ToList() }; + = new("(NES Controller fragment)") { BoolButtons = P1Buttons.Concat(P2Buttons).ToList() }; private bool _resetting; private int _latchedP1; @@ -936,7 +936,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public class OekaKids : IFamicomExpansion { public ControllerDefinition ControllerDefFragment { get; } - = new ControllerDefinition { BoolButtons = { "0Click", "0Touch" } } + = new ControllerDefinition("(NES Controller fragment)") { BoolButtons = { "0Click", "0Touch" } } .AddZapper("0Pen {0}"); // why would a tablet have the same resolution as a CRT monitor? --yoshi private bool _resetting; @@ -999,7 +999,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public class UnpluggedFam : IFamicomExpansion { - public ControllerDefinition ControllerDefFragment => new(); + public ControllerDefinition ControllerDefFragment => new("(NES Controller fragment)"); public void Strobe(StrobeInfo s, IController c) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index ba3b981ac3..8eaef8e34a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -119,8 +119,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES private void SetControllerDefinition() { - var def = new ControllerDefinition(); - def.Name = "NES Controller"; + ControllerDefinition def = new("NES Controller"); if (_syncSettings.LeftPortConnected || _syncSettings.RightPortConnected) def.BoolButtons.AddRange(PadP1.Select(p => p.Name)); if (_syncSettings.LeftPortConnected && _syncSettings.RightPortConnected) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesControllerDeck.cs index 2e03fb39ca..17b12ca43a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesControllerDeck.cs @@ -60,13 +60,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES Factory(ss.RightPort, ss) }; - Definition = ControllerDefinitionMerger.GetMerged(_ports.Select(p => p.Definition), out var tmp); + Definition = ControllerDefinitionMerger.GetMerged( + "SNES Controller", + _ports.Select(p => p.Definition), + out var tmp); _mergers = tmp.ToArray(); // add buttons that the core itself will handle Definition.BoolButtons.Add("Reset"); Definition.BoolButtons.Add("Power"); - Definition.Name = "SNES Controller"; } public void NativeInit(LibsnesApi api) @@ -161,7 +163,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES return order[btn]; } - private static readonly ControllerDefinition _definition = new ControllerDefinition + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Buttons.OrderBy(ButtonOrder).ToList() }; @@ -223,7 +225,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES return order[btn]; } - private static readonly ControllerDefinition _definition = new ControllerDefinition + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Enumerable.Range(0, 4) .SelectMany(i => Buttons @@ -253,7 +255,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { public LibsnesApi.SNES_INPUT_PORT PortType { get; } = LibsnesApi.SNES_INPUT_PORT.Multitap; - private static readonly ControllerDefinition _definition = new ControllerDefinition + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Enumerable.Range(0, 32).Select(i => "0B" + i).ToList() }; @@ -270,7 +272,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { public LibsnesApi.SNES_INPUT_PORT PortType { get; } = LibsnesApi.SNES_INPUT_PORT.None; - private static readonly ControllerDefinition _definition = new ControllerDefinition(); + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)"); public ControllerDefinition Definition { get; } = _definition; @@ -285,7 +287,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.Mouse; private static readonly ControllerDefinition _definition - = new ControllerDefinition { BoolButtons = { "0Mouse Left", "0Mouse Right" } } + = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Mouse Left", "0Mouse Right" } } .AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndDown, (-127).RangeTo(127), 0); //TODO verify direction against hardware, R+D inferred from behaviour in Mario Paint public ControllerDefinition Definition => _definition; @@ -327,7 +329,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.SuperScope; private static readonly ControllerDefinition _definition - = new ControllerDefinition { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } } + = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } } .AddLightGun("0Scope {0}"); public ControllerDefinition Definition => _definition; @@ -361,7 +363,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.Justifier; private static readonly ControllerDefinition _definition - = new ControllerDefinition { BoolButtons = { "0Trigger", "0Start", "1Trigger", "1Start" } } + = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start", "1Trigger", "1Start" } } .AddLightGun("0Justifier {0}") .AddLightGun("1Justifier {0}"); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index b3040d33dc..1bf890733d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -108,12 +108,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X } _controllerDefinition = ControllerDefinitionMerger.GetMerged( - _controllers.Select(c => c.Definition), out _cdums); + "SNES Controller", + _controllers.Select(c => c.Definition), + out _cdums); // add buttons that the core itself will handle _controllerDefinition.BoolButtons.Add("Reset"); _controllerDefinition.BoolButtons.Add("Power"); - _controllerDefinition.Name = "SNES Controller"; } private void UpdateControls(IController c) @@ -174,7 +175,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X return order[btn]; } - private static readonly ControllerDefinition _definition = new ControllerDefinition + private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)") { BoolButtons = Buttons.OrderBy(ButtonOrder).ToList() }; @@ -204,7 +205,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X private class Mouse : Analog { private static readonly ControllerDefinition _definition - = new ControllerDefinition { BoolButtons = { "0Mouse Left", "0Mouse Right" } } + = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Mouse Left", "0Mouse Right" } } .AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware public override ControllerDefinition Definition => _definition; @@ -213,7 +214,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X private class SuperScope : Analog { private static readonly ControllerDefinition _definition - = new ControllerDefinition { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } } + = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } } .AddLightGun("0Scope {0}"); public override ControllerDefinition Definition => _definition; @@ -222,7 +223,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X private class Justifier : Analog { private static readonly ControllerDefinition _definition - = new ControllerDefinition { BoolButtons = { "0Trigger", "0Start" } } + = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start" } } .AddLightGun("0Justifier {0}"); public override ControllerDefinition Definition => _definition; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs index 70056decd8..c5c687759c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs @@ -104,9 +104,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB ["Start"] = 14 }; - private static readonly ControllerDefinition VirtualBoyController = new ControllerDefinition + private static readonly ControllerDefinition VirtualBoyController = new ControllerDefinition("VirtualBoy Controller") { - Name = "VirtualBoy Controller", BoolButtons = CoreButtons .OrderBy(b => _buttonOrdinals[b]) .Concat(new[] { "Power" }) diff --git a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PceControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PceControllerDeck.cs index b765942f48..ad7998a41c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PceControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PceControllerDeck.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using BizHawk.Emulation.Common; @@ -33,9 +32,8 @@ namespace BizHawk.Emulation.Cores.PCEngine _port4 = (IPort)Activator.CreateInstance(Implementors[(int)controller4], 4); _port5 = (IPort)Activator.CreateInstance(Implementors[(int)controller5], 5); - Definition = new ControllerDefinition + Definition = new("PC Engine Controller") { - Name = "PC Engine Controller", BoolButtons = _port1.Definition.BoolButtons .Concat(_port2.Definition.BoolButtons) .Concat(_port3.Definition.BoolButtons) @@ -92,10 +90,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public UnpluggedController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition - { - BoolButtons = new List() - }; + Definition = new("(PC Engine Controller fragment)"); } public byte Read(IController c, bool sel) @@ -113,7 +108,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public StandardController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("(PC Engine Controller fragment)") { BoolButtons = BaseDefinition .Select(b => $"P{PortNum} " + b) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs index e2649e95eb..043a20950e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs @@ -19,9 +19,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink ? ctor2(2) : throw new InvalidOperationException($"Invalid controller type: {controller2Name}"); - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, BoolButtons = Port1.Definition.BoolButtons .Concat(Port2.Definition.BoolButtons) .Concat(new[] { "Toggle Cable" } ) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs index 121fc9e79e..b3c54b0e46 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs @@ -26,9 +26,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink public StandardControls(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("GG Controller") { - Name = "GG Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs index 6e777e94f0..c217b63c9b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs @@ -123,9 +123,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive public bool Is32XActive { get; } - public static readonly ControllerDefinition PicoDriveController = new ControllerDefinition + public static readonly ControllerDefinition PicoDriveController = new ControllerDefinition("PicoDrive Genesis Controller") { - Name = "PicoDrive Genesis Controller", BoolButtons = { "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 A", "P1 B", "P1 C", "P1 Start", "P1 X", "P1 Y", "P1 Z", "P1 Mode", diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllerDeck.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllerDeck.cs index b3dc4bfa8d..c7c50504cf 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllerDeck.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllerDeck.cs @@ -18,10 +18,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem // Port 2 is defined, but not used for Game Gear Port2 = new GGController(2); - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, - BoolButtons = new[] { "Reset" } .Concat(Port1.Definition.BoolButtons) .ToList() @@ -34,10 +32,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem if (!use_keyboard) { - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, - BoolButtons = new[] { "Reset", "Pause" } .Concat(Port1.Definition.BoolButtons) .Concat(Port2.Definition.BoolButtons) @@ -46,10 +42,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } else { - Definition = new ControllerDefinition + Definition = new ControllerDefinition(Port1.Definition.Name) { - Name = Port1.Definition.Name, - BoolButtons = new[] { "Reset", "Pause" } .Concat(Port1.Definition.BoolButtons) .Concat(Port2.Definition.BoolButtons) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllers.cs index 7167e7b970..02c3484da7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMSControllers.cs @@ -49,9 +49,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public SmsController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("SMS Controller") { - Name = "SMS Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() @@ -130,9 +129,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public GGController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new("GG Controller") { - Name = "GG Controller", BoolButtons = BaseDefinition .Select(b => "P" + PortNum + " " + b) .ToList() @@ -203,9 +201,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public SMSPaddleController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("SMS Paddle Controller") { - Name = "SMS Paddle Controller", BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList() }.AddAxis($"P{PortNum} Paddle", 0.RangeTo(255), 128); } @@ -336,9 +333,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public SMSSportsPadController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("SMS Sports Pad Controller") { - Name = "SMS Sports Pad Controller", BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList() }.AddXYPair($"P{PortNum} {{0}}", AxisPairOrientation.RightAndUp, (-64).RangeTo(63), 0); //TODO verify direction against hardware } @@ -626,9 +622,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public SMSLightPhaserController(int portNum) { PortNum = portNum; - Definition = new ControllerDefinition + Definition = new ControllerDefinition("SMS Light Phaser Controller") { - Name = "SMS Light Phaser Controller", BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList() }.AddXYPair($"P{PortNum} {{0}}", AxisPairOrientation.RightAndUp, 0.RangeTo(127), 64, 0.RangeTo(192), 96); //TODO verify direction against hardware } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs index 1addc3711c..a4f62a2e3d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs @@ -179,7 +179,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx int player = 1; - ControllerDef = new ControllerDefinition(); + ControllerDef = new("GPGX Genesis Controller"); ControllerDef.BoolButtons.Add("Power"); ControllerDef.BoolButtons.Add("Reset"); @@ -235,8 +235,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx throw new Exception("Unknown Genesis control device! Something went wrong."); } } - - ControllerDef.Name = "GPGX Genesis Controller"; } public void Convert(IController source, LibGPGX.InputData target) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PS2/DobieStation.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PS2/DobieStation.cs index fccf4b5618..2437c6843a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PS2/DobieStation.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PS2/DobieStation.cs @@ -135,9 +135,8 @@ namespace BizHawk.Emulation.Cores.Sony.PS2 : PutSettingsDirtyBits.None; } - private static readonly ControllerDefinition DualShock = new ControllerDefinition + private static readonly ControllerDefinition DualShock = new ControllerDefinition("PS2 DualShock") { - Name = "PS2 DualShock", BoolButtons = { "SELECT", diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 6d31d36a60..e7f325d4ec 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -285,7 +285,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public static ControllerDefinition CreateControllerDefinition(SyncSettings syncSettings) { - var definition = new ControllerDefinition { Name = "PSX Front Panel" }; + ControllerDefinition definition = new("PSX Front Panel"); var cfg = syncSettings.FIOConfig.ToLogical(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs index 65db5b1716..71c0e1d2d1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs @@ -4,9 +4,8 @@ namespace BizHawk.Emulation.Cores.WonderSwan { partial class WonderSwan { - public static readonly ControllerDefinition WonderSwanController = new ControllerDefinition + public static readonly ControllerDefinition WonderSwanController = new ControllerDefinition("WonderSwan Controller") { - Name = "WonderSwan Controller", BoolButtons = { "P1 X1", diff --git a/src/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs b/src/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs index 1efe9ece05..cf6e961116 100644 --- a/src/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs +++ b/src/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs @@ -245,8 +245,7 @@ namespace BizHawk.Emulation.Cores.Libretro public static ControllerDefinition CreateControllerDefinition(SyncSettings syncSettings) { - ControllerDefinition definition = new ControllerDefinition(); - definition.Name = "LibRetro Controls"; // <-- for compatibility + ControllerDefinition definition = new("LibRetro Controls"/*for compatibility*/); foreach(var item in new[] { "P1 {0} Up", "P1 {0} Down", "P1 {0} Left", "P1 {0} Right", "P1 {0} Select", "P1 {0} Start", "P1 {0} Y", "P1 {0} B", "P1 {0} X", "P1 {0} A", "P1 {0} L", "P1 {0} R", diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs index 88afe1b055..7e23a56b59 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs @@ -46,9 +46,8 @@ namespace BizHawk.Emulation.Cores.Waterbox HashSet hiddenPorts, string controllerDeckName) { - var ret = new ControllerDefinition + ControllerDefinition ret = new(controllerDeckName) { - Name = controllerDeckName, CategoryLabels = { { "Power", "System" }, diff --git a/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs b/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs index 445fc5b722..76ed84514e 100644 --- a/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs +++ b/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs @@ -16,8 +16,8 @@ namespace BizHawk.Tests.Client.Common.Display [TestInitialize] public void Initializer() { - _boolController = new(new ControllerDefinition { BoolButtons = { "A" } }); - _axisController = new(new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(200), MidValue)); + _boolController = new(new ControllerDefinition("Dummy Gamepad") { BoolButtons = { "A" } }); + _axisController = new(new ControllerDefinition("Dummy Gamepad").AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(200), MidValue)); } [TestMethod] diff --git a/src/BizHawk.Tests/Client.Common/Movie/LogGeneratorTests.cs b/src/BizHawk.Tests/Client.Common/Movie/LogGeneratorTests.cs index d349d6d0ce..febd92ba49 100644 --- a/src/BizHawk.Tests/Client.Common/Movie/LogGeneratorTests.cs +++ b/src/BizHawk.Tests/Client.Common/Movie/LogGeneratorTests.cs @@ -15,14 +15,14 @@ namespace BizHawk.Tests.Client.Common.Movie [TestInitialize] public void Initializer() { - _boolController = new(new ControllerDefinition { BoolButtons = { "A" } }); - _axisController = new(new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(200), 100)); + _boolController = new(new ControllerDefinition("Dummy Gamepad") { BoolButtons = { "A" } }); + _axisController = new(new ControllerDefinition("Dummy Gamepad").AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(200), 100)); } [TestMethod] public void GenerateLogEntry_ExclamationForUnknownButtons() { - SimpleController controller = new(new ControllerDefinition { BoolButtons = { "Unknown Button" } }); + SimpleController controller = new(new ControllerDefinition("Dummy Gamepad") { BoolButtons = { "Unknown Button" } }); var lg = new Bk2LogEntryGenerator("NES", controller); controller["Unknown Button"] = true; var actual = lg.GenerateLogEntry();