using System.Collections.Generic; using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { /// /// A basic implementation of IController /// public class SimpleController : IController { public ControllerDefinition Definition { get; set; } protected WorkingDictionary Buttons { get; private set; } = new WorkingDictionary(); protected WorkingDictionary Axes { get; private set; } = new WorkingDictionary(); public void Clear() { Buttons = new WorkingDictionary(); Axes = new WorkingDictionary(); } public bool this[string button] { get => Buttons[button]; set => Buttons[button] = value; } public virtual bool IsPressed(string button) => this[button]; public float AxisValue(string name) => Axes[name]; public IEnumerable> BoolButtons() { return Buttons; } public void AcceptNewAxes((string AxisID, float Value) newValue) { Axes[newValue.AxisID] = newValue.Value; } public void AcceptNewAxes(IEnumerable<(string AxisID, float Value)> newValues) { foreach (var (axisID, value) in newValues) { Axes[axisID] = value; } } } }