Skip to content

Commit

Permalink
Revert "fix(combos)Fix bug with overlapping combos timeouts (zmkfirmw…
Browse files Browse the repository at this point in the history
…are#1945)"

This reverts commit aa4cb14.
  • Loading branch information
Ciutadellla committed Nov 20, 2023
1 parent 57b4cd6 commit 06be651
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 126 deletions.
26 changes: 7 additions & 19 deletions app/src/combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,34 +204,22 @@ static inline bool candidate_is_completely_pressed(struct combo_cfg *candidate)
static int cleanup();

static int filter_timed_out_candidates(int64_t timestamp) {
int remaining_candidates = 0;
int num_candidates = 0;
for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) {
struct combo_candidate *candidate = &candidates[i];
if (candidate->combo == NULL) {
break;
}
if (candidate->timeout_at > timestamp) {
bool need_to_bubble_up = remaining_candidates != i;
if (need_to_bubble_up) {
// bubble up => reorder candidates so they're contiguous
candidates[remaining_candidates].combo = candidate->combo;
candidates[remaining_candidates].timeout_at = candidate->timeout_at;
// clear the previous location
candidates[i].combo = NULL;
candidates[i].timeout_at = 0;
}

remaining_candidates++;
// reorder candidates so they're contiguous
candidates[num_candidates].combo = candidate->combo;
candidates[num_candidates].timeout_at = candidate->timeout_at;
num_candidates++;
} else {
candidate->combo = NULL;
}
}

LOG_DBG(
"after filtering out timed out combo candidates: remaining_candidates=%d timestamp=%lld",
remaining_candidates, timestamp);

return remaining_candidates;
return num_candidates;
}

static int clear_candidates() {
Expand Down Expand Up @@ -461,7 +449,7 @@ static void combo_timeout_handler(struct k_work *item) {
// timer was cancelled or rescheduled.
return;
}
if (filter_timed_out_candidates(timeout_task_timeout_at) == 0) {
if (filter_timed_out_candidates(timeout_task_timeout_at) < 2) {
cleanup();
}
update_timeout_task();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 06be651

Please sign in to comment.