Fix cross-half reactive RGB splash on BCORNE split.
Mirror master matrix state and sync remote keypresses to rgb_matrix so splash propagates from the left half onto the right, and close the LED coordinate gap at the split seam. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+52
-2
@@ -26,6 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# include "split_common/split_util.h"
|
||||
# include "split_common/transactions.h"
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
# include "rgb_matrix.h"
|
||||
#endif
|
||||
|
||||
# define ROWS_PER_HAND (MATRIX_ROWS / 2)
|
||||
|
||||
|
||||
@@ -229,6 +233,45 @@ bool is_keyboard_master_impl(void) {
|
||||
|
||||
static bool last_connected = false;
|
||||
uint32_t counter1 = 1;
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
static void rgb_matrix_sync_remote_half(matrix_row_t remote_prev[ROWS_PER_HAND], uint8_t remote_offset) {
|
||||
for (uint8_t r = 0; r < ROWS_PER_HAND; r++) {
|
||||
const uint8_t row = remote_offset + r;
|
||||
const matrix_row_t current = matrix[row];
|
||||
const matrix_row_t delta = current ^ remote_prev[r];
|
||||
|
||||
if (!delta) {
|
||||
continue;
|
||||
}
|
||||
|
||||
matrix_row_t col_mask = 1;
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++, col_mask <<= 1) {
|
||||
if (delta & col_mask) {
|
||||
rgb_matrix_handle_key_event(row, col, current & col_mask);
|
||||
}
|
||||
}
|
||||
|
||||
remote_prev[r] = current;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
static matrix_row_t master_remote_prev[ROWS_PER_HAND] = {0};
|
||||
static matrix_row_t slave_mirror_prev[ROWS_PER_HAND] = {0};
|
||||
|
||||
if (is_keyboard_master()) {
|
||||
rgb_matrix_sync_remote_half(master_remote_prev, thatHand);
|
||||
} else {
|
||||
rgb_matrix_sync_remote_half(slave_mirror_prev, thatHand);
|
||||
}
|
||||
#endif
|
||||
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
bool matrix_post_scan_qf(void) {
|
||||
counter1++;
|
||||
bool changed = false;
|
||||
@@ -248,8 +291,6 @@ bool matrix_post_scan_qf(void) {
|
||||
}
|
||||
|
||||
if (changed) memcpy(matrix + thatHand, slave_matrix, sizeof(slave_matrix));
|
||||
|
||||
matrix_scan_kb();
|
||||
} else {
|
||||
if(counter1 % 15000 ==0){
|
||||
// extern bool usb_bus_detected(void);
|
||||
@@ -262,11 +303,20 @@ bool matrix_post_scan_qf(void) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
matrix_row_t remote_before[ROWS_PER_HAND];
|
||||
memcpy(remote_before, matrix + thatHand, sizeof(remote_before));
|
||||
|
||||
transport_slave(matrix + thatHand, matrix + thisHand);
|
||||
|
||||
if (memcmp(remote_before, matrix + thatHand, sizeof(remote_before)) != 0) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
matrix_slave_scan_kb();
|
||||
}
|
||||
|
||||
matrix_scan_kb();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user