Class XInputController
An XInput-compatible game controller.
Inherited Members
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
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
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
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>