Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Diff: Input/Input.cpp
- Revision:
- 9:3a7776a29a11
- Parent:
- 5:3efbdcb3efaf
- Child:
- 10:5762d7fae033
--- a/Input/Input.cpp Fri Mar 15 16:39:06 2019 +0000
+++ b/Input/Input.cpp Fri Mar 15 20:30:01 2019 +0000
@@ -1,5 +1,34 @@
#include "Input.h"
+void Input::init() {
+ for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
+ states[i] = RELEASED;
+ }
+}
+
+void Input::deinit() {
+
+}
+
void Input::update() {
+ // update existing states
+ for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
+ if (states[i] == RELEASED_FRAME) {
+ states[i] = RELEASED;
+ }
+ if (states[i] == HIT_FRAME) {
+ states[i] = HELD;
+ }
+ }
+ // check inputs
+}
+
+bool Input::buttonHit(Button button) {
+ return states[button] == HIT_FRAME;
+}
+
+bool Input::buttonHeld(Button button) {
+ return states[button] == HIT_FRAME
+ || states[button] == HELD;
}
\ No newline at end of file
