From f4689ec56a678c33381891bbf408f753eac064b0 Mon Sep 17 00:00:00 2001 From: Peewi Date: Tue, 31 Jan 2023 21:10:06 +0100 Subject: [PATCH] Vibration and LED --- Facepunch.Steamworks/Structs/Controller.cs | 57 +++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/Facepunch.Steamworks/Structs/Controller.cs b/Facepunch.Steamworks/Structs/Controller.cs index f694ecd..c13353b 100644 --- a/Facepunch.Steamworks/Structs/Controller.cs +++ b/Facepunch.Steamworks/Structs/Controller.cs @@ -47,6 +47,61 @@ public AnalogState GetAnalogState( string actionName ) return SteamInput.Internal.GetAnalogActionData( Handle, SteamInput.GetAnalogActionHandle( actionName ) ); } + /// + /// Trigger a vibration event on supported controllers. + /// + /// + /// This API call will be ignored for incompatible controller models. + /// This generates the traditional "rumble" vibration effect. + /// + /// The intensity value for the left rumble motor. + /// The intensity value of the right rumble motor. + public void TriggerVibration( ushort leftSpeed, ushort rightSpeed ) + { + SteamInput.Internal.TriggerVibration( Handle, leftSpeed, rightSpeed ); + } + + /// + /// Trigger a vibration event on supported controllers, including impulse trigger for Xbox One controllers. + /// This API call will be ignored for incompatible controller models. + /// This generates the traditional "rumble" vibration effect. + /// + /// The intensity value for the left rumble motor. + /// The intensity value of the right rumble motor. + /// + /// + public void TriggerVibrationExtended( ushort leftSpeed, ushort rightSpeed, ushort leftTriggerSpeed, ushort rightTriggerSpeed ) + { + SteamInput.Internal.TriggerVibrationExtended( Handle, leftSpeed, rightSpeed, leftTriggerSpeed, rightTriggerSpeed ); + } + + /// + /// Set the controller LED color on supported controllers. + /// + /// The red component of the color to set (0-255). + /// The green component of the color to set (0-255). + /// The blue component of the color to set (0-255). + public void SetLEDColor( byte red, byte green, byte blue ) + { + SteamInput.Internal.SetLEDColor( Handle, red, green, blue, (uint)SteamControllerLEDFlag.SetColor ); + } + + /// + /// Set the controller LED color on supported controllers. + /// + /// Color to set the LED + public void SetLEDColor( Color color ) + { + SteamInput.Internal.SetLEDColor( Handle, color.r, color.g, color.b, (uint)SteamControllerLEDFlag.SetColor ); + } + + /// + /// Restore the controller LED color to default (out-of-game) settings + /// + public void RestoreUserLEDColor() + { + SteamInput.Internal.SetLEDColor( Handle, 0, 0, 0, (uint)SteamControllerLEDFlag.RestoreUserDefault ); + } public override string ToString() => $"{InputType}.{Handle.Value}"; @@ -94,4 +149,4 @@ public struct DigitalState public bool Pressed => BState != 0; public bool Active => BActive != 0; } -} \ No newline at end of file +}