aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/config.h2
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c73
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk2
-rw-r--r--keyboards/handwired/tractyl_manuform/tm_sync.c2
-rw-r--r--keyboards/handwired/tractyl_manuform/tractyl_manuform.c5
-rw-r--r--keyboards/splitkb/kyria/keymaps/drashna/config.h16
-rw-r--r--layouts/community/split_3x6_3/drashna/keymap.c2
-rw-r--r--layouts/community/split_3x6_3/drashna/rules.mk1
-rw-r--r--users/drashna/config.h16
-rw-r--r--users/drashna/oled_stuff.c15
-rw-r--r--users/drashna/rules.mk4
-rw-r--r--users/drashna/transport_sync.c137
12 files changed, 204 insertions, 71 deletions
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
index 915582c07..260fa038e 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
@@ -75,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
75#define ENCODERS_PAD_A \ 75#define ENCODERS_PAD_A \
76 { D5 } 76 { D5 }
77#define ENCODERS_PAD_B \ 77#define ENCODERS_PAD_B \
78 { D6 } 78 { D4 }
79#define ENCODER_RESOLUTION 4 79#define ENCODER_RESOLUTION 4
80 80
81/* Set 0 if debouncing isn't needed */ 81/* Set 0 if debouncing isn't needed */
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
index a57da64d5..61f302f16 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
@@ -140,9 +140,9 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
140#else 140#else
141bool encoder_update_user(uint8_t index, bool clockwise) { 141bool encoder_update_user(uint8_t index, bool clockwise) {
142 if (index == 0) { 142 if (index == 0) {
143 tap_code_delay(clockwise ? KC_VOLU : KC_VOLD, 5); 143 tap_code_delay(clockwise ? KC_VOLD : KC_VOLU, 5);
144 } else if (index == 1) { 144 } else if (index == 1) {
145 tap_code_delay(clockwise ? KC_WH_U : KC_WH_D, 5); 145 tap_code_delay(clockwise ? KC_WH_D : KC_WH_U, 5);
146 } 146 }
147 return false; 147 return false;
148} 148}
@@ -155,26 +155,29 @@ static uint16_t mouse_debounce_timer = 0;
155static uint8_t mouse_keycode_tracker = 0; 155static uint8_t mouse_keycode_tracker = 0;
156bool tap_toggling = false; 156bool tap_toggling = false;
157 157
158void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
159 if ((x || y) && timer_elapsed(mouse_timer) > 125) {
160 mouse_timer = timer_read();
161 if (!layer_state_is(_MOUSE) && !(layer_state_is(_GAMEPAD) || layer_state_is(_DIABLO)) && timer_elapsed(mouse_debounce_timer) > 125) {
162 layer_on(_MOUSE);
163 }
164 }
165
166# ifdef TAPPING_TERM_PER_KEY 158# ifdef TAPPING_TERM_PER_KEY
167 if (timer_elapsed(mouse_debounce_timer) > get_tapping_term(KC_BTN1, NULL) 159# define TAP_CHECK get_tapping_term(KC_BTN1, NULL)
168# else 160# else
169 if (timer_elapsed(mouse_debounce_timer) > TAPPING_TERM 161# ifndef TAPPING_TERM
162# define TAPPING_TERM 200
163# endif
164# define TAP_CHECK TAPPING_TERM
170# endif 165# endif
171 || (layer_state_is(_GAMEPAD) || layer_state_is(_DIABLO))) { 166
172 mouse_report->x = x; 167void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
173 mouse_report->y = y; 168 if (x != 0 && y != 0) {
174 } 169 mouse_timer = timer_read();
175# ifdef OLED_DRIVER_ENABLE 170# ifdef OLED_DRIVER_ENABLE
176 if (x || y) oled_timer = timer_read32(); 171 oled_timer = timer_read32();
177# endif 172# endif
173 if (timer_elapsed(mouse_debounce_timer) > TAP_CHECK) {
174 mouse_report->x = x;
175 mouse_report->y = y;
176 if (!layer_state_is(_MOUSE)) {
177 layer_on(_MOUSE);
178 }
179 }
180 }
178} 181}
179 182
180void matrix_scan_keymap(void) { 183void matrix_scan_keymap(void) {
@@ -191,26 +194,29 @@ void matrix_scan_keymap(void) {
191bool process_record_keymap(uint16_t keycode, keyrecord_t* record) { 194bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
192 switch (keycode) { 195 switch (keycode) {
193 case TT(_MOUSE): 196 case TT(_MOUSE):
194 { 197 if (record->event.pressed) {
195 if (record->event.pressed) { 198 mouse_keycode_tracker++;
196 mouse_keycode_tracker++; 199 } else {
197 } else {
198# if TAPPING_TOGGLE != 0 200# if TAPPING_TOGGLE != 0
199 if (record->tap.count == TAPPING_TOGGLE) { 201 if (record->tap.count == TAPPING_TOGGLE) {
200 tap_toggling ^= 1; 202 tap_toggling ^= 1;
201# if TAPPING_TOGGLE == 1 203# if TAPPING_TOGGLE == 1
202 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count + 1; 204 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count + 1;
203# else 205# else
204 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count; 206 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count;
205# endif 207# endif
206 } else { 208 } else {
207 mouse_keycode_tracker--; 209 mouse_keycode_tracker--;
208 }
209# endif
210 } 210 }
211 mouse_timer = timer_read(); 211# endif
212 break;
213 } 212 }
213 mouse_timer = timer_read();
214 break;
215 case TG(_MOUSE):
216 if (record->event.pressed) {
217 tap_toggling ^= 1;
218 }
219 break;
214 case MO(_MOUSE): 220 case MO(_MOUSE):
215 case DPI_CONFIG: 221 case DPI_CONFIG:
216 case KC_MS_UP ... KC_MS_WH_RIGHT: 222 case KC_MS_UP ... KC_MS_WH_RIGHT:
@@ -219,6 +225,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
219 break; 225 break;
220 default: 226 default:
221 if (IS_NOEVENT(record->event)) break; 227 if (IS_NOEVENT(record->event)) break;
228 if ((keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) && (((keycode >> 0x8) & 0xF) == _MOUSE)) {
229 record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
230 mouse_timer = timer_read();
231 break;
232 }
222 if (layer_state_is(_MOUSE) && !mouse_keycode_tracker) { 233 if (layer_state_is(_MOUSE) && !mouse_keycode_tracker) {
223 layer_off(_MOUSE); 234 layer_off(_MOUSE);
224 } 235 }
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk
index b95b166d8..585a2e9d8 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk
@@ -10,3 +10,5 @@ WPM_ENABLE = yes
10ENCODER_ENABLE = yes 10ENCODER_ENABLE = yes
11ENCODER_MAP_ENABLE = yes 11ENCODER_MAP_ENABLE = yes
12# DEBOUNCE_TYPE = sym_eager_pk 12# DEBOUNCE_TYPE = sym_eager_pk
13
14LTO_SUPPORTED = no
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c
index f0a611206..0088fcc4f 100644
--- a/keyboards/handwired/tractyl_manuform/tm_sync.c
+++ b/keyboards/handwired/tractyl_manuform/tm_sync.c
@@ -61,7 +61,7 @@ void keyboard_post_init_kb(void) {
61 61
62void kb_state_update(void) { 62void kb_state_update(void) {
63# ifdef POINTING_DEVICE_ENABLE 63# ifdef POINTING_DEVICE_ENABLE
64 if (is_keyboard_master() && !is_keyboard_left()) { 64 if (is_keyboard_master()) {
65 static uint16_t cpi = 0; 65 static uint16_t cpi = 0;
66 if (cpi != kb_state.device_cpi) { 66 if (cpi != kb_state.device_cpi) {
67 cpi = kb_state.device_cpi; 67 cpi = kb_state.device_cpi;
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
index 49a833682..e992c446c 100644
--- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
+++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
@@ -207,12 +207,11 @@ void master_mouse_send(int8_t x, int8_t y) {
207#endif 207#endif
208} 208}
209void trackball_set_cpi(uint16_t cpi) { 209void trackball_set_cpi(uint16_t cpi) {
210 if (!is_keyboard_left()) {
211 pmw_set_cpi(cpi);
212 } else {
213#ifdef SPLIT_TRANSACTION_IDS_KB 210#ifdef SPLIT_TRANSACTION_IDS_KB
214 kb_state.device_cpi = cpi; 211 kb_state.device_cpi = cpi;
215#endif 212#endif
213 if (!is_keyboard_left()) {
214 pmw_set_cpi(cpi);
216 } 215 }
217} 216}
218#endif 217#endif
diff --git a/keyboards/splitkb/kyria/keymaps/drashna/config.h b/keyboards/splitkb/kyria/keymaps/drashna/config.h
index af6f73815..8fec73950 100644
--- a/keyboards/splitkb/kyria/keymaps/drashna/config.h
+++ b/keyboards/splitkb/kyria/keymaps/drashna/config.h
@@ -25,11 +25,19 @@
25#ifdef RGBLIGHT_ENABLE 25#ifdef RGBLIGHT_ENABLE
26# define RGBLIGHT_SLEEP 26# define RGBLIGHT_SLEEP
27# define RGBLIGHT_LIMIT_VAL 200 27# define RGBLIGHT_LIMIT_VAL 200
28# define RGBLIGHT_HUE_STEP 8 28# define RGBLIGHT_HUE_STEP 8
29# define RGBLIGHT_SAT_STEP 8 29# define RGBLIGHT_SAT_STEP 8
30# define RGBLIGHT_VAL_STEP 8 30# define RGBLIGHT_VAL_STEP 8
31# define RGBLIGHT_SPLIT 31# define RGBLIGHT_SPLIT
32// # define RGBLIGHT_LAYERS 32// # define RGBLIGHT_LAYERS
33#endif 33#endif
34 34
35#define KEYLOGGER_LENGTH 10 35#define KEYLOGGER_LENGTH 10
36
37#define QMK_ESC_INPUT D4
38#define QMK_ESC_OUTPUT B2
39
40#define BOOTMAGIC_LITE_ROW 0
41#define BOOTMAGIC_LITE_COLUMN 7
42#define BOOTMAGIC_LITE_ROW_RIGHT 4
43#define BOOTMAGIC_LITE_COLUMN_RIGHT 7
diff --git a/layouts/community/split_3x6_3/drashna/keymap.c b/layouts/community/split_3x6_3/drashna/keymap.c
index 0840fc262..6e71527a4 100644
--- a/layouts/community/split_3x6_3/drashna/keymap.c
+++ b/layouts/community/split_3x6_3/drashna/keymap.c
@@ -37,7 +37,7 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
37 KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \ 37 KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
38 ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(K1B), \ 38 ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(K1B), \
39 OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \ 39 OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
40 RGB_MOD, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \ 40 OS_LGUI, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \
41 ) 41 )
42#define LAYOUT_base_wrapper(...) LAYOUT_split_3x6_3_base(__VA_ARGS__) 42#define LAYOUT_base_wrapper(...) LAYOUT_split_3x6_3_base(__VA_ARGS__)
43 43
diff --git a/layouts/community/split_3x6_3/drashna/rules.mk b/layouts/community/split_3x6_3/drashna/rules.mk
index 5abdda9a1..e0ac86d69 100644
--- a/layouts/community/split_3x6_3/drashna/rules.mk
+++ b/layouts/community/split_3x6_3/drashna/rules.mk
@@ -31,4 +31,5 @@ ifeq ($(strip $(CTPC)), yes)
31 WS2812_DRIVER = pwm # won't work without a patch to the ctpc mk file 31 WS2812_DRIVER = pwm # won't work without a patch to the ctpc mk file
32 SERIAL_DRIVER = usart 32 SERIAL_DRIVER = usart
33 SWAP_HANDS_ENABLE = yes 33 SWAP_HANDS_ENABLE = yes
34 WPM_ENABLE = yes
34endif 35endif
diff --git a/users/drashna/config.h b/users/drashna/config.h
index fbba210e7..ab0080234 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -23,13 +23,15 @@
23#define USB_POLLING_INTERVAL_MS 1 23#define USB_POLLING_INTERVAL_MS 1
24 24
25#if defined(SPLIT_KEYBOARD) 25#if defined(SPLIT_KEYBOARD)
26# define SPLIT_MODS_ENABLE 26// # define SPLIT_TRANSPORT_MIRROR
27# define SPLIT_LAYER_STATE_ENABLE 27# define SPLIT_LAYER_STATE_ENABLE
28# define SPLIT_LED_STATE_ENABLE 28# define SPLIT_LED_STATE_ENABLE
29 29# define SPLIT_MODS_ENABLE
30// # define SPLIT_TRANSPORT_MIRROR 30# ifdef WPM_ENABLE
31# define SERIAL_USE_MULTI_TRANSACTION 31# define SPLIT_WPM_ENABLE
32# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC 32# endif
33# define SELECT_SOFT_SERIAL_SPEED 1
34# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC
33#endif 35#endif
34 36
35#ifdef AUDIO_ENABLE 37#ifdef AUDIO_ENABLE
@@ -165,8 +167,8 @@
165 167
166#ifdef QMK_KEYS_PER_SCAN 168#ifdef QMK_KEYS_PER_SCAN
167# undef QMK_KEYS_PER_SCAN 169# undef QMK_KEYS_PER_SCAN
168# define QMK_KEYS_PER_SCAN 2 170#endif
169#endif // !QMK_KEYS_PER_SCAN 171#define QMK_KEYS_PER_SCAN 4
170 172
171// this makes it possible to do rolling combos (zx) with keys that 173// this makes it possible to do rolling combos (zx) with keys that
172// convert to other keys on hold (z becomes ctrl when you hold it, 174// convert to other keys on hold (z becomes ctrl when you hold it,
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c
index b2f49a2e7..103b1fc7a 100644
--- a/users/drashna/oled_stuff.c
+++ b/users/drashna/oled_stuff.c
@@ -141,10 +141,8 @@ void render_keylock_status(uint8_t led_usb_state) {
141 oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK)); 141 oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
142 oled_write_P(PSTR(" "), false); 142 oled_write_P(PSTR(" "), false);
143 oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK)); 143 oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
144#ifndef OLED_DISPLAY_128X64
145 oled_advance_page(true);
146#endif
147} 144}
145
148void render_matrix_scan_rate(void) { 146void render_matrix_scan_rate(void) {
149#ifdef DEBUG_MATRIX_SCAN_RATE 147#ifdef DEBUG_MATRIX_SCAN_RATE
150 char matrix_rate[5]; 148 char matrix_rate[5];
@@ -315,12 +313,11 @@ void render_wpm(void) {
315} 313}
316 314
317#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) 315#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
318extern keyboard_config_t keyboard_config;
319extern uint16_t dpi_array[];
320 316
317extern kb_runtime_config_t kb_state;
321void render_pointing_dpi_status(void) { 318void render_pointing_dpi_status(void) {
322 char dpi_status[6]; 319 char dpi_status[6];
323 uint16_t n = dpi_array[keyboard_config.dpi_config]; 320 uint16_t n = kb_state.device_cpi;
324 dpi_status[5] = '\0'; 321 dpi_status[5] = '\0';
325 dpi_status[4] = '0' + n % 10; 322 dpi_status[4] = '0' + n % 10;
326 dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 323 dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
@@ -340,7 +337,9 @@ void render_status_secondary(void) {
340 render_default_layer_state(); 337 render_default_layer_state();
341 render_layer_state(); 338 render_layer_state();
342 render_mod_status(get_mods() | get_oneshot_mods()); 339 render_mod_status(get_mods() | get_oneshot_mods());
343 340#if !defined(OLED_DISPLAY_128X64) && defined(WPM_ENABLE)
341 render_wpm();
342#endif
344 // render_keylock_status(host_keyboard_leds()); 343 // render_keylock_status(host_keyboard_leds());
345} 344}
346 345
@@ -349,7 +348,7 @@ void render_status_main(void) {
349 oled_driver_render_logo(); 348 oled_driver_render_logo();
350# ifdef DEBUG_MATRIX_SCAN_RATE 349# ifdef DEBUG_MATRIX_SCAN_RATE
351 render_matrix_scan_rate(); 350 render_matrix_scan_rate();
352# else 351# elif defined(WPM_ENABLE)
353 render_wpm(); 352 render_wpm();
354# endif 353# endif
355# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) 354# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index 1ccc51ecf..b93ab1ee6 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -2,7 +2,9 @@ SRC += drashna.c \
2 process_records.c 2 process_records.c
3 3
4ifneq ($(PLATFORM),CHIBIOS) 4ifneq ($(PLATFORM),CHIBIOS)
5 LTO_ENABLE = yes 5 ifneq ($(strip $(LTO_SUPPORTED)), no)
6 LTO_ENABLE = yes
7 endif
6endif 8endif
7SPACE_CADET_ENABLE = no 9SPACE_CADET_ENABLE = no
8GRAVE_ESC_ENABLE = no 10GRAVE_ESC_ENABLE = no
diff --git a/users/drashna/transport_sync.c b/users/drashna/transport_sync.c
index 8a3e6d1bf..c3ef2eff5 100644
--- a/users/drashna/transport_sync.c
+++ b/users/drashna/transport_sync.c
@@ -3,31 +3,77 @@
3# include "transactions.h" 3# include "transactions.h"
4# include <string.h> 4# include <string.h>
5 5
6# ifdef UNICODE_ENABLE
7extern unicode_config_t unicode_config;
8# endif
9# ifdef AUDIO_ENABLE
10# include "audio.h"
11# endif
12# if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
13extern bool tap_toggling;
14# endif
15# ifdef SWAP_HANDS_ENABLE
16extern bool swap_hands;
17# endif
18extern userspace_config_t userspace_config;
19
6typedef struct { 20typedef struct {
7 bool oled_on; 21 bool oled_on;
8 uint16_t keymap_config; 22 bool audio_enable;
23 bool audio_clicky_enable;
24 bool tap_toggling;
25 bool unicode_mode;
26 bool swap_hands;
27 uint8_t reserved :2;
9} user_runtime_config_t; 28} user_runtime_config_t;
10 29
30uint16_t transport_keymap_config = 0;
31uint32_t transport_userspace_config = 0;
32
11user_runtime_config_t user_state; 33user_runtime_config_t user_state;
12 34
13void user_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { 35void user_state_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
14 if (initiator2target_buffer_size == sizeof(user_state)) { 36 if (initiator2target_buffer_size == sizeof(user_state)) {
15 memcpy(&user_state, initiator2target_buffer, initiator2target_buffer_size); 37 memcpy(&user_state, initiator2target_buffer, initiator2target_buffer_size);
16 } 38 }
17} 39}
40void user_keymap_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
41 if (initiator2target_buffer_size == sizeof(transport_keymap_config)) {
42 memcpy(&transport_keymap_config, initiator2target_buffer, initiator2target_buffer_size);
43 }
44}
45void user_config_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
46 if (initiator2target_buffer_size == sizeof(transport_userspace_config)) {
47 memcpy(&transport_userspace_config, initiator2target_buffer, initiator2target_buffer_size);
48 }
49}
18 50
19void keyboard_post_init_transport_sync(void) { 51void keyboard_post_init_transport_sync(void) {
20 // Register keyboard state sync split transaction 52 // Register keyboard state sync split transaction
21 transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_sync); 53 transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync);
54 transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync);
55 transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync);
22} 56}
23 57
24void user_state_update(void) { 58void user_transport_update(void) {
25 if (is_keyboard_master()) { 59 if (is_keyboard_master()) {
26# ifdef OLED_DRIVER_ENABLE 60# ifdef OLED_DRIVER_ENABLE
27 user_state.oled_on = is_oled_on(); 61 user_state.oled_on = is_oled_on();
28# endif 62# endif
29 63
30 user_state.keymap_config = keymap_config.raw; 64 transport_keymap_config = keymap_config.raw;
65 transport_userspace_config = userspace_config.raw;
66# ifdef AUDIO_ENABLE
67 user_state.audio_enable = is_audio_on();
68 user_state.audio_clicky_enable = is_clicky_on();
69# endif
70# if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
71 user_state.tap_toggling = tap_toggling;
72# endif
73# ifdef SWAP_HANDS_ENABLE
74 user_state.swap_hands = swap_hands;
75# endif
76
31 } else { 77 } else {
32# ifdef OLED_DRIVER_ENABLE 78# ifdef OLED_DRIVER_ENABLE
33 if (user_state.oled_on) { 79 if (user_state.oled_on) {
@@ -36,17 +82,43 @@ void user_state_update(void) {
36 oled_off(); 82 oled_off();
37 } 83 }
38# endif 84# endif
39 if (keymap_config.raw != user_state.keymap_config) { 85 keymap_config.raw = transport_keymap_config;
40 keymap_config.raw = user_state.keymap_config; 86 userspace_config.raw = transport_userspace_config;
87# ifdef UNICODE_ENABLE
88 unicode_config.input_mode = user_state.unicode_mode;
89# endif
90# ifdef AUDIO_ENABLE
91 if (user_state.audio_enable != is_audio_on()) {
92 if (user_state.audio_enable) {
93 audio_on();
94 } else {
95 audio_off();
96 }
97 }
98 if (user_state.audio_clicky_enable != is_clicky_on()) {
99 if (user_state.audio_clicky_enable) {
100 clicky_on();
101 } else {
102 clicky_off();
103 }
41 } 104 }
105# endif
106# if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
107 tap_toggling = user_state.tap_toggling;
108# endif
109# ifdef SWAP_HANDS_ENABLE
110 swap_hands = user_state.swap_hands;
111# endif
42 } 112 }
43} 113}
44 114
45void user_state_sync(void) { 115void user_transport_sync(void) {
46 if (is_keyboard_master()) { 116 if (is_keyboard_master()) {
47 // Keep track of the last state, so that we can tell if we need to propagate to slave 117 // Keep track of the last state, so that we can tell if we need to propagate to slave
48 static user_runtime_config_t last_user_state; 118 static user_runtime_config_t last_user_state;
49 static uint32_t last_sync; 119 static uint16_t last_keymap = 0;
120 static uint32_t last_config = 0;
121 static uint32_t last_sync[3];
50 bool needs_sync = false; 122 bool needs_sync = false;
51 123
52 // Check if the state values are different 124 // Check if the state values are different
@@ -54,16 +126,53 @@ void user_state_sync(void) {
54 needs_sync = true; 126 needs_sync = true;
55 memcpy(&last_user_state, &user_state, sizeof(user_state)); 127 memcpy(&last_user_state, &user_state, sizeof(user_state));
56 } 128 }
57
58 // Send to slave every 500ms regardless of state change 129 // Send to slave every 500ms regardless of state change
59 if (timer_elapsed32(last_sync) > 250) { 130 if (timer_elapsed32(last_sync[0]) > 250) {
60 needs_sync = true; 131 needs_sync = true;
61 } 132 }
62 133
63 // Perform the sync if requested 134 // Perform the sync if requested
64 if (needs_sync) { 135 if (needs_sync) {
65 if (transaction_rpc_send(RPC_ID_USER_STATE_SYNC, sizeof(user_state), &user_state)) { 136 if (transaction_rpc_send(RPC_ID_USER_STATE_SYNC, sizeof(user_state), &user_state)) {
66 last_sync = timer_read32(); 137 last_sync[0] = timer_read32();
138 }
139 needs_sync = false;
140 }
141
142 // Check if the state values are different
143 if (memcmp(&transport_keymap_config, &last_keymap, sizeof(transport_keymap_config))) {
144 needs_sync = true;
145 memcpy(&last_keymap, &transport_keymap_config, sizeof(transport_keymap_config));
146 }
147
148 // Send to slave every 500ms regardless of state change
149 if (timer_elapsed32(last_sync[1]) > 250) {
150 needs_sync = true;
151 }
152
153 // Perform the sync if requested
154 if (needs_sync) {
155 if (transaction_rpc_send(RPC_ID_USER_KEYMAP_SYNC, sizeof(transport_keymap_config), &transport_keymap_config)) {
156 last_sync[1] = timer_read32();
157 }
158 needs_sync = false;
159 }
160
161 // Check if the state values are different
162 if (memcmp(&user_state, &last_config, sizeof(transport_userspace_config))) {
163 needs_sync = true;
164 memcpy(&last_config, &user_state, sizeof(transport_userspace_config));
165 }
166
167 // Send to slave every 500ms regardless of state change
168 if (timer_elapsed32(last_sync[2]) > 250) {
169 needs_sync = true;
170 }
171
172 // Perform the sync if requested
173 if (needs_sync) {
174 if (transaction_rpc_send(RPC_ID_USER_CONFIG_SYNC, sizeof(transport_userspace_config), &transport_userspace_config)) {
175 last_sync[2] = timer_read32();
67 } 176 }
68 } 177 }
69 } 178 }
@@ -71,9 +180,9 @@ void user_state_sync(void) {
71 180
72void housekeeping_task_user(void) { 181void housekeeping_task_user(void) {
73 // Update kb_state so we can send to slave 182 // Update kb_state so we can send to slave
74 user_state_update(); 183 user_transport_update();
75 184
76 // Data sync from master to slave 185 // Data sync from master to slave
77 user_state_sync(); 186 user_transport_sync();
78} 187}
79#endif 188#endif