Skip to content

Instantly share code, notes, and snippets.

@petejohanson
Created August 1, 2022 03:17
Show Gist options
  • Save petejohanson/b28ab5e47cfe473d756fcfd82900820f to your computer and use it in GitHub Desktop.
Save petejohanson/b28ab5e47cfe473d756fcfd82900820f to your computer and use it in GitHub Desktop.
Combo bug
static int filter_timed_out_candidates(int64_t timestamp) {
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) {
// reorder candidates so they're contiguous
candidates[num_candidates].combo = candidate->combo;
candidates[num_candidates].timeout_at = candidates->timeout_at;
num_candidates++;
} else {
candidate->combo = NULL;
}
}
return num_candidates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment