Struct InputControlScheme.DeviceRequirement
Inherited Members
Namespace: UnityEngine.Experimental.Input
Syntax
public struct DeviceRequirement : IEquatable<InputControlScheme.DeviceRequirement>
Remarks
Note that device requirements may require specific controls to be present rather than only requiring the presence of a certain type of device. For example, a requirement with a controlPath of "*/{PrimaryAction}" will be satisfied by any device that has a control marked as PrimaryAction.
Requirements are ordered in a list and can combine with their previous requirement in either isAND or in isOR fashion. The default is for requirements to combine with AND.
Note that it is not possible to express nested constraints like (a AND b) OR (c AND d)
. Also note that
operator precedence is the opposite of C#, meaning that OR has higher precedence than AND. This means
that a OR b AND c OR d
reads as (a OR b) AND (c OR d)
(in C# it would read as a OR
(b AND c) OR d
.
More complex expressions can often be expressed differently. For example, (a AND b) OR (c AND d)
can be expressed as a OR c AND b OR d
.
Properties
controlPath
InputControlPath that is matched against a device to determine whether it qualifies for the control scheme.
Declaration
public string controlPath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Examples
// A left-hand XR controller.
"<XRController>{LeftHand}"
// A gamepad.
"<Gamepad>"
isAND
Whether the requirement combines with the previous requirement (if any) as a boolean AND.
Declaration
public bool isAND { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This is the default. For example, to require both a left hand and a right XR controller, the first requirement would be for "<XRController>{LeftHand}" and the second requirement would be for ">XRController>{RightHand}" and would return true for this property.
See Also
isOptional
If true, a device with the given controlPath is employed by the control scheme if one is available. If none is available, the control scheme is still functional.
Declaration
public bool isOptional { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
isOR
Whether the requirement combines with the previous requirement (if any) as a boolean OR.
Declaration
public bool isOR { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This allows designing control schemes that flexibly work with combinations of devices such that if one specific device isn't present, another device can substitute for it.
For example, to design a mouse+keyboard control scheme that can alternatively work with a pen instead of a mouse, the first requirement could be for "<Keyboard>", the second one could be for "<Mouse>" and the third one could be for "<Pen>" and return true for this property. Both the mouse and the pen would be marked as required (i.e. not isOptional) but the device requirements are satisfied even if either device is present.
Note that if both a pen and a mouse are present at the same time, still only one device is picked. In this case, the mouse "wins" as it comes first in the list of requirements.
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Equals(InputControlScheme.DeviceRequirement)
Declaration
public bool Equals(InputControlScheme.DeviceRequirement other)
Parameters
Type | Name | Description |
---|---|---|
InputControlScheme.DeviceRequirement | other |
Returns
Type | Description |
---|---|
System.Boolean |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Operators
Equality(InputControlScheme.DeviceRequirement, InputControlScheme.DeviceRequirement)
Declaration
public static bool operator ==(InputControlScheme.DeviceRequirement left, InputControlScheme.DeviceRequirement right)
Parameters
Type | Name | Description |
---|---|---|
InputControlScheme.DeviceRequirement | left | |
InputControlScheme.DeviceRequirement | right |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(InputControlScheme.DeviceRequirement, InputControlScheme.DeviceRequirement)
Declaration
public static bool operator !=(InputControlScheme.DeviceRequirement left, InputControlScheme.DeviceRequirement right)
Parameters
Type | Name | Description |
---|---|---|
InputControlScheme.DeviceRequirement | left | |
InputControlScheme.DeviceRequirement | right |
Returns
Type | Description |
---|---|
System.Boolean |