Rework nyma controller overrides
This commit is contained in:
parent
5b2b1cf13b
commit
b8bea93cce
|
@ -0,0 +1,22 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
|
{
|
||||||
|
partial class NymaCore
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Override button names. Technically this should be per core, but a lot of the names and overrides are the same,
|
||||||
|
/// and an override that doesn't apply to a particular core will just be ignored
|
||||||
|
/// </summary>
|
||||||
|
private string OverrideButtonName(string original)
|
||||||
|
{
|
||||||
|
original = Regex.Replace(original, @"\s*(↑|↓|←|→)\s*", "");
|
||||||
|
original = Regex.Replace(original, @"\s*\([^\)]+\)\s*", "");
|
||||||
|
original = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(original.ToLowerInvariant());
|
||||||
|
// TODO: Add dictionaries or whatever here as needed
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
private void InitControls(List<NPortInfoT> allPorts, bool hasCds, ref SystemInfo si)
|
private void InitControls(List<NPortInfoT> allPorts, bool hasCds, ref SystemInfo si)
|
||||||
{
|
{
|
||||||
_controllerAdapter = new ControllerAdapter(
|
_controllerAdapter = new ControllerAdapter(
|
||||||
allPorts, _syncSettingsActual.PortDevices, ButtonNameOverrides, hasCds, ref si, ComputeHiddenPorts());
|
allPorts, _syncSettingsActual.PortDevices, OverrideButtonName, hasCds, ref si, ComputeHiddenPorts());
|
||||||
_nyma.SetInputDevices(_controllerAdapter.Devices);
|
_nyma.SetInputDevices(_controllerAdapter.Devices);
|
||||||
ControllerDefinition = _controllerAdapter.Definition;
|
ControllerDefinition = _controllerAdapter.Definition;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
public ControllerAdapter(
|
public ControllerAdapter(
|
||||||
List<NPortInfoT> allPorts,
|
List<NPortInfoT> allPorts,
|
||||||
IDictionary<int, string> config,
|
IDictionary<int, string> config,
|
||||||
IDictionary<string, string> overrides,
|
Func<string, string> overrideName,
|
||||||
bool hasCds,
|
bool hasCds,
|
||||||
ref SystemInfo systemInfo,
|
ref SystemInfo systemInfo,
|
||||||
HashSet<string> hiddenPorts)
|
HashSet<string> hiddenPorts)
|
||||||
|
@ -100,8 +100,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
var byteStart = devByteStart + bitOffset / 8;
|
var byteStart = devByteStart + bitOffset / 8;
|
||||||
bitOffset %= 8;
|
bitOffset %= 8;
|
||||||
var baseName = input.Name;
|
var baseName = input.Name;
|
||||||
if (baseName != null && overrides.ContainsKey(baseName))
|
if (baseName != null)
|
||||||
baseName = overrides[baseName];
|
baseName = overrideName(baseName);
|
||||||
var name = input.Type == InputType.ResetButton ? "Reset" : $"P{port + 1} {baseName}";
|
var name = input.Type == InputType.ResetButton ? "Reset" : $"P{port + 1} {baseName}";
|
||||||
|
|
||||||
switch (input.Type)
|
switch (input.Type)
|
||||||
|
@ -303,7 +303,6 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual IDictionary<string, string> ButtonNameOverrides { get; } = new Dictionary<string, string>();
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// On some cores, some controller ports are not relevant when certain settings are off (like multitap).
|
/// 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
|
/// Override this if your core has such an issue
|
||||||
|
|
Loading…
Reference in New Issue