using UnityEngine.Scripting;
////TODO: move clamping settings into struct and add process function; then embed both here and in AxisControl
namespace UnityEngine.InputSystem.Processors
{
///
/// Clamp a floating-point input to between and . This is equivalent
/// to Mathf.Clamp(value, min, max).
///
///
/// This processor is registered (see ) under the name "clamp" by default.
///
/// Note that no normalization is performed. If you want to re-normalize the input value after clamping,
/// add a . Alternatively, add a which
/// both clamps and normalizes.
///
///
///
///
/// // Bind to right trigger on gamepad such that the value never drops below 0.3 and never goes
/// // above 0.7.
/// new InputAction(binding: "<Gamepad>/rightTrigger", processors: "clamp(min=0.3,max=0.7)");
///
///
public class ClampProcessor : InputProcessor
{
///
/// Minimum value (inclusive!) of the accepted value range.
///
public float min;
///
/// Maximum value (inclusive!) of the accepted value range.
///
public float max;
///
/// Clamp to the range of and .
///
/// Input value.
/// Ignored.
/// Clamped value.
public override float Process(float value, InputControl control)
{
return Mathf.Clamp(value, min, max);
}
///
public override string ToString()
{
return $"Clamp(min={min},max={max})";
}
}
}