From 66193ec03e33019be2646fdb5e65913db7b99fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB=E3=82=BF=E3=83=BC=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=83=91=E3=83=BC?= <76888457+filterpaper@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:07:30 +0800 Subject: [PATCH] Refactor debounce algorithm with static allocation * Converted arrays to static allocation * Standardised use of MATRIX_ROWS_PER_HAND for array sizing * Added Doxygen comments for primary debounce functions * Removed debounce_free() --- quantum/debounce.h | 2 - quantum/debounce/asym_eager_defer_pk.c | 71 ++++++++++--------- quantum/debounce/none.c | 4 +- quantum/debounce/sym_defer_g.c | 1 - quantum/debounce/sym_defer_pk.c | 68 ++++++++++-------- quantum/debounce/sym_defer_pr.c | 9 ++- quantum/debounce/sym_eager_pk.c | 70 +++++++++--------- quantum/debounce/sym_eager_pr.c | 68 +++++++++--------- .../debounce/tests/debounce_test_common.cpp | 2 - 9 files changed, 156 insertions(+), 139 deletions(-) diff --git a/quantum/debounce.h b/quantum/debounce.h index cea1f2b5260..30d2621d185 100644 --- a/quantum/debounce.h +++ b/quantum/debounce.h @@ -17,5 +17,3 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed); void debounce_init(uint8_t num_rows); - -void debounce_free(void); diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c index 78b34f8e39a..173c64beed1 100644 --- a/quantum/debounce/asym_eager_defer_pk.c +++ b/quantum/debounce/asym_eager_defer_pk.c @@ -25,7 +25,7 @@ releasing a key, that state is pushed after no changes occur for DEBOUNCE millis #include "debounce.h" #include "timer.h" -#include +#include "util.h" #ifdef PROTOCOL_CHIBIOS # if CH_CFG_USE_MEMCORE == FALSE @@ -49,32 +49,19 @@ typedef struct { } debounce_counter_t; #if DEBOUNCE > 0 -static debounce_counter_t *debounce_counters; -static fast_timer_t last_time; -static bool counters_need_update; -static bool matrix_need_update; -static bool cooked_changed; +// Uses MATRIX_ROWS_PER_HAND instead of MATRIX_ROWS to support split keyboards +static debounce_counter_t debounce_counters[MATRIX_ROWS_PER_HAND * MATRIX_COLS] = {0}; +static fast_timer_t last_time; +static bool counters_need_update; +static bool matrix_need_update; +static bool cooked_changed; # define DEBOUNCE_ELAPSED 0 -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); -static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); +static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time); +static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]); -// we use num_rows rather than MATRIX_ROWS to support split keyboards -void debounce_init(uint8_t num_rows) { - debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t)); - int i = 0; - for (uint8_t r = 0; r < num_rows; r++) { - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - debounce_counters[i++].time = DEBOUNCE_ELAPSED; - } - } -} - -void debounce_free(void) { - free(debounce_counters); - debounce_counters = NULL; -} +void debounce_init(uint8_t num_rows) {} bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { bool updated_last = false; @@ -86,12 +73,10 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = now; updated_last = true; - if (elapsed_time > UINT8_MAX) { - elapsed_time = UINT8_MAX; - } if (elapsed_time > 0) { - update_debounce_counters_and_transfer_if_expired(raw, cooked, num_rows, elapsed_time); + // Update debounce counters with elapsed timer clamped to UINT8_MAX + update_debounce_counters_and_transfer_if_expired(raw, cooked, MIN(elapsed_time, UINT8_MAX)); } } @@ -100,17 +85,28 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = timer_read_fast(); } - transfer_matrix_values(raw, cooked, num_rows); + transfer_matrix_values(raw, cooked); } return cooked_changed; } -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) { +/** + * @brief Processes per-key debounce counters and updates the debounced matrix state. + * + * This function iterates through each key in the matrix and updates its debounce counter + * based on the elapsed time. If the debounce period has expired, the debounced state is + * updated accordingly for key-down (eager) and key-up (defer) events. + * + * @param raw The current raw key state matrix. + * @param cooked The debounced key state matrix to be updated. + * @param elapsed_time The time elapsed since the last debounce update, in milliseconds. + */ +static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time) { counters_need_update = false; matrix_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { uint16_t index = row * MATRIX_COLS + col; @@ -137,10 +133,21 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], } } -static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) { +/** + * @brief Applies debounced changes to the matrix state based on per-key counters. + * + * This function compares the raw and cooked key state matrices to detect changes. + * For each key, it updates the debounce counter and the debounced state according + * to the debounce algorithm. Key-down events are handled eagerly, while key-up + * events are deferred until the debounce period has elapsed. + * + * @param raw The current raw key state matrix. + * @param cooked The debounced key state matrix to be updated. + */ +static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]) { matrix_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { matrix_row_t delta = raw[row] ^ cooked[row]; for (uint8_t col = 0; col < MATRIX_COLS; col++) { uint16_t index = row * MATRIX_COLS + col; diff --git a/quantum/debounce/none.c b/quantum/debounce/none.c index 0a8ccfc4eec..f996e478dbe 100644 --- a/quantum/debounce/none.c +++ b/quantum/debounce/none.c @@ -31,6 +31,4 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool } return cooked_changed; -} - -void debounce_free(void) {} +} \ No newline at end of file diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c index d96758fab35..a807e3e0bda 100644 --- a/quantum/debounce/sym_defer_g.c +++ b/quantum/debounce/sym_defer_g.c @@ -54,7 +54,6 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool return cooked_changed; } -void debounce_free(void) {} #else // no debouncing. # include "none.c" #endif diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c index e4136a20e73..9c1b57db9d8 100644 --- a/quantum/debounce/sym_defer_pk.c +++ b/quantum/debounce/sym_defer_pk.c @@ -21,7 +21,7 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state. #include "debounce.h" #include "timer.h" -#include +#include "util.h" #ifdef PROTOCOL_CHIBIOS # if CH_CFG_USE_MEMCORE == FALSE @@ -42,31 +42,18 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state. typedef uint8_t debounce_counter_t; #if DEBOUNCE > 0 -static debounce_counter_t *debounce_counters; -static fast_timer_t last_time; -static bool counters_need_update; -static bool cooked_changed; +// Uses MATRIX_ROWS_PER_HAND instead of MATRIX_ROWS to support split keyboards +static debounce_counter_t debounce_counters[MATRIX_ROWS_PER_HAND * MATRIX_COLS] = {0}; +static fast_timer_t last_time; +static bool counters_need_update; +static bool cooked_changed; # define DEBOUNCE_ELAPSED 0 -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); -static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); +static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time); +static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[]); -// we use num_rows rather than MATRIX_ROWS to support split keyboards -void debounce_init(uint8_t num_rows) { - debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t)); - int i = 0; - for (uint8_t r = 0; r < num_rows; r++) { - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - debounce_counters[i++] = DEBOUNCE_ELAPSED; - } - } -} - -void debounce_free(void) { - free(debounce_counters); - debounce_counters = NULL; -} +void debounce_init(uint8_t num_rows) {} bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { bool updated_last = false; @@ -78,12 +65,10 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = now; updated_last = true; - if (elapsed_time > UINT8_MAX) { - elapsed_time = UINT8_MAX; - } if (elapsed_time > 0) { - update_debounce_counters_and_transfer_if_expired(raw, cooked, num_rows, elapsed_time); + // Update debounce counters with elapsed timer clamped to UINT8_MAX + update_debounce_counters_and_transfer_if_expired(raw, cooked, MIN(elapsed_time, UINT8_MAX)); } } @@ -92,15 +77,26 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = timer_read_fast(); } - start_debounce_counters(raw, cooked, num_rows); + start_debounce_counters(raw, cooked); } return cooked_changed; } -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) { +/** + * @brief Updates debounce counters and transfers debounced key states if the debounce period has expired. + * + * Iterates through each key in the matrix and checks its debounce counter. If the debounce period has expired + * for a key, the debounced state is updated to match the raw state. Otherwise, the debounce counter is decremented + * by the elapsed time and marked for further updates. + * + * @param raw The current raw key state matrix. + * @param cooked The debounced key state matrix to be updated. + * @param elapsed_time The time elapsed since the last debounce update, in milliseconds. + */ +static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time) { counters_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { uint16_t index = row * MATRIX_COLS + col; @@ -120,8 +116,18 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], } } -static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) { - for (uint8_t row = 0; row < num_rows; row++) { +/** + * @brief Initializes debounce counters for keys with changed states. + * + * For each key in the matrix, this function checks if the raw state differs from the debounced state. + * If a change is detected and the debounce counter has elapsed, the counter is set to the debounce period + * and marked for update. Otherwise, the counter is cleared. + * + * @param raw The current raw key state matrix. + * @param cooked The debounced key state matrix. + */ +static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[]) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { matrix_row_t delta = raw[row] ^ cooked[row]; for (uint8_t col = 0; col < MATRIX_COLS; col++) { uint16_t index = row * MATRIX_COLS + col; diff --git a/quantum/debounce/sym_defer_pr.c b/quantum/debounce/sym_defer_pr.c index 3ef98bb3634..84437e03fa2 100644 --- a/quantum/debounce/sym_defer_pr.c +++ b/quantum/debounce/sym_defer_pr.c @@ -19,6 +19,8 @@ DEBOUNCE milliseconds have elapsed since the last change. #include "debounce.h" #include "timer.h" +#include "util.h" +#include #ifndef DEBOUNCE # define DEBOUNCE 5 @@ -30,7 +32,10 @@ static uint8_t countdowns[MATRIX_ROWS_PER_HAND] = {0}; // Last raw state for each matrix row, indexed by row. static matrix_row_t last_raw[MATRIX_ROWS_PER_HAND] = {0}; -void debounce_init(uint8_t num_rows) {} +void debounce_init(uint8_t num_rows) { + memset(countdowns, 0, sizeof(countdowns)); + memset(last_raw, 0, sizeof(last_raw)); +} /** * @brief Debounces the raw matrix state and updates the cooked (debounced) state. @@ -49,7 +54,7 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool uint16_t now = timer_read(); uint16_t elapsed16 = TIMER_DIFF_16(now, last_time); last_time = now; - uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16; + uint8_t elapsed = MIN(elapsed16, UINT8_MAX); bool cooked_changed = false; uint8_t* countdown = countdowns; diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c index f01aa9a5f41..b8cddd5c46e 100644 --- a/quantum/debounce/sym_eager_pk.c +++ b/quantum/debounce/sym_eager_pk.c @@ -21,7 +21,7 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. #include "debounce.h" #include "timer.h" -#include +#include "util.h" #ifdef PROTOCOL_CHIBIOS # if CH_CFG_USE_MEMCORE == FALSE @@ -42,32 +42,19 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. typedef uint8_t debounce_counter_t; #if DEBOUNCE > 0 -static debounce_counter_t *debounce_counters; -static fast_timer_t last_time; -static bool counters_need_update; -static bool matrix_need_update; -static bool cooked_changed; +// Uses MATRIX_ROWS_PER_HAND instead of MATRIX_ROWS to support split keyboards +static debounce_counter_t debounce_counters[MATRIX_ROWS_PER_HAND * MATRIX_COLS] = {0}; +static fast_timer_t last_time; +static bool counters_need_update; +static bool matrix_need_update; +static bool cooked_changed; # define DEBOUNCE_ELAPSED 0 -static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); -static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); +static void update_debounce_counters(uint8_t elapsed_time); +static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]); -// we use num_rows rather than MATRIX_ROWS to support split keyboards -void debounce_init(uint8_t num_rows) { - debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t)); - int i = 0; - for (uint8_t r = 0; r < num_rows; r++) { - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - debounce_counters[i++] = DEBOUNCE_ELAPSED; - } - } -} - -void debounce_free(void) { - free(debounce_counters); - debounce_counters = NULL; -} +void debounce_init(uint8_t num_rows) {} bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { bool updated_last = false; @@ -79,12 +66,10 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = now; updated_last = true; - if (elapsed_time > UINT8_MAX) { - elapsed_time = UINT8_MAX; - } if (elapsed_time > 0) { - update_debounce_counters(num_rows, elapsed_time); + // Update debounce counters with elapsed timer clamped to UINT8_MAX + update_debounce_counters(MIN(elapsed_time, UINT8_MAX)); } } @@ -93,17 +78,25 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = timer_read_fast(); } - transfer_matrix_values(raw, cooked, num_rows); + transfer_matrix_values(raw, cooked); } return cooked_changed; } -// If the current time is > debounce counter, set the counter to enable input. -static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) { +/** + * @brief Updates per-key debounce counters and determines if matrix needs updating. + * + * Iterates through each key in the matrix and checks its debounce counter. + * If the debounce period has elapsed for a key, the counter is reset and the matrix is marked for update. + * Otherwise, the counter is decremented by the elapsed time and marked for further updates if needed. + * + * @param elapsed_time The time elapsed since the last debounce update, in milliseconds. + */ +static void update_debounce_counters(uint8_t elapsed_time) { counters_need_update = false; matrix_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { uint16_t index = row * MATRIX_COLS + col; @@ -120,10 +113,19 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) { } } -// upload from raw_matrix to final matrix; -static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) { +/** + * @brief Transfers debounced key states from the raw matrix to the cooked matrix. + * + * For each key in the matrix, this function checks if its state has changed and if its + * debounce counter has elapsed. If so, the debounce counter is reset, the cooked matrix + * is updated to reflect the new state, and the matrix is marked for further updates. + * + * @param raw The current raw key state matrix. + * @param cooked The debounced key state matrix to be updated. + */ +static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]) { matrix_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { matrix_row_t delta = raw[row] ^ cooked[row]; matrix_row_t existing_row = cooked[row]; for (uint8_t col = 0; col < MATRIX_COLS; col++) { diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c index 18a970366e5..d63da208c04 100644 --- a/quantum/debounce/sym_eager_pr.c +++ b/quantum/debounce/sym_eager_pr.c @@ -21,7 +21,7 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. #include "debounce.h" #include "timer.h" -#include +#include "util.h" #ifdef PROTOCOL_CHIBIOS # if CH_CFG_USE_MEMCORE == FALSE @@ -42,30 +42,19 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. typedef uint8_t debounce_counter_t; #if DEBOUNCE > 0 -static bool matrix_need_update; - -static debounce_counter_t *debounce_counters; -static fast_timer_t last_time; -static bool counters_need_update; -static bool cooked_changed; +// Uses MATRIX_ROWS_PER_HAND instead of MATRIX_ROWS to support split keyboards +static debounce_counter_t debounce_counters[MATRIX_ROWS_PER_HAND] = {0}; +static fast_timer_t last_time; +static bool counters_need_update; +static bool matrix_need_update; +static bool cooked_changed; # define DEBOUNCE_ELAPSED 0 -static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); -static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); +static void update_debounce_counters(uint8_t elapsed_time); +static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]); -// we use num_rows rather than MATRIX_ROWS to support split keyboards -void debounce_init(uint8_t num_rows) { - debounce_counters = (debounce_counter_t *)malloc(num_rows * sizeof(debounce_counter_t)); - for (uint8_t r = 0; r < num_rows; r++) { - debounce_counters[r] = DEBOUNCE_ELAPSED; - } -} - -void debounce_free(void) { - free(debounce_counters); - debounce_counters = NULL; -} +void debounce_init(uint8_t num_rows) {} bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { bool updated_last = false; @@ -77,12 +66,10 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = now; updated_last = true; - if (elapsed_time > UINT8_MAX) { - elapsed_time = UINT8_MAX; - } if (elapsed_time > 0) { - update_debounce_counters(num_rows, elapsed_time); + // Update debounce counters with elapsed timer clamped to UINT8_MAX + update_debounce_counters(MIN(elapsed_time, UINT8_MAX)); } } @@ -91,17 +78,25 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool last_time = timer_read_fast(); } - transfer_matrix_values(raw, cooked, num_rows); + transfer_matrix_values(raw, cooked); } return cooked_changed; } -// If the current time is > debounce counter, set the counter to enable input. -static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) { +/** + * @brief Updates per-row debounce counters and determines if matrix needs updating. + * + * Iterates through each row in the matrix and checks its debounce counter. If the debounce + * period has elapsed, the counter is reset and the matrix is marked for update. Otherwise, + * the counter is decremented by the elapsed time and marked for further updates if needed. + * + * @param elapsed_time The time elapsed since the last debounce update, in milliseconds. + */ +static void update_debounce_counters(uint8_t elapsed_time) { counters_need_update = false; matrix_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { if (debounce_counters[row] != DEBOUNCE_ELAPSED) { if (debounce_counters[row] <= elapsed_time) { debounce_counters[row] = DEBOUNCE_ELAPSED; @@ -114,10 +109,19 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) { } } -// upload from raw_matrix to final matrix; -static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) { +/** + * @brief Transfers debounced key states from the raw matrix to the cooked matrix. + * + * For each row in the matrix, this function checks if its state has changed and if its + * debounce counter has elapsed. If so, the debounce counter is reset, the cooked matrix + * is updated to reflect the new state, and the matrix is marked for further updates. + * + * @param raw The current raw key state matrix. + * @param cooked The debounced key state matrix + */ +static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]) { matrix_need_update = false; - for (uint8_t row = 0; row < num_rows; row++) { + for (uint8_t row = 0; row < MATRIX_ROWS_PER_HAND; row++) { matrix_row_t existing_row = cooked[row]; matrix_row_t raw_row = raw[row]; diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp index fd4b6f01a62..3782f51411d 100644 --- a/quantum/debounce/tests/debounce_test_common.cpp +++ b/quantum/debounce/tests/debounce_test_common.cpp @@ -121,8 +121,6 @@ void DebounceTest::runEventsInternal() { checkCookedMatrix(false, "debounce() modified cooked matrix"); advance_time(1); } - - debounce_free(); } void DebounceTest::runDebounce(bool changed) {