ELEC2645 (2018/19) / Mbed 2 deprecated el17ajf

Dependencies:   mbed

Fork of el17ajf by Angus Findlay

Revision:
12:beb0d7632531
Parent:
10:5762d7fae033
Child:
13:59e17cab320a
--- a/Input/Input.cpp	Sun Mar 17 10:55:11 2019 +0000
+++ b/Input/Input.cpp	Sun Mar 17 12:14:56 2019 +0000
@@ -1,15 +1,24 @@
 #include "Input.h"
+#include "mbed.h" // TODO DELETE
+
+const int NUMBER_OF_BUTTONS = 4;
 
 Input::State Input::states[NUMBER_OF_BUTTONS];
+Gamepad * Input::gamepad;
 
 void Input::init() {
-    for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
+    gamepad = new Gamepad();
+    gamepad->init();
+    //printf("%d\n", NUMBER_OF_BUTTONS);
+    /*
+    for (int i = 0; i < 4; i++) {
         Input::states[i] = RELEASED;
     }
+    */
 }
 
 void Input::deinit() {
-    
+    delete gamepad;
 }
 
 void Input::update() {
@@ -24,6 +33,10 @@
     }
     
     // check inputs
+    if (gamepad->check_event(Gamepad::Y_PRESSED)) {
+//        states[RIGHT] = HIT_FRAME;
+        printf("RIGHT\n");
+    }
 }
 
 bool Input::buttonHit(Button button) {