From ca7a8b3a7b0a1243a9b3200b86a08e50498e6ee1 Mon Sep 17 00:00:00 2001 From: George Wang Date: Sat, 16 May 2026 21:48:22 -0600 Subject: [PATCH 1/2] Add method to detect if any button is pressed. --- libs/hardware/InputManager/include/InputManager.h | 7 +++++++ libs/hardware/InputManager/src/InputManager.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/libs/hardware/InputManager/include/InputManager.h b/libs/hardware/InputManager/include/InputManager.h index 34fc67b..e13ff1f 100644 --- a/libs/hardware/InputManager/include/InputManager.h +++ b/libs/hardware/InputManager/include/InputManager.h @@ -21,6 +21,13 @@ class InputManager { */ bool isPressed(uint8_t buttonIndex) const; + /** + * Returns true if any button was being held at the time of the last #update() call. + * + * @return true if any button was being held at the time of the last #update() call + */ + bool iAnyPressed() const; + /** * Returns true if the button went from unpressed to pressed between the last two #update() calls. * diff --git a/libs/hardware/InputManager/src/InputManager.cpp b/libs/hardware/InputManager/src/InputManager.cpp index 86442ab..8fbe84d 100644 --- a/libs/hardware/InputManager/src/InputManager.cpp +++ b/libs/hardware/InputManager/src/InputManager.cpp @@ -120,6 +120,10 @@ bool InputManager::isPressed(const uint8_t buttonIndex) const { return currentState & (1 << buttonIndex); } +bool InputManager::iAnyPressed() const { + return currentState > 0; +} + bool InputManager::wasPressed(const uint8_t buttonIndex) const { return pressedEvents & (1 << buttonIndex); } From 1c2b2623e67d67903b7b7dc87bdc2962d21859b5 Mon Sep 17 00:00:00 2001 From: George Wang Date: Sat, 16 May 2026 22:01:40 -0600 Subject: [PATCH 2/2] Fixed type --- libs/hardware/InputManager/include/InputManager.h | 2 +- libs/hardware/InputManager/src/InputManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/hardware/InputManager/include/InputManager.h b/libs/hardware/InputManager/include/InputManager.h index e13ff1f..40fda39 100644 --- a/libs/hardware/InputManager/include/InputManager.h +++ b/libs/hardware/InputManager/include/InputManager.h @@ -26,7 +26,7 @@ class InputManager { * * @return true if any button was being held at the time of the last #update() call */ - bool iAnyPressed() const; + bool isAnyPressed() const; /** * Returns true if the button went from unpressed to pressed between the last two #update() calls. diff --git a/libs/hardware/InputManager/src/InputManager.cpp b/libs/hardware/InputManager/src/InputManager.cpp index 8fbe84d..68fb61e 100644 --- a/libs/hardware/InputManager/src/InputManager.cpp +++ b/libs/hardware/InputManager/src/InputManager.cpp @@ -120,7 +120,7 @@ bool InputManager::isPressed(const uint8_t buttonIndex) const { return currentState & (1 << buttonIndex); } -bool InputManager::iAnyPressed() const { +bool InputManager::isAnyPressed() const { return currentState > 0; }