From 04257ec676df387ec5138d351d21d4cb799cc4a3 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 27 Mar 2021 11:05:35 +1000 Subject: [PATCH] Resolve TODO in Controller.NormalizeAxes _axes and _axisRanges have the same keys, and should probably be one dict, and _axisBindings has the same keys or a subset --- src/BizHawk.Client.Common/Controller.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/BizHawk.Client.Common/Controller.cs b/src/BizHawk.Client.Common/Controller.cs index 862312de13..29528e74de 100644 --- a/src/BizHawk.Client.Common/Controller.cs +++ b/src/BizHawk.Client.Common/Controller.cs @@ -53,7 +53,7 @@ namespace BizHawk.Client.Common { foreach (var kvp in _axisBindings) { - if (!_axisRanges.TryGetValue(kvp.Key, out var range)) continue; //TODO throw (or use indexer instead of TryGetValue)? this `continue` should never be hit --yoshi + var range = _axisRanges[kvp.Key]; // values of _axes are ints in -10000..10000 (or 0..10000), so scale to -1..1, using floats to keep fractional part var value = _axes[kvp.Key] / 10000.0f; @@ -99,12 +99,7 @@ namespace BizHawk.Client.Common foreach (var kvp in _axisBindings) { - var input = controller.AxisValue(kvp.Value.Value); - string outKey = kvp.Key; - if (_axisRanges.ContainsKey(outKey)) - { - _axes[outKey] = input; - } + _axes[kvp.Key] = controller.AxisValue(kvp.Value.Value); } // it's not sure where this should happen, so for backwards compatibility.. do it every time