From 9ac4042974d945cedac9e618b9be0741a3e19f78 Mon Sep 17 00:00:00 2001 From: Peewi Date: Tue, 31 Jan 2023 17:33:41 +0100 Subject: [PATCH 1/3] Initialize Steam Input so it actually works --- Facepunch.Steamworks/SteamInput.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Facepunch.Steamworks/SteamInput.cs b/Facepunch.Steamworks/SteamInput.cs index f4c8dc3d..c31afbb9 100644 --- a/Facepunch.Steamworks/SteamInput.cs +++ b/Facepunch.Steamworks/SteamInput.cs @@ -14,6 +14,7 @@ public class SteamInput : SteamClientClass internal override bool InitializeInterface( bool server ) { SetInterface( server, new ISteamInput( server ) ); + Internal.Init( false ); if ( Interface.Self == IntPtr.Zero ) return false; return true; From f4689ec56a678c33381891bbf408f753eac064b0 Mon Sep 17 00:00:00 2001 From: Peewi Date: Tue, 31 Jan 2023 21:10:06 +0100 Subject: [PATCH 2/3] 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 f694ecd2..c13353bb 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 +} From ae292921f225eb4cd6fc0c9bfdbba3eed1e19004 Mon Sep 17 00:00:00 2001 From: Peewi Date: Wed, 1 Feb 2023 15:12:12 +0100 Subject: [PATCH 3/3] Add missing parameter description --- Facepunch.Steamworks/Structs/Controller.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Facepunch.Steamworks/Structs/Controller.cs b/Facepunch.Steamworks/Structs/Controller.cs index c13353bb..e0051376 100644 --- a/Facepunch.Steamworks/Structs/Controller.cs +++ b/Facepunch.Steamworks/Structs/Controller.cs @@ -68,8 +68,8 @@ public void TriggerVibration( ushort leftSpeed, ushort rightSpeed ) /// /// The intensity value for the left rumble motor. /// The intensity value of the right rumble motor. - /// - /// + /// The intensity value of the Xbox One left trigger rumble + /// The intensity value of the Xbox One right trigger rumble. public void TriggerVibrationExtended( ushort leftSpeed, ushort rightSpeed, ushort leftTriggerSpeed, ushort rightTriggerSpeed ) { SteamInput.Internal.TriggerVibrationExtended( Handle, leftSpeed, rightSpeed, leftTriggerSpeed, rightTriggerSpeed );