Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions source-code/source/plugins/TLAC/Input/Bindings/Binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,31 @@ namespace TLAC::Input

bool Binding::AnyDown()
{
int i = 0;
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;

i++;
}

return false;
}

bool Binding::AnyTapped()
{
int i = 0;
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;
}

i++;
}

return false;
Expand Down
3 changes: 3 additions & 0 deletions source-code/source/plugins/TLAC/Input/Bindings/Binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace TLAC::Input
{
class Binding
{
// Used in down & tapped events
int lastDownId = -1;

public:
std::vector<IInputBinding*> InputBindings;

Expand Down