Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix combo_disable #13988

Merged
merged 1 commit into from
Aug 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions quantum/process_keycode/process_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@ void clear_combos(void) {
}

static inline void dump_key_buffer(void) {
/* First call start from 0 index; recursive calls need to start from i+1 index */
static uint8_t key_buffer_next = 0;

if (key_buffer_size == 0) {
return;
}

for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) {
for (uint8_t key_buffer_i = key_buffer_next; key_buffer_i < key_buffer_size; key_buffer_i++) {
key_buffer_next = key_buffer_i + 1;

queued_record_t *qrecord = &key_buffer[key_buffer_i];
keyrecord_t *record = &qrecord->record;
Expand All @@ -189,7 +193,7 @@ static inline void dump_key_buffer(void) {
record->event.time = 0;
}

key_buffer_size = 0;
key_buffer_next = key_buffer_size = 0;
}

#define NO_COMBO_KEYS_ARE_DOWN (0 == COMBO_STATE(combo))
Expand Down Expand Up @@ -340,9 +344,9 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
return false;
}

bool key_is_part_of_combo = !COMBO_DISABLED(combo);
bool key_is_part_of_combo = !COMBO_DISABLED(combo) && is_combo_enabled();

if (record->event.pressed && !COMBO_DISABLED(combo)) {
if (record->event.pressed && key_is_part_of_combo) {
uint16_t time = _get_combo_term(combo_index, combo);
if (!COMBO_ACTIVE(combo)) {
KEY_STATE_DOWN(combo->state, key_index);
Expand Down Expand Up @@ -472,10 +476,6 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
return true;
}

if (!is_combo_enabled()) {
return true;
}

#ifdef COMBO_ONLY_FROM_LAYER
/* Only check keycodes from one layer. */
keycode = keymap_key_to_keycode(COMBO_ONLY_FROM_LAYER, record->event.key);
Expand Down Expand Up @@ -550,6 +550,8 @@ void combo_disable(void) {
#endif
b_combo_enable = false;
combo_buffer_read = combo_buffer_write;
clear_combos();
dump_key_buffer();
}

void combo_toggle(void) {
Expand Down