diff options
Diffstat (limited to 'users/drashna/drashna_transport.c')
| -rw-r--r-- | users/drashna/drashna_transport.c | 199 |
1 files changed, 147 insertions, 52 deletions
diff --git a/users/drashna/drashna_transport.c b/users/drashna/drashna_transport.c index f0908b490..9df11c9bd 100644 --- a/users/drashna/drashna_transport.c +++ b/users/drashna/drashna_transport.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include QMK_KEYBOARD_H | 21 | #include QMK_KEYBOARD_H |
| 22 | 22 | ||
| 23 | #define ROWS_PER_HAND (MATRIX_ROWS / 2) | 23 | #define ROWS_PER_HAND (MATRIX_ROWS / 2) |
| 24 | #define SYNC_TIMER_OFFSET 2 | ||
| 24 | 25 | ||
| 25 | #ifdef RGBLIGHT_ENABLE | 26 | #ifdef RGBLIGHT_ENABLE |
| 26 | # include "rgblight.h" | 27 | # include "rgblight.h" |
| @@ -37,19 +38,33 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A; | |||
| 37 | #endif | 38 | #endif |
| 38 | 39 | ||
| 39 | #ifdef POINTING_DEVICE_ENABLE | 40 | #ifdef POINTING_DEVICE_ENABLE |
| 40 | static int8_t split_mouse_x = 0, split_mouse_y = 0; | 41 | static uint16_t device_cpi = 0; |
| 42 | static int8_t split_mouse_x = 0, split_mouse_y = 0; | ||
| 41 | #endif | 43 | #endif |
| 42 | 44 | ||
| 43 | #ifdef OLED_DRIVER_ENABLE | 45 | #ifdef OLED_DRIVER_ENABLE |
| 44 | # include "oled_driver.h" | 46 | # include "oled_driver.h" |
| 45 | #endif | 47 | #endif |
| 46 | 48 | ||
| 49 | #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | ||
| 50 | # include "led_matrix.h" | ||
| 51 | #endif | ||
| 52 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 53 | # include "rgb_matrix.h" | ||
| 54 | #endif | ||
| 55 | |||
| 47 | #if defined(USE_I2C) | 56 | #if defined(USE_I2C) |
| 48 | 57 | ||
| 49 | # include "i2c_master.h" | 58 | # include "i2c_master.h" |
| 50 | # include "i2c_slave.h" | 59 | # include "i2c_slave.h" |
| 51 | 60 | ||
| 52 | typedef struct _I2C_slave_buffer_t { | 61 | typedef struct _I2C_slave_buffer_t { |
| 62 | # ifndef DISABLE_SYNC_TIMER | ||
| 63 | uint32_t sync_timer; | ||
| 64 | # endif | ||
| 65 | # ifdef SPLIT_TRANSPORT_MIRROR | ||
| 66 | matrix_row_t mmatrix[ROWS_PER_HAND]; | ||
| 67 | # endif | ||
| 53 | matrix_row_t smatrix[ROWS_PER_HAND]; | 68 | matrix_row_t smatrix[ROWS_PER_HAND]; |
| 54 | # ifdef SPLIT_MODS_ENABLE | 69 | # ifdef SPLIT_MODS_ENABLE |
| 55 | uint8_t real_mods; | 70 | uint8_t real_mods; |
| @@ -70,19 +85,29 @@ typedef struct _I2C_slave_buffer_t { | |||
| 70 | # ifdef WPM_ENABLE | 85 | # ifdef WPM_ENABLE |
| 71 | uint8_t current_wpm; | 86 | uint8_t current_wpm; |
| 72 | # endif | 87 | # endif |
| 88 | # if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) | ||
| 89 | led_eeconfig_t led_matrix; | ||
| 90 | bool led_suspend_state; | ||
| 91 | # endif | ||
| 92 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 93 | rgb_config_t rgb_matrix; | ||
| 94 | bool rgb_suspend_state; | ||
| 95 | # endif | ||
| 73 | int8_t mouse_x; | 96 | int8_t mouse_x; |
| 74 | int8_t mouse_y; | 97 | int8_t mouse_y; |
| 98 | uint16_t device_cpi; | ||
| 75 | bool oled_on; | 99 | bool oled_on; |
| 76 | layer_state_t t_layer_state; | 100 | layer_state_t t_layer_state; |
| 77 | layer_state_t t_default_layer_state; | 101 | layer_state_t t_default_layer_state; |
| 78 | bool is_rgb_matrix_suspended; | ||
| 79 | } __attribute__((packed)) I2C_slave_buffer_t; | 102 | } __attribute__((packed)) I2C_slave_buffer_t; |
| 80 | 103 | ||
| 81 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; | 104 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; |
| 82 | 105 | ||
| 83 | # define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level) | 106 | # define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level) |
| 84 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) | 107 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) |
| 85 | # define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) | 108 | # define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix) |
| 109 | # define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix) | ||
| 110 | # define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer) | ||
| 86 | # define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods) | 111 | # define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods) |
| 87 | # define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods) | 112 | # define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods) |
| 88 | # define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods) | 113 | # define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods) |
| @@ -90,10 +115,14 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re | |||
| 90 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) | 115 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) |
| 91 | # define I2C_MOUSE_X_START offsetof(I2C_slave_buffer_t, mouse_x) | 116 | # define I2C_MOUSE_X_START offsetof(I2C_slave_buffer_t, mouse_x) |
| 92 | # define I2C_MOUSE_Y_START offsetof(I2C_slave_buffer_t, mouse_y) | 117 | # define I2C_MOUSE_Y_START offsetof(I2C_slave_buffer_t, mouse_y) |
| 118 | # define I2C_MOUSE_DPI_START offsetof(I2C_slave_buffer_t, device_cpi) | ||
| 93 | # define I2C_OLED_ON_START offsetof(I2C_slave_buffer_t, oled_on) | 119 | # define I2C_OLED_ON_START offsetof(I2C_slave_buffer_t, oled_on) |
| 94 | # define I2C_LAYER_STATE_START offsetof(I2C_slave_buffer_t, t_layer_state) | 120 | # define I2C_LAYER_STATE_START offsetof(I2C_slave_buffer_t, t_layer_state) |
| 95 | # define I2C_DEFAULT_LAYER_STATE_START offsetof(I2C_slave_buffer_t, t_default_layer_state) | 121 | # define I2C_DEFAULT_LAYER_STATE_START offsetof(I2C_slave_buffer_t, t_default_layer_state) |
| 96 | # define I2C_RGB_MATRIX_SUSPEND_START offsetof(I2C_slave_buffer_t, is_rgb_matrix_suspended) | 122 | # define I2C_LED_MATRIX_START offsetof(I2C_slave_buffer_t, led_matrix) |
| 123 | # define I2C_LED_SUSPEND_START offsetof(I2C_slave_buffer_t, led_suspend_state) | ||
| 124 | # define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix) | ||
| 125 | # define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state) | ||
| 97 | 126 | ||
| 98 | # define TIMEOUT 100 | 127 | # define TIMEOUT 100 |
| 99 | 128 | ||
| @@ -102,9 +131,11 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re | |||
| 102 | # endif | 131 | # endif |
| 103 | 132 | ||
| 104 | // Get rows from other half over i2c | 133 | // Get rows from other half over i2c |
| 105 | bool transport_master(matrix_row_t matrix[]) { | 134 | bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 106 | i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT); | 135 | i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT); |
| 107 | 136 | # ifdef SPLIT_TRANSPORT_MIRROR | |
| 137 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT); | ||
| 138 | # endif | ||
| 108 | // write backlight info | 139 | // write backlight info |
| 109 | # ifdef BACKLIGHT_ENABLE | 140 | # ifdef BACKLIGHT_ENABLE |
| 110 | uint8_t level = is_backlight_enabled() ? get_backlight_level() : 0; | 141 | uint8_t level = is_backlight_enabled() ? get_backlight_level() : 0; |
| @@ -147,6 +178,12 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 147 | i2c_readReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_Y_START, (void *)&i2c_buffer->mouse_y, sizeof(i2c_buffer->mouse_y), TIMEOUT); | 178 | i2c_readReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_Y_START, (void *)&i2c_buffer->mouse_y, sizeof(i2c_buffer->mouse_y), TIMEOUT); |
| 148 | temp_report.y = i2c_buffer->mouse_y; | 179 | temp_report.y = i2c_buffer->mouse_y; |
| 149 | pointing_device_set_report(temp_report); | 180 | pointing_device_set_report(temp_report); |
| 181 | |||
| 182 | if (device_cpi != i2c_buffer->device_cpi) { | ||
| 183 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_DPI_START, (void *)&device_cpi, sizeof(device_cpi), TIMEOUT) >= 0) { | ||
| 184 | i2c_buffer->device_cpi = device_cpi | ||
| 185 | } | ||
| 186 | } | ||
| 150 | } | 187 | } |
| 151 | # endif | 188 | # endif |
| 152 | 189 | ||
| @@ -188,29 +225,42 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 188 | } | 225 | } |
| 189 | 226 | ||
| 190 | # ifdef OLED_DRIVER_ENABLE | 227 | # ifdef OLED_DRIVER_ENABLE |
| 191 | bool is_oled = is_oled_on(); | 228 | bool is_oled_on = is_oled_on(); |
| 192 | if (is_oled != i2c_buffer->oled_on) { | 229 | if (is_oled_on != i2c_buffer->oled_on) { |
| 193 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LAYER_STATE_START, (void *)&is_oled, sizeof(is_oled), TIMEOUT) >= 0) { | 230 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LAYER_STATE_START, (void *)&is_oled_on, sizeof(is_oled_on), TIMEOUT) >= 0) { |
| 194 | i2c_buffer->oled_on = is_oled; | 231 | i2c_buffer->oled_on = is_oled_on; |
| 195 | } | 232 | } |
| 196 | } | 233 | } |
| 197 | # endif | 234 | # endif |
| 198 | 235 | ||
| 199 | # ifdef RGB_MATRIX_ENABLE | 236 | # if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 200 | bool sus_state = rgb_matrix_get_suspend_state(); | 237 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_MATRIX_START, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix), TIMEOUT); |
| 201 | if (sus_state != i2c_buffer->is_rgb_matrix_suspended) { | 238 | bool suspend_state = led_matrix_get_suspend_state(); |
| 202 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_SUSPEND_START, (void *)&sus_state, sizeof(sus_state), TIMEOUT) >= 0) { | 239 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->led_suspend_state), TIMEOUT); |
| 203 | i2c_buffer->is_rgb_matrix_suspended = sus_state; | 240 | # endif |
| 204 | } | 241 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) |
| 205 | } | 242 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT); |
| 243 | bool suspend_state = rgb_matrix_get_suspend_state(); | ||
| 244 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT); | ||
| 245 | # endif | ||
| 246 | |||
| 247 | # ifndef DISABLE_SYNC_TIMER | ||
| 248 | i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | ||
| 249 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); | ||
| 206 | # endif | 250 | # endif |
| 207 | 251 | ||
| 208 | return true; | 252 | return true; |
| 209 | } | 253 | } |
| 210 | 254 | ||
| 211 | void transport_slave(matrix_row_t matrix[]) { | 255 | void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 256 | # ifndef DISABLE_SYNC_TIMER | ||
| 257 | sync_timer_update(i2c_buffer->sync_timer); | ||
| 258 | # endif | ||
| 212 | // Copy matrix to I2C buffer | 259 | // Copy matrix to I2C buffer |
| 213 | memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix)); | 260 | memcpy((void *)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix)); |
| 261 | # ifdef SPLIT_TRANSPORT_MIRROR | ||
| 262 | memcpy((void *)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix)); | ||
| 263 | # endif | ||
| 214 | 264 | ||
| 215 | // Read Backlight Info | 265 | // Read Backlight Info |
| 216 | # ifdef BACKLIGHT_ENABLE | 266 | # ifdef BACKLIGHT_ENABLE |
| @@ -235,6 +285,11 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 235 | 285 | ||
| 236 | # ifdef POINTING_DEVICE_ENABLE | 286 | # ifdef POINTING_DEVICE_ENABLE |
| 237 | if (!is_keyboard_left()) { | 287 | if (!is_keyboard_left()) { |
| 288 | static uint16_t cpi; | ||
| 289 | if (cpi != i2c_buffer->device_cpi) { | ||
| 290 | cpi = i2c_buffer->device_cpi; | ||
| 291 | pmw_set_cpi(cpi); | ||
| 292 | } | ||
| 238 | i2c_buffer->mouse_x = split_mouse_x; | 293 | i2c_buffer->mouse_x = split_mouse_x; |
| 239 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_X_START, (void *)&i2c_buffer->mouse_x, sizeof(i2c_buffer->mouse_x), TIMEOUT); | 294 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_X_START, (void *)&i2c_buffer->mouse_x, sizeof(i2c_buffer->mouse_x), TIMEOUT); |
| 240 | i2c_buffer->mouse_y = split_mouse_y; | 295 | i2c_buffer->mouse_y = split_mouse_y; |
| @@ -266,8 +321,13 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 266 | } | 321 | } |
| 267 | # endif | 322 | # endif |
| 268 | 323 | ||
| 269 | # ifdef RGB_MATRIX_ENABLE | 324 | # if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 270 | rgb_matrix_set_suspend_state(i2c_buffer->is_rgb_matrix_suspended); | 325 | memcpy((void *)i2c_buffer->led_matrix, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix)); |
| 326 | led_matrix_set_suspend_state(i2c_buffer->led_suspend_state); | ||
| 327 | # endif | ||
| 328 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 329 | memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix)); | ||
| 330 | rgb_matrix_set_suspend_state(i2c_buffer->rgb_suspend_state); | ||
| 271 | # endif | 331 | # endif |
| 272 | } | 332 | } |
| 273 | 333 | ||
| @@ -283,30 +343,44 @@ typedef struct _Serial_s2m_buffer_t { | |||
| 283 | // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack | 343 | // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack |
| 284 | matrix_row_t smatrix[ROWS_PER_HAND]; | 344 | matrix_row_t smatrix[ROWS_PER_HAND]; |
| 285 | # ifdef ENCODER_ENABLE | 345 | # ifdef ENCODER_ENABLE |
| 286 | uint8_t encoder_state[NUMBER_OF_ENCODERS]; | 346 | uint8_t encoder_state[NUMBER_OF_ENCODERS]; |
| 287 | # endif | 347 | # endif |
| 288 | int8_t mouse_x; | 348 | int8_t mouse_x; |
| 289 | int8_t mouse_y; | 349 | int8_t mouse_y; |
| 290 | } __attribute__((packed)) Serial_s2m_buffer_t; | 350 | } __attribute__((packed)) Serial_s2m_buffer_t; |
| 291 | 351 | ||
| 292 | typedef struct _Serial_m2s_buffer_t { | 352 | typedef struct _Serial_m2s_buffer_t { |
| 293 | # ifdef SPLIT_MODS_ENABLE | 353 | # ifdef SPLIT_MODS_ENABLE |
| 294 | uint8_t real_mods; | 354 | uint8_t real_mods; |
| 295 | uint8_t weak_mods; | 355 | uint8_t weak_mods; |
| 296 | # ifndef NO_ACTION_ONESHOT | 356 | # ifndef NO_ACTION_ONESHOT |
| 297 | uint8_t oneshot_mods; | 357 | uint8_t oneshot_mods; |
| 298 | # endif | 358 | # endif |
| 299 | # endif | 359 | # endif |
| 360 | # ifndef DISABLE_SYNC_TIMER | ||
| 361 | uint32_t sync_timer; | ||
| 362 | # endif | ||
| 363 | # ifdef SPLIT_TRANSPORT_MIRROR | ||
| 364 | matrix_row_t mmatrix[ROWS_PER_HAND]; | ||
| 365 | # endif | ||
| 300 | # ifdef BACKLIGHT_ENABLE | 366 | # ifdef BACKLIGHT_ENABLE |
| 301 | uint8_t backlight_level; | 367 | uint8_t backlight_level; |
| 302 | # endif | 368 | # endif |
| 303 | # ifdef WPM_ENABLE | 369 | # ifdef WPM_ENABLE |
| 304 | uint8_t current_wpm; | 370 | uint8_t current_wpm; |
| 305 | # endif | 371 | # endif |
| 372 | uint16_t device_cpi; | ||
| 306 | bool oled_on; | 373 | bool oled_on; |
| 307 | layer_state_t t_layer_state; | 374 | layer_state_t t_layer_state; |
| 308 | layer_state_t t_default_layer_state; | 375 | layer_state_t t_default_layer_state; |
| 309 | bool is_rgb_matrix_suspended; | 376 | # if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 377 | led_eeconfig_t led_matrix; | ||
| 378 | bool led_suspend_state; | ||
| 379 | # endif | ||
| 380 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 381 | rgb_config_t rgb_matrix; | ||
| 382 | bool rgb_suspend_state; | ||
| 383 | # endif | ||
| 310 | } __attribute__((packed)) Serial_m2s_buffer_t; | 384 | } __attribute__((packed)) Serial_m2s_buffer_t; |
| 311 | 385 | ||
| 312 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 386 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| @@ -383,7 +457,7 @@ void transport_rgblight_slave(void) { | |||
| 383 | # define transport_rgblight_slave() | 457 | # define transport_rgblight_slave() |
| 384 | # endif | 458 | # endif |
| 385 | 459 | ||
| 386 | bool transport_master(matrix_row_t matrix[]) { | 460 | bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 387 | # ifndef SERIAL_USE_MULTI_TRANSACTION | 461 | # ifndef SERIAL_USE_MULTI_TRANSACTION |
| 388 | if (soft_serial_transaction() != TRANSACTION_END) { | 462 | if (soft_serial_transaction() != TRANSACTION_END) { |
| 389 | return false; | 463 | return false; |
| @@ -397,7 +471,10 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 397 | 471 | ||
| 398 | // TODO: if MATRIX_COLS > 8 change to unpack() | 472 | // TODO: if MATRIX_COLS > 8 change to unpack() |
| 399 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 473 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
| 400 | matrix[i] = serial_s2m_buffer.smatrix[i]; | 474 | slave_matrix[i] = serial_s2m_buffer.smatrix[i]; |
| 475 | # ifdef SPLIT_TRANSPORT_MIRROR | ||
| 476 | serial_m2s_buffer.mmatrix[i] = master_matrix[i]; | ||
| 477 | # endif | ||
| 401 | } | 478 | } |
| 402 | 479 | ||
| 403 | # ifdef BACKLIGHT_ENABLE | 480 | # ifdef BACKLIGHT_ENABLE |
| @@ -411,12 +488,12 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 411 | 488 | ||
| 412 | # ifdef WPM_ENABLE | 489 | # ifdef WPM_ENABLE |
| 413 | // Write wpm to slave | 490 | // Write wpm to slave |
| 414 | serial_m2s_buffer.current_wpm = get_current_wpm(); | 491 | serial_m2s_buffer.current_wpm = get_current_wpm(); |
| 415 | # endif | 492 | # endif |
| 416 | 493 | ||
| 417 | # ifdef SPLIT_MODS_ENABLE | 494 | # ifdef SPLIT_MODS_ENABLE |
| 418 | serial_m2s_buffer.real_mods = get_mods(); | 495 | serial_m2s_buffer.real_mods = get_mods(); |
| 419 | serial_m2s_buffer.weak_mods = get_weak_mods(); | 496 | serial_m2s_buffer.weak_mods = get_weak_mods(); |
| 420 | # ifndef NO_ACTION_ONESHOT | 497 | # ifndef NO_ACTION_ONESHOT |
| 421 | serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); | 498 | serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); |
| 422 | # endif | 499 | # endif |
| @@ -428,28 +505,43 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 428 | temp_report.x = serial_s2m_buffer.mouse_x; | 505 | temp_report.x = serial_s2m_buffer.mouse_x; |
| 429 | temp_report.y = serial_s2m_buffer.mouse_y; | 506 | temp_report.y = serial_s2m_buffer.mouse_y; |
| 430 | pointing_device_set_report(temp_report); | 507 | pointing_device_set_report(temp_report); |
| 508 | serial_m2s_buffer.device_cpi = device_cpi; | ||
| 431 | } | 509 | } |
| 432 | # endif | 510 | # endif |
| 433 | 511 | ||
| 434 | serial_m2s_buffer.t_layer_state = layer_state; | 512 | serial_m2s_buffer.t_layer_state = layer_state; |
| 435 | serial_m2s_buffer.t_default_layer_state = default_layer_state; | 513 | serial_m2s_buffer.t_default_layer_state = default_layer_state; |
| 436 | # ifdef OLED_DRIVER_ENABLE | 514 | # ifdef OLED_DRIVER_ENABLE |
| 437 | serial_m2s_buffer.oled_on = is_oled_on(); | 515 | serial_m2s_buffer.oled_on = is_oled_on(); |
| 438 | # endif | 516 | # endif |
| 439 | 517 | ||
| 440 | # ifdef RGB_MATRIX_ENABLE | 518 | # if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 441 | serial_m2s_buffer.is_rgb_matrix_suspended = rgb_matrix_get_suspend_state(); | 519 | serial_m2s_buffer.led_matrix = led_matrix_eeconfig; |
| 520 | serial_m2s_buffer.led_suspend_state = led_matrix_get_suspend_state(); | ||
| 521 | # endif | ||
| 522 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 523 | serial_m2s_buffer.rgb_matrix = rgb_matrix_config; | ||
| 524 | serial_m2s_buffer.rgb_suspend_state = rgb_matrix_get_suspend_state(); | ||
| 442 | # endif | 525 | # endif |
| 443 | 526 | ||
| 527 | # ifndef DISABLE_SYNC_TIMER | ||
| 528 | serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | ||
| 529 | # endif | ||
| 444 | return true; | 530 | return true; |
| 445 | } | 531 | } |
| 446 | 532 | ||
| 447 | void transport_slave(matrix_row_t matrix[]) { | 533 | void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 448 | transport_rgblight_slave(); | 534 | transport_rgblight_slave(); |
| 535 | # ifndef DISABLE_SYNC_TIMER | ||
| 536 | sync_timer_update(serial_m2s_buffer.sync_timer); | ||
| 537 | # endif | ||
| 449 | 538 | ||
| 450 | // TODO: if MATRIX_COLS > 8 change to pack() | 539 | // TODO: if MATRIX_COLS > 8 change to pack() |
| 451 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 540 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
| 452 | serial_s2m_buffer.smatrix[i] = matrix[i]; | 541 | serial_s2m_buffer.smatrix[i] = slave_matrix[i]; |
| 542 | # ifdef SPLIT_TRANSPORT_MIRROR | ||
| 543 | master_matrix[i] = serial_m2s_buffer.mmatrix[i]; | ||
| 544 | # endif | ||
| 453 | } | 545 | } |
| 454 | 546 | ||
| 455 | # ifdef BACKLIGHT_ENABLE | 547 | # ifdef BACKLIGHT_ENABLE |
| @@ -474,6 +566,11 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 474 | 566 | ||
| 475 | # ifdef POINTING_DEVICE_ENABLE | 567 | # ifdef POINTING_DEVICE_ENABLE |
| 476 | if (!is_keyboard_left()) { | 568 | if (!is_keyboard_left()) { |
| 569 | static uint16_t cpi; | ||
| 570 | if (cpi != serial_m2s_buffer.device_cpi) { | ||
| 571 | cpi = serial_m2s_buffer.device_cpi; | ||
| 572 | pmw_set_cpi(cpi); | ||
| 573 | } | ||
| 477 | serial_s2m_buffer.mouse_x = split_mouse_x; | 574 | serial_s2m_buffer.mouse_x = split_mouse_x; |
| 478 | serial_s2m_buffer.mouse_y = split_mouse_y; | 575 | serial_s2m_buffer.mouse_y = split_mouse_y; |
| 479 | } | 576 | } |
| @@ -493,16 +590,14 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 493 | } | 590 | } |
| 494 | # endif | 591 | # endif |
| 495 | 592 | ||
| 496 | # ifdef RGB_MATRIX_ENABLE | 593 | # if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) |
| 497 | rgb_matrix_set_suspend_state(serial_m2s_buffer.is_rgb_matrix_suspended); | 594 | led_matrix_eeconfig = serial_m2s_buffer.led_matrix; |
| 595 | led_matrix_set_suspend_state(serial_m2s_buffer.led_suspend_state); | ||
| 596 | # endif | ||
| 597 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 598 | rgb_matrix_config = serial_m2s_buffer.rgb_matrix; | ||
| 599 | rgb_matrix_set_suspend_state(serial_m2s_buffer.rgb_suspend_state); | ||
| 498 | # endif | 600 | # endif |
| 499 | } | 601 | } |
| 500 | 602 | ||
| 501 | #endif | 603 | #endif |
| 502 | |||
| 503 | #ifdef POINTING_DEVICE_ENABLE | ||
| 504 | void master_mouse_send(int8_t x, int8_t y) { | ||
| 505 | split_mouse_x = x; | ||
| 506 | split_mouse_y = y; | ||
| 507 | } | ||
| 508 | #endif | ||
