Class InputControlPathUtil
Reads the <Device> prefix out of a Unity Input System control path.
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public static class InputControlPathUtil
Remarks
Lives beside the conflict engine rather than with the rebinding helpers because the engine must not depend on anything under the rebinding namespace: the same rules run at edit time, where no rebinding manager exists.
Methods
DevicePrefixMatches(string, int, int, string, int, int)
Reports whether two already-located device prefixes match, comparing spans so no substring is allocated.
Declaration
public static bool DevicePrefixMatches(string pathA, int startA, int lengthA, string pathB, int startB, int lengthB)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pathA | First control path. |
| int | startA | Start of the first prefix. |
| int | lengthA | Length of the first prefix, or zero for none. |
| string | pathB | Second control path. |
| int | startB | Start of the second prefix. |
| int | lengthB | Length of the second prefix, or zero for none. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
This is the overload the conflict engine calls, using ranges precomputed once per binding rather than rescanned on every comparison. A length of zero encodes "no recognizable prefix" and matches unconditionally, which is unambiguous because a real prefix is at least one character.
DevicePrefixMatches(string, string)
Reports whether two control paths name the same device class.
Declaration
public static bool DevicePrefixMatches(string pathA, string pathB)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pathA | First control path. |
| string | pathB | Second control path. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
A path with no recognizable prefix matches everything. That is deliberate: the answer feeds a conflict check, and the conservative outcome is to let the check proceed rather than exclude a pair on the strength of an unparseable path.
GetDevicePrefix(string)
Extracts the device prefix from a control path, for example Keyboard from
<Keyboard>/space.
Declaration
public static string GetDevicePrefix(string controlPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | controlPath | The control path. |
Returns
| Type | Description |
|---|---|
| string | The prefix, or an empty string when the path carries none. |
TryFindDevicePrefixRange(string, out int, out int)
Locates the device prefix inside a control path and returns its inner range, between the angle brackets, without allocating.
Declaration
public static bool TryFindDevicePrefixRange(string controlPath, out int start, out int length)
Parameters
| Type | Name | Description |
|---|---|---|
| string | controlPath | The control path, for example |
| int | start | Index of the first character after the opening bracket. |
| int | length | Number of characters before the closing bracket. |
Returns
| Type | Description |
|---|---|
| bool |
|