Move input surface candidates into runtime

This commit is contained in:
Meta Vens 2026-06-21 23:12:59 +01:00
commit 4bb93813eb
3 changed files with 95 additions and 49 deletions

View file

@ -3584,11 +3584,9 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
"ActionGameManager.RequestRuntimeActionBarInput",
"action.ApplyBindingOverride",
"new InputAction(\"Aetheria Input Capture\")",
"AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths",
"AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(",
"AetheriaRuntimeInputSettingsSurfaceBuilder.Project(",
"new AetheriaRuntimeObservedInputBinding(",
"new AetheriaRuntimeInputPathSurfaceLabel(",
"HideLegacyChildren()"
};
@ -3630,7 +3628,9 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
"new AetheriaRuntimeInputBindingSurfaceState(",
"new AetheriaRuntimeActionBarInputSurfaceState(",
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(",
"new SortedDictionary<string, string>(StringComparer.Ordinal)"
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarCandidates(",
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
"private IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates("
};
var survivingLegacySymbols = forbiddenInputScreenSymbols
@ -3663,9 +3663,11 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
"public sealed class AetheriaRuntimeInputPathSurfaceLabel",
"public sealed class AetheriaRuntimeObservedInputBinding",
"public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths",
"public static readonly IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> DefaultActionBarCandidateInputPaths",
"public static bool IsSupportedCapturePath(string path)",
"public static AetheriaRuntimeInputSettingsSurfaceState Project(",
"public static IReadOnlyList<AetheriaRuntimeInputBindingSurfaceState> ProjectBindingInputs(",
"public static IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates(",
"public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(",
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
"public enum AetheriaRuntimeInputSettingsCommandKind",

View file

@ -168,7 +168,6 @@ public class InputDisplayLayout : MonoBehaviour
return AetheriaRuntimeInputSettingsSurfaceBuilder.Project(
ProjectObservedBindings(),
runtimeSettings.ActionBarInputs,
ProjectActionBarCandidates(runtimeSettings.ActionBarInputs),
capturePending: _captureBindingIndex >= 0 && !string.IsNullOrWhiteSpace(_captureActionName),
capturePrompt: BuildCapturePrompt(),
updatedAtUtc: DateTime.UtcNow.ToString("O"));
@ -200,51 +199,6 @@ public class InputDisplayLayout : MonoBehaviour
.ToArray();
}
private IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates(
IEnumerable<string> enabledActionBarInputPaths)
{
var candidates = new List<AetheriaRuntimeInputPathSurfaceLabel>();
foreach (var defaultPath in AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths)
{
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
defaultPath,
DescribeInputPath(defaultPath)));
}
foreach (var inputPath in enabledActionBarInputPaths ?? Array.Empty<string>())
{
if (!string.IsNullOrWhiteSpace(inputPath))
{
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
inputPath,
DescribeInputPath(inputPath)));
}
}
if (Input != null)
{
foreach (var action in Input.Where(action => action.actionMap.name != "UI"))
{
foreach (var binding in action.bindings)
{
if (binding.isComposite ||
string.IsNullOrWhiteSpace(binding.effectivePath) ||
!AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(binding.effectivePath))
{
continue;
}
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
binding.effectivePath,
DescribeInputPath(binding.effectivePath)));
}
}
}
return candidates;
}
private static string DescribeBinding(string actionName, InputBinding binding)
{
if (binding.isPartOfComposite && !string.IsNullOrWhiteSpace(binding.name))

View file

@ -128,6 +128,22 @@ namespace GameCult.Aetheria.State.Verse
"<Keyboard>/leftShift"
};
public static readonly IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> DefaultActionBarCandidateInputPaths =
new[]
{
new AetheriaRuntimeInputPathSurfaceLabel("<Mouse>/leftButton", "Left Button"),
new AetheriaRuntimeInputPathSurfaceLabel("<Mouse>/rightButton", "Right Button"),
new AetheriaRuntimeInputPathSurfaceLabel("<Mouse>/middleButton", "Middle Button"),
new AetheriaRuntimeInputPathSurfaceLabel("<Mouse>/forwardButton", "Forward Button"),
new AetheriaRuntimeInputPathSurfaceLabel("<Mouse>/backButton", "Back Button"),
new AetheriaRuntimeInputPathSurfaceLabel("<Keyboard>/1", "1"),
new AetheriaRuntimeInputPathSurfaceLabel("<Keyboard>/2", "2"),
new AetheriaRuntimeInputPathSurfaceLabel("<Keyboard>/3", "3"),
new AetheriaRuntimeInputPathSurfaceLabel("<Keyboard>/4", "4"),
new AetheriaRuntimeInputPathSurfaceLabel("<Keyboard>/5", "5"),
new AetheriaRuntimeInputPathSurfaceLabel("<Keyboard>/leftShift", "Left Shift")
};
public static bool IsSupportedCapturePath(string path)
{
return !string.IsNullOrWhiteSpace(path) &&
@ -135,6 +151,26 @@ namespace GameCult.Aetheria.State.Verse
path.StartsWith("<Mouse>/", StringComparison.Ordinal));
}
public static AetheriaRuntimeInputSettingsSurfaceState Project(
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings,
IEnumerable<string> enabledActionBarInputPaths,
bool capturePending,
string capturePrompt,
string updatedAtUtc)
{
var observed = (observedBindings ?? Array.Empty<AetheriaRuntimeObservedInputBinding>())
.Where(binding => binding != null)
.ToArray();
return Project(
observed,
enabledActionBarInputPaths,
ProjectActionBarCandidates(observed, enabledActionBarInputPaths),
capturePending,
capturePrompt,
updatedAtUtc);
}
public static AetheriaRuntimeInputSettingsSurfaceState Project(
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings,
IEnumerable<string> enabledActionBarInputPaths,
@ -170,6 +206,41 @@ namespace GameCult.Aetheria.State.Verse
.ToArray();
}
public static IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates(
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings,
IEnumerable<string> enabledInputPaths)
{
var candidates = new List<AetheriaRuntimeInputPathSurfaceLabel>();
candidates.AddRange(DefaultActionBarCandidateInputPaths);
foreach (var inputPath in enabledInputPaths ?? Array.Empty<string>())
{
if (!string.IsNullOrWhiteSpace(inputPath))
{
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
inputPath,
ReadInputLabel(inputPath, observedBindings)));
}
}
foreach (var binding in observedBindings ?? Array.Empty<AetheriaRuntimeObservedInputBinding>())
{
if (binding == null ||
!binding.Include ||
string.IsNullOrWhiteSpace(binding.InputPath) ||
!IsSupportedCapturePath(binding.InputPath))
{
continue;
}
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
binding.InputPath,
string.IsNullOrWhiteSpace(binding.InputLabel) ? binding.InputPath : binding.InputLabel));
}
return candidates;
}
public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(
IEnumerable<string> enabledInputPaths,
IEnumerable<AetheriaRuntimeInputPathSurfaceLabel> candidateInputPaths)
@ -207,6 +278,25 @@ namespace GameCult.Aetheria.State.Verse
.ToArray();
}
private static string ReadInputLabel(
string inputPath,
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings)
{
foreach (var binding in observedBindings ?? Array.Empty<AetheriaRuntimeObservedInputBinding>())
{
if (binding == null ||
!string.Equals(binding.InputPath, inputPath, StringComparison.Ordinal) ||
string.IsNullOrWhiteSpace(binding.InputLabel))
{
continue;
}
return binding.InputLabel;
}
return inputPath;
}
public static AetheriaRuntimeSurfaceDocument Build(
AetheriaRuntimeInputSettingsSurfaceState settings,
long version = 1)