summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-01-18 05:01:38 +1100
committerGitHub <noreply@github.com>2021-01-18 05:01:38 +1100
commite702c7f1b4cfa8fe1579498ef2877994baa64056 (patch)
tree6fcb6c74a1e69f7f981303659cae857f50d0a208 /quantum
parentd6d15b91f3a43b74f177fea9fd2f632eaf303696 (diff)
downloadqmk_firmware-e702c7f1b4cfa8fe1579498ef2877994baa64056.tar.gz
qmk_firmware-e702c7f1b4cfa8fe1579498ef2877994baa64056.zip
Keep track of last matrix activity. (#11552)
Co-authored-by: Dasky <daskygit@users.noreply.github.com> Co-authored-by: Dasky <daskygit@users.noreply.github.com>
Diffstat (limited to 'quantum')
-rw-r--r--quantum/split_common/matrix.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index 22ff89bfc6..631e960ead 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -251,21 +251,33 @@ void matrix_init(void) {
split_post_init();
}
-void matrix_post_scan(void) {
+bool matrix_post_scan(void) {
+ bool changed = false;
if (is_keyboard_master()) {
static uint8_t error_count;
- if (!transport_master(matrix + thatHand)) {
+ matrix_row_t slave_matrix[ROWS_PER_HAND] = {0};
+ if (!transport_master(slave_matrix)) {
error_count++;
if (error_count > ERROR_DISCONNECT_COUNT) {
// reset other half if disconnected
for (int i = 0; i < ROWS_PER_HAND; ++i) {
matrix[thatHand + i] = 0;
+ slave_matrix[i] = 0;
}
+
+ changed = true;
}
} else {
error_count = 0;
+
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ if (matrix[thatHand + i] != slave_matrix[i]) {
+ matrix[thatHand + i] = slave_matrix[i];
+ changed = true;
+ }
+ }
}
matrix_scan_quantum();
@@ -274,25 +286,27 @@ void matrix_post_scan(void) {
matrix_slave_scan_user();
}
+
+ return changed;
}
uint8_t matrix_scan(void) {
- bool changed = false;
+ bool local_changed = false;
#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
// Set row, read cols
for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) {
- changed |= read_cols_on_row(raw_matrix, current_row);
+ local_changed |= read_cols_on_row(raw_matrix, current_row);
}
#elif (DIODE_DIRECTION == ROW2COL)
// Set col, read rows
for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
- changed |= read_rows_on_col(raw_matrix, current_col);
+ local_changed |= read_rows_on_col(raw_matrix, current_col);
}
#endif
- debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);
+ debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed);
- matrix_post_scan();
- return (uint8_t)changed;
+ bool remote_changed = matrix_post_scan();
+ return (uint8_t)(local_changed || remote_changed);
}