Achieve functional footboard sending alt+number
This commit is contained in:
parent
8136e6499c
commit
b8c173a5b8
2 changed files with 12 additions and 31 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
sketch.yaml
Normal file
1
sketch.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
default_fqbn: teensy:avr:teensyLC:usb=keyboard,opt=o1lto
|
||||
Loading…
Add table
Reference in a new issue