PCE: Hide controllers 2-5 if multitap is disabled

They have no power in that situation
This commit is contained in:
nattthebear 2020-06-13 16:39:21 -04:00
parent 2dd618b6f2
commit 60614ffa7b
2 changed files with 35 additions and 3 deletions

View File

@ -69,6 +69,21 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
["RUN"] = "Run"
};
protected override HashSet<string> ComputeHiddenPorts()
{
if (SettingsQuery("pce.input.multitap") == "1")
{
return new HashSet<string>();
}
else
{
return new HashSet<string>
{
"port2", "port3", "port4", "port5"
};
}
}
// pce always has two layers, sgx always has 4, and mednafen knows this
public bool IsSgx => SettingsInfo.LayerNames.Count == 4;

View File

@ -15,7 +15,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
private void InitControls(List<NPortInfoT> allPorts, bool hasCds)
{
_controllerAdapter = new ControllerAdapter(allPorts, _syncSettingsActual.PortDevices, ButtonNameOverrides, hasCds);
_controllerAdapter = new ControllerAdapter(
allPorts, _syncSettingsActual.PortDevices, ButtonNameOverrides, hasCds, ComputeHiddenPorts());
_nyma.SetInputDevices(_controllerAdapter.Devices);
ControllerDefinition = _controllerAdapter.Definition;
}
@ -37,7 +38,12 @@ namespace BizHawk.Emulation.Cores.Waterbox
/// </summary>
public string[] Devices { get; }
public ControllerDefinition Definition { get; }
public ControllerAdapter(List<NPortInfoT> allPorts, IDictionary<int, string> config, IDictionary<string, string> overrides, bool hasCds)
public ControllerAdapter(
List<NPortInfoT> allPorts,
IDictionary<int, string> config,
IDictionary<string, string> overrides,
bool hasCds,
HashSet<string> hiddenPorts)
{
var ret = new ControllerDefinition
{
@ -62,6 +68,9 @@ namespace BizHawk.Emulation.Cores.Waterbox
var deviceName = config.ContainsKey(port) ? config[port] : portInfo.DefaultDeviceShortName;
finalDevices.Add(deviceName);
if (hiddenPorts.Contains(portInfo.ShortName))
continue;
var devices = portInfo.Devices;
var device = devices.FirstOrDefault(a => a.ShortName == deviceName);
@ -264,6 +273,14 @@ namespace BizHawk.Emulation.Cores.Waterbox
}
}
protected virtual IDictionary<string, string> ButtonNameOverrides { get; }= new Dictionary<string, string>();
protected virtual IDictionary<string, string> ButtonNameOverrides { get; } = new Dictionary<string, string>();
/// <summary>
/// On some cores, some controller ports are not relevant when certain settings are off (like multitap).
/// Override this if your core has such an issue
/// </summary>
protected virtual HashSet<string> ComputeHiddenPorts()
{
return new HashSet<string>();
}
}
}