/// <summary> /// Set the speed of the low-frequency (usually left) and high-frequency (usually right) motor /// on <paramref name="device"/>. Updates <see cref="lowFrequencyMotorSpeed"/> and /// <see cref="highFrequencyMotorSpeed"/>. /// </summary> /// <param name="device">Device to send command to.</param> /// <param name="lowFrequency">Speed of the low-frequency (left) motor. Normalized [0..1] value /// with 1 indicating maximum speed and 0 indicating the motor is turned off. Will automatically /// be clamped into range.</param> /// <param name="highFrequency">Speed of the high-frequency (right) motor. Normalized [0..1] value /// with 1 indicating maximum speed and 0 indicating the motor is turned off. Will automatically /// be clamped into range.</param> /// <remarks> /// Sends <see cref="DualMotorRumbleCommand"/> to <paramref name="device"/>. /// </remarks> /// <exception cref="ArgumentNullException"><paramref name="device"/> is null.</exception> public void SetMotorSpeeds(InputDevice device, float lowFrequency, float highFrequency) { if (device == null) { throw new ArgumentNullException("device"); } lowFrequencyMotorSpeed = Mathf.Clamp(lowFrequency, 0.0f, 1.0f); highFrequencyMotorSpeed = Mathf.Clamp(highFrequency, 0.0f, 1.0f); var command = DualMotorRumbleCommand.Create(lowFrequencyMotorSpeed, highFrequencyMotorSpeed); device.ExecuteCommand(ref command); }
/// <summary> /// Reset motor speeds to zero but retain current values for <see cref="lowFrequencyMotorSpeed"/> /// and <see cref="highFrequencyMotorSpeed"/>. /// </summary> /// <param name="device">Device to send command to.</param> /// <exception cref="ArgumentNullException"><paramref name="device"/> is null.</exception> public void PauseHaptics(InputDevice device) { if (device == null) { throw new ArgumentNullException("device"); } if (!isRumbling) { return; } var command = DualMotorRumbleCommand.Create(0f, 0f); device.ExecuteCommand(ref command); }