|
|
|
@ -5,34 +5,34 @@
|
|
|
|
|
|
|
|
|
|
#include "KeyboardioFirmware.h"
|
|
|
|
|
#include "HID-Project.h"
|
|
|
|
|
|
|
|
|
|
KeyboardStorage Storage;
|
|
|
|
|
|
|
|
|
|
KeyboardStorage Storage;
|
|
|
|
|
LEDControl BlinkyLights;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void set_keymap(Key keymapEntry, byte matrixStateEntry) {
|
|
|
|
|
// this logic sucks. there is a better way TODO this
|
|
|
|
|
if (! (keymapEntry.flags ^ ( MOMENTARY | SWITCH_TO_KEYMAP))) {
|
|
|
|
|
if (key_toggled_on(matrixStateEntry)) {
|
|
|
|
|
if ( keymapEntry.rawKey == KEYMAP_NEXT) {
|
|
|
|
|
temporary_keymap++;
|
|
|
|
|
} else if ( keymapEntry.rawKey == KEYMAP_PREVIOUS) {
|
|
|
|
|
temporary_keymap--;
|
|
|
|
|
} else {
|
|
|
|
|
temporary_keymap = keymapEntry.rawKey;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (key_toggled_off(matrixStateEntry)) {
|
|
|
|
|
temporary_keymap = primary_keymap;
|
|
|
|
|
// this logic sucks. there is a better way TODO this
|
|
|
|
|
if (! (keymapEntry.flags ^ ( MOMENTARY | SWITCH_TO_KEYMAP))) {
|
|
|
|
|
if (key_toggled_on(matrixStateEntry)) {
|
|
|
|
|
if ( keymapEntry.rawKey == KEYMAP_NEXT) {
|
|
|
|
|
temporary_keymap++;
|
|
|
|
|
} else if ( keymapEntry.rawKey == KEYMAP_PREVIOUS) {
|
|
|
|
|
temporary_keymap--;
|
|
|
|
|
} else {
|
|
|
|
|
temporary_keymap = keymapEntry.rawKey;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (key_toggled_off(matrixStateEntry)) {
|
|
|
|
|
temporary_keymap = primary_keymap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (! (keymapEntry.flags ^ ( SWITCH_TO_KEYMAP ))) {
|
|
|
|
|
// switch keymap and stay there
|
|
|
|
|
if (key_toggled_on(matrixStateEntry)) {
|
|
|
|
|
temporary_keymap = primary_keymap = keymapEntry.rawKey;
|
|
|
|
|
Storage.save_primary_keymap(primary_keymap);
|
|
|
|
|
}
|
|
|
|
|
} else if (! (keymapEntry.flags ^ ( SWITCH_TO_KEYMAP ))) {
|
|
|
|
|
// switch keymap and stay there
|
|
|
|
|
if (key_toggled_on(matrixStateEntry)) {
|
|
|
|
|
temporary_keymap = primary_keymap = keymapEntry.rawKey;
|
|
|
|
|
Storage.save_primary_keymap(primary_keymap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scan_matrix() {
|
|
|
|
@ -136,7 +136,7 @@ void handle_key_event(byte row, byte col) {
|
|
|
|
|
|
|
|
|
|
byte switchState = matrixState[row][col];
|
|
|
|
|
Key mappedKey = keymaps[temporary_keymap][row][col];
|
|
|
|
|
if (keymapEntry.flags & SWITCH_TO_KEYMAP) {
|
|
|
|
|
if (keymaps[primary_keymap][row][col].flags & SWITCH_TO_KEYMAP) {
|
|
|
|
|
set_keymap(keymaps[primary_keymap][row][col], switchState);
|
|
|
|
|
}
|
|
|
|
|
if (mappedKey.flags & SYNTHETIC_KEY) {
|
|
|
|
|