Actually fix `GenOrderedControls` invariant, dropping Libretro hack

fixes a8368849a and 3384ce862
This commit is contained in:
YoshiRulz 2024-12-23 02:37:56 +10:00
parent 1eb8433b4a
commit b091344896
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 4 additions and 32 deletions

View File

@ -16,15 +16,9 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException("Can't generate input display string with empty mnemonics cache");
var sb = new StringBuilder();
var controls = source.Definition.ControlsOrdered.ToList();
// index 0 is for controls that don't belong to any indexed player
if (controls.ElementAtOrDefault(0) != null)
{
controls.Add(controls[0]);
controls.RemoveAt(0);
}
foreach ((string buttonName, AxisSpec? axisSpec) in controls.SelectMany(x => x))
var players = source.Definition.ControlsOrdered;
var playersNewOrder = players.Skip(1).Concat(players.Take(1)); // move first ("player 0") to end
foreach ((string buttonName, AxisSpec? axisSpec) in playersNewOrder.SelectMany(static x => x))
{
if (axisSpec.HasValue)
{

View File

@ -114,6 +114,7 @@ namespace BizHawk.Emulation.Common
if (!_mutable) throw new InvalidOperationException(ERR_MSG);
}
/// <remarks>implementors should include empty lists for empty players, including "player 0", to match this base implementation</remarks>
protected virtual IReadOnlyList<IReadOnlyList<(string Name, AxisSpec? AxisSpec)>> GenOrderedControls()
{
var ret = new List<(string, AxisSpec?)>[PlayerCount + 1];

View File

@ -111,29 +111,6 @@ namespace BizHawk.Emulation.Cores.Libretro
MakeImmutable();
}
protected override IReadOnlyList<IReadOnlyList<(string Name, AxisSpec? AxisSpec)>> GenOrderedControls()
{
// all this is to remove the keyboard buttons from P0 and put them in P3 so they appear at the end of the input display
var players = base.GenOrderedControls().ToList();
List<(string, AxisSpec?)> retroKeyboard = new();
var p0 = (List<(string, AxisSpec?)>) players[0];
for (var i = 0; i < p0.Count; /* incremented in body */)
{
(string ButtonName, AxisSpec?) button = p0[i];
if (CategoryLabels.TryGetValue(button.ButtonName, out var v) && v is CAT_KEYBOARD)
{
retroKeyboard.Add(button);
p0.RemoveAt(i);
}
else
{
i++;
}
}
players.Add(retroKeyboard);
return players;
}
}
public ControllerDefinition ControllerDefinition { get; }