From 4efdee06b3fd902bb1ccc99208d3c4151cb1f2dc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 11 Jan 2021 20:12:08 +1100 Subject: [PATCH] Simplify split matrix last changed. --- quantum/split_common/matrix.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 5b28ef9b6943..06bab734e742 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -245,7 +245,7 @@ void matrix_init(void) { split_post_init(); } -bool matrix_pre_scan(void) { +bool matrix_post_scan(void) { bool changed = false; if (is_keyboard_master()) { static uint8_t error_count; @@ -253,15 +253,15 @@ bool matrix_pre_scan(void) { matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; if (!transport_master(slave_matrix)) { error_count++; - } else { - error_count = 0; - } - if (error_count > ERROR_DISCONNECT_COUNT) { - // reset other half if disconnected - for (int i = 0; i < ROWS_PER_HAND; ++i) { - slave_matrix[i] = 0; + if (error_count > ERROR_DISCONNECT_COUNT) { + // reset other half if disconnected + for (int i = 0; i < ROWS_PER_HAND; ++i) { + slave_matrix[i] = 0; + } } + } else { + error_count = 0; } for (int i = 0; i < ROWS_PER_HAND; ++i) { @@ -270,23 +270,19 @@ bool matrix_pre_scan(void) { changed = true; } } - } - return changed; -} -void matrix_post_scan(void) { - if (is_keyboard_master()) { matrix_scan_quantum(); } else { transport_slave(matrix + thisHand); matrix_slave_scan_user(); } + + return changed; } uint8_t matrix_scan(void) { bool local_changed = false; - bool remote_changed = matrix_pre_scan(); #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) // Set row, read cols @@ -302,6 +298,6 @@ uint8_t matrix_scan(void) { debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); - matrix_post_scan(); + bool remote_changed = matrix_post_scan(); return (uint8_t)(local_changed || remote_changed); }