diff options
| author | QMK Bot <hello@qmk.fm> | 2022-02-12 10:29:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-12 18:29:31 +0000 |
| commit | 63646e8906e062d1c1de3925cba70c4e3426a855 (patch) | |
| tree | 4e91648b77b838e1125cf86331d7e84bde6d07a9 /quantum/process_keycode/process_combo.c | |
| parent | afcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff) | |
Format code according to conventions (#16322)
Diffstat (limited to 'quantum/process_keycode/process_combo.c')
| -rw-r--r-- | quantum/process_keycode/process_combo.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 21fd737ab7..efaf8fe0e9 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
| @@ -30,33 +30,45 @@ extern uint16_t COMBO_LEN; | |||
| 30 | __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} | 30 | __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} |
| 31 | 31 | ||
| 32 | #ifdef COMBO_MUST_HOLD_PER_COMBO | 32 | #ifdef COMBO_MUST_HOLD_PER_COMBO |
| 33 | __attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { return false; } | 33 | __attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { |
| 34 | return false; | ||
| 35 | } | ||
| 34 | #endif | 36 | #endif |
| 35 | 37 | ||
| 36 | #ifdef COMBO_MUST_TAP_PER_COMBO | 38 | #ifdef COMBO_MUST_TAP_PER_COMBO |
| 37 | __attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) { return false; } | 39 | __attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) { |
| 40 | return false; | ||
| 41 | } | ||
| 38 | #endif | 42 | #endif |
| 39 | 43 | ||
| 40 | #ifdef COMBO_TERM_PER_COMBO | 44 | #ifdef COMBO_TERM_PER_COMBO |
| 41 | __attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) { return COMBO_TERM; } | 45 | __attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) { |
| 46 | return COMBO_TERM; | ||
| 47 | } | ||
| 42 | #endif | 48 | #endif |
| 43 | 49 | ||
| 44 | #ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO | 50 | #ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO |
| 45 | __attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) { return true; } | 51 | __attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) { |
| 52 | return true; | ||
| 53 | } | ||
| 46 | #endif | 54 | #endif |
| 47 | 55 | ||
| 48 | #ifdef COMBO_PROCESS_KEY_RELEASE | 56 | #ifdef COMBO_PROCESS_KEY_RELEASE |
| 49 | __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) { return false; } | 57 | __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) { |
| 58 | return false; | ||
| 59 | } | ||
| 50 | #endif | 60 | #endif |
| 51 | 61 | ||
| 52 | #ifdef COMBO_SHOULD_TRIGGER | 62 | #ifdef COMBO_SHOULD_TRIGGER |
| 53 | __attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { return true; } | 63 | __attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { |
| 64 | return true; | ||
| 65 | } | ||
| 54 | #endif | 66 | #endif |
| 55 | 67 | ||
| 56 | #ifndef COMBO_NO_TIMER | 68 | #ifndef COMBO_NO_TIMER |
| 57 | static uint16_t timer = 0; | 69 | static uint16_t timer = 0; |
| 58 | #endif | 70 | #endif |
| 59 | static bool b_combo_enable = true; // defaults to enabled | 71 | static bool b_combo_enable = true; // defaults to enabled |
| 60 | static uint16_t longest_term = 0; | 72 | static uint16_t longest_term = 0; |
| 61 | 73 | ||
| 62 | typedef struct { | 74 | typedef struct { |
| @@ -462,7 +474,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 462 | // get possible longer waiting time for tap-/hold-only combos. | 474 | // get possible longer waiting time for tap-/hold-only combos. |
| 463 | longest_term = _get_wait_time(combo_index, combo); | 475 | longest_term = _get_wait_time(combo_index, combo); |
| 464 | } | 476 | } |
| 465 | } // if timer elapsed end | 477 | } // if timer elapsed end |
| 466 | } | 478 | } |
| 467 | } else { | 479 | } else { |
| 468 | // chord releases | 480 | // chord releases |
| @@ -477,7 +489,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 477 | else if (get_combo_must_tap(combo_index, combo)) { | 489 | else if (get_combo_must_tap(combo_index, combo)) { |
| 478 | // immediately apply tap-only combo | 490 | // immediately apply tap-only combo |
| 479 | apply_combo(combo_index, combo); | 491 | apply_combo(combo_index, combo); |
| 480 | apply_combos(); // also apply other prepared combos and dump key buffer | 492 | apply_combos(); // also apply other prepared combos and dump key buffer |
| 481 | # ifdef COMBO_PROCESS_KEY_RELEASE | 493 | # ifdef COMBO_PROCESS_KEY_RELEASE |
| 482 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { | 494 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { |
| 483 | release_combo(combo_index, combo); | 495 | release_combo(combo_index, combo); |
| @@ -559,7 +571,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { | |||
| 559 | key_buffer[key_buffer_size++] = (queued_record_t){ | 571 | key_buffer[key_buffer_size++] = (queued_record_t){ |
| 560 | .record = *record, | 572 | .record = *record, |
| 561 | .keycode = keycode, | 573 | .keycode = keycode, |
| 562 | .combo_index = -1, // this will be set when applying combos | 574 | .combo_index = -1, // this will be set when applying combos |
| 563 | }; | 575 | }; |
| 564 | } | 576 | } |
| 565 | } else { | 577 | } else { |
| @@ -598,7 +610,9 @@ void combo_task(void) { | |||
| 598 | #endif | 610 | #endif |
| 599 | } | 611 | } |
| 600 | 612 | ||
| 601 | void combo_enable(void) { b_combo_enable = true; } | 613 | void combo_enable(void) { |
| 614 | b_combo_enable = true; | ||
| 615 | } | ||
| 602 | 616 | ||
| 603 | void combo_disable(void) { | 617 | void combo_disable(void) { |
| 604 | #ifndef COMBO_NO_TIMER | 618 | #ifndef COMBO_NO_TIMER |
| @@ -618,4 +632,6 @@ void combo_toggle(void) { | |||
| 618 | } | 632 | } |
| 619 | } | 633 | } |
| 620 | 634 | ||
| 621 | bool is_combo_enabled(void) { return b_combo_enable; } | 635 | bool is_combo_enabled(void) { |
| 636 | return b_combo_enable; | ||
| 637 | } | ||
