[Win] Implemented XInput vibration support

This commit is contained in:
Stefanos A 2014-01-16 01:20:32 +01:00 committed by thefiddler
parent 06e63946cc
commit c3b289ee9b

View file

@ -116,7 +116,14 @@ namespace OpenTK.Platform.Windows
public bool SetVibration(int index, float left, float right)
{
return false;
left = MathHelper.Clamp(left, 0.0f, 1.0f);
right = MathHelper.Clamp(right, 0.0f, 1.0f);
XInputVibration vibration = new XInputVibration(
(ushort)(left * UInt16.MaxValue),
(ushort)(right * UInt16.MaxValue));
return xinput.SetState((XInputUserIndex)index, ref vibration) == XInputErrorCode.Success;
}
#endregion
@ -285,8 +292,14 @@ namespace OpenTK.Platform.Windows
struct XInputVibration
{
public short LeftMotorSpeed;
public short RightMotorSpeed;
public ushort LeftMotorSpeed;
public ushort RightMotorSpeed;
public XInputVibration(ushort left, ushort right)
{
LeftMotorSpeed = left;
RightMotorSpeed = right;
}
}
struct XInputDeviceCapabilities