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
This commit is contained in:
YoshiRulz 2021-03-27 11:05:35 +10:00
parent b6f1afcce8
commit 04257ec676
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 2 additions and 7 deletions

View File

@ -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