Merge pull request #24 from algernon/f/abstracting-for-testing

Improved custom key event handling
pull/25/head
Jesse Vincent 8 years ago committed by GitHub
commit b0d6bc9fcc

@ -52,6 +52,16 @@ bool handle_user_key_event(byte row, byte col, uint8_t currentState, uint8_t pre
return false;
}
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 mappedKey;
@ -64,7 +74,7 @@ void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previous
//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
if (handle_user_key_event(row, col, currentState, previousState)) {
if ((*customHandler)(row, col, currentState, previousState)) {
return;
}

@ -13,6 +13,11 @@
extern uint8_t primary_keymap;
extern uint8_t temporary_keymap;
typedef bool (*custom_handler_t)(byte row, byte col, uint8_t currentState, uint8_t previousState);
void set_custom_handler(custom_handler_t f);
custom_handler_t get_custom_handler();
// sending events to the computer
void handle_synthetic_key_event( Key mappedKey, uint8_t currentState, uint8_t previousState);
void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previousState);

Loading…
Cancel
Save