Share input surface projection policy

This commit is contained in:
Meta Vens 2026-06-21 21:20:16 +01:00
commit 8e8d680a31
3 changed files with 104 additions and 37 deletions

View file

@ -3555,6 +3555,10 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
"ActionGameManager.RequestRuntimeActionBarInput",
"action.ApplyBindingOverride",
"new InputAction(\"Aetheria Input Capture\")",
"AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths",
"AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(",
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(",
"new AetheriaRuntimeInputPathSurfaceLabel(",
"HideLegacyChildren()"
};
@ -3589,7 +3593,10 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
"ToggleActionBarInput(request.Payload)",
"private void BeginCapture(IReadOnlyDictionary<string, string> payload)",
"private void ToggleActionBarInput(IReadOnlyDictionary<string, string> payload)",
"request.Payload"
"request.Payload",
"private static readonly string[] DefaultActionBarCandidatePaths",
"private static bool IsSupportedCapturePath(string path)",
"new SortedDictionary<string, string>(StringComparer.Ordinal)"
};
var survivingLegacySymbols = forbiddenInputScreenSymbols
@ -3619,6 +3626,11 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
"public sealed class AetheriaRuntimeInputSettingsSurfaceState",
"public sealed class AetheriaRuntimeInputBindingSurfaceState",
"public sealed class AetheriaRuntimeActionBarInputSurfaceState",
"public sealed class AetheriaRuntimeInputPathSurfaceLabel",
"public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths",
"public static bool IsSupportedCapturePath(string path)",
"public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(",
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
"public enum AetheriaRuntimeInputSettingsCommandKind",
"public readonly struct AetheriaRuntimeInputSettingsSurfaceCommand",
"public static class AetheriaRuntimeInputSettingsSurfaceCommands",

View file

@ -11,21 +11,6 @@ using UnityEngine.UIElements;
public class InputDisplayLayout : MonoBehaviour
{
private static readonly string[] DefaultActionBarCandidatePaths =
{
"<Mouse>/leftButton",
"<Mouse>/rightButton",
"<Mouse>/middleButton",
"<Mouse>/forwardButton",
"<Mouse>/backButton",
"<Keyboard>/1",
"<Keyboard>/2",
"<Keyboard>/3",
"<Keyboard>/4",
"<Keyboard>/5",
"<Keyboard>/leftShift"
};
private UIDocument _surfaceDocument;
private AetheriaInput _ownedInput;
private InputAction _captureAction;
@ -202,7 +187,7 @@ public class InputDisplayLayout : MonoBehaviour
.Where(entry =>
!entry.binding.isComposite &&
!string.IsNullOrWhiteSpace(entry.binding.effectivePath) &&
IsSupportedCapturePath(entry.binding.effectivePath))
AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(entry.binding.effectivePath))
.Select(entry => new AetheriaRuntimeInputBindingSurfaceState(
entry.action.name,
entry.bindingIndex,
@ -215,18 +200,22 @@ public class InputDisplayLayout : MonoBehaviour
private IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarRows()
{
var runtimeSettings = ActionGameManager.RuntimePlayerSettings.InputSettings;
var candidates = new SortedDictionary<string, string>(StringComparer.Ordinal);
var candidates = new List<AetheriaRuntimeInputPathSurfaceLabel>();
foreach (var defaultPath in DefaultActionBarCandidatePaths)
foreach (var defaultPath in AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths)
{
candidates[defaultPath] = DescribeInputPath(defaultPath);
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
defaultPath,
DescribeInputPath(defaultPath)));
}
foreach (var inputPath in runtimeSettings.ActionBarInputs)
{
if (!string.IsNullOrWhiteSpace(inputPath))
{
candidates[inputPath] = DescribeInputPath(inputPath);
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
inputPath,
DescribeInputPath(inputPath)));
}
}
@ -236,29 +225,23 @@ public class InputDisplayLayout : MonoBehaviour
{
foreach (var binding in action.bindings)
{
if (binding.isComposite || string.IsNullOrWhiteSpace(binding.effectivePath) || !IsSupportedCapturePath(binding.effectivePath))
if (binding.isComposite ||
string.IsNullOrWhiteSpace(binding.effectivePath) ||
!AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(binding.effectivePath))
{
continue;
}
candidates[binding.effectivePath] = DescribeInputPath(binding.effectivePath);
candidates.Add(new AetheriaRuntimeInputPathSurfaceLabel(
binding.effectivePath,
DescribeInputPath(binding.effectivePath)));
}
}
}
return candidates
.Select(entry => new AetheriaRuntimeActionBarInputSurfaceState(
entry.Key,
entry.Value,
runtimeSettings.ActionBarInputs.Contains(entry.Key)))
.ToArray();
}
private static bool IsSupportedCapturePath(string path)
{
return !string.IsNullOrWhiteSpace(path) &&
(path.StartsWith("<Keyboard>/", StringComparison.Ordinal) ||
path.StartsWith("<Mouse>/", StringComparison.Ordinal));
return AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(
runtimeSettings.ActionBarInputs,
candidates);
}
private static string DescribeBinding(string actionName, InputBinding binding)
@ -362,7 +345,7 @@ public class InputDisplayLayout : MonoBehaviour
var inputPath = context.control?.path ?? "";
if (string.IsNullOrWhiteSpace(inputPath) ||
inputPath.EndsWith("anyKey", StringComparison.Ordinal) ||
!IsSupportedCapturePath(inputPath) ||
!AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(inputPath) ||
Input == null)
{
return;

View file

@ -72,8 +72,80 @@ namespace GameCult.Aetheria.State.Verse
public bool Enabled { get; }
}
public sealed class AetheriaRuntimeInputPathSurfaceLabel
{
public AetheriaRuntimeInputPathSurfaceLabel(string inputPath, string label)
{
InputPath = inputPath ?? "";
Label = label ?? "";
}
public string InputPath { get; }
public string Label { get; }
}
public static class AetheriaRuntimeInputSettingsSurfaceBuilder
{
public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths = new[]
{
"<Mouse>/leftButton",
"<Mouse>/rightButton",
"<Mouse>/middleButton",
"<Mouse>/forwardButton",
"<Mouse>/backButton",
"<Keyboard>/1",
"<Keyboard>/2",
"<Keyboard>/3",
"<Keyboard>/4",
"<Keyboard>/5",
"<Keyboard>/leftShift"
};
public static bool IsSupportedCapturePath(string path)
{
return !string.IsNullOrWhiteSpace(path) &&
(path.StartsWith("<Keyboard>/", StringComparison.Ordinal) ||
path.StartsWith("<Mouse>/", StringComparison.Ordinal));
}
public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(
IEnumerable<string> enabledInputPaths,
IEnumerable<AetheriaRuntimeInputPathSurfaceLabel> candidateInputPaths)
{
var enabledPaths = new HashSet<string>(
(enabledInputPaths ?? Array.Empty<string>()).Where(path => !string.IsNullOrWhiteSpace(path)),
StringComparer.Ordinal);
var candidates = new SortedDictionary<string, string>(StringComparer.Ordinal);
foreach (var candidate in candidateInputPaths ?? Array.Empty<AetheriaRuntimeInputPathSurfaceLabel>())
{
if (candidate == null || string.IsNullOrWhiteSpace(candidate.InputPath))
{
continue;
}
candidates[candidate.InputPath] = string.IsNullOrWhiteSpace(candidate.Label)
? candidate.InputPath
: candidate.Label;
}
foreach (var enabledPath in enabledPaths)
{
if (!candidates.ContainsKey(enabledPath))
{
candidates[enabledPath] = enabledPath;
}
}
return candidates
.Select(entry => new AetheriaRuntimeActionBarInputSurfaceState(
entry.Key,
entry.Value,
enabledPaths.Contains(entry.Key)))
.ToArray();
}
public static AetheriaRuntimeSurfaceDocument Build(
AetheriaRuntimeInputSettingsSurfaceState settings,
long version = 1)