1. a new variable is introduced "lastDownId". 2. This variable is used to track the last pressed button. In case of "holds" the button HAS to be the last one pressed, this is the case on all the official games. 3. This will fix the syndrome "just hold R2 / L2 to get the full hold score".
102 lines
1.5 KiB
C++
102 lines
1.5 KiB
C++
#include "Binding.h"
|
|
|
|
namespace TLAC::Input
|
|
{
|
|
Binding::Binding()
|
|
{
|
|
}
|
|
|
|
Binding::~Binding()
|
|
{
|
|
for (auto& binding : InputBindings)
|
|
delete binding;
|
|
}
|
|
|
|
void Binding::AddBinding(IInputBinding* inputBinding)
|
|
{
|
|
InputBindings.push_back(inputBinding);
|
|
}
|
|
|
|
bool Binding::AnyDown()
|
|
{
|
|
int i = 0;
|
|
for (const auto& binding : InputBindings)
|
|
{
|
|
// If an old input is still held down, don't register it, only a new input is allowed.
|
|
if (binding->IsDown() && this->lastDownId == i)
|
|
return true;
|
|
|
|
i++;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool Binding::AnyTapped()
|
|
{
|
|
int i = 0;
|
|
for (const auto& binding : InputBindings)
|
|
{
|
|
if (binding->IsTapped()) {
|
|
// This saves the last button id to a variable, so that it's known as the last input registered (see AnyDown()).
|
|
this->lastDownId = i;
|
|
return true;
|
|
}
|
|
|
|
i++;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool Binding::AnyReleased()
|
|
{
|
|
for (const auto& binding : InputBindings)
|
|
{
|
|
if (binding->IsReleased())
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
int Binding::GetDownCount()
|
|
{
|
|
int count = 0;
|
|
|
|
for (const auto& binding : InputBindings)
|
|
{
|
|
if (binding->IsDown())
|
|
count++;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
int Binding::GetTappedCount()
|
|
{
|
|
int count = 0;
|
|
|
|
for (const auto& binding : InputBindings)
|
|
{
|
|
if (binding->IsTapped())
|
|
count++;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
int Binding::GetReleasedCount()
|
|
{
|
|
int count = 0;
|
|
|
|
for (const auto& binding : InputBindings)
|
|
{
|
|
if (binding->IsReleased())
|
|
count++;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|