Pizza: Only show one controller in GB mode

This commit is contained in:
nattthebear 2017-06-28 22:23:03 -04:00
parent 203a0521b5
commit 2a15502999
1 changed files with 17 additions and 8 deletions

View File

@ -85,23 +85,32 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
#region Controller #region Controller
private static readonly ControllerDefinition _definition; private static readonly ControllerDefinition _gbDefinition;
public override ControllerDefinition ControllerDefinition => _definition; private static readonly ControllerDefinition _sgbDefinition;
public override ControllerDefinition ControllerDefinition => _sgb ? _sgbDefinition : _gbDefinition;
static Pizza() private static ControllerDefinition CreateControllerDefinition(int p)
{ {
_definition = new ControllerDefinition { Name = "Gameboy Controller" }; var ret = new ControllerDefinition { Name = "Gameboy Controller" };
for (int i = 0; i < 4; i++) for (int i = 0; i < p; i++)
{ {
_definition.BoolButtons.AddRange( ret.BoolButtons.AddRange(
new[] { "Up", "Down", "Left", "Right", "A", "B", "Select", "Start" } new[] { "Up", "Down", "Left", "Right", "A", "B", "Select", "Start" }
.Select(s => $"P{i + 1} {s}")); .Select(s => $"P{i + 1} {s}"));
} }
return ret;
} }
private static LibPizza.Buttons GetButtons(IController c)
static Pizza()
{
_gbDefinition = CreateControllerDefinition(1);
_sgbDefinition = CreateControllerDefinition(4);
}
private LibPizza.Buttons GetButtons(IController c)
{ {
LibPizza.Buttons b = 0; LibPizza.Buttons b = 0;
for (int i = 4; i > 0; i--) for (int i = _sgb ? 4 : 1; i > 0; i--)
{ {
if (c.IsPressed($"P{i} Up")) if (c.IsPressed($"P{i} Up"))
b |= LibPizza.Buttons.UP; b |= LibPizza.Buttons.UP;