2022-07-12 23:09:23 +00:00
|
|
|
namespace MoonWorks.Input
|
|
|
|
{
|
2023-09-14 18:23:04 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A virtual button corresponding to a trigger on a gamepad.
|
|
|
|
/// If the trigger value exceeds the threshold, it will be treated as a press.
|
|
|
|
/// </summary>
|
2022-07-12 23:09:23 +00:00
|
|
|
public class TriggerButton : VirtualButton
|
|
|
|
{
|
|
|
|
public Trigger Parent { get; }
|
|
|
|
public TriggerCode Code => Parent.Code;
|
|
|
|
|
|
|
|
private float threshold = 0.7f;
|
|
|
|
public float Threshold
|
|
|
|
{
|
|
|
|
get => threshold;
|
|
|
|
set => threshold = System.Math.Clamp(value, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal TriggerButton(Trigger parent)
|
|
|
|
{
|
|
|
|
Parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal override bool CheckPressed()
|
|
|
|
{
|
|
|
|
return Parent.Value >= Threshold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|