Move input surface candidates into runtime
This commit is contained in:
parent
3370802cd0
commit
4bb93813eb
3 changed files with 95 additions and 49 deletions
|
|
@ -3584,11 +3584,9 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
|
||||||
"ActionGameManager.RequestRuntimeActionBarInput",
|
"ActionGameManager.RequestRuntimeActionBarInput",
|
||||||
"action.ApplyBindingOverride",
|
"action.ApplyBindingOverride",
|
||||||
"new InputAction(\"Aetheria Input Capture\")",
|
"new InputAction(\"Aetheria Input Capture\")",
|
||||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths",
|
|
||||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(",
|
"AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(",
|
||||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.Project(",
|
"AetheriaRuntimeInputSettingsSurfaceBuilder.Project(",
|
||||||
"new AetheriaRuntimeObservedInputBinding(",
|
"new AetheriaRuntimeObservedInputBinding(",
|
||||||
"new AetheriaRuntimeInputPathSurfaceLabel(",
|
|
||||||
"HideLegacyChildren()"
|
"HideLegacyChildren()"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -3630,7 +3628,9 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
|
||||||
"new AetheriaRuntimeInputBindingSurfaceState(",
|
"new AetheriaRuntimeInputBindingSurfaceState(",
|
||||||
"new AetheriaRuntimeActionBarInputSurfaceState(",
|
"new AetheriaRuntimeActionBarInputSurfaceState(",
|
||||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(",
|
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(",
|
||||||
"new SortedDictionary<string, string>(StringComparer.Ordinal)"
|
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarCandidates(",
|
||||||
|
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
|
||||||
|
"private IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates("
|
||||||
};
|
};
|
||||||
|
|
||||||
var survivingLegacySymbols = forbiddenInputScreenSymbols
|
var survivingLegacySymbols = forbiddenInputScreenSymbols
|
||||||
|
|
@ -3663,9 +3663,11 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
|
||||||
"public sealed class AetheriaRuntimeInputPathSurfaceLabel",
|
"public sealed class AetheriaRuntimeInputPathSurfaceLabel",
|
||||||
"public sealed class AetheriaRuntimeObservedInputBinding",
|
"public sealed class AetheriaRuntimeObservedInputBinding",
|
||||||
"public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths",
|
"public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths",
|
||||||
|
"public static readonly IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> DefaultActionBarCandidateInputPaths",
|
||||||
"public static bool IsSupportedCapturePath(string path)",
|
"public static bool IsSupportedCapturePath(string path)",
|
||||||
"public static AetheriaRuntimeInputSettingsSurfaceState Project(",
|
"public static AetheriaRuntimeInputSettingsSurfaceState Project(",
|
||||||
"public static IReadOnlyList<AetheriaRuntimeInputBindingSurfaceState> ProjectBindingInputs(",
|
"public static IReadOnlyList<AetheriaRuntimeInputBindingSurfaceState> ProjectBindingInputs(",
|
||||||
|
"public static IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates(",
|
||||||
"public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(",
|
"public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(",
|
||||||
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
|
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
|
||||||
"public enum AetheriaRuntimeInputSettingsCommandKind",
|
"public enum AetheriaRuntimeInputSettingsCommandKind",
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,6 @@ public class InputDisplayLayout : MonoBehaviour
|
||||||
return AetheriaRuntimeInputSettingsSurfaceBuilder.Project(
|
return AetheriaRuntimeInputSettingsSurfaceBuilder.Project(
|
||||||
ProjectObservedBindings(),
|
ProjectObservedBindings(),
|
||||||
runtimeSettings.ActionBarInputs,
|
runtimeSettings.ActionBarInputs,
|
||||||
ProjectActionBarCandidates(runtimeSettings.ActionBarInputs),
|
|
||||||
capturePending: _captureBindingIndex >= 0 && !string.IsNullOrWhiteSpace(_captureActionName),
|
capturePending: _captureBindingIndex >= 0 && !string.IsNullOrWhiteSpace(_captureActionName),
|
||||||
capturePrompt: BuildCapturePrompt(),
|
capturePrompt: BuildCapturePrompt(),
|
||||||
updatedAtUtc: DateTime.UtcNow.ToString("O"));
|
updatedAtUtc: DateTime.UtcNow.ToString("O"));
|
||||||
|
|
@ -200,51 +199,6 @@ public class InputDisplayLayout : MonoBehaviour
|
||||||
.ToArray();
|
.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)
|
private static string DescribeBinding(string actionName, InputBinding binding)
|
||||||
{
|
{
|
||||||
if (binding.isPartOfComposite && !string.IsNullOrWhiteSpace(binding.name))
|
if (binding.isPartOfComposite && !string.IsNullOrWhiteSpace(binding.name))
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,22 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
"<Keyboard>/leftShift"
|
"<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)
|
public static bool IsSupportedCapturePath(string path)
|
||||||
{
|
{
|
||||||
return !string.IsNullOrWhiteSpace(path) &&
|
return !string.IsNullOrWhiteSpace(path) &&
|
||||||
|
|
@ -135,6 +151,26 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
path.StartsWith("<Mouse>/", StringComparison.Ordinal));
|
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(
|
public static AetheriaRuntimeInputSettingsSurfaceState Project(
|
||||||
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings,
|
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings,
|
||||||
IEnumerable<string> enabledActionBarInputPaths,
|
IEnumerable<string> enabledActionBarInputPaths,
|
||||||
|
|
@ -170,6 +206,41 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
.ToArray();
|
.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(
|
public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(
|
||||||
IEnumerable<string> enabledInputPaths,
|
IEnumerable<string> enabledInputPaths,
|
||||||
IEnumerable<AetheriaRuntimeInputPathSurfaceLabel> candidateInputPaths)
|
IEnumerable<AetheriaRuntimeInputPathSurfaceLabel> candidateInputPaths)
|
||||||
|
|
@ -207,6 +278,25 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
.ToArray();
|
.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(
|
public static AetheriaRuntimeSurfaceDocument Build(
|
||||||
AetheriaRuntimeInputSettingsSurfaceState settings,
|
AetheriaRuntimeInputSettingsSurfaceState settings,
|
||||||
long version = 1)
|
long version = 1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue