Holds are now fixed! #22

Open
mez0ru wants to merge 1 commits from mez0ru/dev into dev
2 changed files with 15 additions and 2 deletions
@@ -19,10 +19,14 @@ namespace TLAC::Input
bool Binding::AnyDown() bool Binding::AnyDown()
{ {
int i = 0;
for (const auto& binding : InputBindings) for (const auto& binding : InputBindings)
{ {
if (binding->IsDown()) // 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; return true;
i++;
} }
return false; return false;
@@ -30,10 +34,16 @@ namespace TLAC::Input
bool Binding::AnyTapped() bool Binding::AnyTapped()
{ {
int i = 0;
for (const auto& binding : InputBindings) for (const auto& binding : InputBindings)
{ {
if (binding->IsTapped()) 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; return true;
}
i++;
} }
return false; return false;
@@ -6,6 +6,9 @@ namespace TLAC::Input
{ {
class Binding class Binding
{ {
// Used in down & tapped events
int lastDownId = -1;
public: public:
std::vector<IInputBinding*> InputBindings; std::vector<IInputBinding*> InputBindings;