aboutsummaryrefslogtreecommitdiff
path: root/src/core/frontend/input_interpreter.h
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2021-01-16 10:34:39 -0500
committerMorph <39850852+Morph1984@users.noreply.github.com>2021-01-16 10:34:39 -0500
commit3c8f936b31c310a3ad037cc2e260b53d07577fcf (patch)
treebef1999d57e5106a379fc9ac19acb01d84913085 /src/core/frontend/input_interpreter.h
parenta7fd61fcce4634b8e849ab65a732080e77fad902 (diff)
input_interpreter: Add method to check for a button press state
This allows to check for continuous input for the duration of a button press/hold
Diffstat (limited to 'src/core/frontend/input_interpreter.h')
-rw-r--r--src/core/frontend/input_interpreter.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/frontend/input_interpreter.h b/src/core/frontend/input_interpreter.h
index fea9aebe67..36a92a6b67 100644
--- a/src/core/frontend/input_interpreter.h
+++ b/src/core/frontend/input_interpreter.h
@@ -67,6 +67,27 @@ public:
void PollInput();
/**
+ * Checks whether the button is pressed.
+ *
+ * @param button The button to check.
+ *
+ * @returns True when the button is pressed.
+ */
+ [[nodiscard]] bool IsButtonPressed(HIDButton button) const;
+
+ /**
+ * Checks whether any of the buttons in the parameter list is pressed.
+ *
+ * @tparam HIDButton The buttons to check.
+ *
+ * @returns True when at least one of the buttons is pressed.
+ */
+ template <HIDButton... T>
+ [[nodiscard]] bool IsAnyButtonPressed() {
+ return (IsButtonPressed(T) || ...);
+ }
+
+ /**
* The specified button is considered to be pressed once
* if it is currently pressed and not pressed previously.
*