aboutsummaryrefslogtreecommitdiff
path: root/quantum/debounce
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/debounce')
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c22
-rw-r--r--quantum/debounce/sym_defer_g.c2
-rw-r--r--quantum/debounce/sym_defer_pk.c6
-rw-r--r--quantum/debounce/sym_eager_pk.c8
-rw-r--r--quantum/debounce/sym_eager_pr.c8
-rw-r--r--quantum/debounce/tests/asym_eager_defer_pk_tests.cpp66
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp72
-rw-r--r--quantum/debounce/tests/debounce_test_common.h24
-rw-r--r--quantum/debounce/tests/sym_defer_g_tests.cpp45
-rw-r--r--quantum/debounce/tests/sym_defer_pk_tests.cpp45
-rw-r--r--quantum/debounce/tests/sym_eager_pk_tests.cpp48
-rw-r--r--quantum/debounce/tests/sym_eager_pr_tests.cpp57
12 files changed, 231 insertions, 172 deletions
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
48typedef struct { 48typedef 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
54static debounce_counter_t *debounce_counters; 54static debounce_counter_t *debounce_counters;
55static fast_timer_t last_time; 55static fast_timer_t last_time;
56static bool counters_need_update; 56static bool counters_need_update;
57static bool matrix_need_update; 57static bool matrix_need_update;
58 58
59#define DEBOUNCE_ELAPSED 0 59# define DEBOUNCE_ELAPSED 0
60 60
61static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); 61static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time);
62static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 62static 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
65void debounce_init(uint8_t num_rows) { 65void 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
28static bool debouncing = false; 28static bool debouncing = false;
29static fast_timer_t debouncing_time; 29static fast_timer_t debouncing_time;
30 30
31void debounce_init(uint8_t num_rows) {} 31void 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;
49static fast_timer_t last_time; 49static fast_timer_t last_time;
50static bool counters_need_update; 50static bool counters_need_update;
51 51
52#define DEBOUNCE_ELAPSED 0 52# define DEBOUNCE_ELAPSED 0
53 53
54static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); 54static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time);
55static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 55static 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;
50static bool counters_need_update; 50static bool counters_need_update;
51static bool matrix_need_update; 51static bool matrix_need_update;
52 52
53#define DEBOUNCE_ELAPSED 0 53# define DEBOUNCE_ELAPSED 0
54 54
55static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); 55static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time);
56static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 56static 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;
49static fast_timer_t last_time; 49static fast_timer_t last_time;
50static bool counters_need_update; 50static bool counters_need_update;
51 51
52#define DEBOUNCE_ELAPSED 0 52# define DEBOUNCE_ELAPSED 0
53 53
54static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); 54static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time);
55static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 55static 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
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_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
45TEST_F(DebounceTest, OneKeyShort2) { 46TEST_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
60TEST_F(DebounceTest, OneKeyShort3) { 62TEST_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
75TEST_F(DebounceTest, OneKeyShort4) { 78TEST_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
90TEST_F(DebounceTest, OneKeyShort5) { 94TEST_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
104TEST_F(DebounceTest, OneKeyShort6) { 109TEST_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
118TEST_F(DebounceTest, OneKeyShort7) { 124TEST_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
132TEST_F(DebounceTest, OneKeyShort8) { 139TEST_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
147TEST_F(DebounceTest, OneKeyShort9) { 155TEST_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
161TEST_F(DebounceTest, OneKeyBouncing1) { 170TEST_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
187TEST_F(DebounceTest, OneKeyBouncing2) { 197TEST_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
219TEST_F(DebounceTest, OneKeyLong) { 230TEST_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
238TEST_F(DebounceTest, TwoKeysShort) { 250TEST_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
258TEST_F(DebounceTest, OneKeyDelayedScan1) { 270TEST_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
271TEST_F(DebounceTest, OneKeyDelayedScan2) { 284TEST_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
285TEST_F(DebounceTest, OneKeyDelayedScan3) { 299TEST_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
300TEST_F(DebounceTest, OneKeyDelayedScan4) { 315TEST_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
316TEST_F(DebounceTest, OneKeyDelayedScan5) { 332TEST_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
331TEST_F(DebounceTest, OneKeyDelayedScan6) { 348TEST_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
347TEST_F(DebounceTest, OneKeyDelayedScan7) { 365TEST_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
360TEST_F(DebounceTest, OneKeyDelayedScan8) { 379TEST_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);
31void advance_time(uint32_t ms); 31void advance_time(uint32_t ms);
32} 32}
33 33
34void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { 34void 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
38void DebounceTest::runEvents() { 36void 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
55void DebounceTest::runEventsInternal() { 53void 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
142void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) { 133void 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
151std::string DebounceTest::strTime() { 139std::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
182bool DebounceTest::directionValue(Direction direction) { 168bool 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
192std::string DebounceTest::directionLabel(Direction direction) { 178std::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 */
203void DebounceTest::matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event) { 189void 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
221DebounceTestEvent::DebounceTestEvent(fast_timer_t time, 203DebounceTestEvent::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
227MatrixTestEvent::MatrixTestEvent(int row, int col, Direction direction) 205MatrixTestEvent::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
33class MatrixTestEvent { 33class MatrixTestEvent {
34public: 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
42class DebounceTestEvent { 42class DebounceTestEvent {
43public: 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
54class DebounceTest : public ::testing::Test { 52class DebounceTest : public ::testing::Test {
55protected: 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
62private: 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
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_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
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_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
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_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
60TEST_F(DebounceTest, OneKeyTooQuick1) { 63TEST_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
69TEST_F(DebounceTest, OneKeyTooQuick2) { 73TEST_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
82TEST_F(DebounceTest, OneKeyBouncing1) { 87TEST_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
96TEST_F(DebounceTest, OneKeyBouncing2) { 102TEST_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
110TEST_F(DebounceTest, OneKeyLong) { 117TEST_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
127TEST_F(DebounceTest, TwoKeysShort) { 135TEST_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
142TEST_F(DebounceTest, TwoKeysSimultaneous1) { 151TEST_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
154TEST_F(DebounceTest, TwoKeysSimultaneous2) { 164TEST_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
169TEST_F(DebounceTest, OneKeyDelayedScan1) { 180TEST_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
184TEST_F(DebounceTest, OneKeyDelayedScan2) { 196TEST_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
199TEST_F(DebounceTest, OneKeyDelayedScan3) { 212TEST_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
210TEST_F(DebounceTest, OneKeyDelayedScan4) { 224TEST_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
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_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
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_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
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_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
60TEST_F(DebounceTest, OneKeyTooQuick1) { 63TEST_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
69TEST_F(DebounceTest, OneKeyTooQuick2) { 73TEST_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
82TEST_F(DebounceTest, OneKeyBouncing1) { 87TEST_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
96TEST_F(DebounceTest, OneKeyBouncing2) { 102TEST_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
110TEST_F(DebounceTest, OneKeyLong) { 117TEST_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
127TEST_F(DebounceTest, TwoKeysShort) { 135TEST_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
144TEST_F(DebounceTest, TwoKeysSimultaneous1) { 153TEST_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
156TEST_F(DebounceTest, TwoKeysSimultaneous2) { 166TEST_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
171TEST_F(DebounceTest, OneKeyDelayedScan1) { 182TEST_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
186TEST_F(DebounceTest, OneKeyDelayedScan2) { 198TEST_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
201TEST_F(DebounceTest, OneKeyDelayedScan3) { 214TEST_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
212TEST_F(DebounceTest, OneKeyDelayedScan4) { 226TEST_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
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_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
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_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
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_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
60TEST_F(DebounceTest, OneKeyShort4) { 63TEST_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
73TEST_F(DebounceTest, OneKeyShort5) { 77TEST_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
85TEST_F(DebounceTest, OneKeyShort6) { 90TEST_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
97TEST_F(DebounceTest, OneKeyBouncing1) { 103TEST_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
112TEST_F(DebounceTest, OneKeyBouncing2) { 119TEST_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
137TEST_F(DebounceTest, OneKeyLong) { 145TEST_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
148TEST_F(DebounceTest, TwoKeysShort) { 157TEST_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
169TEST_F(DebounceTest, OneKeyDelayedScan1) { 179TEST_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
180TEST_F(DebounceTest, OneKeyDelayedScan2) { 191TEST_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
192TEST_F(DebounceTest, OneKeyDelayedScan3) { 204TEST_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
204TEST_F(DebounceTest, OneKeyDelayedScan4) { 217TEST_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
215TEST_F(DebounceTest, OneKeyDelayedScan5) { 229TEST_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
227TEST_F(DebounceTest, OneKeyDelayedScan6) { 242TEST_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
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_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
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_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
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_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
60TEST_F(DebounceTest, OneKeyShort4) { 63TEST_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
73TEST_F(DebounceTest, OneKeyShort5) { 77TEST_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
85TEST_F(DebounceTest, OneKeyShort6) { 90TEST_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
97TEST_F(DebounceTest, OneKeyBouncing1) { 103TEST_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
112TEST_F(DebounceTest, OneKeyBouncing2) { 119TEST_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
137TEST_F(DebounceTest, OneKeyLong) { 145TEST_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
148TEST_F(DebounceTest, TwoRowsShort) { 157TEST_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
169TEST_F(DebounceTest, TwoKeysOverlap) { 179TEST_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
192TEST_F(DebounceTest, TwoKeysSimultaneous1) { 203TEST_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
204TEST_F(DebounceTest, TwoKeysSimultaneous2) { 216TEST_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
212TEST_F(DebounceTest, OneKeyDelayedScan1) { 225TEST_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
223TEST_F(DebounceTest, OneKeyDelayedScan2) { 237TEST_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
235TEST_F(DebounceTest, OneKeyDelayedScan3) { 250TEST_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
247TEST_F(DebounceTest, OneKeyDelayedScan4) { 263TEST_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
258TEST_F(DebounceTest, OneKeyDelayedScan5) { 275TEST_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
270TEST_F(DebounceTest, OneKeyDelayedScan6) { 288TEST_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 */