Class DualShockGamepad
A Sony DualShock/DualSense controller.
Inherited Members
Namespace: UnityEngine .InputSystem .DualShock
Assembly: Unity.InputSystem.dll
Syntax
public class DualShockGamepad : Gamepad, IDualShockHaptics, IDualMotorRumble, IHaptics
Properties
L1
The left shoulder button.
Declaration
public ButtonControl L1 { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Equivalent to left |
L2
The left trigger button.
Declaration
public ButtonControl L2 { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Equivalent to left |
L3
The left stick press button.
Declaration
public ButtonControl L3 { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Equivalent to left |
R1
The right shoulder button.
Declaration
public ButtonControl R1 { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Equivalent to right |
R2
The right trigger button.
Declaration
public ButtonControl R2 { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Equivalent to right |
R3
The right stick press button.
Declaration
public ButtonControl R3 { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Equivalent to right |
current
The last used/added DualShock controller.
Declaration
public static DualShockGamepad current { get; }
Property Value
Type | Description |
---|---|
Dual |
Equivalent to left |
optionsButton
The right side button in the middle section of the controller. Equivalent to
start
Declaration
public ButtonControl optionsButton { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Same as start |
shareButton
The left side button in the middle section of the controller. Equivalent to
select
Declaration
public ButtonControl shareButton { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Same as select |
touchpadButton
Button that is triggered when the touchbar on the controller is pressed down.
Declaration
public ButtonControl touchpadButton { get; protected set; }
Property Value
Type | Description |
---|---|
Button |
Control representing the touchbar button. |
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.
Examples
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");
}
}
MakeCurrent()
Make the gamepad the current gamepad.
Declaration
public override void MakeCurrent()
Overrides
Remarks
This is called automatically by the system when there is input on a gamepad.
More remarks are available in Make
Examples
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class MakeCurrentGamepadExample : MonoBehaviour
{
void Update()
{
/// Make the first Gamepad always the current one
if (Gamepad.all.Count > 0)
{
Gamepad.all[0].MakeCurrent();
}
}
}
OnRemoved()
Called by the system when the device is removed from devices.
Declaration
protected override void OnRemoved()
Overrides
Remarks
Examples
using UnityEngine.InputSystem;
public class MyDevice : InputDevice
{
public static MyDevice current { get; private set; }
protected override void OnRemoved()
{
// use this context to unassign the current device for instance
base.OnRemoved();
if (current == this)
current = null;
}
}
SetLightBarColor(Color)
Set the color of the light bar on the back of the controller.
Declaration
public virtual void SetLightBarColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Color to use for the light bar. Alpha component is ignored. Also, RBG values are clamped into [0..1] range. |