diff options
author | Joel Challis <git@zvecr.com> | 2021-11-01 19:18:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 19:18:33 +0000 |
commit | 92385e30cdad61ddfc0461b1ce1340bcb494a68a (patch) | |
tree | d472f93ed9f4e42e4972630d8178a387b91a51bc /quantum | |
parent | ee371c1295f00c119dd5a1bb2f3d4acedff832a7 (diff) | |
download | qmk_firmware-92385e30cdad61ddfc0461b1ce1340bcb494a68a.tar.gz qmk_firmware-92385e30cdad61ddfc0461b1ce1340bcb494a68a.zip |
Manually format develop (#15003)
Diffstat (limited to 'quantum')
22 files changed, 464 insertions, 373 deletions
diff --git a/quantum/action.c b/quantum/action.c index 8c34b84ef..5c33bd6d2 100644 --- a/quantum/action.c +++ b/quantum/action.c | |||
@@ -821,9 +821,10 @@ void register_code(uint8_t code) { | |||
821 | } | 821 | } |
822 | #endif | 822 | #endif |
823 | 823 | ||
824 | else if IS_KEY (code) { | 824 | else if |
825 | // TODO: should push command_proc out of this block? | 825 | IS_KEY(code) { |
826 | if (command_proc(code)) return; | 826 | // TODO: should push command_proc out of this block? |
827 | if (command_proc(code)) return; | ||
827 | 828 | ||
828 | #ifndef NO_ACTION_ONESHOT | 829 | #ifndef NO_ACTION_ONESHOT |
829 | /* TODO: remove | 830 | /* TODO: remove |
@@ -840,33 +841,35 @@ void register_code(uint8_t code) { | |||
840 | } else | 841 | } else |
841 | */ | 842 | */ |
842 | #endif | 843 | #endif |
843 | { | 844 | { |
844 | // Force a new key press if the key is already pressed | 845 | // Force a new key press if the key is already pressed |
845 | // without this, keys with the same keycode, but different | 846 | // without this, keys with the same keycode, but different |
846 | // modifiers will be reported incorrectly, see issue #1708 | 847 | // modifiers will be reported incorrectly, see issue #1708 |
847 | if (is_key_pressed(keyboard_report, code)) { | 848 | if (is_key_pressed(keyboard_report, code)) { |
848 | del_key(code); | 849 | del_key(code); |
850 | send_keyboard_report(); | ||
851 | } | ||
852 | add_key(code); | ||
849 | send_keyboard_report(); | 853 | send_keyboard_report(); |
850 | } | 854 | } |
851 | add_key(code); | 855 | } |
856 | else if | ||
857 | IS_MOD(code) { | ||
858 | add_mods(MOD_BIT(code)); | ||
852 | send_keyboard_report(); | 859 | send_keyboard_report(); |
853 | } | 860 | } |
854 | } else if IS_MOD (code) { | ||
855 | add_mods(MOD_BIT(code)); | ||
856 | send_keyboard_report(); | ||
857 | } | ||
858 | #ifdef EXTRAKEY_ENABLE | 861 | #ifdef EXTRAKEY_ENABLE |
859 | else if IS_SYSTEM (code) { | 862 | else if |
860 | host_system_send(KEYCODE2SYSTEM(code)); | 863 | IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); } |
861 | } else if IS_CONSUMER (code) { | 864 | else if |
862 | host_consumer_send(KEYCODE2CONSUMER(code)); | 865 | IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); } |
863 | } | ||
864 | #endif | 866 | #endif |
865 | #ifdef MOUSEKEY_ENABLE | 867 | #ifdef MOUSEKEY_ENABLE |
866 | else if IS_MOUSEKEY (code) { | 868 | else if |
867 | mousekey_on(code); | 869 | IS_MOUSEKEY(code) { |
868 | mousekey_send(); | 870 | mousekey_on(code); |
869 | } | 871 | mousekey_send(); |
872 | } | ||
870 | #endif | 873 | #endif |
871 | } | 874 | } |
872 | 875 | ||
@@ -911,22 +914,26 @@ void unregister_code(uint8_t code) { | |||
911 | } | 914 | } |
912 | #endif | 915 | #endif |
913 | 916 | ||
914 | else if IS_KEY (code) { | 917 | else if |
915 | del_key(code); | 918 | IS_KEY(code) { |
916 | send_keyboard_report(); | 919 | del_key(code); |
917 | } else if IS_MOD (code) { | 920 | send_keyboard_report(); |
918 | del_mods(MOD_BIT(code)); | 921 | } |
919 | send_keyboard_report(); | 922 | else if |
920 | } else if IS_SYSTEM (code) { | 923 | IS_MOD(code) { |
921 | host_system_send(0); | 924 | del_mods(MOD_BIT(code)); |
922 | } else if IS_CONSUMER (code) { | 925 | send_keyboard_report(); |
923 | host_consumer_send(0); | 926 | } |
924 | } | 927 | else if |
928 | IS_SYSTEM(code) { host_system_send(0); } | ||
929 | else if | ||
930 | IS_CONSUMER(code) { host_consumer_send(0); } | ||
925 | #ifdef MOUSEKEY_ENABLE | 931 | #ifdef MOUSEKEY_ENABLE |
926 | else if IS_MOUSEKEY (code) { | 932 | else if |
927 | mousekey_off(code); | 933 | IS_MOUSEKEY(code) { |
928 | mousekey_send(); | 934 | mousekey_off(code); |
929 | } | 935 | mousekey_send(); |
936 | } | ||
930 | #endif | 937 | #endif |
931 | } | 938 | } |
932 | 939 | ||
diff --git a/quantum/action.h b/quantum/action.h index 8a357ded8..b562f18c5 100644 --- a/quantum/action.h +++ b/quantum/action.h | |||
@@ -88,7 +88,7 @@ extern bool disable_action_cache; | |||
88 | 88 | ||
89 | /* Code for handling one-handed key modifiers. */ | 89 | /* Code for handling one-handed key modifiers. */ |
90 | #ifdef SWAP_HANDS_ENABLE | 90 | #ifdef SWAP_HANDS_ENABLE |
91 | extern bool swap_hands; | 91 | extern bool swap_hands; |
92 | extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; | 92 | extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; |
93 | # if (MATRIX_COLS <= 8) | 93 | # if (MATRIX_COLS <= 8) |
94 | typedef uint8_t swap_state_row_t; | 94 | typedef uint8_t swap_state_row_t; |
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index 36839f9fa..60e56fb81 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c | |||
@@ -18,11 +18,11 @@ | |||
18 | # define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) | 18 | # define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) |
19 | # define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) | 19 | # define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) |
20 | # define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) | 20 | # define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) |
21 | #ifndef COMBO_ENABLE | 21 | # ifndef COMBO_ENABLE |
22 | # define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key))) | 22 | # define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key))) |
23 | #else | 23 | # else |
24 | # define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode) | 24 | # define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode) |
25 | #endif | 25 | # endif |
26 | 26 | ||
27 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; } | 27 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; } |
28 | 28 | ||
@@ -212,11 +212,15 @@ bool process_tapping(keyrecord_t *keyp) { | |||
212 | if (tapping_key.tap.count > 1) { | 212 | if (tapping_key.tap.count > 1) { |
213 | debug("Tapping: Start new tap with releasing last tap(>1).\n"); | 213 | debug("Tapping: Start new tap with releasing last tap(>1).\n"); |
214 | // unregister key | 214 | // unregister key |
215 | process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false, | 215 | process_record(&(keyrecord_t){ |
216 | #ifdef COMBO_ENABLE | 216 | .tap = tapping_key.tap, |
217 | .keycode = tapping_key.keycode, | 217 | .event.key = tapping_key.event.key, |
218 | #endif | 218 | .event.time = event.time, |
219 | }); | 219 | .event.pressed = false, |
220 | # ifdef COMBO_ENABLE | ||
221 | .keycode = tapping_key.keycode, | ||
222 | # endif | ||
223 | }); | ||
220 | } else { | 224 | } else { |
221 | debug("Tapping: Start while last tap(1).\n"); | 225 | debug("Tapping: Start while last tap(1).\n"); |
222 | } | 226 | } |
@@ -254,11 +258,15 @@ bool process_tapping(keyrecord_t *keyp) { | |||
254 | if (tapping_key.tap.count > 1) { | 258 | if (tapping_key.tap.count > 1) { |
255 | debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); | 259 | debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); |
256 | // unregister key | 260 | // unregister key |
257 | process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false, | 261 | process_record(&(keyrecord_t){ |
258 | #ifdef COMBO_ENABLE | 262 | .tap = tapping_key.tap, |
259 | .keycode = tapping_key.keycode, | 263 | .event.key = tapping_key.event.key, |
260 | #endif | 264 | .event.time = event.time, |
261 | }); | 265 | .event.pressed = false, |
266 | # ifdef COMBO_ENABLE | ||
267 | .keycode = tapping_key.keycode, | ||
268 | # endif | ||
269 | }); | ||
262 | } else { | 270 | } else { |
263 | debug("Tapping: Start while last timeout tap(1).\n"); | 271 | debug("Tapping: Start while last timeout tap(1).\n"); |
264 | } | 272 | } |
diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c index 24380dc5e..81f39383c 100644 --- a/quantum/debounce/asym_eager_defer_pk.c +++ b/quantum/debounce/asym_eager_defer_pk.c | |||
@@ -46,17 +46,17 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state. | |||
46 | #define ROW_SHIFTER ((matrix_row_t)1) | 46 | #define ROW_SHIFTER ((matrix_row_t)1) |
47 | 47 | ||
48 | typedef struct { | 48 | typedef struct { |
49 | bool pressed : 1; | 49 | bool pressed : 1; |
50 | uint8_t time : 7; | 50 | uint8_t time : 7; |
51 | } debounce_counter_t; | 51 | } debounce_counter_t; |
52 | 52 | ||
53 | #if DEBOUNCE > 0 | 53 | #if DEBOUNCE > 0 |
54 | static debounce_counter_t *debounce_counters; | 54 | static debounce_counter_t *debounce_counters; |
55 | static fast_timer_t last_time; | 55 | static fast_timer_t last_time; |
56 | static bool counters_need_update; | 56 | static bool counters_need_update; |
57 | static bool matrix_need_update; | 57 | static bool matrix_need_update; |
58 | 58 | ||
59 | #define DEBOUNCE_ELAPSED 0 | 59 | # define DEBOUNCE_ELAPSED 0 |
60 | 60 | ||
61 | static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); | 61 | static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); |
62 | static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); | 62 | static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); |
@@ -64,7 +64,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui | |||
64 | // we use num_rows rather than MATRIX_ROWS to support split keyboards | 64 | // we use num_rows rather than MATRIX_ROWS to support split keyboards |
65 | void debounce_init(uint8_t num_rows) { | 65 | void debounce_init(uint8_t num_rows) { |
66 | debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t)); | 66 | debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t)); |
67 | int i = 0; | 67 | int i = 0; |
68 | for (uint8_t r = 0; r < num_rows; r++) { | 68 | for (uint8_t r = 0; r < num_rows; r++) { |
69 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 69 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
70 | debounce_counters[i++].time = DEBOUNCE_ELAPSED; | 70 | debounce_counters[i++].time = DEBOUNCE_ELAPSED; |
@@ -81,10 +81,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
81 | bool updated_last = false; | 81 | bool updated_last = false; |
82 | 82 | ||
83 | if (counters_need_update) { | 83 | if (counters_need_update) { |
84 | fast_timer_t now = timer_read_fast(); | 84 | fast_timer_t now = timer_read_fast(); |
85 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); | 85 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); |
86 | 86 | ||
87 | last_time = now; | 87 | last_time = now; |
88 | updated_last = true; | 88 | updated_last = true; |
89 | if (elapsed_time > UINT8_MAX) { | 89 | if (elapsed_time > UINT8_MAX) { |
90 | elapsed_time = UINT8_MAX; | 90 | elapsed_time = UINT8_MAX; |
@@ -108,7 +108,7 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], | |||
108 | debounce_counter_t *debounce_pointer = debounce_counters; | 108 | debounce_counter_t *debounce_pointer = debounce_counters; |
109 | 109 | ||
110 | counters_need_update = false; | 110 | counters_need_update = false; |
111 | matrix_need_update = false; | 111 | matrix_need_update = false; |
112 | 112 | ||
113 | for (uint8_t row = 0; row < num_rows; row++) { | 113 | for (uint8_t row = 0; row < num_rows; row++) { |
114 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | 114 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { |
@@ -146,8 +146,8 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui | |||
146 | if (delta & col_mask) { | 146 | if (delta & col_mask) { |
147 | if (debounce_pointer->time == DEBOUNCE_ELAPSED) { | 147 | if (debounce_pointer->time == DEBOUNCE_ELAPSED) { |
148 | debounce_pointer->pressed = (raw[row] & col_mask); | 148 | debounce_pointer->pressed = (raw[row] & col_mask); |
149 | debounce_pointer->time = DEBOUNCE; | 149 | debounce_pointer->time = DEBOUNCE; |
150 | counters_need_update = true; | 150 | counters_need_update = true; |
151 | 151 | ||
152 | if (debounce_pointer->pressed) { | 152 | if (debounce_pointer->pressed) { |
153 | // key-down: eager | 153 | // key-down: eager |
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c index fbefd55ed..9155eb914 100644 --- a/quantum/debounce/sym_defer_g.c +++ b/quantum/debounce/sym_defer_g.c | |||
@@ -25,7 +25,7 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state. | |||
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #if DEBOUNCE > 0 | 27 | #if DEBOUNCE > 0 |
28 | static bool debouncing = false; | 28 | static bool debouncing = false; |
29 | static fast_timer_t debouncing_time; | 29 | static fast_timer_t debouncing_time; |
30 | 30 | ||
31 | void debounce_init(uint8_t num_rows) {} | 31 | void debounce_init(uint8_t num_rows) {} |
diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c index 626a9be84..1b698ba34 100644 --- a/quantum/debounce/sym_defer_pk.c +++ b/quantum/debounce/sym_defer_pk.c | |||
@@ -49,7 +49,7 @@ static debounce_counter_t *debounce_counters; | |||
49 | static fast_timer_t last_time; | 49 | static fast_timer_t last_time; |
50 | static bool counters_need_update; | 50 | static bool counters_need_update; |
51 | 51 | ||
52 | #define DEBOUNCE_ELAPSED 0 | 52 | # define DEBOUNCE_ELAPSED 0 |
53 | 53 | ||
54 | static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); | 54 | static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); |
55 | static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); | 55 | static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); |
@@ -74,10 +74,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
74 | bool updated_last = false; | 74 | bool updated_last = false; |
75 | 75 | ||
76 | if (counters_need_update) { | 76 | if (counters_need_update) { |
77 | fast_timer_t now = timer_read_fast(); | 77 | fast_timer_t now = timer_read_fast(); |
78 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); | 78 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); |
79 | 79 | ||
80 | last_time = now; | 80 | last_time = now; |
81 | updated_last = true; | 81 | updated_last = true; |
82 | if (elapsed_time > UINT8_MAX) { | 82 | if (elapsed_time > UINT8_MAX) { |
83 | elapsed_time = UINT8_MAX; | 83 | elapsed_time = UINT8_MAX; |
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c index 15a3242e6..9da000ea9 100644 --- a/quantum/debounce/sym_eager_pk.c +++ b/quantum/debounce/sym_eager_pk.c | |||
@@ -50,7 +50,7 @@ static fast_timer_t last_time; | |||
50 | static bool counters_need_update; | 50 | static bool counters_need_update; |
51 | static bool matrix_need_update; | 51 | static bool matrix_need_update; |
52 | 52 | ||
53 | #define DEBOUNCE_ELAPSED 0 | 53 | # define DEBOUNCE_ELAPSED 0 |
54 | 54 | ||
55 | static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); | 55 | static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); |
56 | static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); | 56 | static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); |
@@ -75,10 +75,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
75 | bool updated_last = false; | 75 | bool updated_last = false; |
76 | 76 | ||
77 | if (counters_need_update) { | 77 | if (counters_need_update) { |
78 | fast_timer_t now = timer_read_fast(); | 78 | fast_timer_t now = timer_read_fast(); |
79 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); | 79 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); |
80 | 80 | ||
81 | last_time = now; | 81 | last_time = now; |
82 | updated_last = true; | 82 | updated_last = true; |
83 | if (elapsed_time > UINT8_MAX) { | 83 | if (elapsed_time > UINT8_MAX) { |
84 | elapsed_time = UINT8_MAX; | 84 | elapsed_time = UINT8_MAX; |
@@ -107,7 +107,7 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) { | |||
107 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | 107 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { |
108 | if (*debounce_pointer != DEBOUNCE_ELAPSED) { | 108 | if (*debounce_pointer != DEBOUNCE_ELAPSED) { |
109 | if (*debounce_pointer <= elapsed_time) { | 109 | if (*debounce_pointer <= elapsed_time) { |
110 | *debounce_pointer = DEBOUNCE_ELAPSED; | 110 | *debounce_pointer = DEBOUNCE_ELAPSED; |
111 | matrix_need_update = true; | 111 | matrix_need_update = true; |
112 | } else { | 112 | } else { |
113 | *debounce_pointer -= elapsed_time; | 113 | *debounce_pointer -= elapsed_time; |
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c index 2ad592c5a..eda92a263 100644 --- a/quantum/debounce/sym_eager_pr.c +++ b/quantum/debounce/sym_eager_pr.c | |||
@@ -49,7 +49,7 @@ static debounce_counter_t *debounce_counters; | |||
49 | static fast_timer_t last_time; | 49 | static fast_timer_t last_time; |
50 | static bool counters_need_update; | 50 | static bool counters_need_update; |
51 | 51 | ||
52 | #define DEBOUNCE_ELAPSED 0 | 52 | # define DEBOUNCE_ELAPSED 0 |
53 | 53 | ||
54 | static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); | 54 | static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); |
55 | static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); | 55 | static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); |
@@ -71,10 +71,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
71 | bool updated_last = false; | 71 | bool updated_last = false; |
72 | 72 | ||
73 | if (counters_need_update) { | 73 | if (counters_need_update) { |
74 | fast_timer_t now = timer_read_fast(); | 74 | fast_timer_t now = timer_read_fast(); |
75 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); | 75 | fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); |
76 | 76 | ||
77 | last_time = now; | 77 | last_time = now; |
78 | updated_last = true; | 78 | updated_last = true; |
79 | if (elapsed_time > UINT8_MAX) { | 79 | if (elapsed_time > UINT8_MAX) { |
80 | elapsed_time = UINT8_MAX; | 80 | elapsed_time = UINT8_MAX; |
@@ -102,7 +102,7 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) { | |||
102 | for (uint8_t row = 0; row < num_rows; row++) { | 102 | for (uint8_t row = 0; row < num_rows; row++) { |
103 | if (*debounce_pointer != DEBOUNCE_ELAPSED) { | 103 | if (*debounce_pointer != DEBOUNCE_ELAPSED) { |
104 | if (*debounce_pointer <= elapsed_time) { | 104 | if (*debounce_pointer <= elapsed_time) { |
105 | *debounce_pointer = DEBOUNCE_ELAPSED; | 105 | *debounce_pointer = DEBOUNCE_ELAPSED; |
106 | matrix_need_update = true; | 106 | matrix_need_update = true; |
107 | } else { | 107 | } else { |
108 | *debounce_pointer -= elapsed_time; | 108 | *debounce_pointer -= elapsed_time; |
diff --git a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp index fe374c3df..44b4fe195 100644 --- a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp +++ b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "debounce_test_common.h" | 19 | #include "debounce_test_common.h" |
20 | 20 | ||
21 | TEST_F(DebounceTest, OneKeyShort1) { | 21 | TEST_F(DebounceTest, OneKeyShort1) { |
22 | addEvents({ /* Time, Inputs, Outputs */ | 22 | addEvents({ |
23 | /* Time, Inputs, Outputs */ | ||
23 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 24 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
24 | /* Release key after 1ms delay */ | 25 | /* Release key after 1ms delay */ |
25 | {1, {{0, 1, UP}}, {}}, | 26 | {1, {{0, 1, UP}}, {}}, |
@@ -43,7 +44,8 @@ TEST_F(DebounceTest, OneKeyShort1) { | |||
43 | } | 44 | } |
44 | 45 | ||
45 | TEST_F(DebounceTest, OneKeyShort2) { | 46 | TEST_F(DebounceTest, OneKeyShort2) { |
46 | addEvents({ /* Time, Inputs, Outputs */ | 47 | addEvents({ |
48 | /* Time, Inputs, Outputs */ | ||
47 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 49 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
48 | /* Release key after 2ms delay */ | 50 | /* Release key after 2ms delay */ |
49 | {2, {{0, 1, UP}}, {}}, | 51 | {2, {{0, 1, UP}}, {}}, |
@@ -58,7 +60,8 @@ TEST_F(DebounceTest, OneKeyShort2) { | |||
58 | } | 60 | } |
59 | 61 | ||
60 | TEST_F(DebounceTest, OneKeyShort3) { | 62 | TEST_F(DebounceTest, OneKeyShort3) { |
61 | addEvents({ /* Time, Inputs, Outputs */ | 63 | addEvents({ |
64 | /* Time, Inputs, Outputs */ | ||
62 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 65 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
63 | /* Release key after 3ms delay */ | 66 | /* Release key after 3ms delay */ |
64 | {3, {{0, 1, UP}}, {}}, | 67 | {3, {{0, 1, UP}}, {}}, |
@@ -73,7 +76,8 @@ TEST_F(DebounceTest, OneKeyShort3) { | |||
73 | } | 76 | } |
74 | 77 | ||
75 | TEST_F(DebounceTest, OneKeyShort4) { | 78 | TEST_F(DebounceTest, OneKeyShort4) { |
76 | addEvents({ /* Time, Inputs, Outputs */ | 79 | addEvents({ |
80 | /* Time, Inputs, Outputs */ | ||
77 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 81 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
78 | /* Release key after 4ms delay */ | 82 | /* Release key after 4ms delay */ |
79 | {4, {{0, 1, UP}}, {}}, | 83 | {4, {{0, 1, UP}}, {}}, |
@@ -88,7 +92,8 @@ TEST_F(DebounceTest, OneKeyShort4) { | |||
88 | } | 92 | } |
89 | 93 | ||
90 | TEST_F(DebounceTest, OneKeyShort5) { | 94 | TEST_F(DebounceTest, OneKeyShort5) { |
91 | addEvents({ /* Time, Inputs, Outputs */ | 95 | addEvents({ |
96 | /* Time, Inputs, Outputs */ | ||
92 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 97 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
93 | 98 | ||
94 | /* Release key after 5ms delay */ | 99 | /* Release key after 5ms delay */ |
@@ -102,7 +107,8 @@ TEST_F(DebounceTest, OneKeyShort5) { | |||
102 | } | 107 | } |
103 | 108 | ||
104 | TEST_F(DebounceTest, OneKeyShort6) { | 109 | TEST_F(DebounceTest, OneKeyShort6) { |
105 | addEvents({ /* Time, Inputs, Outputs */ | 110 | addEvents({ |
111 | /* Time, Inputs, Outputs */ | ||
106 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 112 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
107 | 113 | ||
108 | /* Release key after 6ms delay */ | 114 | /* Release key after 6ms delay */ |
@@ -116,7 +122,8 @@ TEST_F(DebounceTest, OneKeyShort6) { | |||
116 | } | 122 | } |
117 | 123 | ||
118 | TEST_F(DebounceTest, OneKeyShort7) { | 124 | TEST_F(DebounceTest, OneKeyShort7) { |
119 | addEvents({ /* Time, Inputs, Outputs */ | 125 | addEvents({ |
126 | /* Time, Inputs, Outputs */ | ||
120 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 127 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
121 | 128 | ||
122 | /* Release key after 7ms delay */ | 129 | /* Release key after 7ms delay */ |
@@ -130,7 +137,8 @@ TEST_F(DebounceTest, OneKeyShort7) { | |||
130 | } | 137 | } |
131 | 138 | ||
132 | TEST_F(DebounceTest, OneKeyShort8) { | 139 | TEST_F(DebounceTest, OneKeyShort8) { |
133 | addEvents({ /* Time, Inputs, Outputs */ | 140 | addEvents({ |
141 | /* Time, Inputs, Outputs */ | ||
134 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 142 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
135 | /* Release key after 1ms delay */ | 143 | /* Release key after 1ms delay */ |
136 | {1, {{0, 1, UP}}, {}}, | 144 | {1, {{0, 1, UP}}, {}}, |
@@ -145,7 +153,8 @@ TEST_F(DebounceTest, OneKeyShort8) { | |||
145 | } | 153 | } |
146 | 154 | ||
147 | TEST_F(DebounceTest, OneKeyShort9) { | 155 | TEST_F(DebounceTest, OneKeyShort9) { |
148 | addEvents({ /* Time, Inputs, Outputs */ | 156 | addEvents({ |
157 | /* Time, Inputs, Outputs */ | ||
149 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 158 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
150 | /* Release key after 1ms delay */ | 159 | /* Release key after 1ms delay */ |
151 | {1, {{0, 1, UP}}, {}}, | 160 | {1, {{0, 1, UP}}, {}}, |
@@ -159,7 +168,8 @@ TEST_F(DebounceTest, OneKeyShort9) { | |||
159 | } | 168 | } |
160 | 169 | ||
161 | TEST_F(DebounceTest, OneKeyBouncing1) { | 170 | TEST_F(DebounceTest, OneKeyBouncing1) { |
162 | addEvents({ /* Time, Inputs, Outputs */ | 171 | addEvents({ |
172 | /* Time, Inputs, Outputs */ | ||
163 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 173 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
164 | {1, {{0, 1, UP}}, {}}, | 174 | {1, {{0, 1, UP}}, {}}, |
165 | {2, {{0, 1, DOWN}}, {}}, | 175 | {2, {{0, 1, DOWN}}, {}}, |
@@ -185,7 +195,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) { | |||
185 | } | 195 | } |
186 | 196 | ||
187 | TEST_F(DebounceTest, OneKeyBouncing2) { | 197 | TEST_F(DebounceTest, OneKeyBouncing2) { |
188 | addEvents({ /* Time, Inputs, Outputs */ | 198 | addEvents({ |
199 | /* Time, Inputs, Outputs */ | ||
189 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 200 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
190 | /* Change twice in the same time period */ | 201 | /* Change twice in the same time period */ |
191 | {1, {{0, 1, UP}}, {}}, | 202 | {1, {{0, 1, UP}}, {}}, |
@@ -217,7 +228,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) { | |||
217 | } | 228 | } |
218 | 229 | ||
219 | TEST_F(DebounceTest, OneKeyLong) { | 230 | TEST_F(DebounceTest, OneKeyLong) { |
220 | addEvents({ /* Time, Inputs, Outputs */ | 231 | addEvents({ |
232 | /* Time, Inputs, Outputs */ | ||
221 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 233 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
222 | 234 | ||
223 | {25, {{0, 1, UP}}, {}}, | 235 | {25, {{0, 1, UP}}, {}}, |
@@ -236,7 +248,8 @@ TEST_F(DebounceTest, OneKeyLong) { | |||
236 | } | 248 | } |
237 | 249 | ||
238 | TEST_F(DebounceTest, TwoKeysShort) { | 250 | TEST_F(DebounceTest, TwoKeysShort) { |
239 | addEvents({ /* Time, Inputs, Outputs */ | 251 | addEvents({ |
252 | /* Time, Inputs, Outputs */ | ||
240 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 253 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
241 | {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, | 254 | {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, |
242 | /* Release key after 2ms delay */ | 255 | /* Release key after 2ms delay */ |
@@ -249,14 +262,14 @@ TEST_F(DebounceTest, TwoKeysShort) { | |||
249 | {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */ | 262 | {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */ |
250 | /* Press key again after 1ms delay */ | 263 | /* Press key again after 1ms delay */ |
251 | {11, {{0, 1, DOWN}}, {{0, 1, DOWN}, {0, 2, UP}}}, /* 5ms+5ms after DOWN at time 0 */ | 264 | {11, {{0, 1, DOWN}}, {{0, 1, DOWN}, {0, 2, UP}}}, /* 5ms+5ms after DOWN at time 0 */ |
252 | {12, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, /* 5ms+5ms after DOWN at time 0 */ | 265 | {12, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, /* 5ms+5ms after DOWN at time 0 */ |
253 | }); | 266 | }); |
254 | runEvents(); | 267 | runEvents(); |
255 | } | 268 | } |
256 | 269 | ||
257 | |||
258 | TEST_F(DebounceTest, OneKeyDelayedScan1) { | 270 | TEST_F(DebounceTest, OneKeyDelayedScan1) { |
259 | addEvents({ /* Time, Inputs, Outputs */ | 271 | addEvents({ |
272 | /* Time, Inputs, Outputs */ | ||
260 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 273 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
261 | 274 | ||
262 | /* Processing is very late, immediately release key */ | 275 | /* Processing is very late, immediately release key */ |
@@ -269,7 +282,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) { | |||
269 | } | 282 | } |
270 | 283 | ||
271 | TEST_F(DebounceTest, OneKeyDelayedScan2) { | 284 | TEST_F(DebounceTest, OneKeyDelayedScan2) { |
272 | addEvents({ /* Time, Inputs, Outputs */ | 285 | addEvents({ |
286 | /* Time, Inputs, Outputs */ | ||
273 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 287 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
274 | 288 | ||
275 | /* Processing is very late, immediately release key */ | 289 | /* Processing is very late, immediately release key */ |
@@ -283,7 +297,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) { | |||
283 | } | 297 | } |
284 | 298 | ||
285 | TEST_F(DebounceTest, OneKeyDelayedScan3) { | 299 | TEST_F(DebounceTest, OneKeyDelayedScan3) { |
286 | addEvents({ /* Time, Inputs, Outputs */ | 300 | addEvents({ |
301 | /* Time, Inputs, Outputs */ | ||
287 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 302 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
288 | 303 | ||
289 | /* Processing is very late */ | 304 | /* Processing is very late */ |
@@ -298,7 +313,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) { | |||
298 | } | 313 | } |
299 | 314 | ||
300 | TEST_F(DebounceTest, OneKeyDelayedScan4) { | 315 | TEST_F(DebounceTest, OneKeyDelayedScan4) { |
301 | addEvents({ /* Time, Inputs, Outputs */ | 316 | addEvents({ |
317 | /* Time, Inputs, Outputs */ | ||
302 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 318 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
303 | 319 | ||
304 | /* Processing is very late */ | 320 | /* Processing is very late */ |
@@ -314,7 +330,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) { | |||
314 | } | 330 | } |
315 | 331 | ||
316 | TEST_F(DebounceTest, OneKeyDelayedScan5) { | 332 | TEST_F(DebounceTest, OneKeyDelayedScan5) { |
317 | addEvents({ /* Time, Inputs, Outputs */ | 333 | addEvents({ |
334 | /* Time, Inputs, Outputs */ | ||
318 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 335 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
319 | 336 | ||
320 | {5, {{0, 1, UP}}, {}}, | 337 | {5, {{0, 1, UP}}, {}}, |
@@ -329,7 +346,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan5) { | |||
329 | } | 346 | } |
330 | 347 | ||
331 | TEST_F(DebounceTest, OneKeyDelayedScan6) { | 348 | TEST_F(DebounceTest, OneKeyDelayedScan6) { |
332 | addEvents({ /* Time, Inputs, Outputs */ | 349 | addEvents({ |
350 | /* Time, Inputs, Outputs */ | ||
333 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 351 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
334 | 352 | ||
335 | {5, {{0, 1, UP}}, {}}, | 353 | {5, {{0, 1, UP}}, {}}, |
@@ -345,7 +363,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan6) { | |||
345 | } | 363 | } |
346 | 364 | ||
347 | TEST_F(DebounceTest, OneKeyDelayedScan7) { | 365 | TEST_F(DebounceTest, OneKeyDelayedScan7) { |
348 | addEvents({ /* Time, Inputs, Outputs */ | 366 | addEvents({ |
367 | /* Time, Inputs, Outputs */ | ||
349 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 368 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
350 | 369 | ||
351 | {5, {{0, 1, UP}}, {}}, | 370 | {5, {{0, 1, UP}}, {}}, |
@@ -358,7 +377,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan7) { | |||
358 | } | 377 | } |
359 | 378 | ||
360 | TEST_F(DebounceTest, OneKeyDelayedScan8) { | 379 | TEST_F(DebounceTest, OneKeyDelayedScan8) { |
361 | addEvents({ /* Time, Inputs, Outputs */ | 380 | addEvents({ |
381 | /* Time, Inputs, Outputs */ | ||
362 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 382 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
363 | 383 | ||
364 | /* Processing is a bit late */ | 384 | /* Processing is a bit late */ |
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp index 1c5e7c9f4..f9414e571 100644 --- a/quantum/debounce/tests/debounce_test_common.cpp +++ b/quantum/debounce/tests/debounce_test_common.cpp | |||
@@ -31,9 +31,7 @@ void set_time(uint32_t t); | |||
31 | void advance_time(uint32_t ms); | 31 | void advance_time(uint32_t ms); |
32 | } | 32 | } |
33 | 33 | ||
34 | void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { | 34 | void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { events_.insert(events_.end(), events.begin(), events.end()); } |
35 | events_.insert(events_.end(), events.begin(), events.end()); | ||
36 | } | ||
37 | 35 | ||
38 | void DebounceTest::runEvents() { | 36 | void DebounceTest::runEvents() { |
39 | /* Run the test multiple times, from 1kHz to 10kHz scan rate */ | 37 | /* Run the test multiple times, from 1kHz to 10kHz scan rate */ |
@@ -54,7 +52,7 @@ void DebounceTest::runEvents() { | |||
54 | 52 | ||
55 | void DebounceTest::runEventsInternal() { | 53 | void DebounceTest::runEventsInternal() { |
56 | fast_timer_t previous = 0; | 54 | fast_timer_t previous = 0; |
57 | bool first = true; | 55 | bool first = true; |
58 | 56 | ||
59 | /* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */ | 57 | /* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */ |
60 | debounce_init(MATRIX_ROWS); | 58 | debounce_init(MATRIX_ROWS); |
@@ -80,7 +78,7 @@ void DebounceTest::runEventsInternal() { | |||
80 | } | 78 | } |
81 | } | 79 | } |
82 | 80 | ||
83 | first = false; | 81 | first = false; |
84 | previous = event.time_; | 82 | previous = event.time_; |
85 | 83 | ||
86 | /* Prepare input matrix */ | 84 | /* Prepare input matrix */ |
@@ -98,12 +96,7 @@ void DebounceTest::runEventsInternal() { | |||
98 | 96 | ||
99 | /* Check output matrix has expected change events */ | 97 | /* Check output matrix has expected change events */ |
100 | for (auto &output : event.outputs_) { | 98 | for (auto &output : event.outputs_) { |
101 | EXPECT_EQ(!!(cooked_matrix_[output.row_] & (1U << output.col_)), directionValue(output.direction_)) | 99 | EXPECT_EQ(!!(cooked_matrix_[output.row_] & (1U << output.col_)), directionValue(output.direction_)) << "Missing event at " << strTime() << " expected key " << output.row_ << "," << output.col_ << " " << directionLabel(output.direction_) << "\ninput_matrix: changed=" << !event.inputs_.empty() << "\n" << strMatrix(input_matrix_) << "\nexpected_matrix:\n" << strMatrix(output_matrix_) << "\nactual_matrix:\n" << strMatrix(cooked_matrix_); |
102 | << "Missing event at " << strTime() | ||
103 | << " expected key " << output.row_ << "," << output.col_ << " " << directionLabel(output.direction_) | ||
104 | << "\ninput_matrix: changed=" << !event.inputs_.empty() << "\n" << strMatrix(input_matrix_) | ||
105 | << "\nexpected_matrix:\n" << strMatrix(output_matrix_) | ||
106 | << "\nactual_matrix:\n" << strMatrix(cooked_matrix_); | ||
107 | } | 100 | } |
108 | 101 | ||
109 | /* Check output matrix has no other changes */ | 102 | /* Check output matrix has no other changes */ |
@@ -133,27 +126,20 @@ void DebounceTest::runDebounce(bool changed) { | |||
133 | debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed); | 126 | debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed); |
134 | 127 | ||
135 | if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) { | 128 | if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) { |
136 | FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() | 129 | FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nraw_matrix:\n" << strMatrix(raw_matrix_); |
137 | << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) | ||
138 | << "\nraw_matrix:\n" << strMatrix(raw_matrix_); | ||
139 | } | 130 | } |
140 | } | 131 | } |
141 | 132 | ||
142 | void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) { | 133 | void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) { |
143 | if (!std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_))) { | 134 | if (!std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_))) { |
144 | FAIL() << "Unexpected event: " << error_message << " at " << strTime() | 135 | FAIL() << "Unexpected event: " << error_message << " at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nexpected_matrix:\n" << strMatrix(output_matrix_) << "\nactual_matrix:\n" << strMatrix(cooked_matrix_); |
145 | << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) | ||
146 | << "\nexpected_matrix:\n" << strMatrix(output_matrix_) | ||
147 | << "\nactual_matrix:\n" << strMatrix(cooked_matrix_); | ||
148 | } | 136 | } |
149 | } | 137 | } |
150 | 138 | ||
151 | std::string DebounceTest::strTime() { | 139 | std::string DebounceTest::strTime() { |
152 | std::stringstream text; | 140 | std::stringstream text; |
153 | 141 | ||
154 | text << "time " << (timer_read_fast() - time_offset_) | 142 | text << "time " << (timer_read_fast() - time_offset_) << " (extra_iterations=" << extra_iterations_ << ", auto_advance_time=" << auto_advance_time_ << ")"; |
155 | << " (extra_iterations=" << extra_iterations_ | ||
156 | << ", auto_advance_time=" << auto_advance_time_ << ")"; | ||
157 | 143 | ||
158 | return text.str(); | 144 | return text.str(); |
159 | } | 145 | } |
@@ -181,49 +167,39 @@ std::string DebounceTest::strMatrix(matrix_row_t matrix[]) { | |||
181 | 167 | ||
182 | bool DebounceTest::directionValue(Direction direction) { | 168 | bool DebounceTest::directionValue(Direction direction) { |
183 | switch (direction) { | 169 | switch (direction) { |
184 | case DOWN: | 170 | case DOWN: |
185 | return true; | 171 | return true; |
186 | 172 | ||
187 | case UP: | 173 | case UP: |
188 | return false; | 174 | return false; |
189 | } | 175 | } |
190 | } | 176 | } |
191 | 177 | ||
192 | std::string DebounceTest::directionLabel(Direction direction) { | 178 | std::string DebounceTest::directionLabel(Direction direction) { |
193 | switch (direction) { | 179 | switch (direction) { |
194 | case DOWN: | 180 | case DOWN: |
195 | return "DOWN"; | 181 | return "DOWN"; |
196 | 182 | ||
197 | case UP: | 183 | case UP: |
198 | return "UP"; | 184 | return "UP"; |
199 | } | 185 | } |
200 | } | 186 | } |
201 | 187 | ||
202 | /* Modify a matrix and verify that events always specify a change */ | 188 | /* Modify a matrix and verify that events always specify a change */ |
203 | void DebounceTest::matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event) { | 189 | void DebounceTest::matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event) { |
204 | ASSERT_NE(!!(matrix[event.row_] & (1U << event.col_)), directionValue(event.direction_)) | 190 | ASSERT_NE(!!(matrix[event.row_] & (1U << event.col_)), directionValue(event.direction_)) << "Test " << name << " at " << strTime() << " sets key " << event.row_ << "," << event.col_ << " " << directionLabel(event.direction_) << " but it is already " << directionLabel(event.direction_) << "\n" << name << "_matrix:\n" << strMatrix(matrix); |
205 | << "Test " << name << " at " << strTime() | ||
206 | << " sets key " << event.row_ << "," << event.col_ << " " << directionLabel(event.direction_) | ||
207 | << " but it is already " << directionLabel(event.direction_) | ||
208 | << "\n" << name << "_matrix:\n" << strMatrix(matrix); | ||
209 | 191 | ||
210 | switch (event.direction_) { | 192 | switch (event.direction_) { |
211 | case DOWN: | 193 | case DOWN: |
212 | matrix[event.row_] |= (1U << event.col_); | 194 | matrix[event.row_] |= (1U << event.col_); |
213 | break; | 195 | break; |
214 | 196 | ||
215 | case UP: | 197 | case UP: |
216 | matrix[event.row_] &= ~(1U << event.col_); | 198 | matrix[event.row_] &= ~(1U << event.col_); |
217 | break; | 199 | break; |
218 | } | 200 | } |
219 | } | 201 | } |
220 | 202 | ||
221 | DebounceTestEvent::DebounceTestEvent(fast_timer_t time, | 203 | DebounceTestEvent::DebounceTestEvent(fast_timer_t time, std::initializer_list<MatrixTestEvent> inputs, std::initializer_list<MatrixTestEvent> outputs) : time_(time), inputs_(inputs), outputs_(outputs) {} |
222 | std::initializer_list<MatrixTestEvent> inputs, | ||
223 | std::initializer_list<MatrixTestEvent> outputs) | ||
224 | : time_(time), inputs_(inputs), outputs_(outputs) { | ||
225 | } | ||
226 | 204 | ||
227 | MatrixTestEvent::MatrixTestEvent(int row, int col, Direction direction) | 205 | MatrixTestEvent::MatrixTestEvent(int row, int col, Direction direction) : row_(row), col_(col), direction_(direction) {} |
228 | : row_(row), col_(col), direction_(direction) { | ||
229 | } | ||
diff --git a/quantum/debounce/tests/debounce_test_common.h b/quantum/debounce/tests/debounce_test_common.h index d87e31059..b7becb378 100644 --- a/quantum/debounce/tests/debounce_test_common.h +++ b/quantum/debounce/tests/debounce_test_common.h | |||
@@ -31,36 +31,34 @@ enum Direction { | |||
31 | }; | 31 | }; |
32 | 32 | ||
33 | class MatrixTestEvent { | 33 | class MatrixTestEvent { |
34 | public: | 34 | public: |
35 | MatrixTestEvent(int row, int col, Direction direction); | 35 | MatrixTestEvent(int row, int col, Direction direction); |
36 | 36 | ||
37 | const int row_; | 37 | const int row_; |
38 | const int col_; | 38 | const int col_; |
39 | const Direction direction_; | 39 | const Direction direction_; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | class DebounceTestEvent { | 42 | class DebounceTestEvent { |
43 | public: | 43 | public: |
44 | // 0, {{0, 1, DOWN}}, {{0, 1, DOWN}}) | 44 | // 0, {{0, 1, DOWN}}, {{0, 1, DOWN}}) |
45 | DebounceTestEvent(fast_timer_t time, | 45 | DebounceTestEvent(fast_timer_t time, std::initializer_list<MatrixTestEvent> inputs, std::initializer_list<MatrixTestEvent> outputs); |
46 | std::initializer_list<MatrixTestEvent> inputs, | ||
47 | std::initializer_list<MatrixTestEvent> outputs); | ||
48 | 46 | ||
49 | const fast_timer_t time_; | 47 | const fast_timer_t time_; |
50 | const std::list<MatrixTestEvent> inputs_; | 48 | const std::list<MatrixTestEvent> inputs_; |
51 | const std::list<MatrixTestEvent> outputs_; | 49 | const std::list<MatrixTestEvent> outputs_; |
52 | }; | 50 | }; |
53 | 51 | ||
54 | class DebounceTest : public ::testing::Test { | 52 | class DebounceTest : public ::testing::Test { |
55 | protected: | 53 | protected: |
56 | void addEvents(std::initializer_list<DebounceTestEvent> events); | 54 | void addEvents(std::initializer_list<DebounceTestEvent> events); |
57 | void runEvents(); | 55 | void runEvents(); |
58 | 56 | ||
59 | fast_timer_t time_offset_ = 7777; | 57 | fast_timer_t time_offset_ = 7777; |
60 | bool time_jumps_ = false; | 58 | bool time_jumps_ = false; |
61 | 59 | ||
62 | private: | 60 | private: |
63 | static bool directionValue(Direction direction); | 61 | static bool directionValue(Direction direction); |
64 | static std::string directionLabel(Direction direction); | 62 | static std::string directionLabel(Direction direction); |
65 | 63 | ||
66 | void runEventsInternal(); | 64 | void runEventsInternal(); |
@@ -78,6 +76,6 @@ private: | |||
78 | matrix_row_t cooked_matrix_[MATRIX_ROWS]; | 76 | matrix_row_t cooked_matrix_[MATRIX_ROWS]; |
79 | matrix_row_t output_matrix_[MATRIX_ROWS]; | 77 | matrix_row_t output_matrix_[MATRIX_ROWS]; |
80 | 78 | ||
81 | int extra_iterations_; | 79 | int extra_iterations_; |
82 | bool auto_advance_time_; | 80 | bool auto_advance_time_; |
83 | }; | 81 | }; |
diff --git a/quantum/debounce/tests/sym_defer_g_tests.cpp b/quantum/debounce/tests/sym_defer_g_tests.cpp index a56aecd8f..73d3d45e3 100644 --- a/quantum/debounce/tests/sym_defer_g_tests.cpp +++ b/quantum/debounce/tests/sym_defer_g_tests.cpp | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "debounce_test_common.h" | 19 | #include "debounce_test_common.h" |
20 | 20 | ||
21 | TEST_F(DebounceTest, OneKeyShort1) { | 21 | TEST_F(DebounceTest, OneKeyShort1) { |
22 | addEvents({ /* Time, Inputs, Outputs */ | 22 | addEvents({ |
23 | /* Time, Inputs, Outputs */ | ||
23 | {0, {{0, 1, DOWN}}, {}}, | 24 | {0, {{0, 1, DOWN}}, {}}, |
24 | 25 | ||
25 | {5, {}, {{0, 1, DOWN}}}, | 26 | {5, {}, {{0, 1, DOWN}}}, |
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) { | |||
32 | } | 33 | } |
33 | 34 | ||
34 | TEST_F(DebounceTest, OneKeyShort2) { | 35 | TEST_F(DebounceTest, OneKeyShort2) { |
35 | addEvents({ /* Time, Inputs, Outputs */ | 36 | addEvents({ |
37 | /* Time, Inputs, Outputs */ | ||
36 | {0, {{0, 1, DOWN}}, {}}, | 38 | {0, {{0, 1, DOWN}}, {}}, |
37 | 39 | ||
38 | {5, {}, {{0, 1, DOWN}}}, | 40 | {5, {}, {{0, 1, DOWN}}}, |
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) { | |||
45 | } | 47 | } |
46 | 48 | ||
47 | TEST_F(DebounceTest, OneKeyShort3) { | 49 | TEST_F(DebounceTest, OneKeyShort3) { |
48 | addEvents({ /* Time, Inputs, Outputs */ | 50 | addEvents({ |
51 | /* Time, Inputs, Outputs */ | ||
49 | {0, {{0, 1, DOWN}}, {}}, | 52 | {0, {{0, 1, DOWN}}, {}}, |
50 | 53 | ||
51 | {5, {}, {{0, 1, DOWN}}}, | 54 | {5, {}, {{0, 1, DOWN}}}, |
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) { | |||
58 | } | 61 | } |
59 | 62 | ||
60 | TEST_F(DebounceTest, OneKeyTooQuick1) { | 63 | TEST_F(DebounceTest, OneKeyTooQuick1) { |
61 | addEvents({ /* Time, Inputs, Outputs */ | 64 | addEvents({ |
65 | /* Time, Inputs, Outputs */ | ||
62 | {0, {{0, 1, DOWN}}, {}}, | 66 | {0, {{0, 1, DOWN}}, {}}, |
63 | /* Release key exactly on the debounce time */ | 67 | /* Release key exactly on the debounce time */ |
64 | {5, {{0, 1, UP}}, {}}, | 68 | {5, {{0, 1, UP}}, {}}, |
@@ -67,7 +71,8 @@ TEST_F(DebounceTest, OneKeyTooQuick1) { | |||
67 | } | 71 | } |
68 | 72 | ||
69 | TEST_F(DebounceTest, OneKeyTooQuick2) { | 73 | TEST_F(DebounceTest, OneKeyTooQuick2) { |
70 | addEvents({ /* Time, Inputs, Outputs */ | 74 | addEvents({ |
75 | /* Time, Inputs, Outputs */ | ||
71 | {0, {{0, 1, DOWN}}, {}}, | 76 | {0, {{0, 1, DOWN}}, {}}, |
72 | 77 | ||
73 | {5, {}, {{0, 1, DOWN}}}, | 78 | {5, {}, {{0, 1, DOWN}}}, |
@@ -80,7 +85,8 @@ TEST_F(DebounceTest, OneKeyTooQuick2) { | |||
80 | } | 85 | } |
81 | 86 | ||
82 | TEST_F(DebounceTest, OneKeyBouncing1) { | 87 | TEST_F(DebounceTest, OneKeyBouncing1) { |
83 | addEvents({ /* Time, Inputs, Outputs */ | 88 | addEvents({ |
89 | /* Time, Inputs, Outputs */ | ||
84 | {0, {{0, 1, DOWN}}, {}}, | 90 | {0, {{0, 1, DOWN}}, {}}, |
85 | {1, {{0, 1, UP}}, {}}, | 91 | {1, {{0, 1, UP}}, {}}, |
86 | {2, {{0, 1, DOWN}}, {}}, | 92 | {2, {{0, 1, DOWN}}, {}}, |
@@ -94,7 +100,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) { | |||
94 | } | 100 | } |
95 | 101 | ||
96 | TEST_F(DebounceTest, OneKeyBouncing2) { | 102 | TEST_F(DebounceTest, OneKeyBouncing2) { |
97 | addEvents({ /* Time, Inputs, Outputs */ | 103 | addEvents({ |
104 | /* Time, Inputs, Outputs */ | ||
98 | {0, {{0, 1, DOWN}}, {}}, | 105 | {0, {{0, 1, DOWN}}, {}}, |
99 | {5, {}, {{0, 1, DOWN}}}, | 106 | {5, {}, {{0, 1, DOWN}}}, |
100 | {6, {{0, 1, UP}}, {}}, | 107 | {6, {{0, 1, UP}}, {}}, |
@@ -108,7 +115,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) { | |||
108 | } | 115 | } |
109 | 116 | ||
110 | TEST_F(DebounceTest, OneKeyLong) { | 117 | TEST_F(DebounceTest, OneKeyLong) { |
111 | addEvents({ /* Time, Inputs, Outputs */ | 118 | addEvents({ |
119 | /* Time, Inputs, Outputs */ | ||
112 | {0, {{0, 1, DOWN}}, {}}, | 120 | {0, {{0, 1, DOWN}}, {}}, |
113 | 121 | ||
114 | {5, {}, {{0, 1, DOWN}}}, | 122 | {5, {}, {{0, 1, DOWN}}}, |
@@ -125,7 +133,8 @@ TEST_F(DebounceTest, OneKeyLong) { | |||
125 | } | 133 | } |
126 | 134 | ||
127 | TEST_F(DebounceTest, TwoKeysShort) { | 135 | TEST_F(DebounceTest, TwoKeysShort) { |
128 | addEvents({ /* Time, Inputs, Outputs */ | 136 | addEvents({ |
137 | /* Time, Inputs, Outputs */ | ||
129 | {0, {{0, 1, DOWN}}, {}}, | 138 | {0, {{0, 1, DOWN}}, {}}, |
130 | {1, {{0, 2, DOWN}}, {}}, | 139 | {1, {{0, 2, DOWN}}, {}}, |
131 | 140 | ||
@@ -140,7 +149,8 @@ TEST_F(DebounceTest, TwoKeysShort) { | |||
140 | } | 149 | } |
141 | 150 | ||
142 | TEST_F(DebounceTest, TwoKeysSimultaneous1) { | 151 | TEST_F(DebounceTest, TwoKeysSimultaneous1) { |
143 | addEvents({ /* Time, Inputs, Outputs */ | 152 | addEvents({ |
153 | /* Time, Inputs, Outputs */ | ||
144 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}}, | 154 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}}, |
145 | 155 | ||
146 | {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}}, | 156 | {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}}, |
@@ -152,7 +162,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous1) { | |||
152 | } | 162 | } |
153 | 163 | ||
154 | TEST_F(DebounceTest, TwoKeysSimultaneous2) { | 164 | TEST_F(DebounceTest, TwoKeysSimultaneous2) { |
155 | addEvents({ /* Time, Inputs, Outputs */ | 165 | addEvents({ |
166 | /* Time, Inputs, Outputs */ | ||
156 | {0, {{0, 1, DOWN}}, {}}, | 167 | {0, {{0, 1, DOWN}}, {}}, |
157 | {1, {{0, 2, DOWN}}, {}}, | 168 | {1, {{0, 2, DOWN}}, {}}, |
158 | 169 | ||
@@ -167,7 +178,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous2) { | |||
167 | } | 178 | } |
168 | 179 | ||
169 | TEST_F(DebounceTest, OneKeyDelayedScan1) { | 180 | TEST_F(DebounceTest, OneKeyDelayedScan1) { |
170 | addEvents({ /* Time, Inputs, Outputs */ | 181 | addEvents({ |
182 | /* Time, Inputs, Outputs */ | ||
171 | {0, {{0, 1, DOWN}}, {}}, | 183 | {0, {{0, 1, DOWN}}, {}}, |
172 | 184 | ||
173 | /* Processing is very late */ | 185 | /* Processing is very late */ |
@@ -182,7 +194,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) { | |||
182 | } | 194 | } |
183 | 195 | ||
184 | TEST_F(DebounceTest, OneKeyDelayedScan2) { | 196 | TEST_F(DebounceTest, OneKeyDelayedScan2) { |
185 | addEvents({ /* Time, Inputs, Outputs */ | 197 | addEvents({ |
198 | /* Time, Inputs, Outputs */ | ||
186 | {0, {{0, 1, DOWN}}, {}}, | 199 | {0, {{0, 1, DOWN}}, {}}, |
187 | 200 | ||
188 | /* Processing is very late */ | 201 | /* Processing is very late */ |
@@ -197,7 +210,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) { | |||
197 | } | 210 | } |
198 | 211 | ||
199 | TEST_F(DebounceTest, OneKeyDelayedScan3) { | 212 | TEST_F(DebounceTest, OneKeyDelayedScan3) { |
200 | addEvents({ /* Time, Inputs, Outputs */ | 213 | addEvents({ |
214 | /* Time, Inputs, Outputs */ | ||
201 | {0, {{0, 1, DOWN}}, {}}, | 215 | {0, {{0, 1, DOWN}}, {}}, |
202 | 216 | ||
203 | /* Release key before debounce expires */ | 217 | /* Release key before debounce expires */ |
@@ -208,7 +222,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) { | |||
208 | } | 222 | } |
209 | 223 | ||
210 | TEST_F(DebounceTest, OneKeyDelayedScan4) { | 224 | TEST_F(DebounceTest, OneKeyDelayedScan4) { |
211 | addEvents({ /* Time, Inputs, Outputs */ | 225 | addEvents({ |
226 | /* Time, Inputs, Outputs */ | ||
212 | {0, {{0, 1, DOWN}}, {}}, | 227 | {0, {{0, 1, DOWN}}, {}}, |
213 | 228 | ||
214 | /* Processing is a bit late */ | 229 | /* Processing is a bit late */ |
diff --git a/quantum/debounce/tests/sym_defer_pk_tests.cpp b/quantum/debounce/tests/sym_defer_pk_tests.cpp index 1f3061e59..7542c2dad 100644 --- a/quantum/debounce/tests/sym_defer_pk_tests.cpp +++ b/quantum/debounce/tests/sym_defer_pk_tests.cpp | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "debounce_test_common.h" | 19 | #include "debounce_test_common.h" |
20 | 20 | ||
21 | TEST_F(DebounceTest, OneKeyShort1) { | 21 | TEST_F(DebounceTest, OneKeyShort1) { |
22 | addEvents({ /* Time, Inputs, Outputs */ | 22 | addEvents({ |
23 | /* Time, Inputs, Outputs */ | ||
23 | {0, {{0, 1, DOWN}}, {}}, | 24 | {0, {{0, 1, DOWN}}, {}}, |
24 | 25 | ||
25 | {5, {}, {{0, 1, DOWN}}}, | 26 | {5, {}, {{0, 1, DOWN}}}, |
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) { | |||
32 | } | 33 | } |
33 | 34 | ||
34 | TEST_F(DebounceTest, OneKeyShort2) { | 35 | TEST_F(DebounceTest, OneKeyShort2) { |
35 | addEvents({ /* Time, Inputs, Outputs */ | 36 | addEvents({ |
37 | /* Time, Inputs, Outputs */ | ||
36 | {0, {{0, 1, DOWN}}, {}}, | 38 | {0, {{0, 1, DOWN}}, {}}, |
37 | 39 | ||
38 | {5, {}, {{0, 1, DOWN}}}, | 40 | {5, {}, {{0, 1, DOWN}}}, |
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) { | |||
45 | } | 47 | } |
46 | 48 | ||
47 | TEST_F(DebounceTest, OneKeyShort3) { | 49 | TEST_F(DebounceTest, OneKeyShort3) { |
48 | addEvents({ /* Time, Inputs, Outputs */ | 50 | addEvents({ |
51 | /* Time, Inputs, Outputs */ | ||
49 | {0, {{0, 1, DOWN}}, {}}, | 52 | {0, {{0, 1, DOWN}}, {}}, |
50 | 53 | ||
51 | {5, {}, {{0, 1, DOWN}}}, | 54 | {5, {}, {{0, 1, DOWN}}}, |
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) { | |||
58 | } | 61 | } |
59 | 62 | ||
60 | TEST_F(DebounceTest, OneKeyTooQuick1) { | 63 | TEST_F(DebounceTest, OneKeyTooQuick1) { |
61 | addEvents({ /* Time, Inputs, Outputs */ | 64 | addEvents({ |
65 | /* Time, Inputs, Outputs */ | ||
62 | {0, {{0, 1, DOWN}}, {}}, | 66 | {0, {{0, 1, DOWN}}, {}}, |
63 | /* Release key exactly on the debounce time */ | 67 | /* Release key exactly on the debounce time */ |
64 | {5, {{0, 1, UP}}, {}}, | 68 | {5, {{0, 1, UP}}, {}}, |
@@ -67,7 +71,8 @@ TEST_F(DebounceTest, OneKeyTooQuick1) { | |||
67 | } | 71 | } |
68 | 72 | ||
69 | TEST_F(DebounceTest, OneKeyTooQuick2) { | 73 | TEST_F(DebounceTest, OneKeyTooQuick2) { |
70 | addEvents({ /* Time, Inputs, Outputs */ | 74 | addEvents({ |
75 | /* Time, Inputs, Outputs */ | ||
71 | {0, {{0, 1, DOWN}}, {}}, | 76 | {0, {{0, 1, DOWN}}, {}}, |
72 | 77 | ||
73 | {5, {}, {{0, 1, DOWN}}}, | 78 | {5, {}, {{0, 1, DOWN}}}, |
@@ -80,7 +85,8 @@ TEST_F(DebounceTest, OneKeyTooQuick2) { | |||
80 | } | 85 | } |
81 | 86 | ||
82 | TEST_F(DebounceTest, OneKeyBouncing1) { | 87 | TEST_F(DebounceTest, OneKeyBouncing1) { |
83 | addEvents({ /* Time, Inputs, Outputs */ | 88 | addEvents({ |
89 | /* Time, Inputs, Outputs */ | ||
84 | {0, {{0, 1, DOWN}}, {}}, | 90 | {0, {{0, 1, DOWN}}, {}}, |
85 | {1, {{0, 1, UP}}, {}}, | 91 | {1, {{0, 1, UP}}, {}}, |
86 | {2, {{0, 1, DOWN}}, {}}, | 92 | {2, {{0, 1, DOWN}}, {}}, |
@@ -94,7 +100,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) { | |||
94 | } | 100 | } |
95 | 101 | ||
96 | TEST_F(DebounceTest, OneKeyBouncing2) { | 102 | TEST_F(DebounceTest, OneKeyBouncing2) { |
97 | addEvents({ /* Time, Inputs, Outputs */ | 103 | addEvents({ |
104 | /* Time, Inputs, Outputs */ | ||
98 | {0, {{0, 1, DOWN}}, {}}, | 105 | {0, {{0, 1, DOWN}}, {}}, |
99 | {5, {}, {{0, 1, DOWN}}}, | 106 | {5, {}, {{0, 1, DOWN}}}, |
100 | {6, {{0, 1, UP}}, {}}, | 107 | {6, {{0, 1, UP}}, {}}, |
@@ -108,7 +115,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) { | |||
108 | } | 115 | } |
109 | 116 | ||
110 | TEST_F(DebounceTest, OneKeyLong) { | 117 | TEST_F(DebounceTest, OneKeyLong) { |
111 | addEvents({ /* Time, Inputs, Outputs */ | 118 | addEvents({ |
119 | /* Time, Inputs, Outputs */ | ||
112 | {0, {{0, 1, DOWN}}, {}}, | 120 | {0, {{0, 1, DOWN}}, {}}, |
113 | 121 | ||
114 | {5, {}, {{0, 1, DOWN}}}, | 122 | {5, {}, {{0, 1, DOWN}}}, |
@@ -125,7 +133,8 @@ TEST_F(DebounceTest, OneKeyLong) { | |||
125 | } | 133 | } |
126 | 134 | ||
127 | TEST_F(DebounceTest, TwoKeysShort) { | 135 | TEST_F(DebounceTest, TwoKeysShort) { |
128 | addEvents({ /* Time, Inputs, Outputs */ | 136 | addEvents({ |
137 | /* Time, Inputs, Outputs */ | ||
129 | {0, {{0, 1, DOWN}}, {}}, | 138 | {0, {{0, 1, DOWN}}, {}}, |
130 | {1, {{0, 2, DOWN}}, {}}, | 139 | {1, {{0, 2, DOWN}}, {}}, |
131 | 140 | ||
@@ -142,7 +151,8 @@ TEST_F(DebounceTest, TwoKeysShort) { | |||
142 | } | 151 | } |
143 | 152 | ||
144 | TEST_F(DebounceTest, TwoKeysSimultaneous1) { | 153 | TEST_F(DebounceTest, TwoKeysSimultaneous1) { |
145 | addEvents({ /* Time, Inputs, Outputs */ | 154 | addEvents({ |
155 | /* Time, Inputs, Outputs */ | ||
146 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}}, | 156 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}}, |
147 | 157 | ||
148 | {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}}, | 158 | {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}}, |
@@ -154,7 +164,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous1) { | |||
154 | } | 164 | } |
155 | 165 | ||
156 | TEST_F(DebounceTest, TwoKeysSimultaneous2) { | 166 | TEST_F(DebounceTest, TwoKeysSimultaneous2) { |
157 | addEvents({ /* Time, Inputs, Outputs */ | 167 | addEvents({ |
168 | /* Time, Inputs, Outputs */ | ||
158 | {0, {{0, 1, DOWN}}, {}}, | 169 | {0, {{0, 1, DOWN}}, {}}, |
159 | {1, {{0, 2, DOWN}}, {}}, | 170 | {1, {{0, 2, DOWN}}, {}}, |
160 | 171 | ||
@@ -169,7 +180,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous2) { | |||
169 | } | 180 | } |
170 | 181 | ||
171 | TEST_F(DebounceTest, OneKeyDelayedScan1) { | 182 | TEST_F(DebounceTest, OneKeyDelayedScan1) { |
172 | addEvents({ /* Time, Inputs, Outputs */ | 183 | addEvents({ |
184 | /* Time, Inputs, Outputs */ | ||
173 | {0, {{0, 1, DOWN}}, {}}, | 185 | {0, {{0, 1, DOWN}}, {}}, |
174 | 186 | ||
175 | /* Processing is very late */ | 187 | /* Processing is very late */ |
@@ -184,7 +196,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) { | |||
184 | } | 196 | } |
185 | 197 | ||
186 | TEST_F(DebounceTest, OneKeyDelayedScan2) { | 198 | TEST_F(DebounceTest, OneKeyDelayedScan2) { |
187 | addEvents({ /* Time, Inputs, Outputs */ | 199 | addEvents({ |
200 | /* Time, Inputs, Outputs */ | ||
188 | {0, {{0, 1, DOWN}}, {}}, | 201 | {0, {{0, 1, DOWN}}, {}}, |
189 | 202 | ||
190 | /* Processing is very late */ | 203 | /* Processing is very late */ |
@@ -199,7 +212,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) { | |||
199 | } | 212 | } |
200 | 213 | ||
201 | TEST_F(DebounceTest, OneKeyDelayedScan3) { | 214 | TEST_F(DebounceTest, OneKeyDelayedScan3) { |
202 | addEvents({ /* Time, Inputs, Outputs */ | 215 | addEvents({ |
216 | /* Time, Inputs, Outputs */ | ||
203 | {0, {{0, 1, DOWN}}, {}}, | 217 | {0, {{0, 1, DOWN}}, {}}, |
204 | 218 | ||
205 | /* Release key before debounce expires */ | 219 | /* Release key before debounce expires */ |
@@ -210,7 +224,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) { | |||
210 | } | 224 | } |
211 | 225 | ||
212 | TEST_F(DebounceTest, OneKeyDelayedScan4) { | 226 | TEST_F(DebounceTest, OneKeyDelayedScan4) { |
213 | addEvents({ /* Time, Inputs, Outputs */ | 227 | addEvents({ |
228 | /* Time, Inputs, Outputs */ | ||
214 | {0, {{0, 1, DOWN}}, {}}, | 229 | {0, {{0, 1, DOWN}}, {}}, |
215 | 230 | ||
216 | /* Processing is a bit late */ | 231 | /* Processing is a bit late */ |
diff --git a/quantum/debounce/tests/sym_eager_pk_tests.cpp b/quantum/debounce/tests/sym_eager_pk_tests.cpp index e0fc205e3..d9a02fe33 100644 --- a/quantum/debounce/tests/sym_eager_pk_tests.cpp +++ b/quantum/debounce/tests/sym_eager_pk_tests.cpp | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "debounce_test_common.h" | 19 | #include "debounce_test_common.h" |
20 | 20 | ||
21 | TEST_F(DebounceTest, OneKeyShort1) { | 21 | TEST_F(DebounceTest, OneKeyShort1) { |
22 | addEvents({ /* Time, Inputs, Outputs */ | 22 | addEvents({ |
23 | /* Time, Inputs, Outputs */ | ||
23 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 24 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
24 | {1, {{0, 1, UP}}, {}}, | 25 | {1, {{0, 1, UP}}, {}}, |
25 | 26 | ||
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) { | |||
32 | } | 33 | } |
33 | 34 | ||
34 | TEST_F(DebounceTest, OneKeyShort2) { | 35 | TEST_F(DebounceTest, OneKeyShort2) { |
35 | addEvents({ /* Time, Inputs, Outputs */ | 36 | addEvents({ |
37 | /* Time, Inputs, Outputs */ | ||
36 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 38 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
37 | {1, {{0, 1, UP}}, {}}, | 39 | {1, {{0, 1, UP}}, {}}, |
38 | 40 | ||
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) { | |||
45 | } | 47 | } |
46 | 48 | ||
47 | TEST_F(DebounceTest, OneKeyShort3) { | 49 | TEST_F(DebounceTest, OneKeyShort3) { |
48 | addEvents({ /* Time, Inputs, Outputs */ | 50 | addEvents({ |
51 | /* Time, Inputs, Outputs */ | ||
49 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 52 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
50 | {1, {{0, 1, UP}}, {}}, | 53 | {1, {{0, 1, UP}}, {}}, |
51 | 54 | ||
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) { | |||
58 | } | 61 | } |
59 | 62 | ||
60 | TEST_F(DebounceTest, OneKeyShort4) { | 63 | TEST_F(DebounceTest, OneKeyShort4) { |
61 | addEvents({ /* Time, Inputs, Outputs */ | 64 | addEvents({ |
65 | /* Time, Inputs, Outputs */ | ||
62 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 66 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
63 | {1, {{0, 1, UP}}, {}}, | 67 | {1, {{0, 1, UP}}, {}}, |
64 | 68 | ||
@@ -71,7 +75,8 @@ TEST_F(DebounceTest, OneKeyShort4) { | |||
71 | } | 75 | } |
72 | 76 | ||
73 | TEST_F(DebounceTest, OneKeyShort5) { | 77 | TEST_F(DebounceTest, OneKeyShort5) { |
74 | addEvents({ /* Time, Inputs, Outputs */ | 78 | addEvents({ |
79 | /* Time, Inputs, Outputs */ | ||
75 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 80 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
76 | {1, {{0, 1, UP}}, {}}, | 81 | {1, {{0, 1, UP}}, {}}, |
77 | 82 | ||
@@ -83,7 +88,8 @@ TEST_F(DebounceTest, OneKeyShort5) { | |||
83 | } | 88 | } |
84 | 89 | ||
85 | TEST_F(DebounceTest, OneKeyShort6) { | 90 | TEST_F(DebounceTest, OneKeyShort6) { |
86 | addEvents({ /* Time, Inputs, Outputs */ | 91 | addEvents({ |
92 | /* Time, Inputs, Outputs */ | ||
87 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 93 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
88 | {1, {{0, 1, UP}}, {}}, | 94 | {1, {{0, 1, UP}}, {}}, |
89 | 95 | ||
@@ -95,7 +101,8 @@ TEST_F(DebounceTest, OneKeyShort6) { | |||
95 | } | 101 | } |
96 | 102 | ||
97 | TEST_F(DebounceTest, OneKeyBouncing1) { | 103 | TEST_F(DebounceTest, OneKeyBouncing1) { |
98 | addEvents({ /* Time, Inputs, Outputs */ | 104 | addEvents({ |
105 | /* Time, Inputs, Outputs */ | ||
99 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 106 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
100 | {1, {{0, 1, UP}}, {}}, | 107 | {1, {{0, 1, UP}}, {}}, |
101 | {2, {{0, 1, DOWN}}, {}}, | 108 | {2, {{0, 1, DOWN}}, {}}, |
@@ -110,7 +117,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) { | |||
110 | } | 117 | } |
111 | 118 | ||
112 | TEST_F(DebounceTest, OneKeyBouncing2) { | 119 | TEST_F(DebounceTest, OneKeyBouncing2) { |
113 | addEvents({ /* Time, Inputs, Outputs */ | 120 | addEvents({ |
121 | /* Time, Inputs, Outputs */ | ||
114 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 122 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
115 | /* Change twice in the same time period */ | 123 | /* Change twice in the same time period */ |
116 | {1, {{0, 1, UP}}, {}}, | 124 | {1, {{0, 1, UP}}, {}}, |
@@ -135,7 +143,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) { | |||
135 | } | 143 | } |
136 | 144 | ||
137 | TEST_F(DebounceTest, OneKeyLong) { | 145 | TEST_F(DebounceTest, OneKeyLong) { |
138 | addEvents({ /* Time, Inputs, Outputs */ | 146 | addEvents({ |
147 | /* Time, Inputs, Outputs */ | ||
139 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 148 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
140 | 149 | ||
141 | {25, {{0, 1, UP}}, {{0, 1, UP}}}, | 150 | {25, {{0, 1, UP}}, {{0, 1, UP}}}, |
@@ -146,7 +155,8 @@ TEST_F(DebounceTest, OneKeyLong) { | |||
146 | } | 155 | } |
147 | 156 | ||
148 | TEST_F(DebounceTest, TwoKeysShort) { | 157 | TEST_F(DebounceTest, TwoKeysShort) { |
149 | addEvents({ /* Time, Inputs, Outputs */ | 158 | addEvents({ |
159 | /* Time, Inputs, Outputs */ | ||
150 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 160 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
151 | {1, {{0, 1, UP}}, {}}, | 161 | {1, {{0, 1, UP}}, {}}, |
152 | {2, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, | 162 | {2, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, |
@@ -167,7 +177,8 @@ TEST_F(DebounceTest, TwoKeysShort) { | |||
167 | } | 177 | } |
168 | 178 | ||
169 | TEST_F(DebounceTest, OneKeyDelayedScan1) { | 179 | TEST_F(DebounceTest, OneKeyDelayedScan1) { |
170 | addEvents({ /* Time, Inputs, Outputs */ | 180 | addEvents({ |
181 | /* Time, Inputs, Outputs */ | ||
171 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 182 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
172 | 183 | ||
173 | /* Processing is very late but the change will now be accepted */ | 184 | /* Processing is very late but the change will now be accepted */ |
@@ -178,7 +189,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) { | |||
178 | } | 189 | } |
179 | 190 | ||
180 | TEST_F(DebounceTest, OneKeyDelayedScan2) { | 191 | TEST_F(DebounceTest, OneKeyDelayedScan2) { |
181 | addEvents({ /* Time, Inputs, Outputs */ | 192 | addEvents({ |
193 | /* Time, Inputs, Outputs */ | ||
182 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 194 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
183 | 195 | ||
184 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ | 196 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ |
@@ -190,7 +202,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) { | |||
190 | } | 202 | } |
191 | 203 | ||
192 | TEST_F(DebounceTest, OneKeyDelayedScan3) { | 204 | TEST_F(DebounceTest, OneKeyDelayedScan3) { |
193 | addEvents({ /* Time, Inputs, Outputs */ | 205 | addEvents({ |
206 | /* Time, Inputs, Outputs */ | ||
194 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 207 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
195 | 208 | ||
196 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ | 209 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ |
@@ -202,7 +215,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) { | |||
202 | } | 215 | } |
203 | 216 | ||
204 | TEST_F(DebounceTest, OneKeyDelayedScan4) { | 217 | TEST_F(DebounceTest, OneKeyDelayedScan4) { |
205 | addEvents({ /* Time, Inputs, Outputs */ | 218 | addEvents({ |
219 | /* Time, Inputs, Outputs */ | ||
206 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 220 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
207 | 221 | ||
208 | /* Processing is a bit late but the change will now be accepted */ | 222 | /* Processing is a bit late but the change will now be accepted */ |
@@ -213,7 +227,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) { | |||
213 | } | 227 | } |
214 | 228 | ||
215 | TEST_F(DebounceTest, OneKeyDelayedScan5) { | 229 | TEST_F(DebounceTest, OneKeyDelayedScan5) { |
216 | addEvents({ /* Time, Inputs, Outputs */ | 230 | addEvents({ |
231 | /* Time, Inputs, Outputs */ | ||
217 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 232 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
218 | 233 | ||
219 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ | 234 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ |
@@ -225,7 +240,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan5) { | |||
225 | } | 240 | } |
226 | 241 | ||
227 | TEST_F(DebounceTest, OneKeyDelayedScan6) { | 242 | TEST_F(DebounceTest, OneKeyDelayedScan6) { |
228 | addEvents({ /* Time, Inputs, Outputs */ | 243 | addEvents({ |
244 | /* Time, Inputs, Outputs */ | ||
229 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 245 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
230 | 246 | ||
231 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ | 247 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ |
diff --git a/quantum/debounce/tests/sym_eager_pr_tests.cpp b/quantum/debounce/tests/sym_eager_pr_tests.cpp index 2c4bca127..e91dd9cb8 100644 --- a/quantum/debounce/tests/sym_eager_pr_tests.cpp +++ b/quantum/debounce/tests/sym_eager_pr_tests.cpp | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "debounce_test_common.h" | 19 | #include "debounce_test_common.h" |
20 | 20 | ||
21 | TEST_F(DebounceTest, OneKeyShort1) { | 21 | TEST_F(DebounceTest, OneKeyShort1) { |
22 | addEvents({ /* Time, Inputs, Outputs */ | 22 | addEvents({ |
23 | /* Time, Inputs, Outputs */ | ||
23 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 24 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
24 | {1, {{0, 1, UP}}, {}}, | 25 | {1, {{0, 1, UP}}, {}}, |
25 | 26 | ||
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) { | |||
32 | } | 33 | } |
33 | 34 | ||
34 | TEST_F(DebounceTest, OneKeyShort2) { | 35 | TEST_F(DebounceTest, OneKeyShort2) { |
35 | addEvents({ /* Time, Inputs, Outputs */ | 36 | addEvents({ |
37 | /* Time, Inputs, Outputs */ | ||
36 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 38 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
37 | {1, {{0, 1, UP}}, {}}, | 39 | {1, {{0, 1, UP}}, {}}, |
38 | 40 | ||
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) { | |||
45 | } | 47 | } |
46 | 48 | ||
47 | TEST_F(DebounceTest, OneKeyShort3) { | 49 | TEST_F(DebounceTest, OneKeyShort3) { |
48 | addEvents({ /* Time, Inputs, Outputs */ | 50 | addEvents({ |
51 | /* Time, Inputs, Outputs */ | ||
49 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 52 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
50 | {1, {{0, 1, UP}}, {}}, | 53 | {1, {{0, 1, UP}}, {}}, |
51 | 54 | ||
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) { | |||
58 | } | 61 | } |
59 | 62 | ||
60 | TEST_F(DebounceTest, OneKeyShort4) { | 63 | TEST_F(DebounceTest, OneKeyShort4) { |
61 | addEvents({ /* Time, Inputs, Outputs */ | 64 | addEvents({ |
65 | /* Time, Inputs, Outputs */ | ||
62 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 66 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
63 | {1, {{0, 1, UP}}, {}}, | 67 | {1, {{0, 1, UP}}, {}}, |
64 | 68 | ||
@@ -71,7 +75,8 @@ TEST_F(DebounceTest, OneKeyShort4) { | |||
71 | } | 75 | } |
72 | 76 | ||
73 | TEST_F(DebounceTest, OneKeyShort5) { | 77 | TEST_F(DebounceTest, OneKeyShort5) { |
74 | addEvents({ /* Time, Inputs, Outputs */ | 78 | addEvents({ |
79 | /* Time, Inputs, Outputs */ | ||
75 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 80 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
76 | {1, {{0, 1, UP}}, {}}, | 81 | {1, {{0, 1, UP}}, {}}, |
77 | 82 | ||
@@ -83,7 +88,8 @@ TEST_F(DebounceTest, OneKeyShort5) { | |||
83 | } | 88 | } |
84 | 89 | ||
85 | TEST_F(DebounceTest, OneKeyShort6) { | 90 | TEST_F(DebounceTest, OneKeyShort6) { |
86 | addEvents({ /* Time, Inputs, Outputs */ | 91 | addEvents({ |
92 | /* Time, Inputs, Outputs */ | ||
87 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 93 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
88 | {1, {{0, 1, UP}}, {}}, | 94 | {1, {{0, 1, UP}}, {}}, |
89 | 95 | ||
@@ -95,7 +101,8 @@ TEST_F(DebounceTest, OneKeyShort6) { | |||
95 | } | 101 | } |
96 | 102 | ||
97 | TEST_F(DebounceTest, OneKeyBouncing1) { | 103 | TEST_F(DebounceTest, OneKeyBouncing1) { |
98 | addEvents({ /* Time, Inputs, Outputs */ | 104 | addEvents({ |
105 | /* Time, Inputs, Outputs */ | ||
99 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 106 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
100 | {1, {{0, 1, UP}}, {}}, | 107 | {1, {{0, 1, UP}}, {}}, |
101 | {2, {{0, 1, DOWN}}, {}}, | 108 | {2, {{0, 1, DOWN}}, {}}, |
@@ -110,7 +117,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) { | |||
110 | } | 117 | } |
111 | 118 | ||
112 | TEST_F(DebounceTest, OneKeyBouncing2) { | 119 | TEST_F(DebounceTest, OneKeyBouncing2) { |
113 | addEvents({ /* Time, Inputs, Outputs */ | 120 | addEvents({ |
121 | /* Time, Inputs, Outputs */ | ||
114 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 122 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
115 | /* Change twice in the same time period */ | 123 | /* Change twice in the same time period */ |
116 | {1, {{0, 1, UP}}, {}}, | 124 | {1, {{0, 1, UP}}, {}}, |
@@ -135,7 +143,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) { | |||
135 | } | 143 | } |
136 | 144 | ||
137 | TEST_F(DebounceTest, OneKeyLong) { | 145 | TEST_F(DebounceTest, OneKeyLong) { |
138 | addEvents({ /* Time, Inputs, Outputs */ | 146 | addEvents({ |
147 | /* Time, Inputs, Outputs */ | ||
139 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 148 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
140 | 149 | ||
141 | {25, {{0, 1, UP}}, {{0, 1, UP}}}, | 150 | {25, {{0, 1, UP}}, {{0, 1, UP}}}, |
@@ -146,7 +155,8 @@ TEST_F(DebounceTest, OneKeyLong) { | |||
146 | } | 155 | } |
147 | 156 | ||
148 | TEST_F(DebounceTest, TwoRowsShort) { | 157 | TEST_F(DebounceTest, TwoRowsShort) { |
149 | addEvents({ /* Time, Inputs, Outputs */ | 158 | addEvents({ |
159 | /* Time, Inputs, Outputs */ | ||
150 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 160 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
151 | {1, {{0, 1, UP}}, {}}, | 161 | {1, {{0, 1, UP}}, {}}, |
152 | {2, {{2, 0, DOWN}}, {{2, 0, DOWN}}}, | 162 | {2, {{2, 0, DOWN}}, {{2, 0, DOWN}}}, |
@@ -167,7 +177,8 @@ TEST_F(DebounceTest, TwoRowsShort) { | |||
167 | } | 177 | } |
168 | 178 | ||
169 | TEST_F(DebounceTest, TwoKeysOverlap) { | 179 | TEST_F(DebounceTest, TwoKeysOverlap) { |
170 | addEvents({ /* Time, Inputs, Outputs */ | 180 | addEvents({ |
181 | /* Time, Inputs, Outputs */ | ||
171 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 182 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
172 | {1, {{0, 1, UP}}, {}}, | 183 | {1, {{0, 1, UP}}, {}}, |
173 | /* Press a second key during the first debounce */ | 184 | /* Press a second key during the first debounce */ |
@@ -190,7 +201,8 @@ TEST_F(DebounceTest, TwoKeysOverlap) { | |||
190 | } | 201 | } |
191 | 202 | ||
192 | TEST_F(DebounceTest, TwoKeysSimultaneous1) { | 203 | TEST_F(DebounceTest, TwoKeysSimultaneous1) { |
193 | addEvents({ /* Time, Inputs, Outputs */ | 204 | addEvents({ |
205 | /* Time, Inputs, Outputs */ | ||
194 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}}, | 206 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}}, |
195 | {20, {{0, 1, UP}}, {{0, 1, UP}}}, | 207 | {20, {{0, 1, UP}}, {{0, 1, UP}}}, |
196 | {21, {{0, 2, UP}}, {}}, | 208 | {21, {{0, 2, UP}}, {}}, |
@@ -202,7 +214,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous1) { | |||
202 | } | 214 | } |
203 | 215 | ||
204 | TEST_F(DebounceTest, TwoKeysSimultaneous2) { | 216 | TEST_F(DebounceTest, TwoKeysSimultaneous2) { |
205 | addEvents({ /* Time, Inputs, Outputs */ | 217 | addEvents({ |
218 | /* Time, Inputs, Outputs */ | ||
206 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}}, | 219 | {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}}, |
207 | {20, {{0, 1, UP}, {0, 2, UP}}, {{0, 1, UP}, {0, 2, UP}}}, | 220 | {20, {{0, 1, UP}, {0, 2, UP}}, {{0, 1, UP}, {0, 2, UP}}}, |
208 | }); | 221 | }); |
@@ -210,7 +223,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous2) { | |||
210 | } | 223 | } |
211 | 224 | ||
212 | TEST_F(DebounceTest, OneKeyDelayedScan1) { | 225 | TEST_F(DebounceTest, OneKeyDelayedScan1) { |
213 | addEvents({ /* Time, Inputs, Outputs */ | 226 | addEvents({ |
227 | /* Time, Inputs, Outputs */ | ||
214 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 228 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
215 | 229 | ||
216 | /* Processing is very late but the change will now be accepted */ | 230 | /* Processing is very late but the change will now be accepted */ |
@@ -221,7 +235,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) { | |||
221 | } | 235 | } |
222 | 236 | ||
223 | TEST_F(DebounceTest, OneKeyDelayedScan2) { | 237 | TEST_F(DebounceTest, OneKeyDelayedScan2) { |
224 | addEvents({ /* Time, Inputs, Outputs */ | 238 | addEvents({ |
239 | /* Time, Inputs, Outputs */ | ||
225 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 240 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
226 | 241 | ||
227 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ | 242 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ |
@@ -233,7 +248,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) { | |||
233 | } | 248 | } |
234 | 249 | ||
235 | TEST_F(DebounceTest, OneKeyDelayedScan3) { | 250 | TEST_F(DebounceTest, OneKeyDelayedScan3) { |
236 | addEvents({ /* Time, Inputs, Outputs */ | 251 | addEvents({ |
252 | /* Time, Inputs, Outputs */ | ||
237 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 253 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
238 | 254 | ||
239 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ | 255 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ |
@@ -245,7 +261,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) { | |||
245 | } | 261 | } |
246 | 262 | ||
247 | TEST_F(DebounceTest, OneKeyDelayedScan4) { | 263 | TEST_F(DebounceTest, OneKeyDelayedScan4) { |
248 | addEvents({ /* Time, Inputs, Outputs */ | 264 | addEvents({ |
265 | /* Time, Inputs, Outputs */ | ||
249 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 266 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
250 | 267 | ||
251 | /* Processing is a bit late but the change will now be accepted */ | 268 | /* Processing is a bit late but the change will now be accepted */ |
@@ -256,7 +273,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) { | |||
256 | } | 273 | } |
257 | 274 | ||
258 | TEST_F(DebounceTest, OneKeyDelayedScan5) { | 275 | TEST_F(DebounceTest, OneKeyDelayedScan5) { |
259 | addEvents({ /* Time, Inputs, Outputs */ | 276 | addEvents({ |
277 | /* Time, Inputs, Outputs */ | ||
260 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 278 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
261 | 279 | ||
262 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ | 280 | /* Processing is very late but the change will now be accepted even with a 1 scan delay */ |
@@ -268,7 +286,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan5) { | |||
268 | } | 286 | } |
269 | 287 | ||
270 | TEST_F(DebounceTest, OneKeyDelayedScan6) { | 288 | TEST_F(DebounceTest, OneKeyDelayedScan6) { |
271 | addEvents({ /* Time, Inputs, Outputs */ | 289 | addEvents({ |
290 | /* Time, Inputs, Outputs */ | ||
272 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, | 291 | {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, |
273 | 292 | ||
274 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ | 293 | /* Processing is very late but the change will now be accepted even with a 1ms delay */ |
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h index ab95b43fd..310aa0740 100644 --- a/quantum/keymap_extras/keymap_steno.h +++ b/quantum/keymap_extras/keymap_steno.h | |||
@@ -74,8 +74,7 @@ enum steno_keycodes { | |||
74 | }; | 74 | }; |
75 | 75 | ||
76 | #ifdef STENO_COMBINEDMAP | 76 | #ifdef STENO_COMBINEDMAP |
77 | enum steno_combined_keycodes | 77 | enum steno_combined_keycodes { |
78 | { | ||
79 | STN_S3 = QK_STENO_COMB, | 78 | STN_S3 = QK_STENO_COMB, |
80 | STN_TKL, | 79 | STN_TKL, |
81 | STN_PWL, | 80 | STN_PWL, |
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index e8661839c..a050161ed 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
@@ -18,10 +18,9 @@ | |||
18 | #include "process_combo.h" | 18 | #include "process_combo.h" |
19 | #include "action_tapping.h" | 19 | #include "action_tapping.h" |
20 | 20 | ||
21 | |||
22 | #ifdef COMBO_COUNT | 21 | #ifdef COMBO_COUNT |
23 | __attribute__((weak)) combo_t key_combos[COMBO_COUNT]; | 22 | __attribute__((weak)) combo_t key_combos[COMBO_COUNT]; |
24 | uint16_t COMBO_LEN = COMBO_COUNT; | 23 | uint16_t COMBO_LEN = COMBO_COUNT; |
25 | #else | 24 | #else |
26 | extern combo_t key_combos[]; | 25 | extern combo_t key_combos[]; |
27 | extern uint16_t COMBO_LEN; | 26 | extern uint16_t COMBO_LEN; |
@@ -46,64 +45,86 @@ __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo | |||
46 | #endif | 45 | #endif |
47 | 46 | ||
48 | #ifndef COMBO_NO_TIMER | 47 | #ifndef COMBO_NO_TIMER |
49 | static uint16_t timer = 0; | 48 | static uint16_t timer = 0; |
50 | #endif | 49 | #endif |
51 | static bool b_combo_enable = true; // defaults to enabled | 50 | static bool b_combo_enable = true; // defaults to enabled |
52 | static uint16_t longest_term = 0; | 51 | static uint16_t longest_term = 0; |
53 | 52 | ||
54 | typedef struct { | 53 | typedef struct { |
55 | keyrecord_t record; | 54 | keyrecord_t record; |
56 | uint16_t combo_index; | 55 | uint16_t combo_index; |
57 | uint16_t keycode; | 56 | uint16_t keycode; |
58 | } queued_record_t; | 57 | } queued_record_t; |
59 | static uint8_t key_buffer_size = 0; | 58 | static uint8_t key_buffer_size = 0; |
60 | static queued_record_t key_buffer[COMBO_KEY_BUFFER_LENGTH]; | 59 | static queued_record_t key_buffer[COMBO_KEY_BUFFER_LENGTH]; |
61 | 60 | ||
62 | typedef struct { | 61 | typedef struct { |
63 | uint16_t combo_index; | 62 | uint16_t combo_index; |
64 | } queued_combo_t; | 63 | } queued_combo_t; |
65 | static uint8_t combo_buffer_write= 0; | 64 | static uint8_t combo_buffer_write = 0; |
66 | static uint8_t combo_buffer_read = 0; | 65 | static uint8_t combo_buffer_read = 0; |
67 | static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH]; | 66 | static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH]; |
68 | 67 | ||
69 | #define INCREMENT_MOD(i) i = (i + 1) % COMBO_BUFFER_LENGTH | 68 | #define INCREMENT_MOD(i) i = (i + 1) % COMBO_BUFFER_LENGTH |
70 | 69 | ||
71 | #define COMBO_KEY_POS ((keypos_t){.col=254, .row=254}) | 70 | #define COMBO_KEY_POS ((keypos_t){.col = 254, .row = 254}) |
72 | |||
73 | 71 | ||
74 | #ifndef EXTRA_SHORT_COMBOS | 72 | #ifndef EXTRA_SHORT_COMBOS |
75 | /* flags are their own elements in combo_t struct. */ | 73 | /* flags are their own elements in combo_t struct. */ |
76 | # define COMBO_ACTIVE(combo) (combo->active) | 74 | # define COMBO_ACTIVE(combo) (combo->active) |
77 | # define COMBO_DISABLED(combo) (combo->disabled) | 75 | # define COMBO_DISABLED(combo) (combo->disabled) |
78 | # define COMBO_STATE(combo) (combo->state) | 76 | # define COMBO_STATE(combo) (combo->state) |
79 | 77 | ||
80 | # define ACTIVATE_COMBO(combo) do {combo->active = true;}while(0) | 78 | # define ACTIVATE_COMBO(combo) \ |
81 | # define DEACTIVATE_COMBO(combo) do {combo->active = false;}while(0) | 79 | do { \ |
82 | # define DISABLE_COMBO(combo) do {combo->disabled = true;}while(0) | 80 | combo->active = true; \ |
83 | # define RESET_COMBO_STATE(combo) do { \ | 81 | } while (0) |
84 | combo->disabled = false; \ | 82 | # define DEACTIVATE_COMBO(combo) \ |
85 | combo->state = 0; \ | 83 | do { \ |
86 | }while(0) | 84 | combo->active = false; \ |
85 | } while (0) | ||
86 | # define DISABLE_COMBO(combo) \ | ||
87 | do { \ | ||
88 | combo->disabled = true; \ | ||
89 | } while (0) | ||
90 | # define RESET_COMBO_STATE(combo) \ | ||
91 | do { \ | ||
92 | combo->disabled = false; \ | ||
93 | combo->state = 0; \ | ||
94 | } while (0) | ||
87 | #else | 95 | #else |
88 | /* flags are at the two high bits of state. */ | 96 | /* flags are at the two high bits of state. */ |
89 | # define COMBO_ACTIVE(combo) (combo->state & 0x80) | 97 | # define COMBO_ACTIVE(combo) (combo->state & 0x80) |
90 | # define COMBO_DISABLED(combo) (combo->state & 0x40) | 98 | # define COMBO_DISABLED(combo) (combo->state & 0x40) |
91 | # define COMBO_STATE(combo) (combo->state & 0x3F) | 99 | # define COMBO_STATE(combo) (combo->state & 0x3F) |
92 | 100 | ||
93 | # define ACTIVATE_COMBO(combo) do {combo->state |= 0x80;}while(0) | 101 | # define ACTIVATE_COMBO(combo) \ |
94 | # define DEACTIVATE_COMBO(combo) do {combo->state &= ~0x80;}while(0) | 102 | do { \ |
95 | # define DISABLE_COMBO(combo) do {combo->state |= 0x40;}while(0) | 103 | combo->state |= 0x80; \ |
96 | # define RESET_COMBO_STATE(combo) do {combo->state &= ~0x7F;}while(0) | 104 | } while (0) |
105 | # define DEACTIVATE_COMBO(combo) \ | ||
106 | do { \ | ||
107 | combo->state &= ~0x80; \ | ||
108 | } while (0) | ||
109 | # define DISABLE_COMBO(combo) \ | ||
110 | do { \ | ||
111 | combo->state |= 0x40; \ | ||
112 | } while (0) | ||
113 | # define RESET_COMBO_STATE(combo) \ | ||
114 | do { \ | ||
115 | combo->state &= ~0x7F; \ | ||
116 | } while (0) | ||
97 | #endif | 117 | #endif |
98 | 118 | ||
99 | static inline void release_combo(uint16_t combo_index, combo_t *combo) { | 119 | static inline void release_combo(uint16_t combo_index, combo_t *combo) { |
100 | if (combo->keycode) { | 120 | if (combo->keycode) { |
101 | keyrecord_t record = { | 121 | keyrecord_t record = { |
102 | .event = { | 122 | .event = |
103 | .key = COMBO_KEY_POS, | 123 | { |
104 | .time = timer_read()|1, | 124 | .key = COMBO_KEY_POS, |
105 | .pressed = false, | 125 | .time = timer_read() | 1, |
106 | }, | 126 | .pressed = false, |
127 | }, | ||
107 | .keycode = combo->keycode, | 128 | .keycode = combo->keycode, |
108 | }; | 129 | }; |
109 | #ifndef NO_ACTION_TAPPING | 130 | #ifndef NO_ACTION_TAPPING |
@@ -123,18 +144,17 @@ static inline bool _get_combo_must_hold(uint16_t combo_index, combo_t *combo) { | |||
123 | #elif defined(COMBO_MUST_HOLD_PER_COMBO) | 144 | #elif defined(COMBO_MUST_HOLD_PER_COMBO) |
124 | return get_combo_must_hold(combo_index, combo); | 145 | return get_combo_must_hold(combo_index, combo); |
125 | #elif defined(COMBO_MUST_HOLD_MODS) | 146 | #elif defined(COMBO_MUST_HOLD_MODS) |
126 | return (KEYCODE_IS_MOD(combo->keycode) || | 147 | return (KEYCODE_IS_MOD(combo->keycode) || (combo->keycode >= QK_MOMENTARY && combo->keycode <= QK_MOMENTARY_MAX)); |
127 | (combo->keycode >= QK_MOMENTARY && combo->keycode <= QK_MOMENTARY_MAX)); | ||
128 | #endif | 148 | #endif |
129 | return false; | 149 | return false; |
130 | } | 150 | } |
131 | 151 | ||
132 | static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo ) { | 152 | static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo) { |
133 | if (_get_combo_must_hold(combo_index, combo) | 153 | if (_get_combo_must_hold(combo_index, combo) |
134 | #ifdef COMBO_MUST_TAP_PER_COMBO | 154 | #ifdef COMBO_MUST_TAP_PER_COMBO |
135 | || get_combo_must_tap(combo_index, combo) | 155 | || get_combo_must_tap(combo_index, combo) |
136 | #endif | 156 | #endif |
137 | ) { | 157 | ) { |
138 | if (longest_term < COMBO_HOLD_TERM) { | 158 | if (longest_term < COMBO_HOLD_TERM) { |
139 | return COMBO_HOLD_TERM; | 159 | return COMBO_HOLD_TERM; |
140 | } | 160 | } |
@@ -144,9 +164,8 @@ static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo ) { | |||
144 | } | 164 | } |
145 | 165 | ||
146 | static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { | 166 | static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { |
147 | |||
148 | #if defined(COMBO_TERM_PER_COMBO) | 167 | #if defined(COMBO_TERM_PER_COMBO) |
149 | return get_combo_term(combo_index, combo); | 168 | return get_combo_term(combo_index, combo); |
150 | #endif | 169 | #endif |
151 | 170 | ||
152 | return COMBO_TERM; | 171 | return COMBO_TERM; |
@@ -154,7 +173,7 @@ static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { | |||
154 | 173 | ||
155 | void clear_combos(void) { | 174 | void clear_combos(void) { |
156 | uint16_t index = 0; | 175 | uint16_t index = 0; |
157 | longest_term = 0; | 176 | longest_term = 0; |
158 | for (index = 0; index < COMBO_LEN; ++index) { | 177 | for (index = 0; index < COMBO_LEN; ++index) { |
159 | combo_t *combo = &key_combos[index]; | 178 | combo_t *combo = &key_combos[index]; |
160 | if (!COMBO_ACTIVE(combo)) { | 179 | if (!COMBO_ACTIVE(combo)) { |
@@ -175,7 +194,7 @@ static inline void dump_key_buffer(void) { | |||
175 | key_buffer_next = key_buffer_i + 1; | 194 | key_buffer_next = key_buffer_i + 1; |
176 | 195 | ||
177 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; | 196 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; |
178 | keyrecord_t *record = &qrecord->record; | 197 | keyrecord_t * record = &qrecord->record; |
179 | 198 | ||
180 | if (IS_NOEVENT(record->event)) { | 199 | if (IS_NOEVENT(record->event)) { |
181 | continue; | 200 | continue; |
@@ -185,9 +204,9 @@ static inline void dump_key_buffer(void) { | |||
185 | process_combo_event(qrecord->combo_index, true); | 204 | process_combo_event(qrecord->combo_index, true); |
186 | } else { | 205 | } else { |
187 | #ifndef NO_ACTION_TAPPING | 206 | #ifndef NO_ACTION_TAPPING |
188 | action_tapping_process(*record); | 207 | action_tapping_process(*record); |
189 | #else | 208 | #else |
190 | process_record(record); | 209 | process_record(record); |
191 | #endif | 210 | #endif |
192 | } | 211 | } |
193 | record->event.time = 0; | 212 | record->event.time = 0; |
@@ -242,7 +261,9 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
242 | /* Apply combo's result keycode to the last chord key of the combo and | 261 | /* Apply combo's result keycode to the last chord key of the combo and |
243 | * disable the other keys. */ | 262 | * disable the other keys. */ |
244 | 263 | ||
245 | if (COMBO_DISABLED(combo)) { return; } | 264 | if (COMBO_DISABLED(combo)) { |
265 | return; | ||
266 | } | ||
246 | 267 | ||
247 | // state to check against so we find the last key of the combo from the buffer | 268 | // state to check against so we find the last key of the combo from the buffer |
248 | #if defined(EXTRA_EXTRA_LONG_COMBOS) | 269 | #if defined(EXTRA_EXTRA_LONG_COMBOS) |
@@ -254,12 +275,11 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
254 | #endif | 275 | #endif |
255 | 276 | ||
256 | for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) { | 277 | for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) { |
257 | |||
258 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; | 278 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; |
259 | keyrecord_t *record = &qrecord->record; | 279 | keyrecord_t * record = &qrecord->record; |
260 | uint16_t keycode = qrecord->keycode; | 280 | uint16_t keycode = qrecord->keycode; |
261 | 281 | ||
262 | uint8_t key_count = 0; | 282 | uint8_t key_count = 0; |
263 | uint16_t key_index = -1; | 283 | uint16_t key_index = -1; |
264 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); | 284 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); |
265 | 285 | ||
@@ -271,7 +291,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
271 | KEY_STATE_DOWN(state, key_index); | 291 | KEY_STATE_DOWN(state, key_index); |
272 | if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) { | 292 | if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) { |
273 | // this in the end executes the combo when the key_buffer is dumped. | 293 | // this in the end executes the combo when the key_buffer is dumped. |
274 | record->keycode = combo->keycode; | 294 | record->keycode = combo->keycode; |
275 | record->event.key = COMBO_KEY_POS; | 295 | record->event.key = COMBO_KEY_POS; |
276 | 296 | ||
277 | qrecord->combo_index = combo_index; | 297 | qrecord->combo_index = combo_index; |
@@ -283,19 +303,15 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
283 | // by making it a TICK event. | 303 | // by making it a TICK event. |
284 | record->event.time = 0; | 304 | record->event.time = 0; |
285 | } | 305 | } |
286 | |||
287 | } | 306 | } |
288 | drop_combo_from_buffer(combo_index); | 307 | drop_combo_from_buffer(combo_index); |
289 | } | 308 | } |
290 | 309 | ||
291 | static inline void apply_combos(void) { | 310 | static inline void apply_combos(void) { |
292 | // Apply all buffered normal combos. | 311 | // Apply all buffered normal combos. |
293 | for (uint8_t i = combo_buffer_read; | 312 | for (uint8_t i = combo_buffer_read; i != combo_buffer_write; INCREMENT_MOD(i)) { |
294 | i != combo_buffer_write; | ||
295 | INCREMENT_MOD(i)) { | ||
296 | |||
297 | queued_combo_t *buffered_combo = &combo_buffer[i]; | 313 | queued_combo_t *buffered_combo = &combo_buffer[i]; |
298 | combo_t *combo = &key_combos[buffered_combo->combo_index]; | 314 | combo_t * combo = &key_combos[buffered_combo->combo_index]; |
299 | 315 | ||
300 | #ifdef COMBO_MUST_TAP_PER_COMBO | 316 | #ifdef COMBO_MUST_TAP_PER_COMBO |
301 | if (get_combo_must_tap(buffered_combo->combo_index, combo)) { | 317 | if (get_combo_must_tap(buffered_combo->combo_index, combo)) { |
@@ -310,15 +326,15 @@ static inline void apply_combos(void) { | |||
310 | clear_combos(); | 326 | clear_combos(); |
311 | } | 327 | } |
312 | 328 | ||
313 | combo_t* overlaps(combo_t *combo1, combo_t *combo2) { | 329 | combo_t *overlaps(combo_t *combo1, combo_t *combo2) { |
314 | /* Checks if the combos overlap and returns the combo that should be | 330 | /* Checks if the combos overlap and returns the combo that should be |
315 | * dropped from the combo buffer. | 331 | * dropped from the combo buffer. |
316 | * The combo that has less keys will be dropped. If they have the same | 332 | * The combo that has less keys will be dropped. If they have the same |
317 | * amount of keys, drop combo1. */ | 333 | * amount of keys, drop combo1. */ |
318 | 334 | ||
319 | uint8_t idx1 = 0, idx2 = 0; | 335 | uint8_t idx1 = 0, idx2 = 0; |
320 | uint16_t key1, key2; | 336 | uint16_t key1, key2; |
321 | bool overlaps = false; | 337 | bool overlaps = false; |
322 | 338 | ||
323 | while ((key1 = pgm_read_word(&combo1->keys[idx1])) != COMBO_END) { | 339 | while ((key1 = pgm_read_word(&combo1->keys[idx1])) != COMBO_END) { |
324 | idx2 = 0; | 340 | idx2 = 0; |
@@ -335,7 +351,7 @@ combo_t* overlaps(combo_t *combo1, combo_t *combo2) { | |||
335 | } | 351 | } |
336 | 352 | ||
337 | static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) { | 353 | static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) { |
338 | uint8_t key_count = 0; | 354 | uint8_t key_count = 0; |
339 | uint16_t key_index = -1; | 355 | uint16_t key_index = -1; |
340 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); | 356 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); |
341 | 357 | ||
@@ -369,12 +385,9 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
369 | 385 | ||
370 | // disable readied combos that overlap with this combo | 386 | // disable readied combos that overlap with this combo |
371 | combo_t *drop = NULL; | 387 | combo_t *drop = NULL; |
372 | for (uint8_t combo_buffer_i = combo_buffer_read; | 388 | for (uint8_t combo_buffer_i = combo_buffer_read; combo_buffer_i != combo_buffer_write; INCREMENT_MOD(combo_buffer_i)) { |
373 | combo_buffer_i != combo_buffer_write; | 389 | queued_combo_t *qcombo = &combo_buffer[combo_buffer_i]; |
374 | INCREMENT_MOD(combo_buffer_i)) { | 390 | combo_t * buffered_combo = &key_combos[qcombo->combo_index]; |
375 | |||
376 | queued_combo_t *qcombo = &combo_buffer[combo_buffer_i]; | ||
377 | combo_t *buffered_combo = &key_combos[qcombo->combo_index]; | ||
378 | 391 | ||
379 | if ((drop = overlaps(buffered_combo, combo))) { | 392 | if ((drop = overlaps(buffered_combo, combo))) { |
380 | DISABLE_COMBO(drop); | 393 | DISABLE_COMBO(drop); |
@@ -387,21 +400,19 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
387 | INCREMENT_MOD(combo_buffer_read); | 400 | INCREMENT_MOD(combo_buffer_read); |
388 | } | 401 | } |
389 | } | 402 | } |
390 | |||
391 | } | 403 | } |
392 | 404 | ||
393 | if (drop != combo) { | 405 | if (drop != combo) { |
394 | // save this combo to buffer | 406 | // save this combo to buffer |
395 | combo_buffer[combo_buffer_write] = (queued_combo_t){ | 407 | combo_buffer[combo_buffer_write] = (queued_combo_t){ |
396 | .combo_index=combo_index, | 408 | .combo_index = combo_index, |
397 | }; | 409 | }; |
398 | INCREMENT_MOD(combo_buffer_write); | 410 | INCREMENT_MOD(combo_buffer_write); |
399 | 411 | ||
400 | // get possible longer waiting time for tap-/hold-only combos. | 412 | // get possible longer waiting time for tap-/hold-only combos. |
401 | longest_term = _get_wait_time(combo_index, combo); | 413 | longest_term = _get_wait_time(combo_index, combo); |
402 | } | 414 | } |
403 | } // if timer elapsed end | 415 | } // if timer elapsed end |
404 | |||
405 | } | 416 | } |
406 | } else { | 417 | } else { |
407 | // chord releases | 418 | // chord releases |
@@ -416,7 +427,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
416 | else if (get_combo_must_tap(combo_index, combo)) { | 427 | else if (get_combo_must_tap(combo_index, combo)) { |
417 | // immediately apply tap-only combo | 428 | // immediately apply tap-only combo |
418 | apply_combo(combo_index, combo); | 429 | apply_combo(combo_index, combo); |
419 | apply_combos(); // also apply other prepared combos and dump key buffer | 430 | apply_combos(); // also apply other prepared combos and dump key buffer |
420 | # ifdef COMBO_PROCESS_KEY_RELEASE | 431 | # ifdef COMBO_PROCESS_KEY_RELEASE |
421 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { | 432 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { |
422 | release_combo(combo_index, combo); | 433 | release_combo(combo_index, combo); |
@@ -424,10 +435,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
424 | # endif | 435 | # endif |
425 | } | 436 | } |
426 | #endif | 437 | #endif |
427 | } else if (COMBO_ACTIVE(combo) | 438 | } else if (COMBO_ACTIVE(combo) && ONLY_ONE_KEY_IS_DOWN(COMBO_STATE(combo)) && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)) { |
428 | && ONLY_ONE_KEY_IS_DOWN(COMBO_STATE(combo)) | ||
429 | && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index) | ||
430 | ) { | ||
431 | /* last key released */ | 439 | /* last key released */ |
432 | release_combo(combo_index, combo); | 440 | release_combo(combo_index, combo); |
433 | key_is_part_of_combo = true; | 441 | key_is_part_of_combo = true; |
@@ -435,9 +443,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
435 | #ifdef COMBO_PROCESS_KEY_RELEASE | 443 | #ifdef COMBO_PROCESS_KEY_RELEASE |
436 | process_combo_key_release(combo_index, combo, key_index, keycode); | 444 | process_combo_key_release(combo_index, combo, key_index, keycode); |
437 | #endif | 445 | #endif |
438 | } else if (COMBO_ACTIVE(combo) | 446 | } else if (COMBO_ACTIVE(combo) && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)) { |
439 | && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index) | ||
440 | ) { | ||
441 | /* first or middle key released */ | 447 | /* first or middle key released */ |
442 | key_is_part_of_combo = true; | 448 | key_is_part_of_combo = true; |
443 | 449 | ||
@@ -489,21 +495,21 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { | |||
489 | 495 | ||
490 | if (record->event.pressed && is_combo_key) { | 496 | if (record->event.pressed && is_combo_key) { |
491 | #ifndef COMBO_NO_TIMER | 497 | #ifndef COMBO_NO_TIMER |
492 | # ifdef COMBO_STRICT_TIMER | 498 | # ifdef COMBO_STRICT_TIMER |
493 | if (!timer) { | 499 | if (!timer) { |
494 | // timer is set only on the first key | 500 | // timer is set only on the first key |
495 | timer = timer_read(); | 501 | timer = timer_read(); |
496 | } | 502 | } |
497 | # else | 503 | # else |
498 | timer = timer_read(); | 504 | timer = timer_read(); |
499 | # endif | 505 | # endif |
500 | #endif | 506 | #endif |
501 | 507 | ||
502 | if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) { | 508 | if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) { |
503 | key_buffer[key_buffer_size++] = (queued_record_t){ | 509 | key_buffer[key_buffer_size++] = (queued_record_t){ |
504 | .record = *record, | 510 | .record = *record, |
505 | .keycode = keycode, | 511 | .keycode = keycode, |
506 | .combo_index = -1, // this will be set when applying combos | 512 | .combo_index = -1, // this will be set when applying combos |
507 | }; | 513 | }; |
508 | } | 514 | } |
509 | } else { | 515 | } else { |
@@ -532,7 +538,7 @@ void combo_task(void) { | |||
532 | if (combo_buffer_read != combo_buffer_write) { | 538 | if (combo_buffer_read != combo_buffer_write) { |
533 | apply_combos(); | 539 | apply_combos(); |
534 | longest_term = 0; | 540 | longest_term = 0; |
535 | timer = 0; | 541 | timer = 0; |
536 | } else { | 542 | } else { |
537 | dump_key_buffer(); | 543 | dump_key_buffer(); |
538 | timer = 0; | 544 | timer = 0; |
@@ -546,9 +552,9 @@ void combo_enable(void) { b_combo_enable = true; } | |||
546 | 552 | ||
547 | void combo_disable(void) { | 553 | void combo_disable(void) { |
548 | #ifndef COMBO_NO_TIMER | 554 | #ifndef COMBO_NO_TIMER |
549 | timer = 0; | 555 | timer = 0; |
550 | #endif | 556 | #endif |
551 | b_combo_enable = false; | 557 | b_combo_enable = false; |
552 | combo_buffer_read = combo_buffer_write; | 558 | combo_buffer_read = combo_buffer_write; |
553 | clear_combos(); | 559 | clear_combos(); |
554 | dump_key_buffer(); | 560 | dump_key_buffer(); |
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index 43c36d79e..4c4e574e3 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h | |||
@@ -43,8 +43,8 @@ typedef struct { | |||
43 | #ifdef EXTRA_SHORT_COMBOS | 43 | #ifdef EXTRA_SHORT_COMBOS |
44 | uint8_t state; | 44 | uint8_t state; |
45 | #else | 45 | #else |
46 | bool disabled; | 46 | bool disabled; |
47 | bool active; | 47 | bool active; |
48 | # if defined(EXTRA_EXTRA_LONG_COMBOS) | 48 | # if defined(EXTRA_EXTRA_LONG_COMBOS) |
49 | uint32_t state; | 49 | uint32_t state; |
50 | # elif defined(EXTRA_LONG_COMBOS) | 50 | # elif defined(EXTRA_LONG_COMBOS) |
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c index a964aead3..5d0bb313b 100644 --- a/quantum/process_keycode/process_steno.c +++ b/quantum/process_keycode/process_steno.c | |||
@@ -67,7 +67,7 @@ static const uint8_t boltmap[64] PROGMEM = {TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, | |||
67 | 67 | ||
68 | #ifdef STENO_COMBINEDMAP | 68 | #ifdef STENO_COMBINEDMAP |
69 | /* Used to look up when pressing the middle row key to combine two consonant or vowel keys */ | 69 | /* Used to look up when pressing the middle row key to combine two consonant or vowel keys */ |
70 | static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E}; | 70 | static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E}; |
71 | static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U}; | 71 | static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U}; |
72 | #endif | 72 | #endif |
73 | 73 | ||
@@ -174,11 +174,10 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) { | |||
174 | return false; | 174 | return false; |
175 | 175 | ||
176 | #ifdef STENO_COMBINEDMAP | 176 | #ifdef STENO_COMBINEDMAP |
177 | case QK_STENO_COMB ... QK_STENO_COMB_MAX: | 177 | case QK_STENO_COMB ... QK_STENO_COMB_MAX: { |
178 | { | ||
179 | uint8_t result; | 178 | uint8_t result; |
180 | result = process_steno(combinedmap_first[keycode-QK_STENO_COMB], record); | 179 | result = process_steno(combinedmap_first[keycode - QK_STENO_COMB], record); |
181 | result &= process_steno(combinedmap_second[keycode-QK_STENO_COMB], record); | 180 | result &= process_steno(combinedmap_second[keycode - QK_STENO_COMB], record); |
182 | return result; | 181 | return result; |
183 | } | 182 | } |
184 | #endif | 183 | #endif |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 2ea81dd4c..373a31a00 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -809,12 +809,12 @@ enum quantum_keycodes { | |||
809 | #define CMD_T(kc) LCMD_T(kc) | 809 | #define CMD_T(kc) LCMD_T(kc) |
810 | #define WIN_T(kc) LWIN_T(kc) | 810 | #define WIN_T(kc) LWIN_T(kc) |
811 | 811 | ||
812 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal | 812 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal |
813 | #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt | 813 | #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt |
814 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI | 814 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI |
815 | #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI | 815 | #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI |
816 | #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | 816 | #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ |
817 | #define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI | 817 | #define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI |
818 | #define SGUI_T(kc) LSG_T(kc) | 818 | #define SGUI_T(kc) LSG_T(kc) |
819 | #define SCMD_T(kc) LSG_T(kc) | 819 | #define SCMD_T(kc) LSG_T(kc) |
820 | #define SWIN_T(kc) LSG_T(kc) | 820 | #define SWIN_T(kc) LSG_T(kc) |
@@ -845,7 +845,7 @@ enum quantum_keycodes { | |||
845 | 845 | ||
846 | #define UC_M_MA UNICODE_MODE_MAC | 846 | #define UC_M_MA UNICODE_MODE_MAC |
847 | #define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias | 847 | #define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias |
848 | #define UC_M_OS UNICODE_MODE_MAC // Deprecated alias | 848 | #define UC_M_OS UNICODE_MODE_MAC // Deprecated alias |
849 | #define UC_M_LN UNICODE_MODE_LNX | 849 | #define UC_M_LN UNICODE_MODE_LNX |
850 | #define UC_M_WI UNICODE_MODE_WIN | 850 | #define UC_M_WI UNICODE_MODE_WIN |
851 | #define UC_M_BS UNICODE_MODE_BSD | 851 | #define UC_M_BS UNICODE_MODE_BSD |
diff --git a/quantum/rgb_matrix/animations/fractal_anim.h b/quantum/rgb_matrix/animations/fractal_anim.h index 99693165d..83a69daa6 100644 --- a/quantum/rgb_matrix/animations/fractal_anim.h +++ b/quantum/rgb_matrix/animations/fractal_anim.h | |||
@@ -18,44 +18,57 @@ | |||
18 | 18 | ||
19 | #ifdef ENABLE_RGB_MATRIX_FRACTAL | 19 | #ifdef ENABLE_RGB_MATRIX_FRACTAL |
20 | RGB_MATRIX_EFFECT(FRACTAL) | 20 | RGB_MATRIX_EFFECT(FRACTAL) |
21 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 21 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
22 | 22 | ||
23 | static bool FRACTAL(effect_params_t* params) { | 23 | static bool FRACTAL(effect_params_t* params) { |
24 | #define MID_COL MATRIX_COLS / 2 | 24 | # define MID_COL MATRIX_COLS / 2 |
25 | static bool led[MATRIX_ROWS][MATRIX_COLS]; | 25 | static bool led[MATRIX_ROWS][MATRIX_COLS]; |
26 | 26 | ||
27 | static uint32_t wait_timer = 0; | 27 | static uint32_t wait_timer = 0; |
28 | if (wait_timer > g_rgb_timer) { return false; } | 28 | if (wait_timer > g_rgb_timer) { |
29 | return false; | ||
30 | } | ||
29 | 31 | ||
30 | inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } | 32 | inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } |
31 | 33 | ||
32 | RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); | 34 | RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); |
33 | for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { | 35 | for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { |
34 | 36 | for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards | |
35 | for (uint8_t l = 0; l < MID_COL-1; ++l) { // Light and move left columns outwards | 37 | if (led[h][l]) { |
36 | if (led[h][l]) { rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); } | 38 | rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); |
37 | else { rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0); } | 39 | } else { |
38 | led[h][l] = led[h][l+1]; | 40 | rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0); |
41 | } | ||
42 | led[h][l] = led[h][l + 1]; | ||
39 | } | 43 | } |
40 | 44 | ||
41 | for (uint8_t r = MATRIX_COLS-1; r > MID_COL; --r) { // Light and move right columns outwards | 45 | for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards |
42 | if (led[h][r]) { rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b); } | 46 | if (led[h][r]) { |
43 | else { rgb_matrix_set_color(g_led_config.matrix_co[h][r], 0, 0, 0); } | 47 | rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b); |
44 | led[h][r] = led[h][r-1]; | 48 | } else { |
49 | rgb_matrix_set_color(g_led_config.matrix_co[h][r], 0, 0, 0); | ||
50 | } | ||
51 | led[h][r] = led[h][r - 1]; | ||
45 | } | 52 | } |
46 | 53 | ||
47 | // Light both middle columns | 54 | // Light both middle columns |
48 | if (led[h][MID_COL]) { rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], rgb.r, rgb.g, rgb.b); } | 55 | if (led[h][MID_COL]) { |
49 | else { rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], 0, 0, 0); } | 56 | rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], rgb.r, rgb.g, rgb.b); |
50 | if (led[h][MID_COL-1]) { rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL-1], rgb.r, rgb.g, rgb.b); } | 57 | } else { |
51 | else { rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL-1], 0, 0, 0); } | 58 | rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], 0, 0, 0); |
59 | } | ||
60 | if (led[h][MID_COL - 1]) { | ||
61 | rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], rgb.r, rgb.g, rgb.b); | ||
62 | } else { | ||
63 | rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], 0, 0, 0); | ||
64 | } | ||
52 | 65 | ||
53 | // Generate new random fractal columns | 66 | // Generate new random fractal columns |
54 | led[h][MID_COL] = led[h][MID_COL-1] = (random8() & 3) ? false : true; | 67 | led[h][MID_COL] = led[h][MID_COL - 1] = (random8() & 3) ? false : true; |
55 | } | 68 | } |
56 | 69 | ||
57 | wait_timer = g_rgb_timer + interval(); | 70 | wait_timer = g_rgb_timer + interval(); |
58 | return false; | 71 | return false; |
59 | } | 72 | } |
60 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 73 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
61 | #endif // ENABLE_RGB_MATRIX_FRACTAL | 74 | #endif // ENABLE_RGB_MATRIX_FRACTAL |
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index fd676f072..3ff87710e 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c | |||
@@ -42,8 +42,8 @@ | |||
42 | { &dummy, 0, 0, sizeof_member(split_shared_memory_t, member), offsetof(split_shared_memory_t, member), cb } | 42 | { &dummy, 0, 0, sizeof_member(split_shared_memory_t, member), offsetof(split_shared_memory_t, member), cb } |
43 | #define trans_target2initiator_initializer(member) trans_target2initiator_initializer_cb(member, NULL) | 43 | #define trans_target2initiator_initializer(member) trans_target2initiator_initializer_cb(member, NULL) |
44 | 44 | ||
45 | #define transport_write(id, data, length) transport_execute_transaction(id, data, length, NULL, 0) | 45 | #define transport_write(id, data, length) transport_execute_transaction(id, data, length, NULL, 0) |
46 | #define transport_read(id, data, length) transport_execute_transaction(id, NULL, 0, data, length) | 46 | #define transport_read(id, data, length) transport_execute_transaction(id, NULL, 0, data, length) |
47 | 47 | ||
48 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) | 48 | #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) |
49 | // Forward-declare the RPC callback handlers | 49 | // Forward-declare the RPC callback handlers |
@@ -157,8 +157,8 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro | |||
157 | memcpy(master_matrix, split_shmem->mmatrix.matrix, sizeof(split_shmem->mmatrix.matrix)); | 157 | memcpy(master_matrix, split_shmem->mmatrix.matrix, sizeof(split_shmem->mmatrix.matrix)); |
158 | } | 158 | } |
159 | 159 | ||
160 | # define TRANSACTIONS_MASTER_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(master_matrix) | 160 | # define TRANSACTIONS_MASTER_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(master_matrix) |
161 | # define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) | 161 | # define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) |
162 | # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), | 162 | # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), |
163 | 163 | ||
164 | #else // SPLIT_TRANSPORT_MIRROR | 164 | #else // SPLIT_TRANSPORT_MIRROR |
@@ -235,8 +235,8 @@ static void sync_timer_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | # define TRANSACTIONS_SYNC_TIMER_MASTER() TRANSACTION_HANDLER_MASTER(sync_timer) | 238 | # define TRANSACTIONS_SYNC_TIMER_MASTER() TRANSACTION_HANDLER_MASTER(sync_timer) |
239 | # define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) | 239 | # define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) |
240 | # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), | 240 | # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), |
241 | 241 | ||
242 | #else // DISABLE_SYNC_TIMER | 242 | #else // DISABLE_SYNC_TIMER |
@@ -300,8 +300,8 @@ static void led_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
300 | set_split_host_keyboard_leds(split_shmem->led_state); | 300 | set_split_host_keyboard_leds(split_shmem->led_state); |
301 | } | 301 | } |
302 | 302 | ||
303 | # define TRANSACTIONS_LED_STATE_MASTER() TRANSACTION_HANDLER_MASTER(led_state) | 303 | # define TRANSACTIONS_LED_STATE_MASTER() TRANSACTION_HANDLER_MASTER(led_state) |
304 | # define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) | 304 | # define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) |
305 | # define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), | 305 | # define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), |
306 | 306 | ||
307 | #else // SPLIT_LED_STATE_ENABLE | 307 | #else // SPLIT_LED_STATE_ENABLE |
@@ -357,8 +357,8 @@ static void mods_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave | |||
357 | # endif | 357 | # endif |
358 | } | 358 | } |
359 | 359 | ||
360 | # define TRANSACTIONS_MODS_MASTER() TRANSACTION_HANDLER_MASTER(mods) | 360 | # define TRANSACTIONS_MODS_MASTER() TRANSACTION_HANDLER_MASTER(mods) |
361 | # define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods) | 361 | # define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods) |
362 | # define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods), | 362 | # define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods), |
363 | 363 | ||
364 | #else // SPLIT_MODS_ENABLE | 364 | #else // SPLIT_MODS_ENABLE |
@@ -382,8 +382,8 @@ static bool backlight_handlers_master(matrix_row_t master_matrix[], matrix_row_t | |||
382 | 382 | ||
383 | static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { backlight_set(split_shmem->backlight_level); } | 383 | static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { backlight_set(split_shmem->backlight_level); } |
384 | 384 | ||
385 | # define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) | 385 | # define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) |
386 | # define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight) | 386 | # define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight) |
387 | # define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level), | 387 | # define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level), |
388 | 388 | ||
389 | #else // BACKLIGHT_ENABLE | 389 | #else // BACKLIGHT_ENABLE |
@@ -419,8 +419,8 @@ static void rgblight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s | |||
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | # define TRANSACTIONS_RGBLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(rgblight) | 422 | # define TRANSACTIONS_RGBLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(rgblight) |
423 | # define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight) | 423 | # define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight) |
424 | # define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync), | 424 | # define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync), |
425 | 425 | ||
426 | #else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 426 | #else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
@@ -449,8 +449,8 @@ static void led_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
449 | led_matrix_set_suspend_state(split_shmem->led_matrix_sync.led_suspend_state); | 449 | led_matrix_set_suspend_state(split_shmem->led_matrix_sync.led_suspend_state); |
450 | } | 450 | } |
451 | 451 | ||
452 | # define TRANSACTIONS_LED_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(led_matrix) | 452 | # define TRANSACTIONS_LED_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(led_matrix) |
453 | # define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix) | 453 | # define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix) |
454 | # define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync), | 454 | # define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync), |
455 | 455 | ||
456 | #else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | 456 | #else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
@@ -479,8 +479,8 @@ static void rgb_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t | |||
479 | rgb_matrix_set_suspend_state(split_shmem->rgb_matrix_sync.rgb_suspend_state); | 479 | rgb_matrix_set_suspend_state(split_shmem->rgb_matrix_sync.rgb_suspend_state); |
480 | } | 480 | } |
481 | 481 | ||
482 | # define TRANSACTIONS_RGB_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(rgb_matrix) | 482 | # define TRANSACTIONS_RGB_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(rgb_matrix) |
483 | # define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix) | 483 | # define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix) |
484 | # define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync), | 484 | # define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync), |
485 | 485 | ||
486 | #else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | 486 | #else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
@@ -504,8 +504,8 @@ static bool wpm_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave | |||
504 | 504 | ||
505 | static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { set_current_wpm(split_shmem->current_wpm); } | 505 | static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { set_current_wpm(split_shmem->current_wpm); } |
506 | 506 | ||
507 | # define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) | 507 | # define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) |
508 | # define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) | 508 | # define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) |
509 | # define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), | 509 | # define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), |
510 | 510 | ||
511 | #else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) | 511 | #else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) |
@@ -535,8 +535,8 @@ static void oled_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave | |||
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | # define TRANSACTIONS_OLED_MASTER() TRANSACTION_HANDLER_MASTER(oled) | 538 | # define TRANSACTIONS_OLED_MASTER() TRANSACTION_HANDLER_MASTER(oled) |
539 | # define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled) | 539 | # define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled) |
540 | # define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state), | 540 | # define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state), |
541 | 541 | ||
542 | #else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) | 542 | #else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) |
@@ -566,8 +566,8 @@ static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla | |||
566 | } | 566 | } |
567 | } | 567 | } |
568 | 568 | ||
569 | # define TRANSACTIONS_ST7565_MASTER() TRANSACTION_HANDLER_MASTER(st7565) | 569 | # define TRANSACTIONS_ST7565_MASTER() TRANSACTION_HANDLER_MASTER(st7565) |
570 | # define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) | 570 | # define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) |
571 | # define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), | 571 | # define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), |
572 | 572 | ||
573 | #else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) | 573 | #else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) |