|
|
@ -48,19 +48,10 @@ void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t pre
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__attribute__((weak))
|
|
|
|
__attribute__((weak))
|
|
|
|
bool handle_user_key_event(byte row, byte col, uint8_t currentState, uint8_t previousState) {
|
|
|
|
custom_handler_t eventHandlers[] = {
|
|
|
|
return false;
|
|
|
|
handle_key_event_default,
|
|
|
|
}
|
|
|
|
(custom_handler_t) NULL
|
|
|
|
|
|
|
|
};
|
|
|
|
static custom_handler_t customHandler = handle_user_key_event;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void set_custom_handler(custom_handler_t f) {
|
|
|
|
|
|
|
|
customHandler = f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
custom_handler_t get_custom_handler() {
|
|
|
|
|
|
|
|
return customHandler;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Key lookup_key(byte keymap, byte row, byte col) {
|
|
|
|
Key lookup_key(byte keymap, byte row, byte col) {
|
|
|
|
Key mappedKey;
|
|
|
|
Key mappedKey;
|
|
|
@ -71,12 +62,16 @@ Key lookup_key(byte keymap, byte row, byte col) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previousState) {
|
|
|
|
void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previousState) {
|
|
|
|
//for every newly pressed button, figure out what logical key it is and send a key down event
|
|
|
|
for (byte i = 0; eventHandlers[i] != NULL; i++) {
|
|
|
|
// for every newly released button, figure out what logical key it is and send a key up event
|
|
|
|
custom_handler_t handler = eventHandlers[i];
|
|
|
|
|
|
|
|
if ((*handler)(row, col, currentState, previousState))
|
|
|
|
if ((*customHandler)(row, col, currentState, previousState)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool handle_key_event_default(byte row, byte col, uint8_t currentState, uint8_t previousState) {
|
|
|
|
|
|
|
|
//for every newly pressed button, figure out what logical key it is and send a key down event
|
|
|
|
|
|
|
|
// for every newly released button, figure out what logical key it is and send a key up event
|
|
|
|
|
|
|
|
|
|
|
|
Key mappedKey = lookup_key(temporary_keymap, row, col);
|
|
|
|
Key mappedKey = lookup_key(temporary_keymap, row, col);
|
|
|
|
Key baseKey = lookup_key(primary_keymap, row, col);
|
|
|
|
Key baseKey = lookup_key(primary_keymap, row, col);
|
|
|
@ -88,6 +83,7 @@ void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previous
|
|
|
|
} else if (key_is_pressed(currentState, previousState)) {
|
|
|
|
} else if (key_is_pressed(currentState, previousState)) {
|
|
|
|
press_key(mappedKey);
|
|
|
|
press_key(mappedKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void press_key(Key mappedKey) {
|
|
|
|
void press_key(Key mappedKey) {
|
|
|
|