docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct InputControlScheme.DeviceRequirement

    Implements
    IEquatable<InputControlScheme.DeviceRequirement>
    Namespace: UnityEngine.InputSystem
    Assembly: Unity.InputSystem.dll
    Syntax
    [Serializable]
    public struct InputControlScheme.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 AND or in OR 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

    Control path 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
    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
    bool
    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
    isOR

    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
    bool
    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.

    isOptional

    If true, a device with the given device path 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
    bool

    Methods

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    Equals(DeviceRequirement)

    Declaration
    public bool Equals(InputControlScheme.DeviceRequirement other)
    Parameters
    Type Name Description
    InputControlScheme.DeviceRequirement other
    Returns
    Type Description
    bool

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    Operators

    operator ==(DeviceRequirement, 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
    bool

    operator !=(DeviceRequirement, 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
    bool

    Implements

    IEquatable<T>

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • controlPath
      • isAND
      • isOR
      • isOptional
    • Methods
      • Equals(object)
      • Equals(DeviceRequirement)
      • GetHashCode()
      • ToString()
    • Operators
      • operator ==(DeviceRequirement, DeviceRequirement)
      • operator !=(DeviceRequirement, DeviceRequirement)
    • Implements
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)