Skip to content

Commit e480c75

Browse files
committed
Merge pull request Facepunch#702 from Peewi/master
Initialize Steam Input so it actually works
2 parents dc8a0c9 + ae29292 commit e480c75

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

Facepunch.Steamworks/SteamInput.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class SteamInput : SteamClientClass<SteamInput>
1414
internal override bool InitializeInterface( bool server )
1515
{
1616
SetInterface( server, new ISteamInput( server ) );
17+
Internal.Init( false );
1718
if ( Interface.Self == IntPtr.Zero ) return false;
1819

1920
return true;

Facepunch.Steamworks/Structs/Controller.cs

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,61 @@ public AnalogState GetAnalogState( string actionName )
4747
return SteamInput.Internal.GetAnalogActionData( Handle, SteamInput.GetAnalogActionHandle( actionName ) );
4848
}
4949

50+
/// <summary>
51+
/// Trigger a vibration event on supported controllers.
52+
/// </summary>
53+
/// <remarks>
54+
/// <para>This API call will be ignored for incompatible controller models.</para>
55+
/// <para>This generates the traditional "rumble" vibration effect.</para>
56+
/// </remarks>
57+
/// <param name="leftSpeed">The intensity value for the left rumble motor.</param>
58+
/// <param name="rightSpeed">The intensity value of the right rumble motor.</param>
59+
public void TriggerVibration( ushort leftSpeed, ushort rightSpeed )
60+
{
61+
SteamInput.Internal.TriggerVibration( Handle, leftSpeed, rightSpeed );
62+
}
63+
64+
/// <summary>
65+
/// Trigger a vibration event on supported controllers, including impulse trigger for Xbox One controllers.
66+
/// <para>This API call will be ignored for incompatible controller models.</para>
67+
/// <para>This generates the traditional "rumble" vibration effect.</para>
68+
/// </summary>
69+
/// <param name="leftSpeed">The intensity value for the left rumble motor.</param>
70+
/// <param name="rightSpeed">The intensity value of the right rumble motor.</param>
71+
/// <param name="leftTriggerSpeed">The intensity value of the Xbox One left trigger rumble</param>
72+
/// <param name="rightTriggerSpeed">The intensity value of the Xbox One right trigger rumble.</param>
73+
public void TriggerVibrationExtended( ushort leftSpeed, ushort rightSpeed, ushort leftTriggerSpeed, ushort rightTriggerSpeed )
74+
{
75+
SteamInput.Internal.TriggerVibrationExtended( Handle, leftSpeed, rightSpeed, leftTriggerSpeed, rightTriggerSpeed );
76+
}
77+
78+
/// <summary>
79+
/// Set the controller LED color on supported controllers.
80+
/// </summary>
81+
/// <param name="red">The red component of the color to set (0-255).</param>
82+
/// <param name="green">The green component of the color to set (0-255).</param>
83+
/// <param name="blue">The blue component of the color to set (0-255).</param>
84+
public void SetLEDColor( byte red, byte green, byte blue )
85+
{
86+
SteamInput.Internal.SetLEDColor( Handle, red, green, blue, (uint)SteamControllerLEDFlag.SetColor );
87+
}
88+
89+
/// <summary>
90+
/// Set the controller LED color on supported controllers.
91+
/// </summary>
92+
/// <param name="color">Color to set the LED</param>
93+
public void SetLEDColor( Color color )
94+
{
95+
SteamInput.Internal.SetLEDColor( Handle, color.r, color.g, color.b, (uint)SteamControllerLEDFlag.SetColor );
96+
}
97+
98+
/// <summary>
99+
/// Restore the controller LED color to default (out-of-game) settings
100+
/// </summary>
101+
public void RestoreUserLEDColor()
102+
{
103+
SteamInput.Internal.SetLEDColor( Handle, 0, 0, 0, (uint)SteamControllerLEDFlag.RestoreUserDefault );
104+
}
50105

51106
public override string ToString() => $"{InputType}.{Handle.Value}";
52107

@@ -94,4 +149,4 @@ public struct DigitalState
94149
public bool Pressed => BState != 0;
95150
public bool Active => BActive != 0;
96151
}
97-
}
152+
}

0 commit comments

Comments
 (0)