diff --git a/controller_without_comm/config.h b/controller_without_comm/config.h new file mode 100644 index 0000000..fbcca7e --- /dev/null +++ b/controller_without_comm/config.h @@ -0,0 +1,44 @@ +#ifndef CONFIG +#define CONFIG + +#define PIN_BUTTON_TUNE_LEFT_0 9 +#define PIN_BUTTON_TUNE_LEFT_1 8 +#define PIN_BUTTON_TUNE_LEFT_2 7 +#define PIN_BUTTON_TUNE_LEFT_3 6 +#define PIN_BUTTON_TUNE_LEFT_SIDE 5 +#define PIN_BUTTON_TUNE_RIGHT_SIDE 4 +#define PIN_BUTTON_TUNE_RIGHT_3 3 +#define PIN_BUTTON_TUNE_RIGHT_2 2 +#define PIN_BUTTON_TUNE_RIGHT_1 1 +#define PIN_BUTTON_TUNE_RIGHT_0 0 +#define PIN_BUTTON_SUB_LEFT_0 13 +#define PIN_BUTTON_SUB_LEFT_1 12 +#define PIN_BUTTON_SUB_RIGHT_0 11 +#define PIN_BUTTON_SUB_RIGHT_1 10 + +#define PIN_BUTTON_DUPLICATED_UPARROW 8 +#define PIN_BUTTON_DUPLICATED_DOWNARROW 1 +#define PIN_BUTTON_DUPLICATED_LEFTARROW 11 +#define PIN_BUTTON_DUPLICATED_RIGHTARROW 10 + +#define KEYBOARD_BUTTON_TUNE_LEFT_0 'a' +#define KEYBOARD_BUTTON_TUNE_LEFT_1 's' +#define KEYBOARD_BUTTON_TUNE_LEFT_2 'd' +#define KEYBOARD_BUTTON_TUNE_LEFT_3 'c' +#define KEYBOARD_BUTTON_TUNE_LEFT_SIDE 129 +#define KEYBOARD_BUTTON_TUNE_RIGHT_SIDE 133 +#define KEYBOARD_BUTTON_TUNE_RIGHT_3 ',' +#define KEYBOARD_BUTTON_TUNE_RIGHT_2 'l' +#define KEYBOARD_BUTTON_TUNE_RIGHT_1 ';' +#define KEYBOARD_BUTTON_TUNE_RIGHT_0 '\'' +#define KEYBOARD_BUTTON_SUB_LEFT_0 179 +#define KEYBOARD_BUTTON_SUB_LEFT_1 176 +#define KEYBOARD_BUTTON_SUB_RIGHT_0 '1' +#define KEYBOARD_BUTTON_SUB_RIGHT_1 '2' + +#define KEYBOARD_BUTTON_DUPLICATED_UPARROW 218 +#define KEYBOARD_BUTTON_DUPLICATED_DOWNARROW 217 +#define KEYBOARD_BUTTON_DUPLICATED_LEFTARROW 216 +#define KEYBOARD_BUTTON_DUPLICATED_RIGHTARROW 215 + +#endif diff --git a/controller_without_comm/controller_without_comm.ino b/controller_without_comm/controller_without_comm.ino new file mode 100644 index 0000000..ef8902a --- /dev/null +++ b/controller_without_comm/controller_without_comm.ino @@ -0,0 +1,204 @@ +#include "config.h" +#include + +bool pressed_button_tune_left_0 = false; +bool pressed_button_tune_left_1 = false; +bool pressed_button_tune_left_2 = false; +bool pressed_button_tune_left_3 = false; +bool pressed_button_tune_left_side = false; +bool pressed_button_tune_right_side = false; +bool pressed_button_tune_right_3 = false; +bool pressed_button_tune_right_2 = false; +bool pressed_button_tune_right_1 = false; +bool pressed_button_tune_right_0 = false; +bool pressed_button_sub_left_0 = false; +bool pressed_button_sub_left_1 = false; +bool pressed_button_sub_right_0 = false; +bool pressed_button_sub_right_1 = false; + +void setup() { + pinMode(PIN_BUTTON_TUNE_LEFT_0, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_LEFT_1, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_LEFT_2, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_LEFT_3, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_LEFT_SIDE, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_RIGHT_SIDE, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_RIGHT_3, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_RIGHT_2, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_RIGHT_1, INPUT_PULLUP); + pinMode(PIN_BUTTON_TUNE_RIGHT_0, INPUT_PULLUP); + pinMode(PIN_BUTTON_SUB_LEFT_0, INPUT_PULLUP); + pinMode(PIN_BUTTON_SUB_LEFT_1, INPUT_PULLUP); + pinMode(PIN_BUTTON_SUB_RIGHT_0, INPUT_PULLUP); + pinMode(PIN_BUTTON_SUB_RIGHT_1, INPUT_PULLUP); +} + +void loop() { + if (!digitalRead(PIN_BUTTON_DUPLICATED_UPARROW)) { + Keyboard.write(KEYBOARD_BUTTON_DUPLICATED_UPARROW); + } + if (!digitalRead(PIN_BUTTON_DUPLICATED_DOWNARROW)) { + Keyboard.write(KEYBOARD_BUTTON_DUPLICATED_DOWNARROW); + } + if (!digitalRead(PIN_BUTTON_DUPLICATED_LEFTARROW)) { + Keyboard.write(KEYBOARD_BUTTON_DUPLICATED_LEFTARROW); + } + if (!digitalRead(PIN_BUTTON_DUPLICATED_RIGHTARROW)) { + Keyboard.write(KEYBOARD_BUTTON_DUPLICATED_RIGHTARROW); + } + + if (!digitalRead(PIN_BUTTON_TUNE_LEFT_0)) { + if (!pressed_button_tune_left_0) { + pressed_button_tune_left_0 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_LEFT_0); + } + } else { + if (pressed_button_tune_left_0) { + pressed_button_tune_left_0 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_LEFT_0); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_LEFT_1)) { + if (!pressed_button_tune_left_1) { + pressed_button_tune_left_1 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_LEFT_1); + } + } else { + if (pressed_button_tune_left_1) { + pressed_button_tune_left_1 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_LEFT_1); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_LEFT_2)) { + if (!pressed_button_tune_left_2) { + pressed_button_tune_left_2 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_LEFT_2); + } + } else { + if (pressed_button_tune_left_2) { + pressed_button_tune_left_2 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_LEFT_2); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_LEFT_3)) { + if (!pressed_button_tune_left_3) { + pressed_button_tune_left_3 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_LEFT_3); + } + } else { + if (pressed_button_tune_left_3) { + pressed_button_tune_left_3 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_LEFT_3); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_LEFT_SIDE)) { + if (!pressed_button_tune_left_side) { + pressed_button_tune_left_side = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_LEFT_SIDE); + } + } else { + if (pressed_button_tune_left_side) { + pressed_button_tune_left_side = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_LEFT_SIDE); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_RIGHT_SIDE)) { + if (!pressed_button_tune_right_side) { + pressed_button_tune_right_side = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_RIGHT_SIDE); + } + } else { + if (pressed_button_tune_right_side) { + pressed_button_tune_right_side = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_RIGHT_SIDE); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_RIGHT_3)) { + if (!pressed_button_tune_right_3) { + pressed_button_tune_right_3 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_RIGHT_3); + } + } else { + if (pressed_button_tune_right_3) { + pressed_button_tune_right_3 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_RIGHT_3); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_RIGHT_2)) { + if (!pressed_button_tune_right_2) { + pressed_button_tune_right_2 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_RIGHT_2); + } + } else { + if (pressed_button_tune_right_2) { + pressed_button_tune_right_2 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_RIGHT_2); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_RIGHT_1)) { + if (!pressed_button_tune_right_1) { + pressed_button_tune_right_1 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_RIGHT_1); + } + } else { + if (pressed_button_tune_right_1) { + pressed_button_tune_right_1 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_RIGHT_1); + } + } + if (!digitalRead(PIN_BUTTON_TUNE_RIGHT_0)) { + if (!pressed_button_tune_right_0) { + pressed_button_tune_right_0 = true; + Keyboard.press(KEYBOARD_BUTTON_TUNE_RIGHT_0); + } + } else { + if (pressed_button_tune_right_0) { + pressed_button_tune_right_0 = false; + Keyboard.release(KEYBOARD_BUTTON_TUNE_RIGHT_0); + } + } + if (!digitalRead(PIN_BUTTON_SUB_LEFT_0)) { + if (!pressed_button_sub_left_0) { + pressed_button_sub_left_0 = true; + Keyboard.press(KEYBOARD_BUTTON_SUB_LEFT_0); + } + } else { + if (pressed_button_sub_left_0) { + pressed_button_sub_left_0 = false; + Keyboard.release(KEYBOARD_BUTTON_SUB_LEFT_0); + } + } + if (!digitalRead(PIN_BUTTON_SUB_LEFT_1)) { + if (!pressed_button_sub_left_1) { + pressed_button_sub_left_1 = true; + Keyboard.press(KEYBOARD_BUTTON_SUB_LEFT_1); + } + } else { + if (pressed_button_sub_left_1) { + pressed_button_sub_left_1 = false; + Keyboard.release(KEYBOARD_BUTTON_SUB_LEFT_1); + } + } + if (!digitalRead(PIN_BUTTON_SUB_RIGHT_0)) { + if (!pressed_button_sub_right_0) { + pressed_button_sub_right_0 = true; + Keyboard.press(KEYBOARD_BUTTON_SUB_RIGHT_0); + } + } else { + if (pressed_button_sub_right_0) { + pressed_button_sub_right_0 = false; + Keyboard.release(KEYBOARD_BUTTON_SUB_RIGHT_0); + } + } + if (!digitalRead(PIN_BUTTON_SUB_RIGHT_1)) { + if (!pressed_button_sub_right_1) { + pressed_button_sub_right_1 = true; + Keyboard.press(KEYBOARD_BUTTON_SUB_RIGHT_1); + } + } else { + if (pressed_button_sub_right_1) { + pressed_button_sub_right_1 = false; + Keyboard.release(KEYBOARD_BUTTON_SUB_RIGHT_1); + } + } +}