aboutsummaryrefslogtreecommitdiff
path: root/quantum/debounce/asym_eager_defer_pk.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/debounce/asym_eager_defer_pk.c')
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c22
1 files changed, 11 insertions, 11 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