diff options
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_combo.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index d8b089db16..8597649c92 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -29,6 +29,12 @@ extern uint16_t COMBO_LEN; __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} +#ifndef COMBO_ONLY_FROM_LAYER +__attribute__((weak)) uint8_t combo_ref_from_layer(uint8_t layer) { + return layer; +} +#endif + #ifdef COMBO_MUST_HOLD_PER_COMBO __attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { return false; @@ -304,7 +310,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { #if defined(EXTRA_EXTRA_LONG_COMBOS) uint32_t state = 0; #elif defined(EXTRA_LONG_COMBOS) - uint16_t state = 0; + uint16_t state = 0; #else uint8_t state = 0; #endif @@ -549,6 +555,12 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { #ifdef COMBO_ONLY_FROM_LAYER /* Only check keycodes from one layer. */ keycode = keymap_key_to_keycode(COMBO_ONLY_FROM_LAYER, record->event.key); +#else + uint8_t highest_layer = get_highest_layer(layer_state); + uint8_t ref_layer = combo_ref_from_layer(highest_layer); + if (ref_layer != highest_layer) { + keycode = keymap_key_to_keycode(ref_layer, record->event.key); + } #endif for (uint16_t idx = 0; idx < COMBO_LEN; ++idx) { |