diff options
Diffstat (limited to 'quantum/matrix.c')
-rw-r--r-- | quantum/matrix.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index 33586c431..4fbcc2419 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
@@ -288,10 +288,8 @@ void matrix_init(void) { | |||
288 | matrix_init_pins(); | 288 | matrix_init_pins(); |
289 | 289 | ||
290 | // initialize matrix state: all keys off | 290 | // initialize matrix state: all keys off |
291 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 291 | memset(matrix, 0, sizeof(matrix)); |
292 | raw_matrix[i] = 0; | 292 | memset(raw_matrix, 0, sizeof(raw_matrix)); |
293 | matrix[i] = 0; | ||
294 | } | ||
295 | 293 | ||
296 | debounce_init(ROWS_PER_HAND); | 294 | debounce_init(ROWS_PER_HAND); |
297 | 295 | ||
@@ -312,24 +310,22 @@ __attribute__((weak)) bool transport_master_if_connected(matrix_row_t master_mat | |||
312 | bool matrix_post_scan(void) { | 310 | bool matrix_post_scan(void) { |
313 | bool changed = false; | 311 | bool changed = false; |
314 | if (is_keyboard_master()) { | 312 | if (is_keyboard_master()) { |
313 | static bool last_connected = false; | ||
315 | matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; | 314 | matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; |
316 | if (transport_master_if_connected(matrix + thisHand, slave_matrix)) { | 315 | if (transport_master_if_connected(matrix + thisHand, slave_matrix)) { |
317 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 316 | changed = memcmp(matrix + thatHand, slave_matrix, sizeof(slave_matrix)) != 0; |
318 | if (matrix[thatHand + i] != slave_matrix[i]) { | ||
319 | matrix[thatHand + i] = slave_matrix[i]; | ||
320 | changed = true; | ||
321 | } | ||
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 | 317 | ||
318 | last_connected = true; | ||
319 | } else if (last_connected) { | ||
320 | // reset other half when disconnected | ||
321 | memset(slave_matrix, 0, sizeof(slave_matrix)); | ||
330 | changed = true; | 322 | changed = true; |
323 | |||
324 | last_connected = false; | ||
331 | } | 325 | } |
332 | 326 | ||
327 | if (changed) memcpy(matrix + thatHand, slave_matrix, sizeof(slave_matrix)); | ||
328 | |||
333 | matrix_scan_quantum(); | 329 | matrix_scan_quantum(); |
334 | } else { | 330 | } else { |
335 | transport_slave(matrix + thatHand, matrix + thisHand); | 331 | transport_slave(matrix + thatHand, matrix + thisHand); |