diff --git a/footboard.ino b/footboard.ino index 97a0f7d..5d68909 100644 --- a/footboard.ino +++ b/footboard.ino @@ -1,21 +1,10 @@ - - char n_buttons = 7; char button_pins[] = {0, 1, 2, 3, 4, 5, 6}; char pin_state[] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH}; -char modKey = (char) KEY_LEFT_CTRL; +char modKey = (char) MODIFIERKEY_CTRL; -char buttons[7][6] = { - {'1'}, - {'2'}, - {'3'}, - {'4'}, - {'5'}, - {'6'}, - {'7'} -}; -char sequence_length[] = {1, 1, 1, 1, 1, 1, 1}; +int buttons[7] = {KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7}; void setup() { @@ -23,7 +12,6 @@ void setup() { for (int i = 0; i < n_buttons; ++i) { pinMode(button_pins[i], INPUT_PULLUP); } - Keyboard.begin(); } @@ -41,23 +29,15 @@ void loop() { void set_button_state(int button_i, char state) { - char *sequence = buttons[button_i]; - char len = sequence_length[button_i]; + char key = buttons[button_i]; - if (sequence_length[button_i] == 1) { - if (state == LOW) { - Keyboard.press(modKey); - Keyboard.press(sequence[0]); - } else { - Keyboard.releaseAll(); - } - } else if(state == LOW) { - Keyboard.press(modKey); - for (int i = 0; i < len; ++i) { - Keyboard.press(sequence[i]); - Keyboard.release(sequence[i]); - delay(12); - } - Keyboard.releaseAll(); + if (state == LOW) { + Keyboard.set_modifier(MODIFIERKEY_ALT); + Keyboard.set_key1(key); + Keyboard.send_now(); + } else { + Keyboard.set_modifier(0); + Keyboard.set_key1(0); + Keyboard.send_now(); } } diff --git a/sketch.yaml b/sketch.yaml new file mode 100644 index 0000000..298b5d5 --- /dev/null +++ b/sketch.yaml @@ -0,0 +1 @@ +default_fqbn: teensy:avr:teensyLC:usb=keyboard,opt=o1lto