1
0
Fork 0

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>
This commit is contained in:
Eric.a Gebhart 2023-02-12 11:31:04 -05:00 committed by GitHub
parent bbf7a20b33
commit db1eeea478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 104 additions and 8 deletions

View file

@ -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) {