docs.unity.cn

Input System 1.12.0

Search Results for

    Show / Hide Table of Contents

    Class Joystick

    A joystick with an arbitrary number of buttons and axes.

    Inheritance
    object
    InputControl
    InputDevice
    Joystick
    AndroidJoystick
    WebGLJoystick
    Inherited Members
    InputDevice.InvalidDeviceId
    InputDevice.description
    InputDevice.enabled
    InputDevice.canRunInBackground
    InputDevice.added
    InputDevice.remote
    InputDevice.native
    InputDevice.updateBeforeRender
    InputDevice.deviceId
    InputDevice.lastUpdateTime
    InputDevice.wasUpdatedThisFrame
    InputDevice.allControls
    InputDevice.valueType
    InputDevice.valueSizeInBytes
    InputDevice.ReadValueFromBufferAsObject(void*, int)
    InputDevice.ReadValueFromStateAsObject(void*)
    InputDevice.ReadValueFromStateIntoBuffer(void*, void*, int)
    InputDevice.CompareValue(void*, void*)
    InputDevice.OnConfigurationChanged()
    InputDevice.ExecuteCommand<TCommand>(ref TCommand)
    InputDevice.ExecuteCommand(InputDeviceCommand*)
    InputControl.name
    InputControl.displayName
    InputControl.shortDisplayName
    InputControl.path
    InputControl.layout
    InputControl.variants
    InputControl.device
    InputControl.parent
    InputControl.children
    InputControl.usages
    InputControl.aliases
    InputControl.stateBlock
    InputControl.noisy
    InputControl.synthetic
    InputControl.this[string]
    InputControl.magnitude
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.EvaluateMagnitude(void*)
    InputControl.WriteValueFromBufferIntoState(void*, int, void*)
    InputControl.WriteValueFromObjectIntoState(object, void*)
    InputControl.TryGetChildControl(string)
    InputControl.TryGetChildControl<TControl>(string)
    InputControl.GetChildControl(string)
    InputControl.GetChildControl<TControl>(string)
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.RefreshConfiguration()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    InputControl.optimizedControlDataType
    InputControl.CalculateOptimizedControlDataType()
    InputControl.ApplyParameterChanges()
    Namespace: UnityEngine.InputSystem
    Assembly: Unity.InputSystem.dll
    Syntax
    public class Joystick : InputDevice
    Remarks

    Joysticks are somewhat hard to classify as there is little commonality other than that there is one main stick 2D control and at least one button. From the input system perspective, everything that is not a Gamepad and that has at least one stick and one trigger control is considered a candidate for being a joystick.

    Optionally, a joystick may also have the ability to twist, i.e. for the stick to rotate around its own axis, and at least one hatswitch.

    Note that devices based on Joystick may have many more controls. Joystick itself only defines a minimum required to separate joysticks as a concept from other types of devices.

    Properties

    all

    A list of joysticks currently connected to the system.

    Declaration
    public static ReadOnlyArray<Joystick> all { get; }
    Property Value
    Type Description
    ReadOnlyArray<Joystick>

    All currently connected joystick.

    Remarks

    Does not cause GC allocation.

    Do not hold on to the value returned by this getter but rather query it whenever you need it. Whenever the joystick setup changes, the value returned by this getter is invalidated.

    See Also
    current

    current

    The joystick that was added or used last. Null if there is none.

    Declaration
    public static Joystick current { get; }
    Property Value
    Type Description
    Joystick

    Joystick that was added or used last.

    Remarks

    See MakeCurrent() for details about when a device is made current.

    See Also
    all

    hatswitch

    An optional control representing a four-way "hat switch" on the joystick. If not supported, will be null.

    Declaration
    public Vector2Control hatswitch { get; protected set; }
    Property Value
    Type Description
    Vector2Control

    Control representing a hatswitch on the joystick.

    Remarks

    Hat switches are usually thumb-operated four-way switches that operate much like the "d-pad" on a gamepad (see dpad). If present, this is the Vector2Control type control on the joystick that has the Hatswitch usage.

    stick

    The 2D axis of the stick itself.

    Declaration
    public StickControl stick { get; protected set; }
    Property Value
    Type Description
    StickControl

    Control representing the main joystick axis.

    Remarks

    This is the StickControl type control on the joystick that has the Primary2DMotion usage.

    trigger

    The primary trigger button of the joystick.

    Declaration
    public ButtonControl trigger { get; protected set; }
    Property Value
    Type Description
    ButtonControl

    Control representing the primary trigger button.

    Remarks

    This is the ButtonControl type control on the joystick that has the PrimaryTrigger usage.

    twist

    An optional control representing the rotation of the stick around its own axis (i.e. side-to-side circular motion). If not supported, will be null.

    Declaration
    public AxisControl twist { get; protected set; }
    Property Value
    Type Description
    AxisControl

    Control representing the twist motion of the joystick.

    Remarks

    This is the AxisControl type control on the joystick that has the Twist usage.

    Methods

    FinishSetup()

    Called when the joystick has been created but before it is added to the system.

    Declaration
    protected override void FinishSetup()
    Overrides
    InputControl.FinishSetup()

    MakeCurrent()

    Make the joystick the current one.

    Declaration
    public override void MakeCurrent()
    Overrides
    InputDevice.MakeCurrent()
    Remarks

    This is called automatically by the input system when a device receives input or is added to the system. See MakeCurrent() for details.

    OnAdded()

    Called when the joystick is added to the system.

    Declaration
    protected override void OnAdded()
    Overrides
    InputDevice.OnAdded()

    OnRemoved()

    Called when the joystick is removed from the system.

    Declaration
    protected override void OnRemoved()
    Overrides
    InputDevice.OnRemoved()

    Extension Methods

    InputControlExtensions.CheckStateIsAtDefault(InputControl)
    InputControlExtensions.CheckStateIsAtDefault(InputControl, void*, void*)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl, void*)
    InputControlExtensions.CompareState(InputControl, void*, void*)
    InputControlExtensions.CompareState(InputControl, void*, void*, void*)
    InputControlExtensions.CompareStateIgnoringNoise(InputControl, void*)
    InputControlExtensions.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, bool>)
    InputControlExtensions.FindInParentChain<TControl>(InputControl)
    InputControlExtensions.GetStatePtrFromStateEvent(InputControl, InputEventPtr)
    InputControlExtensions.HasValueChangeInEvent(InputControl, InputEventPtr)
    InputControlExtensions.HasValueChangeInState(InputControl, void*)
    InputControlExtensions.IsActuated(InputControl, float)
    InputControlExtensions.IsPressed(InputControl, float)
    InputControlExtensions.ReadDefaultValueAsObject(InputControl)
    InputControlExtensions.ReadValueAsObject(InputControl)
    InputControlExtensions.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.ReadValueIntoBuffer(InputControl, void*, int)
    InputControlExtensions.ResetToDefaultStateInEvent(InputControl, InputEventPtr)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, object)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoState(InputControl, void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, void*)
    InputControlExtensions.CopyState(InputDevice, void*, int)
    InputControlExtensions.CopyState<TState>(InputDevice, out TState)
    In This Article
    • Properties
      • all
      • current
      • hatswitch
      • stick
      • trigger
      • twist
    • Methods
      • FinishSetup()
      • MakeCurrent()
      • OnAdded()
      • OnRemoved()
    • Extension Methods
    Back to top
    Copyright © 2025 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)