docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XInputController

    An XInput-compatible game controller.

    Inheritance
    object
    InputControl
    InputDevice
    Gamepad
    XInputController
    XboxOneGamepadAndroid
    XInputControllerWindows
    XboxGamepadMacOS
    XboxOneGampadMacOSWireless
    XboxOneGampadiOS
    Implements
    IDualMotorRumble
    IHaptics
    Inherited Members
    Gamepad.buttonWest
    Gamepad.buttonNorth
    Gamepad.buttonSouth
    Gamepad.buttonEast
    Gamepad.leftStickButton
    Gamepad.rightStickButton
    Gamepad.startButton
    Gamepad.selectButton
    Gamepad.dpad
    Gamepad.leftShoulder
    Gamepad.rightShoulder
    Gamepad.leftStick
    Gamepad.rightStick
    Gamepad.leftTrigger
    Gamepad.rightTrigger
    Gamepad.aButton
    Gamepad.bButton
    Gamepad.xButton
    Gamepad.yButton
    Gamepad.triangleButton
    Gamepad.squareButton
    Gamepad.circleButton
    Gamepad.crossButton
    Gamepad.this[GamepadButton]
    Gamepad.current
    Gamepad.all
    Gamepad.MakeCurrent()
    Gamepad.OnAdded()
    Gamepad.OnRemoved()
    Gamepad.PauseHaptics()
    Gamepad.ResumeHaptics()
    Gamepad.ResetHaptics()
    Gamepad.SetMotorSpeeds(float, float)
    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.XInput
    Assembly: Unity.InputSystem.dll
    Syntax
    public class XInputController : Gamepad, IDualMotorRumble, IHaptics
    Remarks

    Note that on non-Microsoft platforms, XInput controllers will not actually use the XInput interface but will rather be interfaced with through different APIs -- on OSX, for example, HID is used to interface with Xbox controlllers. In those cases, XInput-specific functionality (like XInputController.Capabilities) will not be available.

    On Windows, XInput controllers will be reported with interfaceName set to "XInput" and with a JSON representation of XINPUT_CAPABILITIES available in capabilities. This means that you match on those subType and/or flags for example.

    // Create an XInput-specific guitar layout subtype.
    // NOTE: Works only on Windows.
    InputSystem.RegisterLayout(@"
        {
            ""name"" : ""XInputGuitar"",
            ""displayName"" : ""Guitar"",
            ""extend"" : ""XInputController"",
            ""device"" : {
                ""interface"" : ""XInput"",
                ""capabilities"" : [
                    { ""path"" : ""subType"", ""value"" : ""6"" }
                ]
            }
        }
    ");

    Now, when an XInput controller is connected and reports itself with the subtype "Guitar", it is turned into an "XInputGuitar" instead of an "XInputController".

    Properties

    flags

    Return the device flags as reported by XInput.

    Declaration
    public XInputController.DeviceFlags flags { get; }
    Property Value
    Type Description
    XInputController.DeviceFlags

    XInput device flags.

    See Also
    https://docs.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_capabilities

    menu

    Same as startButton.

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

    Same control as startButton.

    subType

    What specific kind of XInput controller this is.

    Declaration
    public XInputController.DeviceSubType subType { get; }
    Property Value
    Type Description
    XInputController.DeviceSubType

    XInput device subtype.

    Remarks

    When the controller is picked up through interfaces other than XInput or through old versions of XInput, this will always be Unknown. Put another way, this value is meaningful only on recent Microsoft platforms.

    See Also
    https://docs.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes

    view

    Same as selectButton

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

    Same control as selectButton.

    Methods

    FinishSetup()

    Perform final initialization tasks after the control hierarchy has been put into place.

    Declaration
    protected override void FinishSetup()
    Overrides
    Gamepad.FinishSetup()
    Remarks

    This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.

    public class MyDevice : InputDevice
    {
    public ButtonControl button { get; private set; }
    public AxisControl axis { get; private set; }

             protected override void OnFinishSetup()
             {
                 // Cache controls in getters.
                 button = GetChildControl("button");
                 axis = GetChildControl("axis");
             }
         }</code></pre></example>
    

    Implements

    IDualMotorRumble
    IHaptics

    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
    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)