aboutsummaryrefslogtreecommitdiff
path: root/users/drashna
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-08-07 21:40:48 -0700
committerGitHub <noreply@github.com>2021-08-07 21:40:48 -0700
commitb9dcd5ac38bc7cd3dc2fb97ac3842df03ee5f780 (patch)
tree8e7717785d6632f5f13ee769432133ee6726a0a1 /users/drashna
parent100333818f4868cee811854ccc44e4b9ea39a79d (diff)
downloadqmk_firmware-b9dcd5ac38bc7cd3dc2fb97ac3842df03ee5f780.tar.gz
qmk_firmware-b9dcd5ac38bc7cd3dc2fb97ac3842df03ee5f780.zip
[Keymap] Drashna split transport improvement (#13905)
* Fix up split stuff * Fix Split perf issues * Allow LTO to be disabled * Fixup WPM and encoders * Fixup qmk keys per scan * Add bootloader info * Change encoder pins * Fixup corne oled code * Expand transport sync * Improve user transport * Cleanup mouse processing at keymap level * Improve layer checking for mouse layering
Diffstat (limited to 'users/drashna')
-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
4 files changed, 142 insertions, 30 deletions
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