diff options
author | Eric.a Gebhart <e.a.gebhart@gmail.com> | 2023-02-12 11:31:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-13 03:31:04 +1100 |
commit | db1eeea4788de062eccf327da5844fc3f46844f9 (patch) | |
tree | cb8537e4a0222c84d0cd653661eb94a579000036 /quantum/process_keycode/process_combo.c | |
parent | bbf7a20b33de2d203518687cb5cd1aa85005ea27 (diff) |
Add combo hook to allow per layer combo reference layers. (#16699)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Diffstat (limited to 'quantum/process_keycode/process_combo.c')
-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) { |