1
0

Debounce: Deprecate num_rows parameter (#25632)

This commit is contained in:
フィルターペーパー
2025-10-19 10:14:37 +08:00
committed by GitHub
parent 4f21beb715
commit 81df543086
32 changed files with 983 additions and 1106 deletions

View File

@@ -9,11 +9,10 @@
*
* @param raw The current key state
* @param cooked The debounced key state
* @param num_rows Number of rows to debounce
* @param changed True if raw has changed since the last call
* @return true Cooked has new keychanges after debouncing
* @return false Cooked is the same as before
*/
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed);
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed);
void debounce_init(uint8_t num_rows);
void debounce_init(void);

View File

@@ -38,9 +38,9 @@ static bool cooked_changed;
static inline void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time);
static inline void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]);
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
static fast_timer_t last_time;
bool updated_last = false;
cooked_changed = false;

View File

@@ -17,13 +17,13 @@
#include "debounce.h"
#include <string.h>
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
bool cooked_changed = false;
if (changed) {
size_t matrix_size = num_rows * sizeof(matrix_row_t);
size_t matrix_size = MATRIX_ROWS_PER_HAND * sizeof(matrix_row_t);
if (memcmp(cooked, raw, matrix_size) != 0) {
memcpy(cooked, raw, matrix_size);
cooked_changed = true;

View File

@@ -20,9 +20,9 @@
#if DEBOUNCE > 0
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
static fast_timer_t debouncing_time;
static bool debouncing = false;
bool cooked_changed = false;
@@ -31,7 +31,7 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
debouncing = true;
debouncing_time = timer_read_fast();
} else if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
size_t matrix_size = num_rows * sizeof(matrix_row_t);
size_t matrix_size = MATRIX_ROWS_PER_HAND * sizeof(matrix_row_t);
if (memcmp(cooked, raw, matrix_size) != 0) {
memcpy(cooked, raw, matrix_size);
cooked_changed = true;

View File

@@ -32,9 +32,9 @@ static bool cooked_changed;
static inline void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time);
static inline void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[]);
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
static fast_timer_t last_time;
bool updated_last = false;
cooked_changed = false;

View File

@@ -33,9 +33,9 @@ static bool cooked_changed;
static inline void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t elapsed_time);
static inline void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[]);
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
static fast_timer_t last_time;
bool updated_last = false;
cooked_changed = false;

View File

@@ -46,9 +46,9 @@ static bool cooked_changed;
static inline void update_debounce_counters(uint8_t elapsed_time);
static inline void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]);
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
static fast_timer_t last_time;
bool updated_last = false;
cooked_changed = false;

View File

@@ -33,9 +33,9 @@ static bool cooked_changed;
static inline void update_debounce_counters(uint8_t elapsed_time);
static inline void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[]);
void debounce_init(uint8_t num_rows) {}
void debounce_init(void) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) {
static fast_timer_t last_time;
bool updated_last = false;
cooked_changed = false;

View File

@@ -60,7 +60,7 @@ void DebounceTest::runEventsInternal() {
bool first = true;
/* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */
debounce_init(MATRIX_ROWS);
debounce_init();
set_time(time_offset_);
simulate_async_tick(async_time_jumps_);
std::fill(std::begin(input_matrix_), std::end(input_matrix_), 0);
@@ -129,7 +129,7 @@ void DebounceTest::runDebounce(bool changed) {
reset_access_counter();
bool cooked_changed = debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed);
bool cooked_changed = debounce(raw_matrix_, cooked_matrix_, changed);
if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) {
FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nraw_matrix:\n" << strMatrix(raw_matrix_);

View File

@@ -303,7 +303,7 @@ void matrix_init(void) {
memset(matrix, 0, sizeof(matrix));
memset(raw_matrix, 0, sizeof(raw_matrix));
debounce_init(MATRIX_ROWS_PER_HAND);
debounce_init();
matrix_init_kb();
}
@@ -336,9 +336,9 @@ uint8_t matrix_scan(void) {
if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix));
#ifdef SPLIT_KEYBOARD
changed = debounce(raw_matrix, matrix + thisHand, MATRIX_ROWS_PER_HAND, changed) | matrix_post_scan();
changed = debounce(raw_matrix, matrix + thisHand, changed) | matrix_post_scan();
#else
changed = debounce(raw_matrix, matrix, MATRIX_ROWS_PER_HAND, changed);
changed = debounce(raw_matrix, matrix, changed);
matrix_scan_kb();
#endif
return (uint8_t)changed;

View File

@@ -156,7 +156,7 @@ __attribute__((weak)) void matrix_init(void) {
matrix[i] = 0;
}
debounce_init(MATRIX_ROWS_PER_HAND);
debounce_init();
matrix_init_kb();
}
@@ -165,9 +165,9 @@ __attribute__((weak)) uint8_t matrix_scan(void) {
bool changed = matrix_scan_custom(raw_matrix);
#ifdef SPLIT_KEYBOARD
changed = debounce(raw_matrix, matrix + thisHand, MATRIX_ROWS_PER_HAND, changed) | matrix_post_scan();
changed = debounce(raw_matrix, matrix + thisHand, changed) | matrix_post_scan();
#else
changed = debounce(raw_matrix, matrix, MATRIX_ROWS_PER_HAND, changed);
changed = debounce(raw_matrix, matrix, changed);
matrix_scan_kb();
#endif