diff --git a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index 8eca50604e..05f88c8ab3 100644 --- a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -4,8 +4,65 @@ using System.Linq; namespace BizHawk.Emulation.Common { + /// + /// Defines the schema for all the currently available controls for an IEmulator instance + /// + /// public class ControllerDefinition { + public ControllerDefinition() + { + BoolButtons = new List(); + FloatControls = new List(); + FloatRanges = new List(); + AxisConstraints = new List(); + CategoryLabels = new Dictionary(); + } + + public ControllerDefinition(ControllerDefinition source) + : this() + { + Name = source.Name; + BoolButtons.AddRange(source.BoolButtons); + FloatControls.AddRange(source.FloatControls); + FloatRanges.AddRange(source.FloatRanges); + AxisConstraints.AddRange(source.AxisConstraints); + CategoryLabels = source.CategoryLabels; + } + + /// + /// The name of the controller definition + /// + public string Name { get; set; } + + /// + /// A list of all button types that have a boolean (on/off) value + /// + public List BoolButtons { get; set; } + + /// + /// A list of all non-boolean types, that can be represented by a numerical value (such as analog controls, stylus coordinates, etc + /// + public List FloatControls { get; private set; } + + /// + /// A list of all float ranges for each float control (must be one to one with FloatControls) + /// FloatRanges include the min/max/default values + /// + public List FloatRanges { get; private set; } + + /// + /// Axis contraints apply artificial contraints to float values + /// For instance, a N64 controller's analog range is actually larger than the amount allowed by the plastic that artificially contrains it to lower values + /// Axis contraints provide a way to technically allow the full range but have a user option to contrain down to typical values that a real control would have + /// + public List AxisConstraints { get; private set; } + + /// + /// A means of categorizing controls in various controller display and config screens + /// + public Dictionary CategoryLabels { get; private set; } + public void ApplyAxisConstraints(string constraintClass, IDictionary floatButtons) { if (AxisConstraints == null) return; @@ -89,33 +146,6 @@ namespace BizHawk.Emulation.Common public object[] Params; } - public string Name { get; set; } - - public Dictionary CategoryLabels = new Dictionary(); - public List BoolButtons { get; set; } - public List FloatControls { get; private set; } - public List FloatRanges { get; private set; } - public List AxisConstraints { get; private set; } - - public ControllerDefinition(ControllerDefinition source) - : this() - { - CategoryLabels = source.CategoryLabels; - Name = source.Name; - BoolButtons.AddRange(source.BoolButtons); - FloatControls.AddRange(source.FloatControls); - FloatRanges.AddRange(source.FloatRanges); - AxisConstraints.AddRange(source.AxisConstraints); - } - - public ControllerDefinition() - { - BoolButtons = new List(); - FloatControls = new List(); - FloatRanges = new List(); - AxisConstraints = new List(); - } - /// /// Puts the controls in a logical order such as by controller number, /// This is a default implementation that should work most of the time @@ -154,7 +184,7 @@ namespace BizHawk.Emulation.Common } // TODO: a more respectable logic here, and possibly per core implementation - public virtual int PlayerCount + public int PlayerCount { get { @@ -173,7 +203,7 @@ namespace BizHawk.Emulation.Common } } - public virtual bool Any() + public bool Any() { return BoolButtons.Any() || FloatControls.Any(); }