Convert `Bk2Controller.ControlMap` to a struct
This commit is contained in:
parent
bbebe88179
commit
1049a091c0
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
|
@ -16,12 +17,7 @@ namespace BizHawk.Client.Common
|
||||||
private IList<ControlMap> _controlsOrdered;
|
private IList<ControlMap> _controlsOrdered;
|
||||||
|
|
||||||
private IList<ControlMap> ControlsOrdered => _controlsOrdered ??= _type.OrderedControlsFlat
|
private IList<ControlMap> ControlsOrdered => _controlsOrdered ??= _type.OrderedControlsFlat
|
||||||
.Select(c => new ControlMap
|
.Select(name => new ControlMap(name, _type))
|
||||||
{
|
|
||||||
Name = c,
|
|
||||||
IsBool = _type.BoolButtons.Contains(c),
|
|
||||||
IsAxis = _type.Axes.ContainsKey(c)
|
|
||||||
})
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
public IInputDisplayGenerator InputDisplayGenerator { get; set; } = null;
|
public IInputDisplayGenerator InputDisplayGenerator { get; set; } = null;
|
||||||
|
@ -123,11 +119,27 @@ namespace BizHawk.Client.Common
|
||||||
_myAxisControls[buttonName] = value;
|
_myAxisControls[buttonName] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ControlMap
|
private readonly struct ControlMap
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public readonly bool IsAxis;
|
||||||
public bool IsBool { get; set; }
|
|
||||||
public bool IsAxis { get; set; }
|
public readonly bool IsBool;
|
||||||
|
|
||||||
|
public readonly string Name;
|
||||||
|
|
||||||
|
public ControlMap(string name, bool isButton, bool isAxis)
|
||||||
|
{
|
||||||
|
Debug.Assert(isButton ^ isAxis, "axis conflicts with button of the same name?");
|
||||||
|
Name = name;
|
||||||
|
IsBool = isButton;
|
||||||
|
IsAxis = isAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlMap(string name, ControllerDefinition def)
|
||||||
|
: this(
|
||||||
|
name: name,
|
||||||
|
isButton: def.BoolButtons.Contains(name),
|
||||||
|
isAxis: def.Axes.ContainsKey(name)) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Bk2ControllerDefinition : ControllerDefinition
|
private class Bk2ControllerDefinition : ControllerDefinition
|
||||||
|
|
Loading…
Reference in New Issue