aboutsummaryrefslogtreecommitdiff
path: root/keyboards/handwired
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-12-14 20:53:36 -0800
committerGitHub <noreply@github.com>2021-12-14 20:53:36 -0800
commit3fa592a4024a24a636fa0c562e6761667a94f565 (patch)
tree4ce826128e29e36dfe606fa2b5a3d25b3bd0afcc /keyboards/handwired
parentc10bc9f91e737dd3675b2e4492daa09092655af9 (diff)
downloadqmk_firmware-3fa592a4024a24a636fa0c562e6761667a94f565.tar.gz
qmk_firmware-3fa592a4024a24a636fa0c562e6761667a94f565.zip
[Keymap] Unicode and Pointing Device and Autocorect for drashna keymaps (#15415)
Diffstat (limited to 'keyboards/handwired')
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c29
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md5
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c121
-rw-r--r--keyboards/handwired/tractyl_manuform/tm_sync.c3
-rw-r--r--keyboards/handwired/tractyl_manuform/tractyl_manuform.c2
5 files changed, 38 insertions, 122 deletions
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c b/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c
index 700b0685f..5cd269e31 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/f411.c
@@ -16,7 +16,7 @@
16 16
17#include "f411.h" 17#include "f411.h"
18 18
19void matrix_init_sub_kb(void) { setPinInputHigh(A0); } 19void keyboard_pre_init_sub(void) { setPinInputHigh(A0); }
20 20
21void matrix_scan_sub_kb(void) { 21void matrix_scan_sub_kb(void) {
22 if (!readPin(A0)) { 22 if (!readPin(A0)) {
@@ -24,6 +24,33 @@ void matrix_scan_sub_kb(void) {
24 } 24 }
25} 25}
26 26
27void bootmagic_lite(void) {
28 // We need multiple scans because debouncing can't be turned off.
29 matrix_scan();
30#if defined(DEBOUNCE) && DEBOUNCE > 0
31 wait_ms(DEBOUNCE * 2);
32#else
33 wait_ms(30);
34#endif
35 matrix_scan();
36
37 uint8_t row = BOOTMAGIC_LITE_ROW;
38 uint8_t col = BOOTMAGIC_LITE_COLUMN;
39
40#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT)
41 if (!is_keyboard_left()) {
42 row = BOOTMAGIC_LITE_ROW_RIGHT;
43 col = BOOTMAGIC_LITE_COLUMN_RIGHT;
44 }
45#endif
46
47 if (matrix_get_row(row) & (1 << col) || !readPin(A0)) {
48 eeconfig_disable();
49 bootloader_jump();
50 }
51}
52
53
27#ifdef USB_VBUS_PIN 54#ifdef USB_VBUS_PIN
28bool usb_vbus_state(void) { 55bool usb_vbus_state(void) {
29 setPinInputLow(USB_VBUS_PIN); 56 setPinInputLow(USB_VBUS_PIN);
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md b/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md
index b38743512..f732295ba 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md
@@ -1,7 +1,7 @@
1# Drashna's Blackpill Tractyl Manuform (5x6) with a right side trackball 1# Drashna's Blackpill Tractyl Manuform (5x6) with a right side trackball
2 2
3* System Timer on TIM5 3* System Timer on TIM5
4* ~~VBUS mod, using PB10~~ (*doesn't seem to work for me*) 4* VBUS mod, using PB10 -- does work, but not on my tractyl... bad soldering probably
5* Split Hand Pin, using PC14 5* Split Hand Pin, using PC14
6* Full Duplex Serial/USART using PA2 and PA3 on USART2 6* Full Duplex Serial/USART using PA2 and PA3 on USART2
7* PWM Audio using PB1 and TIM3 and GPT on TIM4 7* PWM Audio using PB1 and TIM3 and GPT on TIM4
@@ -12,7 +12,8 @@
12* SSD1306 OLED display (128x64) using PB8-PB9 on I2C1 12* SSD1306 OLED display (128x64) using PB8-PB9 on I2C1
13* Pull-up resistor (22k) on PA10 to fix reset issue. 13* Pull-up resistor (22k) on PA10 to fix reset issue.
14* Pull-up resistor (5.1k) on PA1 for WS2812 LED support, and wire it's VCC to the 5V pin. 14* Pull-up resistor (5.1k) on PA1 for WS2812 LED support, and wire it's VCC to the 5V pin.
15* Pins PA9, PA11, A12 are not useable because they're used for USB connection, and can't be shared. 15* Pins PA9 is meant for VBUS sense, and has an internal pulldown resistor. A 5.1k pullup resistor can work (but should be avoided)
16* Pins PA11 and A12 are not useable because they're used for USB connection, and can't be shared.
16* Pin PB2 is used by BOOT1, and is unusable 17* Pin PB2 is used by BOOT1, and is unusable
17 18
18## Keyboard Info 19## Keyboard Info
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 f893a8cc4..958f69417 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
@@ -16,11 +16,6 @@
16 16
17#include "drashna.h" 17#include "drashna.h"
18 18
19enum tractyl_keycodes {
20 KC_ACCEL = NEW_SAFE_RANGE,
21};
22
23bool enable_acceleration = false;
24// clang-format off 19// clang-format off
25#define LAYOUT_5x6_right_wrapper(...) LAYOUT_5x6_right(__VA_ARGS__) 20#define LAYOUT_5x6_right_wrapper(...) LAYOUT_5x6_right(__VA_ARGS__)
26#define LAYOUT_5x6_right_base( \ 21#define LAYOUT_5x6_right_base( \
@@ -129,10 +124,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
129 VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST, 124 VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST,
130 KEYLOCK, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, TG_MODS, 125 KEYLOCK, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, TG_MODS,
131 UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, KC_MPLY, 126 UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, KC_MPLY,
132 HPT_DWLI, HPT_DWLD, TG_GAME, TG_DBLO, 127 TG(_DIABLOII), AUTO_CTN, TG_GAME, TG_DBLO,
133 HPT_TOG, HPT_BUZ, KC_NUKE, 128 _______, _______, KC_NUKE,
134 _______, _______, _______, 129 _______, _______, _______,
135 _______, TG(_DIABLOII),KC_NUKE, _______ 130 _______, _______, KC_NUKE, _______
136 ), 131 ),
137}; 132};
138 133
@@ -169,116 +164,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
169} 164}
170#endif 165#endif
171 166
172#ifdef POINTING_DEVICE_ENABLE
173static uint16_t mouse_timer = 0;
174static uint16_t mouse_debounce_timer = 0;
175static uint8_t mouse_keycode_tracker = 0;
176bool tap_toggling = false;
177
178# ifdef TAPPING_TERM_PER_KEY
179# define TAP_CHECK get_tapping_term(KC_BTN1, NULL)
180# else
181# ifndef TAPPING_TERM
182# define TAPPING_TERM 200
183# endif
184# define TAP_CHECK TAPPING_TERM
185# endif
186
187report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
188 int8_t x = mouse_report.x, y = mouse_report.y;
189 mouse_report.x = 0;
190 mouse_report.y = 0;
191
192 if (x != 0 && y != 0) {
193 mouse_timer = timer_read();
194# ifdef OLED_ENABLE
195 oled_timer = timer_read32();
196# endif
197 if (timer_elapsed(mouse_debounce_timer) > TAP_CHECK) {
198 if (enable_acceleration) {
199 x = (x > 0 ? x * x / 16 + x : -x * x / 16 + x);
200 y = (y > 0 ? y * y / 16 + y : -y * y / 16 + y);
201 }
202 mouse_report.x = x;
203 mouse_report.y = y;
204 if (!layer_state_is(_MOUSE)) {
205 layer_on(_MOUSE);
206 }
207 }
208 }
209 return mouse_report;
210}
211
212void matrix_scan_keymap(void) {
213 if (timer_elapsed(mouse_timer) > 650 && layer_state_is(_MOUSE) && !mouse_keycode_tracker && !tap_toggling) {
214 layer_off(_MOUSE);
215 }
216 if (tap_toggling) {
217 if (!layer_state_is(_MOUSE)) {
218 layer_on(_MOUSE);
219 }
220 }
221}
222
223bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
224 switch (keycode) {
225 case TT(_MOUSE):
226 if (record->event.pressed) {
227 mouse_keycode_tracker++;
228 } else {
229# if TAPPING_TOGGLE != 0
230 if (record->tap.count == TAPPING_TOGGLE) {
231 tap_toggling ^= 1;
232# if TAPPING_TOGGLE == 1
233 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count + 1;
234# else
235 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count;
236# endif
237 } else {
238 mouse_keycode_tracker--;
239 }
240# endif
241 }
242 mouse_timer = timer_read();
243 break;
244 case TG(_MOUSE):
245 if (record->event.pressed) {
246 tap_toggling ^= 1;
247 }
248 break;
249 case MO(_MOUSE):
250 case DPI_CONFIG:
251 case KC_MS_UP ... KC_MS_WH_RIGHT:
252 record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
253 mouse_timer = timer_read();
254 case KC_ACCEL:
255 enable_acceleration = record->event.pressed;
256 break;
257 default:
258 if (IS_NOEVENT(record->event)) break;
259 if ((keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) && (((keycode >> 0x8) & 0xF) == _MOUSE)) {
260 record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
261 mouse_timer = timer_read();
262 break;
263 }
264 if (layer_state_is(_MOUSE) && !mouse_keycode_tracker) {
265 layer_off(_MOUSE);
266 }
267 mouse_keycode_tracker = 0;
268 mouse_debounce_timer = timer_read();
269 break;
270 }
271 return true;
272}
273
274layer_state_t layer_state_set_keymap(layer_state_t state) {
275 if (layer_state_cmp(state, _GAMEPAD) || layer_state_cmp(state, _DIABLO)) {
276 state |= ((layer_state_t)1 << _MOUSE);
277 }
278 return state;
279}
280#endif
281
282#ifdef OLED_ENABLE 167#ifdef OLED_ENABLE
283// WPM-responsive animation stuff here 168// WPM-responsive animation stuff here
284# define SLEEP_FRAMES 2 169# define SLEEP_FRAMES 2
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c
index 733f09a22..549a17a22 100644
--- a/keyboards/handwired/tractyl_manuform/tm_sync.c
+++ b/keyboards/handwired/tractyl_manuform/tm_sync.c
@@ -1,5 +1,6 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * 2 * Copyright 2021 Dasky (@daskygit)
3
3 * This program is free software: you can redistribute it and/or modify 4 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 6 * the Free Software Foundation, either version 2 of the License, or
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
index 4b36fab54..6095bfb7e 100644
--- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
+++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
@@ -70,6 +70,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
70 return true; 70 return true;
71} 71}
72__attribute__((weak)) void keyboard_pre_init_sync(void) {} 72__attribute__((weak)) void keyboard_pre_init_sync(void) {}
73__attribute__((weak)) void keyboard_pre_init_sub(void) {}
73void keyboard_pre_init_kb(void) { 74void keyboard_pre_init_kb(void) {
74 // debug_enable = true; 75 // debug_enable = true;
75 // debug_matrix = true; 76 // debug_matrix = true;
@@ -82,6 +83,7 @@ void keyboard_pre_init_kb(void) {
82 writePin(DEBUG_LED_PIN, !debug_enable); 83 writePin(DEBUG_LED_PIN, !debug_enable);
83#endif 84#endif
84 85
86 keyboard_pre_init_sub();
85 keyboard_pre_init_sync(); 87 keyboard_pre_init_sync();
86 keyboard_pre_init_user(); 88 keyboard_pre_init_user();
87} 89}