From c3811721c270aba779e909f96c7f75baefb8b10d Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 22 Feb 2020 12:44:03 -0600 Subject: [PATCH] delete unused KeyTurbo.cs and misc small cleanups to InputAdapters --- BizHawk.Client.Common/ControllerBinding.cs | 2 +- BizHawk.Client.Common/Global.cs | 4 +- BizHawk.Client.Common/KeyTurbo.cs | 40 --- .../inputAdapters/AutoPattern.cs | 6 +- ...{OverrideAdaptor.cs => OverrideAdapter.cs} | 236 +++++++++--------- .../inputAdapters/UDLRController.cs | 2 +- BizHawk.sln.DotSettings | 5 + 7 files changed, 129 insertions(+), 166 deletions(-) delete mode 100644 BizHawk.Client.Common/KeyTurbo.cs rename BizHawk.Client.Common/inputAdapters/{OverrideAdaptor.cs => OverrideAdapter.cs} (93%) diff --git a/BizHawk.Client.Common/ControllerBinding.cs b/BizHawk.Client.Common/ControllerBinding.cs index e33b81a528..3338263a4a 100644 --- a/BizHawk.Client.Common/ControllerBinding.cs +++ b/BizHawk.Client.Common/ControllerBinding.cs @@ -177,7 +177,7 @@ namespace BizHawk.Client.Common } } - public void Overrides(OverrideAdaptor controller) + public void Overrides(OverrideAdapter controller) { foreach (var button in controller.Overrides) { diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index c2933b2d98..af8fb96c85 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -43,7 +43,7 @@ namespace BizHawk.Client.Common // the "output" port for the controller chain. public static readonly CopyControllerAdapter ControllerOutput = new CopyControllerAdapter(); - public static readonly UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter(); + public static readonly UdlrControllerAdapter UD_LR_ControllerAdapter = new UdlrControllerAdapter(); public static readonly AutoFireStickyXorAdapter AutofireStickyXORAdapter = new AutoFireStickyXorAdapter(); @@ -55,7 +55,7 @@ namespace BizHawk.Client.Common /// /// Used to AND to another controller, used for JoypadApi.Set /// - public static readonly OverrideAdaptor ButtonOverrideAdaptor = new OverrideAdaptor(); + public static readonly OverrideAdapter ButtonOverrideAdaptor = new OverrideAdapter(); /// /// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons diff --git a/BizHawk.Client.Common/KeyTurbo.cs b/BizHawk.Client.Common/KeyTurbo.cs deleted file mode 100644 index d04306cfde..0000000000 --- a/BizHawk.Client.Common/KeyTurbo.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace BizHawk.Client.Common -{ - public class TurboKey - { - private int _upTime, _downTime, _timer; - - public bool Value { get; set; } - - public void Reset(int downTime, int upTime) - { - Value = false; - _timer = 0; - _upTime = upTime; - _downTime = downTime; - } - - public void Tick(bool down) - { - if (!down) - { - Reset(_downTime, _upTime); - return; - } - - _timer++; - - Value = true; - if (_timer > _downTime) - { - Value = false; - } - - if (_timer > _upTime + _downTime) - { - _timer = 0; - Value = true; - } - } - } -} \ No newline at end of file diff --git a/BizHawk.Client.Common/inputAdapters/AutoPattern.cs b/BizHawk.Client.Common/inputAdapters/AutoPattern.cs index eac3c16eb8..337504aa70 100644 --- a/BizHawk.Client.Common/inputAdapters/AutoPattern.cs +++ b/BizHawk.Client.Common/inputAdapters/AutoPattern.cs @@ -4,7 +4,6 @@ { public AutoPatternBool() { - Pattern = new[] { true }; } /// @@ -34,7 +33,7 @@ private int _index; public bool SkipsLag { get; } = true; - public bool[] Pattern { get; } + public bool[] Pattern { get; } = { true }; public int Loop { get; } /// @@ -77,7 +76,6 @@ /// public AutoPatternFloat() { - Pattern = new[] { 0f }; } /// @@ -112,7 +110,7 @@ private int _index; public bool SkipsLag { get; } = true; - public float[] Pattern { get; } + public float[] Pattern { get; } = { 0f }; public int Loop { get; } /// diff --git a/BizHawk.Client.Common/inputAdapters/OverrideAdaptor.cs b/BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs similarity index 93% rename from BizHawk.Client.Common/inputAdapters/OverrideAdaptor.cs rename to BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs index 190563209f..40efb6b4bc 100644 --- a/BizHawk.Client.Common/inputAdapters/OverrideAdaptor.cs +++ b/BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs @@ -1,118 +1,118 @@ -using System; -using System.Collections.Generic; - -using BizHawk.Emulation.Common; - -namespace BizHawk.Client.Common -{ - /// - /// Used to pass into an Override method to manage the logic overriding input - /// This only works with bool buttons! - /// - public class OverrideAdaptor : IController - { - public ControllerDefinition Definition { get; private set; } - - private readonly Dictionary _overrides = new Dictionary(); - private readonly Dictionary _floatOverrides = new Dictionary(); - private readonly List _inverses = new List(); - - /// not overridden - public bool IsPressed(string button) - { - if (_overrides.ContainsKey(button)) - { - return _overrides[button]; - } - - throw new InvalidOperationException(); - } - - public float GetFloat(string name) - { - if (_floatOverrides.ContainsKey(name)) - { - return _floatOverrides[name]; - } - - return 0.0F; - } - - public IEnumerable Overrides - { - get - { - foreach (var kvp in _overrides) - { - yield return kvp.Key; - } - } - } - - public IEnumerable FloatOverrides - { - get - { - foreach (var kvp in _floatOverrides) - { - yield return kvp.Key; - } - } - } - - public IEnumerable InversedButtons - { - get - { - foreach (var name in _inverses) - { - yield return name; - } - } - } - - public void SetFloat(string name, float value) - { - if (_floatOverrides.ContainsKey(name)) - { - _floatOverrides[name] = value; - } - else - { - _floatOverrides.Add(name, value); - } - } - - public void SetButton(string button, bool value) - { - if (_overrides.ContainsKey(button)) - { - _overrides[button] = value; - } - else - { - _overrides.Add(button, value); - } - - _inverses.Remove(button); - } - - public void UnSet(string button) - { - _overrides.Remove(button); - _inverses.Remove(button); - } - - public void SetInverse(string button) - { - _inverses.Add(button); - } - - public void FrameTick() - { - _overrides.Clear(); - _floatOverrides.Clear(); - _inverses.Clear(); - } - } -} +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.Common +{ + /// + /// Used to pass into an Override method to manage the logic overriding input + /// This only works with bool buttons! + /// + public class OverrideAdapter : IController + { + public ControllerDefinition Definition { get; private set; } + + private readonly Dictionary _overrides = new Dictionary(); + private readonly Dictionary _floatOverrides = new Dictionary(); + private readonly List _inverses = new List(); + + /// not overridden + public bool IsPressed(string button) + { + if (_overrides.ContainsKey(button)) + { + return _overrides[button]; + } + + throw new InvalidOperationException(); + } + + public float GetFloat(string name) + { + if (_floatOverrides.ContainsKey(name)) + { + return _floatOverrides[name]; + } + + return 0.0F; + } + + public IEnumerable Overrides + { + get + { + foreach (var kvp in _overrides) + { + yield return kvp.Key; + } + } + } + + public IEnumerable FloatOverrides + { + get + { + foreach (var kvp in _floatOverrides) + { + yield return kvp.Key; + } + } + } + + public IEnumerable InversedButtons + { + get + { + foreach (var name in _inverses) + { + yield return name; + } + } + } + + public void SetFloat(string name, float value) + { + if (_floatOverrides.ContainsKey(name)) + { + _floatOverrides[name] = value; + } + else + { + _floatOverrides.Add(name, value); + } + } + + public void SetButton(string button, bool value) + { + if (_overrides.ContainsKey(button)) + { + _overrides[button] = value; + } + else + { + _overrides.Add(button, value); + } + + _inverses.Remove(button); + } + + public void UnSet(string button) + { + _overrides.Remove(button); + _inverses.Remove(button); + } + + public void SetInverse(string button) + { + _inverses.Add(button); + } + + public void FrameTick() + { + _overrides.Clear(); + _floatOverrides.Clear(); + _inverses.Clear(); + } + } +} diff --git a/BizHawk.Client.Common/inputAdapters/UDLRController.cs b/BizHawk.Client.Common/inputAdapters/UDLRController.cs index 1fb383e8dc..9e4565c11a 100644 --- a/BizHawk.Client.Common/inputAdapters/UDLRController.cs +++ b/BizHawk.Client.Common/inputAdapters/UDLRController.cs @@ -9,7 +9,7 @@ namespace BizHawk.Client.Common /// Filters input for things called Up and Down while considering the client's AllowUD_LR option. /// This is a bit gross but it is unclear how to do it more nicely /// - public class UD_LR_ControllerAdapter : IController + public class UdlrControllerAdapter : IController { public ControllerDefinition Definition => Source.Definition; diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index a1a212884c..808a4cd6c9 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -338,6 +338,7 @@ True True True + True True True True @@ -356,6 +357,7 @@ True True True + True True True True @@ -428,6 +430,7 @@ True True True + True True True True @@ -439,6 +442,8 @@ True True True + True + True True True True