diff options
author | Drashna Jaelre <[email protected]> | 2021-12-27 15:01:51 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-28 10:01:51 +1100 |
commit | c86baf3ecea618ce42263c06ac5d0922ea8817fa (patch) | |
tree | 09b37a42e78e6edfcc603f1b3c1223ca4466e96f /quantum/matrix_common.c | |
parent | 2689e360cea0ba6d42cc57134ec28edc69089fce (diff) | |
download | qmk_firmware-c86baf3ecea618ce42263c06ac5d0922ea8817fa.tar.gz qmk_firmware-c86baf3ecea618ce42263c06ac5d0922ea8817fa.zip |
[Core] Fix bug and code regression for Split Common (#15603)
Diffstat (limited to 'quantum/matrix_common.c')
-rw-r--r-- | quantum/matrix_common.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c index 79f77421e1..5fdc9186fa 100644 --- a/quantum/matrix_common.c +++ b/quantum/matrix_common.c @@ -95,24 +95,22 @@ uint8_t matrix_key_count(void) { bool matrix_post_scan(void) { bool changed = false; if (is_keyboard_master()) { + static bool last_connected = false; matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; if (transport_master_if_connected(matrix + thisHand, slave_matrix)) { - for (int i = 0; i < ROWS_PER_HAND; ++i) { - if (matrix[thatHand + i] != slave_matrix[i]) { - matrix[thatHand + i] = slave_matrix[i]; - changed = true; - } - } - } else { - // reset other half if disconnected - for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[thatHand + i] = 0; - slave_matrix[i] = 0; - } + changed = memcmp(matrix + thatHand, slave_matrix, sizeof(slave_matrix)) != 0; + last_connected = true; + } else if (last_connected) { + // reset other half when disconnected + memset(slave_matrix, 0, sizeof(slave_matrix)); changed = true; + + last_connected = false; } + if (changed) memcpy(matrix + thatHand, slave_matrix, sizeof(slave_matrix)); + matrix_scan_quantum(); } else { transport_slave(matrix + thatHand, matrix + thisHand); |