is_combo_contiguous convenience function

This commit is contained in:
John Wilmes
2025-08-18 22:05:34 -05:00
parent 2dc201be98
commit 7802fde5a0
2 changed files with 9 additions and 9 deletions

View File

@@ -331,8 +331,12 @@ __attribute__((weak)) bool is_combo_preferred(combo_state_t combo_index1, combo_
return combo_index1 > combo_index2;
}
__attribute__((weak)) bool is_combo_contiguous(uint16_t index, combo_t *combo, uint16_t keycode, keyrecord_t *record, uint8_t n_unpressed_keys) {
return true;
}
/* Default behavior (if none of COMBO_MUST_PRESS_IN_ORDER, COMBO_MUST_PRESS_IN_ORDER_PER_COMBO, or COMBO_SHOULD_TRIGGER are defined)
* is to be interrupted by any key not contained in a combo, and otherwise to not be interrupted (require contiguous presses) */
* is to be interrupted by any key not contained in a combo, and otherwise to not be interrupted (require contiguous presses). */
__attribute__((weak)) bool is_combo_interrupted(uint16_t index, combo_t *combo, uint16_t keycode, keyrecord_t *record, uint8_t n_unpressed_keys, bool combo_has_key) {
if (combo_has_key) {
#ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO
@@ -356,7 +360,7 @@ __attribute__((weak)) bool is_combo_interrupted(uint16_t index, combo_t *combo,
return false;
#endif
}
return true;
return is_combo_contiguous(index, combo, keycode, record, n_unpressed_keys);
}
/*************************

View File

@@ -24,16 +24,12 @@ combo_t key_combos[] = {
};
// clang-format on
/* Return true if the keypress in record interrupts the given combo with the given index,
* preventing it from firing. */
bool is_combo_interrupted(uint16_t index, combo_t *combo, keyrecord_t *record, uint8_t n_unpressed_keys, bool combo_has_key) {
bool is_combo_contiguous(uint16_t index, combo_t *combo, keyrecord_t *record, uint8_t n_unpressed_keys) {
switch (index) {
case xy_2:
case cxy_5:
// Require contiguous
return !combo_has_key;
return true; // xy_2 and cxy_5 are contiguous combos
default:
return false;
return false; // no other combos are contiguous
}
}