diff options
author | Nick Brassel <nick@tzarc.org> | 2022-03-09 19:29:00 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 19:29:00 +1100 |
commit | 8d5eacb7dd76bfd45444ceb1efa9a9f840173552 (patch) | |
tree | b6b8b641dd61f5de0c5b7ee1bf251f6a84043656 /quantum/keymap_common.c | |
parent | 7121a228eb204a0d697c97503ac7a28b762ab598 (diff) |
Add support for encoder mapping. (#13286)
Diffstat (limited to 'quantum/keymap_common.c')
-rw-r--r-- | quantum/keymap_common.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index a91b2a0b36..c1940f0fd3 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -148,6 +148,15 @@ action_t action_for_keycode(uint16_t keycode) { // translates key to keycode __attribute__((weak)) uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { - // Read entire word (16bits) - return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); + if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) { + return pgm_read_word(&keymaps[layer][key.row][key.col]); + } +#ifdef ENCODER_MAP_ENABLE + else if (key.row == KEYLOC_ENCODER_CW && key.col < NUM_ENCODERS) { + return pgm_read_word(&encoder_map[layer][key.col][0]); + } else if (key.row == KEYLOC_ENCODER_CCW && key.col < NUM_ENCODERS) { + return pgm_read_word(&encoder_map[layer][key.col][1]); + } +#endif // ENCODER_MAP_ENABLE + return KC_NO; } |