aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2021-02-15 18:30:33 -0600
committerGitHub <noreply@github.com>2021-02-16 11:30:33 +1100
commitd1806a26e4ad75fa0e0405283803eba22c1a49ba (patch)
tree25bf2750e9770781cff373114bd44736463a91f1
parent1bc8a6e5d49861b268f9274a8686a2640e36e0b5 (diff)
downloadqmk_firmware-d1806a26e4ad75fa0e0405283803eba22c1a49ba.tar.gz
qmk_firmware-d1806a26e4ad75fa0e0405283803eba22c1a49ba.zip
Split transport mirror (#11046)
* Split transport mirror support * Updated RGB Matrix to respond to electrical events instead of key events * split matrix slave fix
-rw-r--r--docs/feature_split_keyboard.md6
-rw-r--r--docs/ja/understanding_qmk.md1
-rw-r--r--docs/understanding_qmk.md1
-rw-r--r--quantum/quantum.c10
-rw-r--r--quantum/rgb_matrix.c19
-rw-r--r--quantum/rgb_matrix.h2
-rw-r--r--quantum/rgb_matrix_animations/typing_heatmap_anim.h4
-rw-r--r--quantum/split_common/matrix.c4
-rw-r--r--quantum/split_common/transport.c37
-rw-r--r--quantum/split_common/transport.h4
-rw-r--r--tmk_core/common/eeconfig.h2
-rw-r--r--tmk_core/common/keyboard.c62
12 files changed, 93 insertions, 59 deletions
diff --git a/docs/feature_split_keyboard.md b/docs/feature_split_keyboard.md
index c285e353d..90af3930f 100644
--- a/docs/feature_split_keyboard.md
+++ b/docs/feature_split_keyboard.md
@@ -191,6 +191,12 @@ communication protocol and may impact the matrix scan speed when enabled.
191The purpose of this feature is to support cosmetic use of modifer state (e.g. 191The purpose of this feature is to support cosmetic use of modifer state (e.g.
192displaying status on an OLED screen). 192displaying status on an OLED screen).
193 193
194```c
195#define SPLIT_TRANSPORT_MIRROR
196```
197
198This mirrors the master side matrix to the slave side for features that react or require knowledge of master side key presses on the slave side. This adds a few bytes of data to the split communication protocol and may impact the matrix scan speed when enabled. The purpose of this feature is to support cosmetic use of key events (e.g. RGB reacting to Keypresses).
199
194### Hardware Configuration Options 200### Hardware Configuration Options
195 201
196There are some settings that you may need to configure, based on how the hardware is set up. 202There are some settings that you may need to configure, based on how the hardware is set up.
diff --git a/docs/ja/understanding_qmk.md b/docs/ja/understanding_qmk.md
index 74b37398f..ab860a609 100644
--- a/docs/ja/understanding_qmk.md
+++ b/docs/ja/understanding_qmk.md
@@ -147,7 +147,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
147 * [`bool process_haptic(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/2cee371bf125a6ec541dd7c5a809573facc7c456/drivers/haptic/haptic.c#L216) 147 * [`bool process_haptic(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/2cee371bf125a6ec541dd7c5a809573facc7c456/drivers/haptic/haptic.c#L216)
148 * [`bool process_record_kb(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/card.c#L20) 148 * [`bool process_record_kb(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/card.c#L20)
149 * [`bool process_record_user(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/keymaps/default/keymap.c#L58) 149 * [`bool process_record_user(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/keymaps/default/keymap.c#L58)
150 * [`bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/rgb_matrix.c#L139)
151 * [`bool process_midi(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_midi.c#L81) 150 * [`bool process_midi(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_midi.c#L81)
152 * [`bool process_audio(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_audio.c#L19) 151 * [`bool process_audio(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_audio.c#L19)
153 * [`bool process_steno(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_steno.c#L160) 152 * [`bool process_steno(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_steno.c#L160)
diff --git a/docs/understanding_qmk.md b/docs/understanding_qmk.md
index 939642425..331b1c893 100644
--- a/docs/understanding_qmk.md
+++ b/docs/understanding_qmk.md
@@ -142,7 +142,6 @@ The `process_record()` function itself is deceptively simple, but hidden within
142 * [`bool process_haptic(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/2cee371bf125a6ec541dd7c5a809573facc7c456/drivers/haptic/haptic.c#L216) 142 * [`bool process_haptic(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/2cee371bf125a6ec541dd7c5a809573facc7c456/drivers/haptic/haptic.c#L216)
143 * [`bool process_record_kb(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/card.c#L20) 143 * [`bool process_record_kb(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/card.c#L20)
144 * [`bool process_record_user(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/keymaps/default/keymap.c#L58) 144 * [`bool process_record_user(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/keymaps/default/keymap.c#L58)
145 * [`bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/rgb_matrix.c#L139)
146 * [`bool process_midi(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_midi.c#L81) 145 * [`bool process_midi(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_midi.c#L81)
147 * [`bool process_audio(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_audio.c#L19) 146 * [`bool process_audio(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_audio.c#L19)
148 * [`bool process_steno(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_steno.c#L160) 147 * [`bool process_steno(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_steno.c#L160)
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 6d202c515..38234bb17 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -221,9 +221,6 @@ bool process_record_quantum(keyrecord_t *record) {
221#ifdef HAPTIC_ENABLE 221#ifdef HAPTIC_ENABLE
222 process_haptic(keycode, record) && 222 process_haptic(keycode, record) &&
223#endif // HAPTIC_ENABLE 223#endif // HAPTIC_ENABLE
224#if defined(RGB_MATRIX_ENABLE)
225 process_rgb_matrix(keycode, record) &&
226#endif
227#if defined(VIA_ENABLE) 224#if defined(VIA_ENABLE)
228 process_record_via(keycode, record) && 225 process_record_via(keycode, record) &&
229#endif 226#endif
@@ -624,9 +621,6 @@ void matrix_init_quantum() {
624#ifdef AUDIO_ENABLE 621#ifdef AUDIO_ENABLE
625 audio_init(); 622 audio_init();
626#endif 623#endif
627#ifdef RGB_MATRIX_ENABLE
628 rgb_matrix_init();
629#endif
630#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) 624#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
631 unicode_input_mode_init(); 625 unicode_input_mode_init();
632#endif 626#endif
@@ -681,10 +675,6 @@ void matrix_scan_quantum() {
681 led_matrix_task(); 675 led_matrix_task();
682#endif 676#endif
683 677
684#ifdef RGB_MATRIX_ENABLE
685 rgb_matrix_task();
686#endif
687
688#ifdef WPM_ENABLE 678#ifdef WPM_ENABLE
689 decay_wpm(); 679 decay_wpm();
690#endif 680#endif
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index a945df68e..ec17b4d72 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -184,11 +184,12 @@ void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
184 184
185void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); } 185void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); }
186 186
187bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { 187void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
188#ifndef RGB_MATRIX_SPLIT
189 if (!is_keyboard_master()) return;
190#endif
188#if RGB_DISABLE_TIMEOUT > 0 191#if RGB_DISABLE_TIMEOUT > 0
189 if (record->event.pressed) { 192 rgb_anykey_timer = 0;
190 rgb_anykey_timer = 0;
191 }
192#endif // RGB_DISABLE_TIMEOUT > 0 193#endif // RGB_DISABLE_TIMEOUT > 0
193 194
194#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 195#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -196,12 +197,12 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
196 uint8_t led_count = 0; 197 uint8_t led_count = 0;
197 198
198# if defined(RGB_MATRIX_KEYRELEASES) 199# if defined(RGB_MATRIX_KEYRELEASES)
199 if (!record->event.pressed) 200 if (!pressed)
200# elif defined(RGB_MATRIX_KEYPRESSES) 201# elif defined(RGB_MATRIX_KEYPRESSES)
201 if (record->event.pressed) 202 if (pressed)
202# endif // defined(RGB_MATRIX_KEYRELEASES) 203# endif // defined(RGB_MATRIX_KEYRELEASES)
203 { 204 {
204 led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led); 205 led_count = rgb_matrix_map_row_column_to_led(row, col, led);
205 } 206 }
206 207
207 if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { 208 if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
@@ -224,11 +225,9 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
224 225
225#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) 226#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
226 if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { 227 if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
227 process_rgb_matrix_typing_heatmap(record); 228 process_rgb_matrix_typing_heatmap(row, col);
228 } 229 }
229#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) 230#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
230
231 return true;
232} 231}
233 232
234void rgb_matrix_test(void) { 233void rgb_matrix_test(void) {
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index 8c80c1bff..bb8bcfab6 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -98,7 +98,7 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
98void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); 98void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
99void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue); 99void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
100 100
101bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record); 101void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed);
102 102
103void rgb_matrix_task(void); 103void rgb_matrix_task(void);
104 104
diff --git a/quantum/rgb_matrix_animations/typing_heatmap_anim.h b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
index e06437bf7..e7dda11a2 100644
--- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h
+++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
@@ -6,9 +6,7 @@ RGB_MATRIX_EFFECT(TYPING_HEATMAP)
6# define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 25 6# define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 25
7# endif 7# endif
8 8
9void process_rgb_matrix_typing_heatmap(keyrecord_t* record) { 9void process_rgb_matrix_typing_heatmap(uint8_t row, uint8_t col) {
10 uint8_t row = record->event.key.row;
11 uint8_t col = record->event.key.col;
12 uint8_t m_row = row - 1; 10 uint8_t m_row = row - 1;
13 uint8_t p_row = row + 1; 11 uint8_t p_row = row + 1;
14 uint8_t m_col = col - 1; 12 uint8_t m_col = col - 1;
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index bad762b49..d6636b886 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -257,7 +257,7 @@ bool matrix_post_scan(void) {
257 static uint8_t error_count; 257 static uint8_t error_count;
258 258
259 matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; 259 matrix_row_t slave_matrix[ROWS_PER_HAND] = {0};
260 if (!transport_master(slave_matrix)) { 260 if (!transport_master(matrix + thisHand, slave_matrix)) {
261 error_count++; 261 error_count++;
262 262
263 if (error_count > ERROR_DISCONNECT_COUNT) { 263 if (error_count > ERROR_DISCONNECT_COUNT) {
@@ -282,7 +282,7 @@ bool matrix_post_scan(void) {
282 282
283 matrix_scan_quantum(); 283 matrix_scan_quantum();
284 } else { 284 } else {
285 transport_slave(matrix + thisHand); 285 transport_slave(matrix + thatHand, matrix + thisHand);
286 286
287 matrix_slave_scan_user(); 287 matrix_slave_scan_user();
288 } 288 }
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index b45ba92c3..977b5dc33 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -31,6 +31,9 @@ typedef struct _I2C_slave_buffer_t {
31# ifndef DISABLE_SYNC_TIMER 31# ifndef DISABLE_SYNC_TIMER
32 uint32_t sync_timer; 32 uint32_t sync_timer;
33# endif 33# endif
34# ifdef SPLIT_TRANSPORT_MIRROR
35 matrix_row_t mmatrix[ROWS_PER_HAND];
36# endif
34 matrix_row_t smatrix[ROWS_PER_HAND]; 37 matrix_row_t smatrix[ROWS_PER_HAND];
35# ifdef SPLIT_MODS_ENABLE 38# ifdef SPLIT_MODS_ENABLE
36 uint8_t real_mods; 39 uint8_t real_mods;
@@ -56,7 +59,8 @@ typedef struct _I2C_slave_buffer_t {
56static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; 59static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
57 60
58# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer) 61# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer)
59# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) 62# define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix)
63# define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix)
60# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods) 64# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods)
61# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods) 65# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods)
62# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods) 66# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods)
@@ -72,8 +76,11 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
72# endif 76# endif
73 77
74// Get rows from other half over i2c 78// Get rows from other half over i2c
75bool transport_master(matrix_row_t matrix[]) { 79bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
76 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT); 80 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
81#ifdef SPLIT_TRANSPORT_MIRROR
82 i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT);
83#endif
77 84
78 // write backlight info 85 // write backlight info
79# ifdef BACKLIGHT_ENABLE 86# ifdef BACKLIGHT_ENABLE
@@ -141,12 +148,15 @@ bool transport_master(matrix_row_t matrix[]) {
141 return true; 148 return true;
142} 149}
143 150
144void transport_slave(matrix_row_t matrix[]) { 151void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
145# ifndef DISABLE_SYNC_TIMER 152# ifndef DISABLE_SYNC_TIMER
146 sync_timer_update(i2c_buffer->sync_timer); 153 sync_timer_update(i2c_buffer->sync_timer);
147# endif 154# endif
148 // Copy matrix to I2C buffer 155 // Copy matrix to I2C buffer
149 memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix)); 156 memcpy((void*)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix));
157#ifdef SPLIT_TRANSPORT_MIRROR
158 memcpy((void*)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix));
159#endif
150 160
151// Read Backlight Info 161// Read Backlight Info
152# ifdef BACKLIGHT_ENABLE 162# ifdef BACKLIGHT_ENABLE
@@ -207,6 +217,9 @@ typedef struct _Serial_m2s_buffer_t {
207# ifndef DISABLE_SYNC_TIMER 217# ifndef DISABLE_SYNC_TIMER
208 uint32_t sync_timer; 218 uint32_t sync_timer;
209# endif 219# endif
220# ifdef SPLIT_TRANSPORT_MIRROR
221 matrix_row_t mmatrix[ROWS_PER_HAND];
222# endif
210# ifdef BACKLIGHT_ENABLE 223# ifdef BACKLIGHT_ENABLE
211 uint8_t backlight_level; 224 uint8_t backlight_level;
212# endif 225# endif
@@ -289,7 +302,7 @@ void transport_rgblight_slave(void) {
289# define transport_rgblight_slave() 302# define transport_rgblight_slave()
290# endif 303# endif
291 304
292bool transport_master(matrix_row_t matrix[]) { 305bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
293# ifndef SERIAL_USE_MULTI_TRANSACTION 306# ifndef SERIAL_USE_MULTI_TRANSACTION
294 if (soft_serial_transaction() != TRANSACTION_END) { 307 if (soft_serial_transaction() != TRANSACTION_END) {
295 return false; 308 return false;
@@ -303,7 +316,10 @@ bool transport_master(matrix_row_t matrix[]) {
303 316
304 // TODO: if MATRIX_COLS > 8 change to unpack() 317 // TODO: if MATRIX_COLS > 8 change to unpack()
305 for (int i = 0; i < ROWS_PER_HAND; ++i) { 318 for (int i = 0; i < ROWS_PER_HAND; ++i) {
306 matrix[i] = serial_s2m_buffer.smatrix[i]; 319 slave_matrix[i] = serial_s2m_buffer.smatrix[i];
320#ifdef SPLIT_TRANSPORT_MIRROR
321 serial_m2s_buffer.mmatrix[i] = master_matrix[i];
322#endif
307 } 323 }
308 324
309# ifdef BACKLIGHT_ENABLE 325# ifdef BACKLIGHT_ENABLE
@@ -333,7 +349,7 @@ bool transport_master(matrix_row_t matrix[]) {
333 return true; 349 return true;
334} 350}
335 351
336void transport_slave(matrix_row_t matrix[]) { 352void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
337 transport_rgblight_slave(); 353 transport_rgblight_slave();
338# ifndef DISABLE_SYNC_TIMER 354# ifndef DISABLE_SYNC_TIMER
339 sync_timer_update(serial_m2s_buffer.sync_timer); 355 sync_timer_update(serial_m2s_buffer.sync_timer);
@@ -341,7 +357,10 @@ void transport_slave(matrix_row_t matrix[]) {
341 357
342 // TODO: if MATRIX_COLS > 8 change to pack() 358 // TODO: if MATRIX_COLS > 8 change to pack()
343 for (int i = 0; i < ROWS_PER_HAND; ++i) { 359 for (int i = 0; i < ROWS_PER_HAND; ++i) {
344 serial_s2m_buffer.smatrix[i] = matrix[i]; 360 serial_s2m_buffer.smatrix[i] = slave_matrix[i];
361#ifdef SPLIT_TRANSPORT_MIRROR
362 master_matrix[i] = serial_m2s_buffer.mmatrix[i];
363#endif
345 } 364 }
346# ifdef BACKLIGHT_ENABLE 365# ifdef BACKLIGHT_ENABLE
347 backlight_set(serial_m2s_buffer.backlight_level); 366 backlight_set(serial_m2s_buffer.backlight_level);
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index c667bfab8..a9f66301b 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -6,5 +6,5 @@ void transport_master_init(void);
6void transport_slave_init(void); 6void transport_slave_init(void);
7 7
8// returns false if valid data not received from slave 8// returns false if valid data not received from slave
9bool transport_master(matrix_row_t matrix[]); 9bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
10void transport_slave(matrix_row_t matrix[]); 10void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index c4f048391..d66c4199c 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <stdbool.h> 21#include <stdbool.h>
22 22
23#ifndef EECONFIG_MAGIC_NUMBER 23#ifndef EECONFIG_MAGIC_NUMBER
24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEC 24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEB // When changing, decrement this value to avoid future re-init issues
25#endif 25#endif
26#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF 26#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
27 27
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 299bda2c1..34fed0cab 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -54,6 +54,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
54#ifdef RGBLIGHT_ENABLE 54#ifdef RGBLIGHT_ENABLE
55# include "rgblight.h" 55# include "rgblight.h"
56#endif 56#endif
57#ifdef RGB_MATRIX_ENABLE
58# include "rgb_matrix.h"
59#endif
57#ifdef ENCODER_ENABLE 60#ifdef ENCODER_ENABLE
58# include "encoder.h" 61# include "encoder.h"
59#endif 62#endif
@@ -304,6 +307,9 @@ void keyboard_init(void) {
304#ifdef RGBLIGHT_ENABLE 307#ifdef RGBLIGHT_ENABLE
305 rgblight_init(); 308 rgblight_init();
306#endif 309#endif
310#ifdef RGB_MATRIX_ENABLE
311 rgb_matrix_init();
312#endif
307#ifdef ENCODER_ENABLE 313#ifdef ENCODER_ENABLE
308 encoder_init(); 314 encoder_init();
309#endif 315#endif
@@ -328,6 +334,17 @@ void keyboard_init(void) {
328 keyboard_post_init_kb(); /* Always keep this last */ 334 keyboard_post_init_kb(); /* Always keep this last */
329} 335}
330 336
337/** \brief key_event_task
338 *
339 * This function is responsible for calling into other systems when they need to respond to electrical switch press events.
340 * This is differnet than keycode events as no layer processing, or filtering occurs.
341 */
342void switch_events(uint8_t row, uint8_t col, bool pressed) {
343#if defined(RGB_MATRIX_ENABLE)
344 process_rgb_matrix(row, col, pressed);
345#endif
346}
347
331/** \brief Keyboard task: Do keyboard routine jobs 348/** \brief Keyboard task: Do keyboard routine jobs
332 * 349 *
333 * Do routine keyboard jobs: 350 * Do routine keyboard jobs:
@@ -358,32 +375,35 @@ void keyboard_task(void) {
358 uint8_t matrix_changed = matrix_scan(); 375 uint8_t matrix_changed = matrix_scan();
359 if (matrix_changed) last_matrix_activity_trigger(); 376 if (matrix_changed) last_matrix_activity_trigger();
360 377
361 if (should_process_keypress()) { 378 for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
362 for (uint8_t r = 0; r < MATRIX_ROWS; r++) { 379 matrix_row = matrix_get_row(r);
363 matrix_row = matrix_get_row(r); 380 matrix_change = matrix_row ^ matrix_prev[r];
364 matrix_change = matrix_row ^ matrix_prev[r]; 381 if (matrix_change) {
365 if (matrix_change) {
366#ifdef MATRIX_HAS_GHOST 382#ifdef MATRIX_HAS_GHOST
367 if (has_ghost_in_row(r, matrix_row)) { 383 if (has_ghost_in_row(r, matrix_row)) {
368 continue; 384 continue;
369 } 385 }
370#endif 386#endif
371 if (debug_matrix) matrix_print(); 387 if (debug_matrix) matrix_print();
372 matrix_row_t col_mask = 1; 388 matrix_row_t col_mask = 1;
373 for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { 389 for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) {
374 if (matrix_change & col_mask) { 390 if (matrix_change & col_mask) {
391 if (should_process_keypress()) {
375 action_exec((keyevent_t){ 392 action_exec((keyevent_t){
376 .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ 393 .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */
377 }); 394 });
378 // record a processed key 395 }
379 matrix_prev[r] ^= col_mask; 396 // record a processed key
397 matrix_prev[r] ^= col_mask;
398
399 switch_events(r, c, (matrix_row & col_mask));
400
380#ifdef QMK_KEYS_PER_SCAN 401#ifdef QMK_KEYS_PER_SCAN
381 // only jump out if we have processed "enough" keys. 402 // only jump out if we have processed "enough" keys.
382 if (++keys_processed >= QMK_KEYS_PER_SCAN) 403 if (++keys_processed >= QMK_KEYS_PER_SCAN)
383#endif 404#endif
384 // process a key per task call 405 // process a key per task call
385 goto MATRIX_LOOP_END; 406 goto MATRIX_LOOP_END;
386 }
387 } 407 }
388 } 408 }
389 } 409 }
@@ -405,6 +425,10 @@ MATRIX_LOOP_END:
405 rgblight_task(); 425 rgblight_task();
406#endif 426#endif
407 427
428#ifdef RGB_MATRIX_ENABLE
429 rgb_matrix_task();
430#endif
431
408#if defined(BACKLIGHT_ENABLE) 432#if defined(BACKLIGHT_ENABLE)
409# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS) 433# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
410 backlight_task(); 434 backlight_task();