aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Arlott <70171+nomis@users.noreply.github.com>2021-06-16 05:00:37 +0100
committerGitHub <noreply@github.com>2021-06-16 14:00:37 +1000
commita0959f1b3393d284b3aa11162497e8851fd94bca (patch)
tree5a3f125d028fddc8822ce994ab756d0a817c2f97
parentb151153211f5f932a6fa19701b9b394f558498c1 (diff)
downloadqmk_firmware-a0959f1b3393d284b3aa11162497e8851fd94bca.tar.gz
qmk_firmware-a0959f1b3393d284b3aa11162497e8851fd94bca.zip
Add asym_eager_defer_pk debounce type (#12689)
-rw-r--r--docs/feature_debounce_type.md4
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c171
-rw-r--r--quantum/debounce/tests/asym_eager_defer_pk_tests.cpp374
-rw-r--r--quantum/debounce/tests/rules.mk5
-rw-r--r--quantum/debounce/tests/testlist.mk3
5 files changed, 554 insertions, 3 deletions
diff --git a/docs/feature_debounce_type.md b/docs/feature_debounce_type.md
index 3ad74224c..306185fe8 100644
--- a/docs/feature_debounce_type.md
+++ b/docs/feature_debounce_type.md
@@ -121,16 +121,16 @@ DEBOUNCE_TYPE = <name of algorithm>
121Where name of algorithm is one of: 121Where name of algorithm is one of:
122* ```sym_defer_g``` - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE``` milliseconds of no changes has occurred, all input changes are pushed. 122* ```sym_defer_g``` - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE``` milliseconds of no changes has occurred, all input changes are pushed.
123 * This is the current default algorithm. This is the highest performance algorithm with lowest memory usage, and it's also noise-resistant. 123 * This is the current default algorithm. This is the highest performance algorithm with lowest memory usage, and it's also noise-resistant.
124* ```sym_eager_pr``` - debouncing per row. On any state change, response is immediate, followed by locking the row ```DEBOUNCE``` milliseconds of no further input for that row. 124* ```sym_eager_pr``` - debouncing per row. On any state change, response is immediate, followed by locking the row ```DEBOUNCE``` milliseconds of no further input for that row.
125For use in keyboards where refreshing ```NUM_KEYS``` 8-bit counters is computationally expensive / low scan rate, and fingers usually only hit one row at a time. This could be 125For use in keyboards where refreshing ```NUM_KEYS``` 8-bit counters is computationally expensive / low scan rate, and fingers usually only hit one row at a time. This could be
126appropriate for the ErgoDox models; the matrix is rotated 90°, and hence its "rows" are really columns, and each finger only hits a single "row" at a time in normal use. 126appropriate for the ErgoDox models; the matrix is rotated 90°, and hence its "rows" are really columns, and each finger only hits a single "row" at a time in normal use.
127* ```sym_eager_pk``` - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE``` milliseconds of no further input for that key 127* ```sym_eager_pk``` - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE``` milliseconds of no further input for that key
128* ```sym_defer_pk``` - debouncing per key. On any state change, a per-key timer is set. When ```DEBOUNCE``` milliseconds of no changes have occurred on that key, the key status change is pushed. 128* ```sym_defer_pk``` - debouncing per key. On any state change, a per-key timer is set. When ```DEBOUNCE``` milliseconds of no changes have occurred on that key, the key status change is pushed.
129* ```asym_eager_defer_pk``` - debouncing per key. On a key-down state change, response is immediate, followed by ```DEBOUNCE``` milliseconds of no further input for that key. On a key-up state change, a per-key timer is set. When ```DEBOUNCE``` milliseconds of no changes have occurred on that key, the key-up status change is pushed.
129 130
130### A couple algorithms that could be implemented in the future: 131### A couple algorithms that could be implemented in the future:
131* ```sym_defer_pr``` 132* ```sym_defer_pr```
132* ```sym_eager_g``` 133* ```sym_eager_g```
133* ```asym_eager_defer_pk```
134 134
135### Use your own debouncing code 135### Use your own debouncing code
136You have the option to implement you own debouncing algorithm. To do this: 136You have the option to implement you own debouncing algorithm. To do this:
diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c
new file mode 100644
index 000000000..24380dc5e
--- /dev/null
+++ b/quantum/debounce/asym_eager_defer_pk.c
@@ -0,0 +1,171 @@
1/*
2 * Copyright 2017 Alex Ong <the.onga@gmail.com>
3 * Copyright 2020 Andrei Purdea <andrei@purdea.ro>
4 * Copyright 2021 Simon Arlott
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21Basic symmetric per-key algorithm. Uses an 8-bit counter per key.
22When no state changes have occured for DEBOUNCE milliseconds, we push the state.
23*/
24
25#include "matrix.h"
26#include "timer.h"
27#include "quantum.h"
28#include <stdlib.h>
29
30#ifdef PROTOCOL_CHIBIOS
31# if CH_CFG_USE_MEMCORE == FALSE
32# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm.
33# endif
34#endif
35
36#ifndef DEBOUNCE
37# define DEBOUNCE 5
38#endif
39
40// Maximum debounce: 127ms
41#if DEBOUNCE > 127
42# undef DEBOUNCE
43# define DEBOUNCE 127
44#endif
45
46#define ROW_SHIFTER ((matrix_row_t)1)
47
48typedef struct {
49 bool pressed : 1;
50 uint8_t time : 7;
51} debounce_counter_t;
52
53#if DEBOUNCE > 0
54static debounce_counter_t *debounce_counters;
55static fast_timer_t last_time;
56static bool counters_need_update;
57static bool matrix_need_update;
58
59#define DEBOUNCE_ELAPSED 0
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);
62static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
63
64// we use num_rows rather than MATRIX_ROWS to support split keyboards
65void debounce_init(uint8_t num_rows) {
66 debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
67 int i = 0;
68 for (uint8_t r = 0; r < num_rows; r++) {
69 for (uint8_t c = 0; c < MATRIX_COLS; c++) {
70 debounce_counters[i++].time = DEBOUNCE_ELAPSED;
71 }
72 }
73}
74
75void debounce_free(void) {
76 free(debounce_counters);
77 debounce_counters = NULL;
78}
79
80void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
81 bool updated_last = false;
82
83 if (counters_need_update) {
84 fast_timer_t now = timer_read_fast();
85 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
86
87 last_time = now;
88 updated_last = true;
89 if (elapsed_time > UINT8_MAX) {
90 elapsed_time = UINT8_MAX;
91 }
92
93 if (elapsed_time > 0) {
94 update_debounce_counters_and_transfer_if_expired(raw, cooked, num_rows, elapsed_time);
95 }
96 }
97
98 if (changed || matrix_need_update) {
99 if (!updated_last) {
100 last_time = timer_read_fast();
101 }
102
103 transfer_matrix_values(raw, cooked, num_rows);
104 }
105}
106
107static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time) {
108 debounce_counter_t *debounce_pointer = debounce_counters;
109
110 counters_need_update = false;
111 matrix_need_update = false;
112
113 for (uint8_t row = 0; row < num_rows; row++) {
114 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
115 matrix_row_t col_mask = (ROW_SHIFTER << col);
116
117 if (debounce_pointer->time != DEBOUNCE_ELAPSED) {
118 if (debounce_pointer->time <= elapsed_time) {
119 debounce_pointer->time = DEBOUNCE_ELAPSED;
120
121 if (debounce_pointer->pressed) {
122 // key-down: eager
123 matrix_need_update = true;
124 } else {
125 // key-up: defer
126 cooked[row] = (cooked[row] & ~col_mask) | (raw[row] & col_mask);
127 }
128 } else {
129 debounce_pointer->time -= elapsed_time;
130 counters_need_update = true;
131 }
132 }
133 debounce_pointer++;
134 }
135 }
136}
137
138static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
139 debounce_counter_t *debounce_pointer = debounce_counters;
140
141 for (uint8_t row = 0; row < num_rows; row++) {
142 matrix_row_t delta = raw[row] ^ cooked[row];
143 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
144 matrix_row_t col_mask = (ROW_SHIFTER << col);
145
146 if (delta & col_mask) {
147 if (debounce_pointer->time == DEBOUNCE_ELAPSED) {
148 debounce_pointer->pressed = (raw[row] & col_mask);
149 debounce_pointer->time = DEBOUNCE;
150 counters_need_update = true;
151
152 if (debounce_pointer->pressed) {
153 // key-down: eager
154 cooked[row] ^= col_mask;
155 }
156 }
157 } else if (debounce_pointer->time != DEBOUNCE_ELAPSED) {
158 if (!debounce_pointer->pressed) {
159 // key-up: defer
160 debounce_pointer->time = DEBOUNCE_ELAPSED;
161 }
162 }
163 debounce_pointer++;
164 }
165 }
166}
167
168bool debounce_active(void) { return true; }
169#else
170# include "none.c"
171#endif
diff --git a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
new file mode 100644
index 000000000..fe374c3df
--- /dev/null
+++ b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
@@ -0,0 +1,374 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 /* Release key after 1ms delay */
25 {1, {{0, 1, UP}}, {}},
26
27 /*
28 * Until the eager timer on DOWN is observed to finish, the defer timer
29 * on UP can't start. There's no workaround for this because it's not
30 * possible to debounce an event that isn't being tracked.
31 *
32 * sym_defer_pk has the same problem but the test has to track that the
33 * key changed state so the DOWN timer is always allowed to finish
34 * before starting the UP timer.
35 */
36 {5, {}, {}},
37
38 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
39 /* Press key again after 1ms delay */
40 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
41 });
42 runEvents();
43}
44
45TEST_F(DebounceTest, OneKeyShort2) {
46 addEvents({ /* Time, Inputs, Outputs */
47 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
48 /* Release key after 2ms delay */
49 {2, {{0, 1, UP}}, {}},
50
51 {5, {}, {}}, /* See OneKeyShort1 */
52
53 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
54 /* Press key again after 1ms delay */
55 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
56 });
57 runEvents();
58}
59
60TEST_F(DebounceTest, OneKeyShort3) {
61 addEvents({ /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 /* Release key after 3ms delay */
64 {3, {{0, 1, UP}}, {}},
65
66 {5, {}, {}}, /* See OneKeyShort1 */
67
68 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
69 /* Press key again after 1ms delay */
70 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
71 });
72 runEvents();
73}
74
75TEST_F(DebounceTest, OneKeyShort4) {
76 addEvents({ /* Time, Inputs, Outputs */
77 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
78 /* Release key after 4ms delay */
79 {4, {{0, 1, UP}}, {}},
80
81 {5, {}, {}}, /* See OneKeyShort1 */
82
83 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
84 /* Press key again after 1ms delay */
85 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
86 });
87 runEvents();
88}
89
90TEST_F(DebounceTest, OneKeyShort5) {
91 addEvents({ /* Time, Inputs, Outputs */
92 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
93
94 /* Release key after 5ms delay */
95 {5, {{0, 1, UP}}, {}},
96
97 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
98 /* Press key again after 1ms delay */
99 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
100 });
101 runEvents();
102}
103
104TEST_F(DebounceTest, OneKeyShort6) {
105 addEvents({ /* Time, Inputs, Outputs */
106 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
107
108 /* Release key after 6ms delay */
109 {6, {{0, 1, UP}}, {}},
110
111 {11, {}, {{0, 1, UP}}}, /* 5ms after UP at time 6 */
112 /* Press key again after 1ms delay */
113 {12, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
114 });
115 runEvents();
116}
117
118TEST_F(DebounceTest, OneKeyShort7) {
119 addEvents({ /* Time, Inputs, Outputs */
120 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
121
122 /* Release key after 7ms delay */
123 {7, {{0, 1, UP}}, {}},
124
125 {12, {}, {{0, 1, UP}}}, /* 5ms after UP at time 7 */
126 /* Press key again after 1ms delay */
127 {13, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
128 });
129 runEvents();
130}
131
132TEST_F(DebounceTest, OneKeyShort8) {
133 addEvents({ /* Time, Inputs, Outputs */
134 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
135 /* Release key after 1ms delay */
136 {1, {{0, 1, UP}}, {}},
137
138 {5, {}, {}}, /* See OneKeyShort1 */
139
140 {10, {}, {{0, 1, UP}}}, /* 5ms after UP at time 7 */
141 /* Press key again after 0ms delay (scan 2) */
142 {10, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
143 });
144 runEvents();
145}
146
147TEST_F(DebounceTest, OneKeyShort9) {
148 addEvents({ /* Time, Inputs, Outputs */
149 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
150 /* Release key after 1ms delay */
151 {1, {{0, 1, UP}}, {}},
152
153 {5, {}, {}}, /* See OneKeyShort1 */
154
155 /* Press key again after 0ms delay (same scan) before debounce finishes */
156 {10, {{0, 1, DOWN}}, {}},
157 });
158 runEvents();
159}
160
161TEST_F(DebounceTest, OneKeyBouncing1) {
162 addEvents({ /* Time, Inputs, Outputs */
163 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
164 {1, {{0, 1, UP}}, {}},
165 {2, {{0, 1, DOWN}}, {}},
166 {3, {{0, 1, UP}}, {}},
167 {4, {{0, 1, DOWN}}, {}},
168 {5, {{0, 1, UP}}, {}},
169 {6, {{0, 1, DOWN}}, {}},
170 {7, {{0, 1, UP}}, {}},
171 {8, {{0, 1, DOWN}}, {}},
172 {9, {{0, 1, UP}}, {}},
173 {10, {{0, 1, DOWN}}, {}},
174 {11, {{0, 1, UP}}, {}},
175 {12, {{0, 1, DOWN}}, {}},
176 {13, {{0, 1, UP}}, {}},
177 {14, {{0, 1, DOWN}}, {}},
178 {15, {{0, 1, UP}}, {}},
179
180 {20, {}, {{0, 1, UP}}},
181 /* Press key again after 1ms delay */
182 {21, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
183 });
184 runEvents();
185}
186
187TEST_F(DebounceTest, OneKeyBouncing2) {
188 addEvents({ /* Time, Inputs, Outputs */
189 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
190 /* Change twice in the same time period */
191 {1, {{0, 1, UP}}, {}},
192 {1, {{0, 1, DOWN}}, {}},
193 /* Change three times in the same time period */
194 {2, {{0, 1, UP}}, {}},
195 {2, {{0, 1, DOWN}}, {}},
196 {2, {{0, 1, UP}}, {}},
197 /* Change twice in the same time period */
198 {6, {{0, 1, DOWN}}, {}},
199 {6, {{0, 1, UP}}, {}},
200 /* Change three times in the same time period */
201 {7, {{0, 1, DOWN}}, {}},
202 {7, {{0, 1, UP}}, {}},
203 {7, {{0, 1, DOWN}}, {}},
204 /* Change twice in the same time period */
205 {8, {{0, 1, UP}}, {}},
206 {8, {{0, 1, DOWN}}, {}},
207 /* Change three times in the same time period */
208 {9, {{0, 1, UP}}, {}},
209 {9, {{0, 1, DOWN}}, {}},
210 {9, {{0, 1, UP}}, {}},
211
212 {14, {}, {{0, 1, UP}}},
213 /* Press key again after 1ms delay */
214 {15, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
215 });
216 runEvents();
217}
218
219TEST_F(DebounceTest, OneKeyLong) {
220 addEvents({ /* Time, Inputs, Outputs */
221 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
222
223 {25, {{0, 1, UP}}, {}},
224
225 {30, {}, {{0, 1, UP}}},
226
227 {50, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
228
229 {75, {{0, 1, UP}}, {}},
230
231 {80, {}, {{0, 1, UP}}},
232
233 {100, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
234 });
235 runEvents();
236}
237
238TEST_F(DebounceTest, TwoKeysShort) {
239 addEvents({ /* Time, Inputs, Outputs */
240 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
241 {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
242 /* Release key after 2ms delay */
243 {2, {{0, 1, UP}}, {}},
244 {3, {{0, 2, UP}}, {}},
245
246 {5, {}, {}}, /* See OneKeyShort1 */
247 {6, {}, {}}, /* See OneKeyShort1 */
248
249 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
250 /* Press key again after 1ms delay */
251 {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 */
253 });
254 runEvents();
255}
256
257
258TEST_F(DebounceTest, OneKeyDelayedScan1) {
259 addEvents({ /* Time, Inputs, Outputs */
260 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
261
262 /* Processing is very late, immediately release key */
263 {300, {{0, 1, UP}}, {}},
264
265 {305, {}, {{0, 1, UP}}},
266 });
267 time_jumps_ = true;
268 runEvents();
269}
270
271TEST_F(DebounceTest, OneKeyDelayedScan2) {
272 addEvents({ /* Time, Inputs, Outputs */
273 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
274
275 /* Processing is very late, immediately release key */
276 {300, {{0, 1, UP}}, {}},
277
278 /* Processing is very late again */
279 {600, {}, {{0, 1, UP}}},
280 });
281 time_jumps_ = true;
282 runEvents();
283}
284
285TEST_F(DebounceTest, OneKeyDelayedScan3) {
286 addEvents({ /* Time, Inputs, Outputs */
287 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
288
289 /* Processing is very late */
290 {300, {}, {}},
291 /* Release key after 1ms */
292 {301, {{0, 1, UP}}, {}},
293
294 {306, {}, {{0, 1, UP}}},
295 });
296 time_jumps_ = true;
297 runEvents();
298}
299
300TEST_F(DebounceTest, OneKeyDelayedScan4) {
301 addEvents({ /* Time, Inputs, Outputs */
302 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
303
304 /* Processing is very late */
305 {300, {}, {}},
306 /* Release key after 1ms */
307 {301, {{0, 1, UP}}, {}},
308
309 /* Processing is very late again */
310 {600, {}, {{0, 1, UP}}},
311 });
312 time_jumps_ = true;
313 runEvents();
314}
315
316TEST_F(DebounceTest, OneKeyDelayedScan5) {
317 addEvents({ /* Time, Inputs, Outputs */
318 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
319
320 {5, {{0, 1, UP}}, {}},
321
322 /* Processing is very late */
323 {300, {}, {{0, 1, UP}}},
324 /* Immediately press key again */
325 {300, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
326 });
327 time_jumps_ = true;
328 runEvents();
329}
330
331TEST_F(DebounceTest, OneKeyDelayedScan6) {
332 addEvents({ /* Time, Inputs, Outputs */
333 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
334
335 {5, {{0, 1, UP}}, {}},
336
337 /* Processing is very late */
338 {300, {}, {{0, 1, UP}}},
339
340 /* Press key again after 1ms */
341 {301, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
342 });
343 time_jumps_ = true;
344 runEvents();
345}
346
347TEST_F(DebounceTest, OneKeyDelayedScan7) {
348 addEvents({ /* Time, Inputs, Outputs */
349 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
350
351 {5, {{0, 1, UP}}, {}},
352
353 /* Press key again before debounce expires */
354 {300, {{0, 1, DOWN}}, {}},
355 });
356 time_jumps_ = true;
357 runEvents();
358}
359
360TEST_F(DebounceTest, OneKeyDelayedScan8) {
361 addEvents({ /* Time, Inputs, Outputs */
362 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
363
364 /* Processing is a bit late */
365 {50, {}, {}},
366 /* Release key after 1ms */
367 {51, {{0, 1, UP}}, {}},
368
369 /* Processing is a bit late again */
370 {100, {}, {{0, 1, UP}}},
371 });
372 time_jumps_ = true;
373 runEvents();
374}
diff --git a/quantum/debounce/tests/rules.mk b/quantum/debounce/tests/rules.mk
index 29fda7889..66928d7eb 100644
--- a/quantum/debounce/tests/rules.mk
+++ b/quantum/debounce/tests/rules.mk
@@ -37,3 +37,8 @@ debounce_sym_eager_pr_DEFS := $(DEBOUNCE_COMMON_DEFS)
37debounce_sym_eager_pr_SRC := $(DEBOUNCE_COMMON_SRC) \ 37debounce_sym_eager_pr_SRC := $(DEBOUNCE_COMMON_SRC) \
38 $(QUANTUM_PATH)/debounce/sym_eager_pr.c \ 38 $(QUANTUM_PATH)/debounce/sym_eager_pr.c \
39 $(QUANTUM_PATH)/debounce/tests/sym_eager_pr_tests.cpp 39 $(QUANTUM_PATH)/debounce/tests/sym_eager_pr_tests.cpp
40
41debounce_asym_eager_defer_pk_DEFS := $(DEBOUNCE_COMMON_DEFS)
42debounce_asym_eager_defer_pk_SRC := $(DEBOUNCE_COMMON_SRC) \
43 $(QUANTUM_PATH)/debounce/asym_eager_defer_pk.c \
44 $(QUANTUM_PATH)/debounce/tests/asym_eager_defer_pk_tests.cpp
diff --git a/quantum/debounce/tests/testlist.mk b/quantum/debounce/tests/testlist.mk
index 16ce8a0a8..c54c45aa6 100644
--- a/quantum/debounce/tests/testlist.mk
+++ b/quantum/debounce/tests/testlist.mk
@@ -2,4 +2,5 @@ TEST_LIST += \
2 debounce_sym_defer_g \ 2 debounce_sym_defer_g \
3 debounce_sym_defer_pk \ 3 debounce_sym_defer_pk \
4 debounce_sym_eager_pk \ 4 debounce_sym_eager_pk \
5 debounce_sym_eager_pr 5 debounce_sym_eager_pr \
6 debounce_asym_eager_defer_pk