diff --git a/corne/firmware/config.h b/corne/firmware/config.h index a708ae9..4789e70 100644 --- a/corne/firmware/config.h +++ b/corne/firmware/config.h @@ -74,6 +74,7 @@ #define SPLIT_HAND_PIN C1 //#define SPLIT_LAYER_STATE_ENABLE #define SPLIT_HAND_PIN_LOW_IS_LEFT +#define SPLIT_TRANSPORT_MIRROR // reactive RGB needs master matrix mirrored to slave //#define SPLIT_LED_STATE_ENABLE diff --git a/corne/firmware/m57.c b/corne/firmware/m57.c index b75e030..ebd7fe6 100644 --- a/corne/firmware/m57.c +++ b/corne/firmware/m57.c @@ -70,11 +70,12 @@ led_config_t g_led_config = { {0,51}, {16,51}, {32,51}, {48,51}, {64,51},{80,51}, // {128,51}, {144,51}, {160,51}, {178,51},{194,51}, {210,51}, {32,63}, {48,63}, {64,63}, // {112,63}, {128,63}, {144,63}, {160,63}, {178,63}, - {128,12}, {144,12}, {160,12}, {178,12},{194,12}, {210,12}, - {112,25}, {128,25}, {144,25}, {160,25}, {178,25},{194,25}, {210,25}, - {112,38}, {128,38}, {144,38}, {160,38}, {178,38},{194,38}, {210,38}, - {128,51}, {144,51}, {160,51}, {178,51},{194,51}, {210,51}, - {112,63}, {128,63}, {144,63}, + // Right-half x coords overlap left inner edge (96) so splash crosses the split + {112,12}, {128,12}, {144,12}, {162,12},{178,12}, {194,12}, + {96,25}, {112,25}, {128,25}, {144,25}, {162,25},{178,25}, {194,25}, + {96,38}, {112,38}, {128,38}, {144,38}, {162,38},{178,38}, {194,38}, + {112,51}, {128,51}, {144,51}, {162,51},{178,51}, {194,51}, + {96,63}, {112,63}, {128,63}, }, { diff --git a/corne/firmware/matrix.c b/corne/firmware/matrix.c index e889694..57857e7 100644 --- a/corne/firmware/matrix.c +++ b/corne/firmware/matrix.c @@ -26,6 +26,10 @@ along with this program. If not, see . # 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; } diff --git a/corne/firmware/split_util_qf.c b/corne/firmware/split_util_qf.c index 490ea8d..aec47e3 100644 --- a/corne/firmware/split_util_qf.c +++ b/corne/firmware/split_util_qf.c @@ -183,8 +183,7 @@ bool is_keyboard_master_impl(void) { } bool is_keyboard_left(void) { - // return split_config.left; - return false; + return split_config.left; } bool is_keyboard_master(void) {