combine button states

main
cosmonaut 2022-07-12 17:57:27 -07:00
parent d07a722fb1
commit ab619192a6
1 changed files with 23 additions and 0 deletions

View File

@ -34,5 +34,28 @@
return new ButtonState(ButtonStatus.Released);
}
public static ButtonState operator |(ButtonState a, ButtonState b)
{
if (a.ButtonStatus == ButtonStatus.Released)
{
return b;
}
else if (a.ButtonStatus == ButtonStatus.Pressed)
{
if (b.ButtonStatus == ButtonStatus.Held)
{
return new ButtonState(ButtonStatus.Held);
}
else
{
return a;
}
}
else // held
{
return a;
}
}
}
}