aboutsummaryrefslogtreecommitdiff
path: root/quantum/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/matrix.c')
-rw-r--r--quantum/matrix.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c
index d22817bf4..33586c431 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -25,10 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
25# include "split_common/split_util.h" 25# include "split_common/split_util.h"
26# include "split_common/transactions.h" 26# include "split_common/transactions.h"
27 27
28# ifndef ERROR_DISCONNECT_COUNT
29# define ERROR_DISCONNECT_COUNT 5
30# endif // ERROR_DISCONNECT_COUNT
31
32# define ROWS_PER_HAND (MATRIX_ROWS / 2) 28# define ROWS_PER_HAND (MATRIX_ROWS / 2)
33#else 29#else
34# define ROWS_PER_HAND (MATRIX_ROWS) 30# define ROWS_PER_HAND (MATRIX_ROWS)
@@ -307,33 +303,31 @@ void matrix_init(void) {
307} 303}
308 304
309#ifdef SPLIT_KEYBOARD 305#ifdef SPLIT_KEYBOARD
306// Fallback implementation for keyboards not using the standard split_util.c
307__attribute__((weak)) bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
308 transport_master(master_matrix, slave_matrix);
309 return true; // Treat the transport as always connected
310}
311
310bool matrix_post_scan(void) { 312bool matrix_post_scan(void) {
311 bool changed = false; 313 bool changed = false;
312 if (is_keyboard_master()) { 314 if (is_keyboard_master()) {
313 static uint8_t error_count;
314
315 matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; 315 matrix_row_t slave_matrix[ROWS_PER_HAND] = {0};
316 if (!transport_master(matrix + thisHand, slave_matrix)) { 316 if (transport_master_if_connected(matrix + thisHand, slave_matrix)) {
317 error_count++;
318
319 if (error_count > ERROR_DISCONNECT_COUNT) {
320 // reset other half if disconnected
321 for (int i = 0; i < ROWS_PER_HAND; ++i) {
322 matrix[thatHand + i] = 0;
323 slave_matrix[i] = 0;
324 }
325
326 changed = true;
327 }
328 } else {
329 error_count = 0;
330
331 for (int i = 0; i < ROWS_PER_HAND; ++i) { 317 for (int i = 0; i < ROWS_PER_HAND; ++i) {
332 if (matrix[thatHand + i] != slave_matrix[i]) { 318 if (matrix[thatHand + i] != slave_matrix[i]) {
333 matrix[thatHand + i] = slave_matrix[i]; 319 matrix[thatHand + i] = slave_matrix[i];
334 changed = true; 320 changed = true;
335 } 321 }
336 } 322 }
323 } else {
324 // reset other half if disconnected
325 for (int i = 0; i < ROWS_PER_HAND; ++i) {
326 matrix[thatHand + i] = 0;
327 slave_matrix[i] = 0;
328 }
329
330 changed = true;
337 } 331 }
338 332
339 matrix_scan_quantum(); 333 matrix_scan_quantum();