mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-09-10 17:15:43 +00:00
is_combo_contiguous convenience function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/*************************
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user