diff --git a/platformio.ini b/platformio.ini index 4237be9..d5701fd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [env] -lib_deps = HID-Project +lib_deps = Joystick [env:sparkfun_promicro16] platform = atmelavr diff --git a/src/main.cpp b/src/main.cpp index 74e9838..972d5dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define NUM_KEYS 12 @@ -17,11 +17,14 @@ uint8_t const pin_select{9}; uint8_t const pin_start{10}; uint8_t const pin_array[] = {pin_lr, pin_rr, pin_left , pin_up , pin_right , pin_down , pin_y, pin_x, pin_b, pin_a, pin_select, pin_start}; -int const key_array[] = {'r' , 'l' , GAMEPAD_DPAD_LEFT, GAMEPAD_DPAD_UP, GAMEPAD_DPAD_RIGHT, GAMEPAD_DPAD_DOWN, 'y' , 'x' , 'b' , 'a' , KEY_RETURN, ' ' }; +// uin8__t const key_array[] = {0, 1, 2, 3, 4, 5, }; +// int const key_array[] = {'r' , 'l' , GAMEPAD_DPAD_LEFT, GAMEPAD_DPAD_UP, GAMEPAD_DPAD_RIGHT, GAMEPAD_DPAD_DOWN, 'y' , 'x' , 'b' , 'a' , KEY_RETURN, ' ' }; bool states [] = {LOW , LOW , LOW , LOW , LOW , LOW , LOW , LOW , LOW , LOW , LOW , LOW }; +Joystick_ Joystick; + void setup() { - Gamepad.begin(); + Joystick.begin(); for (size_t i = 0; i < NUM_KEYS; ++i) { pinMode(pin_array[i], INPUT_PULLUP); states[i] = digitalRead(pin_array[i]); @@ -34,9 +37,9 @@ void loop() { current_state = digitalRead(pin_array[i]); if (current_state != states[i]) { if (current_state == LOW) { - Gamepad.press(key_array[i]); + Joystick.pressButton(i); } else { - Gamepad.release(key_array[i]); + Joystick.releaseButton(i); } states[i] = current_state; }