#include "matrix.h"
-void debounce_init(void); //every debounce algorithm will have unique storage needs.
+void debounce_init(uint8_t num_rows); //every debounce algorithm will have unique storage needs.
// raw is the current key state
// cooked is the debounced input/output key state
// changed is true if raw has changed since the last call
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed);
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed);
bool debounce_active(void);
static bool debouncing = false;
static uint16_t debouncing_time;
-void debounce_init(void) {}
+void debounce_init(uint8_t num_rows) {}
#if DEBOUNCE > 0
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed)
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
{
if (changed) {
debouncing = true;
}
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
- for (int i = 0; i < MATRIX_ROWS; i++) {
+ for (int i = 0; i < num_rows; i++) {
cooked[i] = raw[i];
}
debouncing = false;
}
}
#else //no debouncing.
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed)
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
{
for (int i = 0; i < MATRIX_ROWS; i++) {
cooked[i] = raw[i];
raw_matrix[i] = 0;
matrix[i] = 0;
}
- debounce_init();
+ debounce_init(MATRIX_ROWS);
matrix_init_quantum();
}
}
#endif
- debounce(raw_matrix, matrix, changed);
+ debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
matrix_scan_quantum();
return 1;