Click or drag to resize

DualShock4Extension Class

Allows access to controller-specific functions such as vibration. This extension only applies to desktop platforms. For the PS4 platform, see the PS4 plugin documentation.
Inheritance Hierarchy
SystemObject
  RewiredControllerExtension
    Rewired.ControllerExtensionsDualShock4Extension

Namespace:  Rewired.ControllerExtensions
Assembly:  Rewired_Core (in Rewired_Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public sealed class DualShock4Extension : ControllerExtension, 
	IControllerVibrator, IDualShock4Extension, IHIDControllerExtension

The DualShock4Extension type exposes the following members.

Properties
  NameDescription
Public propertybatteryCharging
Is the battery charging?
Public propertybatteryLevel
Battery level as a percentage. [0 - 100]
Public propertycontroller
The parent controller of this extension.
(Inherited from ControllerExtension.)
Public propertylightColorBlue
Light color blue channel.
Public propertylightColorGreen
Light color green channel.
Public propertylightColorRed
Light color red channel.
Public propertymaxTouches
Number of simultaneous touches supported by this device.
Public propertytouchCount
The current touch count.
Public propertyvibrationMotorCount
The number of vibration motors in this controller.
Top
Methods
  NameDescription
Public methodGetAccelerometerValue
Gets the value from the accelerometer and processes it so that 1G = 1.0 and so that coordinates match Unity coordinate system. The value returned could be thought of as a gravity vector and user acceleration combined. If using this value to apply a force in the direction of the vector, invert each axis first. This value represents the last value reported by the accelerometer.
Public methodGetAccelerometerValueRaw
Gets the raw value from the accelerometer as reported by the device. Reported device coordinates do not match Unity's coordinate system. Format: 1G = 8192f This value represents the last value reported by the accelerometer.
Public methodGetGyroscopeValue
Gets the value from the gyroscope processed into Unity's coordinate system, adjusted for sensitivity, and accumulated over time since the last update. This value is not fused with the accelerometer value and can drift.
Public methodGetGyroscopeValueRaw
Gets the raw value from the gyroscope as reported by the device accumulated over time since the last update. Reported device coordinates do not match Unity's coordinate system. This value is not fused with the accelerometer value and can drift.
Public methodGetLastGyroscopeValue
Gets the last value from the gyroscope processed into Unity's coordinate system and adjusted for sensitivity. The sensor can return more than one value per frame. This represents only the last measurement recorded, not an accumulated value. This value is not fused with the accelerometer value and can drift.
Public methodGetLastGyroscopeValueRaw
Gets the last raw value from the gyroscope as reported by the device. Reported device coordinates do not match Unity's coordinate system. The sensor can return more than one value per frame. This represents only the last measurement recorded, not an accumulated value. This value is not fused with the accelerometer value and can drift.
Public methodGetLightColor
Gets the current light color.
Public methodGetOrientation
Gets the orientation of the controller in Unity coordinates. This is only an estimate because accelerometer + gyroscope is not accurate enough to perfectly determine orientation at all angles. Drift can occur on the world Y axis over time. The orientation can be reset by calling ResetOrientation(). Note: Orientation is not very reliable when connected via Bluetooth due to the possibility of dropped gyro data.
Public methodGetTouchId
Gets the touch id for the touch at the specified index.
Public methodGetTouchPosition
Gets the touch position for a particular index normalized to a 0 - 1 range. (Left = 0, Bottom = 0)
Public methodGetTouchPositionAbsolute
Gets the touch position for a particular index in absolute units as returned by the device. (Left = 0, Bottom = 0)
Public methodGetTouchPositionAbsoluteByTouchId
Gets the touch position for a particular touch id in absolute units as returned by the device. (Left = 0, Bottom = 0)
Public methodGetTouchPositionByTouchId
Gets the touch position for a particular touch id normalized to a 0 - 1 range. (Left = 0, Bottom = 0)
Public methodGetVibration(Int32)
Gets vibration level for a motor at a specified index.
Public methodGetVibration(DualShock4MotorType)
Gets vibration level for a specific motor.
Public methodIsTouching
Determines if the current touch id is valid for any currently active touch.
Public methodIsTouchingByTouchId
Determines if the current touch id is valid for any currently active touch.
Public methodResetOrientation
Resets the orientation to zero state. (Controller laying on back with buttons facing up and the top edge of the controller facing the screen.)
Public methodSetLightColor(Color)
Sets the light color. Alpha can be used to set intensity.
Public methodSetLightColor(Single, Single, Single)
Sets the light color.
Public methodSetLightColor(Single, Single, Single, Single)
Sets the light color.
Public methodSetLightFlash
Sets the light flashing speed. This sets the flashing system directly in the controller hardware and is subject to the hardware limitation of a 2.5 second duration.
Public methodSetVibration(Int32, Single)
Sets vibration level for a motor at a specified index.
Public methodSetVibration(Single, Single)
Sets vibration level for left and right motors.
Public methodSetVibration(DualShock4MotorType, Single)
Sets vibration leves on an individual motor.
Public methodSetVibration(Int32, Single, Boolean)
Sets vibration level for a motor at a specified index.
Public methodSetVibration(Int32, Single, Single)
Sets vibration level for a motor at a specified index with a timeout.
Public methodSetVibration(DualShock4MotorType, Single, Boolean)
Sets vibration level on an individual motor.
Public methodSetVibration(DualShock4MotorType, Single, Single)
Sets vibration leves on an individual motor.
Public methodSetVibration(Int32, Single, Single, Boolean)
Sets vibration level for a motor at a specified index with a timeout.
Public methodSetVibration(Single, Single, Single, Single)
Sets vibration level for left and right motors.
Public methodSetVibration(DualShock4MotorType, Single, Single, Boolean)
Sets vibration level on an individual motor.
Public methodStopLightFlash
Stops the light flashing.
Public methodStopVibration
Stops vibration on all motors.
Top
See Also