Skip to content

Commit

Permalink
feat: simplify controller_without_comm
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeLayer committed Nov 1, 2024
1 parent b89fdc6 commit 41d801f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 142 deletions.
4 changes: 2 additions & 2 deletions controller_without_comm/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#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_SUB_RIGHT_0 216
#define KEYBOARD_BUTTON_SUB_RIGHT_1 215

#define KEYBOARD_BUTTON_DUPLICATED_UPARROW 218
#define KEYBOARD_BUTTON_DUPLICATED_DOWNARROW 217
Expand Down
168 changes: 28 additions & 140 deletions controller_without_comm/controller_without_comm.ino
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
#include "config.h"
#include <Keyboard.h>

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);
Expand All @@ -34,171 +19,74 @@ void setup() {
}

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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
Keyboard.release(KEYBOARD_BUTTON_SUB_RIGHT_1);
}
}

0 comments on commit 41d801f

Please sign in to comment.