docs.unity3d.com
    Show / Hide Table of Contents

    Struct GamepadState

    Default state layout for gamepads.

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Namespace: UnityEngine.InputSystem.LowLevel
    Syntax
    public struct GamepadState : IInputStateTypeInfo
    Remarks

    Be aware that unlike some other devices such as Mouse or Touchscreen, gamepad devices tend to have wildly varying state formats, i.e. forms in which they internally store their input data. In practice, even on the same platform gamepads will often store their data in different formats. This means that GamepadState will often not be the format in which a particular gamepad (such as XInputController, for example) stores its data.

    Constructors

    GamepadState(GamepadButton[])

    Create a gamepad state with the given buttons being pressed.

    Declaration
    public GamepadState(params GamepadButton[] buttons)
    Parameters
    Type Name Description
    GamepadButton[] buttons

    Buttons to put into pressed state.

    Exceptions
    Type Condition
    ArgumentNullException

    buttons is null.

    Fields

    buttons

    Button bit mask.

    Declaration
    public uint buttons
    Field Value
    Type Description
    UInt32

    Button bit mask.

    See Also
    GamepadButton
    buttonSouth
    buttonNorth
    buttonWest
    buttonSouth
    leftShoulder
    rightShoulder
    startButton
    selectButton
    leftStickButton
    rightStickButton

    leftStick

    Left stick position. Each axis goes from -1 to 1 with 0 being center position.

    Declaration
    public Vector2 leftStick
    Field Value
    Type Description
    Vector2

    Left stick position.

    See Also
    leftStick

    leftTrigger

    Position of the left trigger. Goes from 0 (not pressed) to 1 (fully pressed).

    Declaration
    public float leftTrigger
    Field Value
    Type Description
    Single

    Position of left trigger.

    See Also
    leftTrigger

    rightStick

    Right stick position. Each axis from -1 to 1 with 0 being center position.

    Declaration
    public Vector2 rightStick
    Field Value
    Type Description
    Vector2

    Right stick position.

    See Also
    rightStick

    rightTrigger

    Position of the right trigger. Goes from 0 (not pressed) to 1 (fully pressed).

    Declaration
    public float rightTrigger
    Field Value
    Type Description
    Single

    Position of right trigger.

    See Also
    rightTrigger

    Properties

    format

    State format tag for GamepadState.

    Declaration
    public readonly FourCC format { get; }
    Property Value
    Type Description
    FourCC

    Returns "GPAD".

    Implements
    IInputStateTypeInfo.format

    Format

    Declaration
    public static readonly FourCC Format { get; }
    Property Value
    Type Description
    FourCC

    Methods

    WithButton(GamepadButton, Boolean)

    Set the specific buttons to be pressed or unpressed.

    Declaration
    public GamepadState WithButton(GamepadButton button, bool value = true)
    Parameters
    Type Name Description
    GamepadButton button

    A gamepad button.

    Boolean value

    Whether to set button to be pressed or not pressed in buttons.

    Returns
    Type Description
    GamepadState

    GamepadState with a modified buttons mask.

    See Also

    Gamepad
    In This Article
    • Constructors
      • GamepadState(GamepadButton[])
    • Fields
      • buttons
      • leftStick
      • leftTrigger
      • rightStick
      • rightTrigger
    • Properties
      • format
      • Format
    • Methods
      • WithButton(GamepadButton, Boolean)
    • See Also
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023