Skip to content

Commit 9ad2b9d

Browse files
drashnanhongooi
authored andcommitted
[Keymap] Drashna split transport improvement (qmk#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
1 parent 853e038 commit 9ad2b9d

File tree

12 files changed

+204
-71
lines changed

12 files changed

+204
-71
lines changed

keyboards/handwired/tractyl_manuform/5x6_right/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
7575
#define ENCODERS_PAD_A \
7676
{ D5 }
7777
#define ENCODERS_PAD_B \
78-
{ D6 }
78+
{ D4 }
7979
#define ENCODER_RESOLUTION 4
8080

8181
/* Set 0 if debouncing isn't needed */

keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
140140
#else
141141
bool encoder_update_user(uint8_t index, bool clockwise) {
142142
if (index == 0) {
143-
tap_code_delay(clockwise ? KC_VOLU : KC_VOLD, 5);
143+
tap_code_delay(clockwise ? KC_VOLD : KC_VOLU, 5);
144144
} 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);
146146
}
147147
return false;
148148
}
@@ -155,26 +155,29 @@ static uint16_t mouse_debounce_timer = 0;
155155
static uint8_t mouse_keycode_tracker = 0;
156156
bool tap_toggling = false;
157157

158-
void 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-
166158
# 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)
168160
# 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
170165
# endif
171-
|| (layer_state_is(_GAMEPAD) || layer_state_is(_DIABLO))) {
172-
mouse_report->x = x;
173-
mouse_report->y = y;
174-
}
166+
167+
void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
168+
if (x != 0 && y != 0) {
169+
mouse_timer = timer_read();
175170
# ifdef OLED_DRIVER_ENABLE
176-
if (x || y) oled_timer = timer_read32();
171+
oled_timer = timer_read32();
177172
# 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+
}
178181
}
179182

180183
void matrix_scan_keymap(void) {
@@ -191,26 +194,29 @@ void matrix_scan_keymap(void) {
191194
bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
192195
switch (keycode) {
193196
case TT(_MOUSE):
194-
{
195-
if (record->event.pressed) {
196-
mouse_keycode_tracker++;
197-
} else {
197+
if (record->event.pressed) {
198+
mouse_keycode_tracker++;
199+
} else {
198200
# if TAPPING_TOGGLE != 0
199-
if (record->tap.count == TAPPING_TOGGLE) {
200-
tap_toggling ^= 1;
201+
if (record->tap.count == TAPPING_TOGGLE) {
202+
tap_toggling ^= 1;
201203
# 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;
203205
# else
204-
if (!tap_toggling) mouse_keycode_tracker -= record->tap.count;
206+
if (!tap_toggling) mouse_keycode_tracker -= record->tap.count;
205207
# endif
206-
} else {
207-
mouse_keycode_tracker--;
208-
}
209-
# endif
208+
} else {
209+
mouse_keycode_tracker--;
210210
}
211-
mouse_timer = timer_read();
212-
break;
211+
# endif
213212
}
213+
mouse_timer = timer_read();
214+
break;
215+
case TG(_MOUSE):
216+
if (record->event.pressed) {
217+
tap_toggling ^= 1;
218+
}
219+
break;
214220
case MO(_MOUSE):
215221
case DPI_CONFIG:
216222
case KC_MS_UP ... KC_MS_WH_RIGHT:
@@ -219,6 +225,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
219225
break;
220226
default:
221227
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+
}
222233
if (layer_state_is(_MOUSE) && !mouse_keycode_tracker) {
223234
layer_off(_MOUSE);
224235
}

keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ WPM_ENABLE = yes
1010
ENCODER_ENABLE = yes
1111
ENCODER_MAP_ENABLE = yes
1212
# DEBOUNCE_TYPE = sym_eager_pk
13+
14+
LTO_SUPPORTED = no

keyboards/handwired/tractyl_manuform/tm_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void keyboard_post_init_kb(void) {
6161

6262
void kb_state_update(void) {
6363
# ifdef POINTING_DEVICE_ENABLE
64-
if (is_keyboard_master() && !is_keyboard_left()) {
64+
if (is_keyboard_master()) {
6565
static uint16_t cpi = 0;
6666
if (cpi != kb_state.device_cpi) {
6767
cpi = kb_state.device_cpi;

keyboards/handwired/tractyl_manuform/tractyl_manuform.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,11 @@ void master_mouse_send(int8_t x, int8_t y) {
207207
#endif
208208
}
209209
void trackball_set_cpi(uint16_t cpi) {
210-
if (!is_keyboard_left()) {
211-
pmw_set_cpi(cpi);
212-
} else {
213210
#ifdef SPLIT_TRANSACTION_IDS_KB
214211
kb_state.device_cpi = cpi;
215212
#endif
213+
if (!is_keyboard_left()) {
214+
pmw_set_cpi(cpi);
216215
}
217216
}
218217
#endif

keyboards/splitkb/kyria/keymaps/drashna/config.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@
2525
#ifdef RGBLIGHT_ENABLE
2626
# define RGBLIGHT_SLEEP
2727
# define RGBLIGHT_LIMIT_VAL 200
28-
# define RGBLIGHT_HUE_STEP 8
29-
# define RGBLIGHT_SAT_STEP 8
30-
# define RGBLIGHT_VAL_STEP 8
28+
# define RGBLIGHT_HUE_STEP 8
29+
# define RGBLIGHT_SAT_STEP 8
30+
# define RGBLIGHT_VAL_STEP 8
3131
# define RGBLIGHT_SPLIT
3232
// # define RGBLIGHT_LAYERS
3333
#endif
3434

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

layouts/community/split_3x6_3/drashna/keymap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
3737
KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
3838
ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(K1B), \
3939
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 \
4141
)
4242
#define LAYOUT_base_wrapper(...) LAYOUT_split_3x6_3_base(__VA_ARGS__)
4343

layouts/community/split_3x6_3/drashna/rules.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ ifeq ($(strip $(CTPC)), yes)
3131
WS2812_DRIVER = pwm # won't work without a patch to the ctpc mk file
3232
SERIAL_DRIVER = usart
3333
SWAP_HANDS_ENABLE = yes
34+
WPM_ENABLE = yes
3435
endif

users/drashna/config.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
#define USB_POLLING_INTERVAL_MS 1
2424

2525
#if defined(SPLIT_KEYBOARD)
26-
# define SPLIT_MODS_ENABLE
26+
// # define SPLIT_TRANSPORT_MIRROR
2727
# define SPLIT_LAYER_STATE_ENABLE
2828
# define SPLIT_LED_STATE_ENABLE
29-
30-
// # define SPLIT_TRANSPORT_MIRROR
31-
# define SERIAL_USE_MULTI_TRANSACTION
32-
# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC
29+
# define SPLIT_MODS_ENABLE
30+
# ifdef WPM_ENABLE
31+
# define SPLIT_WPM_ENABLE
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
3335
#endif
3436

3537
#ifdef AUDIO_ENABLE
@@ -165,8 +167,8 @@
165167

166168
#ifdef QMK_KEYS_PER_SCAN
167169
# undef QMK_KEYS_PER_SCAN
168-
# define QMK_KEYS_PER_SCAN 2
169-
#endif // !QMK_KEYS_PER_SCAN
170+
#endif
171+
#define QMK_KEYS_PER_SCAN 4
170172

171173
// this makes it possible to do rolling combos (zx) with keys that
172174
// convert to other keys on hold (z becomes ctrl when you hold it,

users/drashna/oled_stuff.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ void render_keylock_status(uint8_t led_usb_state) {
141141
oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
142142
oled_write_P(PSTR(" "), false);
143143
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
147144
}
145+
148146
void render_matrix_scan_rate(void) {
149147
#ifdef DEBUG_MATRIX_SCAN_RATE
150148
char matrix_rate[5];
@@ -315,12 +313,11 @@ void render_wpm(void) {
315313
}
316314

317315
#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
318-
extern keyboard_config_t keyboard_config;
319-
extern uint16_t dpi_array[];
320316

317+
extern kb_runtime_config_t kb_state;
321318
void render_pointing_dpi_status(void) {
322319
char dpi_status[6];
323-
uint16_t n = dpi_array[keyboard_config.dpi_config];
320+
uint16_t n = kb_state.device_cpi;
324321
dpi_status[5] = '\0';
325322
dpi_status[4] = '0' + n % 10;
326323
dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
@@ -340,7 +337,9 @@ void render_status_secondary(void) {
340337
render_default_layer_state();
341338
render_layer_state();
342339
render_mod_status(get_mods() | get_oneshot_mods());
343-
340+
#if !defined(OLED_DISPLAY_128X64) && defined(WPM_ENABLE)
341+
render_wpm();
342+
#endif
344343
// render_keylock_status(host_keyboard_leds());
345344
}
346345

@@ -349,7 +348,7 @@ void render_status_main(void) {
349348
oled_driver_render_logo();
350349
# ifdef DEBUG_MATRIX_SCAN_RATE
351350
render_matrix_scan_rate();
352-
# else
351+
# elif defined(WPM_ENABLE)
353352
render_wpm();
354353
# endif
355354
# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)

users/drashna/rules.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ SRC += drashna.c \
22
process_records.c
33

44
ifneq ($(PLATFORM),CHIBIOS)
5-
LTO_ENABLE = yes
5+
ifneq ($(strip $(LTO_SUPPORTED)), no)
6+
LTO_ENABLE = yes
7+
endif
68
endif
79
SPACE_CADET_ENABLE = no
810
GRAVE_ESC_ENABLE = no

0 commit comments

Comments
 (0)