diff --git a/BizHawk.Client.Common/movie/ControllerLookups/MnemonicGenerators.cs b/BizHawk.Client.Common/movie/ControllerLookups/MnemonicGenerators.cs
index e3b6349c38..128eb45737 100644
--- a/BizHawk.Client.Common/movie/ControllerLookups/MnemonicGenerators.cs
+++ b/BizHawk.Client.Common/movie/ControllerLookups/MnemonicGenerators.cs
@@ -12,10 +12,16 @@ namespace BizHawk.Client.Common
{
IController Source { get; set; }
+ string Name { get; }
+
///
- /// The
+ /// Will be prepended to all button names
+ /// Example: "P1"
///
string ControllerPrefix { get; set; }
+
+ void Add(string key, char value);
+
char this[string key] { get; }
bool IsEmpty { get; }
string MnemonicString { get; }
@@ -32,22 +38,51 @@ namespace BizHawk.Client.Common
IDictionary ParseMnemonicSegment(string mnemonicSegment);
}
- public interface IMnemonicGeneratorCollection
+ ///
+ /// A console specific collection of Mnemonic generators
+ /// This handles includes all the "business" logic specific to the console
+ ///
+ public interface IMnemonicPorts
{
- IEnumerable Generators { get; }
+ ///
+ /// Total number of available controller ports (this does not include the console controls
+ ///
+ int Count { get; }
+
+ ///
+ /// Gets or sets the given port with an IMnemonicGenerator implementation
+ /// Ports are zero based
+ /// Set will throw an InvalidOperationException if a particular implementation is not allowed, this is platform specific logic such as NES doesn't allow a zapper in port 0, etc
+ /// Both will throw an ArgumentOutOfRangeException exception if portNum is not less than Count
+ ///
+ IMnemonicGenerator this[int portNum] { get; set; }
+
+ ///
+ /// Gets an IMnemonicGenerator implementation that represents the buttons and controls on the console itself (Reset, Power, etc)
+ ///
+ IMnemonicGenerator ConsoleControls { get; }
}
public class BooleanControllerMnemonicGenerator : IMnemonicGenerator
{
private NamedDictionary _controllerMnemonics;
- public BooleanControllerMnemonicGenerator(string name)
+ public BooleanControllerMnemonicGenerator(string name, IDictionary mnemonics)
{
_controllerMnemonics = new NamedDictionary(name);
}
+ public void Add(string key, char value)
+ {
+ _controllerMnemonics.Add(key, value);
+ }
+
public IController Source { get; set; }
public string ControllerPrefix { get; set; }
+ public string Name
+ {
+ get { return _controllerMnemonics.Name; }
+ }
public char this[string key]
{
diff --git a/BizHawk.Client.Common/movie/ControllerLookups/NesMnemonicGenerator.cs b/BizHawk.Client.Common/movie/ControllerLookups/NesMnemonicGenerator.cs
index 3eb2e12197..fecd6977e3 100644
--- a/BizHawk.Client.Common/movie/ControllerLookups/NesMnemonicGenerator.cs
+++ b/BizHawk.Client.Common/movie/ControllerLookups/NesMnemonicGenerator.cs
@@ -5,19 +5,160 @@ using System.Text;
namespace BizHawk.Client.Common
{
- public class NesMnemonicGenerator : IMnemonicGeneratorCollection
+ public class NesMnemonicGenerator : IMnemonicPorts
{
- public NesMnemonicGenerator()
+ public NesMnemonicGenerator(bool fds = false, bool isFourscore = false)
{
-
+ _isFds = fds;
+ _isFourscore = isFourscore;
}
- public IEnumerable Generators
+ public bool FourScoreEnabled
+ {
+ get { return _isFourscore; }
+ set { _isFourscore = value; }
+ }
+
+ public bool IsFDS
+ {
+ get { return _isFds; }
+ set { _isFds = value; }
+ }
+
+ #region IMnemonicPorts Implementation
+
+ public int Count
+ {
+ get { return _isFourscore ? 4 : 2; }
+ }
+
+ // This is probably not necessary, but let's see how things go
+ public IEnumerable AvailableGenerators
{
get
{
- return Enumerable.Empty();
+ yield return ConsoleControls;
+
+ for (int i = 0; i < Count; i++)
+ {
+ yield return _controllerPorts[i];
+ }
}
}
+
+ public IMnemonicGenerator ConsoleControls
+ {
+ get { return _isFds ? _fdsConsoleControls : _nesConsoleControls; }
+ }
+
+ public IMnemonicGenerator this[int portNum]
+ {
+ get
+ {
+ if (portNum < Count)
+ {
+ return _controllerPorts[portNum];
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException("portNum");
+ }
+ }
+
+ set
+ {
+ if (portNum < Count)
+ {
+ // Eventually this will support zappers and FDS controllers, Arkanoid paddle, etc
+ if (value is BooleanControllerMnemonicGenerator)
+ {
+ _controllerPorts[portNum] = value;
+ }
+ else
+ {
+ throw new InvalidOperationException("Invalid Mnemonic Generator for the given port");
+ }
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException("portNum");
+ }
+ }
+ }
+
+ #endregion
+
+ #region Privates
+
+ private bool _isFds;
+ private bool _isFourscore;
+
+ private static readonly Dictionary _basicController = new Dictionary
+ {
+ { "Up", 'U' },
+ { "Down", 'D' },
+ { "Left", 'L' },
+ { "Right", 'R' },
+ { "Select", 's' },
+ { "Start", 'S' },
+ { "B", 'B' },
+ { "A", 'A' }
+ };
+
+ private readonly BooleanControllerMnemonicGenerator _nesConsoleControls = new BooleanControllerMnemonicGenerator(
+ "Console",
+ new Dictionary
+ {
+ { "Reset", 'r' },
+ { "Power", 'P' },
+ }
+ )
+ {
+ Source = Global.MovieOutputHardpoint,
+ ControllerPrefix = String.Empty
+ };
+
+ private readonly BooleanControllerMnemonicGenerator _fdsConsoleControls = new BooleanControllerMnemonicGenerator(
+ "Console",
+ new Dictionary
+ {
+ { "Reset", 'r' },
+ { "Power", 'P' },
+ { "FDS Eject", 'E' },
+ { "FDS Insert 0", '0' },
+ { "FDS Insert 1", '1' },
+ }
+ )
+ {
+ Source = Global.MovieOutputHardpoint,
+ ControllerPrefix = String.Empty
+ };
+
+ private readonly List _controllerPorts =
+ new List
+ {
+ new BooleanControllerMnemonicGenerator("Player 1", _basicController)
+ {
+ Source = Global.MovieOutputHardpoint,
+ ControllerPrefix = "P1"
+ },
+ new BooleanControllerMnemonicGenerator("Player 2", _basicController)
+ {
+ Source = Global.MovieOutputHardpoint,
+ ControllerPrefix = "P2"
+ },
+ new BooleanControllerMnemonicGenerator("Player 3", _basicController)
+ {
+ Source = Global.MovieOutputHardpoint,
+ ControllerPrefix = "P3"
+ },
+ new BooleanControllerMnemonicGenerator("Player 4", _basicController)
+ {
+ Source = Global.MovieOutputHardpoint,
+ ControllerPrefix = "P4"
+ }
+ };
+
+ #endregion
}
}