2021-01-22 08:20:07 +00:00
|
|
|
namespace MoonWorks.Input
|
2021-01-19 07:29:07 +00:00
|
|
|
{
|
2021-01-22 22:41:34 +00:00
|
|
|
public class ButtonState
|
2021-01-19 07:29:07 +00:00
|
|
|
{
|
2021-01-22 22:41:34 +00:00
|
|
|
private ButtonStatus ButtonStatus { get; set; }
|
|
|
|
|
|
|
|
public bool IsPressed => ButtonStatus == ButtonStatus.Pressed;
|
|
|
|
public bool IsHeld => ButtonStatus == ButtonStatus.Held;
|
|
|
|
public bool IsDown => ButtonStatus == ButtonStatus.Pressed || ButtonStatus == ButtonStatus.Held;
|
|
|
|
public bool IsReleased => ButtonStatus == ButtonStatus.Released;
|
|
|
|
|
|
|
|
internal void Update(bool isPressed)
|
|
|
|
{
|
|
|
|
if (isPressed)
|
|
|
|
{
|
|
|
|
if (ButtonStatus == ButtonStatus.Pressed)
|
|
|
|
{
|
|
|
|
ButtonStatus = ButtonStatus.Held;
|
|
|
|
}
|
|
|
|
else if (ButtonStatus == ButtonStatus.Released)
|
|
|
|
{
|
|
|
|
ButtonStatus = ButtonStatus.Pressed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ButtonStatus = ButtonStatus.Released;
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 07:29:07 +00:00
|
|
|
}
|
|
|
|
}
|