aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-12-29 20:17:34 -0800
committerGitHub <noreply@github.com>2021-12-29 20:17:34 -0800
commitc4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf (patch)
tree67dc381a45d59626132c4c59b71c4b36fa971f8b
parent1a8a842cfb3e87a82afb57ba29ca59c5fa6fe97b (diff)
downloadqmk_firmware-c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf.tar.gz
qmk_firmware-c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf.zip
[Keymap] Reorganization, cleanup and readmes for drashna code (#15617)
-rw-r--r--keyboards/handwired/tractyl_manuform/4x6_right/keymaps/drashna/keymap.c100
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk46
-rw-r--r--keyboards/keebio/iris/keymaps/drashna/config.h9
-rw-r--r--keyboards/keebio/iris/keymaps/drashna/rules.mk5
-rw-r--r--keyboards/moonlander/keymaps/drashna/keymap.c64
-rw-r--r--keyboards/moonlander/keymaps/drashna/rules.mk10
-rw-r--r--keyboards/splitkb/kyria/keymaps/drashna/rules.mk29
-rw-r--r--keyboards/work_louder/work_board/keymaps/drashna/config.h5
-rw-r--r--keyboards/work_louder/work_board/keymaps/drashna/keymap.c37
-rw-r--r--keyboards/work_louder/work_board/keymaps/drashna/rules.mk4
-rw-r--r--layouts/community/ergodox/drashna/config.h7
-rw-r--r--layouts/community/ergodox/drashna/keymap.c40
-rw-r--r--layouts/community/ortho_4x12/drashna/keymap.c55
-rw-r--r--layouts/community/ortho_4x12/drashna/rules.mk24
-rw-r--r--layouts/community/split_3x6_3/drashna/config.h4
-rw-r--r--layouts/community/split_3x6_3/drashna/keymap.c5
-rw-r--r--layouts/community/split_3x6_3/drashna/rules.mk35
-rw-r--r--users/drashna/callbacks.c215
-rw-r--r--users/drashna/callbacks.h25
-rw-r--r--users/drashna/callbacks.md71
-rw-r--r--users/drashna/config.h35
-rw-r--r--users/drashna/drashna.c291
-rw-r--r--users/drashna/drashna.h59
-rw-r--r--users/drashna/keyrecords/autocorrection/autocorrection.c14
-rw-r--r--users/drashna/keyrecords/autocorrection/autocorrection.h2
-rwxr-xr-xusers/drashna/keyrecords/autocorrection/make_autocorrection_data.py5
-rw-r--r--users/drashna/keyrecords/autocorrection/readme.md301
-rw-r--r--users/drashna/keyrecords/caps_word.c6
-rw-r--r--users/drashna/keyrecords/capwords.md36
-rw-r--r--users/drashna/keyrecords/keycodes.md18
-rw-r--r--users/drashna/keyrecords/process_records.c42
-rw-r--r--users/drashna/keyrecords/process_records.h37
-rw-r--r--users/drashna/keyrecords/readme.md9
-rw-r--r--users/drashna/keyrecords/secrets.md (renamed from users/drashna/readme/secrets.md)0
-rw-r--r--users/drashna/keyrecords/tap_dance.md (renamed from users/drashna/readme/tap_dance.md)4
-rw-r--r--users/drashna/keyrecords/tap_dances.c17
-rw-r--r--users/drashna/keyrecords/tap_dances.h17
-rw-r--r--users/drashna/keyrecords/tapping.c64
-rw-r--r--users/drashna/keyrecords/unicode.c35
-rw-r--r--users/drashna/keyrecords/unicode.md27
-rw-r--r--users/drashna/keyrecords/wrappers.h18
-rw-r--r--users/drashna/keyrecords/wrappers.md (renamed from users/drashna/readme/wrappers.md)0
-rw-r--r--users/drashna/oled/drashna_font.h4
-rw-r--r--users/drashna/oled/oled_stuff.c9
-rw-r--r--users/drashna/oled/readme.md42
-rw-r--r--users/drashna/pointing/pointing.c17
-rw-r--r--users/drashna/pointing/pointing.h17
-rw-r--r--users/drashna/pointing/readme.md19
-rw-r--r--users/drashna/post_config.h21
-rw-r--r--users/drashna/readme.md24
-rw-r--r--users/drashna/readme/handlers.md97
-rw-r--r--users/drashna/readme/keycodes.md10
-rw-r--r--users/drashna/rgb/readme.md (renamed from users/drashna/readme/rgb.md)21
-rw-r--r--users/drashna/rgb/rgb_matrix_stuff.c94
-rw-r--r--users/drashna/rgb/rgb_matrix_stuff.h20
-rw-r--r--users/drashna/rgb/rgb_stuff.c17
-rw-r--r--users/drashna/rgb/rgb_stuff.h17
-rw-r--r--users/drashna/rgblight_breathe_table.h17
-rw-r--r--users/drashna/rules.mk41
-rw-r--r--users/drashna/split/readme.md29
-rw-r--r--users/drashna/split/transport_sync.c57
-rw-r--r--users/drashna/split/transport_sync.h18
-rw-r--r--users/drashna/template.c17
-rw-r--r--users/drashna/template.h17
64 files changed, 1290 insertions, 1162 deletions
diff --git a/keyboards/handwired/tractyl_manuform/4x6_right/keymaps/drashna/keymap.c b/keyboards/handwired/tractyl_manuform/4x6_right/keymaps/drashna/keymap.c
index 78a7db67a..290ea22c5 100644
--- a/keyboards/handwired/tractyl_manuform/4x6_right/keymaps/drashna/keymap.c
+++ b/keyboards/handwired/tractyl_manuform/4x6_right/keymaps/drashna/keymap.c
@@ -115,103 +115,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
115 ), 115 ),
116}; 116};
117// clang-format on 117// clang-format on
118
119#ifdef POINTING_DEVICE_ENABLE
120static uint16_t mouse_timer = 0;
121static uint16_t mouse_debounce_timer = 0;
122static uint8_t mouse_keycode_tracker = 0;
123bool tap_toggling = false;
124
125void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) {
126 if ((x || y) && timer_elapsed(mouse_timer) > 125) {
127 mouse_timer = timer_read();
128 if (!layer_state_is(_MOUSE) && !(layer_state_is(_GAMEPAD) || layer_state_is(_DIABLO)) && timer_elapsed(mouse_debounce_timer) > 125) {
129 layer_on(_MOUSE);
130 }
131 }
132
133# ifdef TAPPING_TERM_PER_KEY
134 if (timer_elapsed(mouse_debounce_timer) > get_tapping_term(KC_BTN1, NULL)
135# else
136 if (timer_elapsed(mouse_debounce_timer) > TAPPING_TERM
137# endif
138 || (layer_state_is(_GAMEPAD) || layer_state_is(_DIABLO))) {
139 mouse_report->x = x;
140 mouse_report->y = y;
141 }
142# ifdef OLED_ENABLE
143 if (x || y) oled_timer = timer_read32();
144# endif
145}
146
147void matrix_scan_keymap(void) {
148 if (timer_elapsed(mouse_timer) > 650 && layer_state_is(_MOUSE) && !mouse_keycode_tracker && !tap_toggling) {
149 layer_off(_MOUSE);
150 }
151 if (tap_toggling) {
152 if (!layer_state_is(_MOUSE)) {
153 layer_on(_MOUSE);
154 }
155 }
156}
157
158bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
159 switch (keycode) {
160 case TT(_MOUSE):
161 {
162 if (record->event.pressed) {
163 mouse_keycode_tracker++;
164 } else {
165# if TAPPING_TOGGLE != 0
166 if (record->tap.count == TAPPING_TOGGLE) {
167 tap_toggling ^= 1;
168# if TAPPING_TOGGLE == 1
169 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count + 1;
170# else
171 if (!tap_toggling) mouse_keycode_tracker -= record->tap.count;
172# endif
173 } else {
174 mouse_keycode_tracker--;
175 }
176# endif
177 }
178 mouse_timer = timer_read();
179 break;
180 }
181 case MO(_MOUSE):
182 case DPI_CONFIG:
183 case KC_MS_UP ... KC_MS_WH_RIGHT:
184 record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
185 mouse_timer = timer_read();
186 break;
187 default:
188 if (layer_state_is(_MOUSE) && !mouse_keycode_tracker) {
189 layer_off(_MOUSE);
190 }
191 mouse_keycode_tracker = 0;
192 mouse_debounce_timer = timer_read();
193 break;
194 }
195 return true;
196}
197
198layer_state_t layer_state_set_keymap(layer_state_t state) {
199 if (layer_state_cmp(state, _GAMEPAD) || layer_state_cmp(state, _DIABLO)) {
200 state |= (1UL << _MOUSE);
201 }
202 return state;
203}
204#endif
205
206void matrix_init_keymap(void) {
207#ifdef AUDIO_ENABLE
208 extern audio_config_t audio_config;
209
210 if (!is_keyboard_master()) {
211 audio_stop_all();
212 audio_config.enable = false;
213 }
214#endif
215}
216
217void keyboard_post_init_keymap(void) { matrix_init_keymap(); }
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 9b9032837..0765bb2c6 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/rules.mk
@@ -1,14 +1,34 @@
1RGBLIGHT_ENABLE = yes 1COMMAND_ENABLE = no
2RGBLIGHT_STARTUP_ANIMATION = yes 2RGBLIGHT_ENABLE = yes
3AUDIO_ENABLE = yes 3RGBLIGHT_STARTUP_ANIMATION = yes
4HAPTIC_ENABLE = no 4AUDIO_ENABLE = yes
5COMMAND_ENABLE = no 5HAPTIC_ENABLE = no
6TAP_DANCE_ENABLE = yes 6TAP_DANCE_ENABLE = yes
7UNICODE_ENABLE = yes 7OLED_ENABLE = yes
8OLED_ENABLE = yes 8WPM_ENABLE = yes
9WPM_ENABLE = yes 9ENCODER_ENABLE = yes
10ENCODER_ENABLE = yes 10ENCODER_MAP_ENABLE = yes
11ENCODER_MAP_ENABLE = yes 11AUTOCORRECTION_ENABLE = yes
12# DEBOUNCE_TYPE = sym_eager_pk 12CAPS_WORD_ENABLE = yes
13 13
14LTO_SUPPORTED = no 14ifeq ($(strip $(KEYBOARD)), handwired/tractyl_manuform/5x6_right/elite_c)
15 RGBLIGHT_ENABLE = no
16 AUDIO_ENABLE = no
17 HAPTIC_ENABLE = no
18 TAP_DANCE_ENABLE = no
19 OLED_ENABLE = no
20 WPM_ENABLE = no
21 ENCODER_ENABLE = no
22 AUTOCORRECTION_ENABLE = no
23 LTO_SUPPORTED = yes
24 SWAP_HANDS_ENABLE = no
25 CUSTOM_UNICODE_ENABLE = no
26 CAPS_WORD_ENABLE = no
27 BOOTLOADER = qmk-hid
28 BOOTLOADER_SIZE = 512
29endif
30ifeq ($(strip $(KEYBOARD)), handwired/tractyl_manuform/5x6_right/teensy2pp)
31 AUTOCORRECTION_ENABLE = no
32 CAPS_WORD_ENABLE = yes
33endif
34# DEBOUNCE_TYPE = sym_eager_pk
diff --git a/keyboards/keebio/iris/keymaps/drashna/config.h b/keyboards/keebio/iris/keymaps/drashna/config.h
index f68166c98..cf67aa698 100644
--- a/keyboards/keebio/iris/keymaps/drashna/config.h
+++ b/keyboards/keebio/iris/keymaps/drashna/config.h
@@ -16,15 +16,6 @@
16 16
17#pragma once 17#pragma once
18 18
19/* Use I2C or Serial, not both */
20
21// #define USE_SERIAL
22#define USE_I2C
23
24/* Select hand configuration */
25
26// #define MASTER_LEFT
27// #define MASTER_RIGHT
28#define EE_HANDS 19#define EE_HANDS
29 20
30#ifdef RGBLIGHT_ENABLE 21#ifdef RGBLIGHT_ENABLE
diff --git a/keyboards/keebio/iris/keymaps/drashna/rules.mk b/keyboards/keebio/iris/keymaps/drashna/rules.mk
index ca140d76c..51b9a105d 100644
--- a/keyboards/keebio/iris/keymaps/drashna/rules.mk
+++ b/keyboards/keebio/iris/keymaps/drashna/rules.mk
@@ -4,7 +4,6 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
4CONSOLE_ENABLE = no # Console for debug 4CONSOLE_ENABLE = no # Console for debug
5COMMAND_ENABLE = no # Commands for debug and configuration 5COMMAND_ENABLE = no # Commands for debug and configuration
6TAP_DANCE_ENABLE = no 6TAP_DANCE_ENABLE = no
7RGBLIGHT_ENABLE = yes
8AUDIO_ENABLE = no 7AUDIO_ENABLE = no
9NKRO_ENABLE = yes 8NKRO_ENABLE = yes
10BACKLIGHT_ENABLE = no 9BACKLIGHT_ENABLE = no
@@ -15,3 +14,7 @@ INDICATOR_LIGHTS = no
15RGBLIGHT_STARTUP_ANIMATION = no 14RGBLIGHT_STARTUP_ANIMATION = no
16CUSTOM_UNICODE_ENABLE = no 15CUSTOM_UNICODE_ENABLE = no
17CUSTOM_SPLIT_TRANSPORT_SYNC = no 16CUSTOM_SPLIT_TRANSPORT_SYNC = no
17
18ifneq ($(strip $(KEYBOARD)), keebio/iris/rev6)
19 RGBLIGHT_ENABLE = yes
20endif
diff --git a/keyboards/moonlander/keymaps/drashna/keymap.c b/keyboards/moonlander/keymaps/drashna/keymap.c
index 1b5280e74..82abdb005 100644
--- a/keyboards/moonlander/keymaps/drashna/keymap.c
+++ b/keyboards/moonlander/keymaps/drashna/keymap.c
@@ -63,27 +63,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
63 63
64 64
65 [_GAMEPAD] = LAYOUT_moonlander_wrapper( 65 [_GAMEPAD] = LAYOUT_moonlander_wrapper(
66 KC_ESC, KC_NO, KC_1, KC_2, KC_3, KC_4, HYPR(KC_Q), KC_TRNS, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO, 66 KC_ESC, XXXXXXX, KC_1, KC_2, KC_3, KC_4, HYPR(KC_Q), _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, KC_NO,
67 KC_F1, KC_K, KC_Q, KC_W, KC_E, KC_R, KC_T, UC_SHRG, UC_DISA, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 67 KC_F1, KC_K, KC_Q, KC_W, KC_E, KC_R, KC_T, UC_SHRG, UC_DISA, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
68 KC_TAB, KC_G, KC_A, KC_S, KC_D, KC_F, KC_TRNS, TG_GAME, KC_I, KC_O, KC_NO, KC_NO, KC_NO, KC_NO, 68 KC_TAB, KC_G, KC_A, KC_S, KC_D, KC_F, _______, TG_GAME, KC_I, KC_O, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
69 KC_LCTL, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_N, KC_M, KC_NO, KC_NO, KC_NO, KC_NO, 69 KC_LCTL, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
70 KC_GRV, KC_U, KC_I, KC_Y, KC_T, KC_PSCR, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_NO, 70 KC_GRV, KC_U, KC_I, KC_Y, KC_T, KC_PSCR, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_NO,
71 KC_V, KC_SPC, KC_H, KC_NO, KC_NO, KC_SWAP_NUM 71 KC_V, KC_SPC, KC_H, KC_NO, XXXXXXX,KC_SWAP_NUM
72 ), 72 ),
73 [_DIABLO] = LAYOUT_moonlander_wrapper( 73 [_DIABLO] = LAYOUT_moonlander_wrapper(
74 KC_ESC, KC_V, KC_D, KC_LALT, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO, 74 KC_ESC, KC_V, KC_D, KC_LALT, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, KC_NO,
75 KC_TAB, KC_S, KC_I, KC_F, KC_M, KC_T, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 75 KC_TAB, KC_S, KC_I, KC_F, KC_M, KC_T, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
76 KC_NO, KC_1, KC_2, KC_3, KC_4, KC_G, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 76 XXXXXXX, KC_1, KC_2, KC_3, KC_4, KC_G, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
77 KC_LCTL, KC_D3_1, KC_D3_2, KC_D3_3, KC_D3_4, KC_Z, KC_N, KC_M, KC_NO, KC_NO, KC_NO, KC_NO, 77 KC_LCTL, KC_D3_1, KC_D3_2, KC_D3_3, KC_D3_4, KC_Z, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
78 KC_NO, KC_NO, KC_L, KC_J, KC_F, KC_PSCR, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 78 XXXXXXX, XXXXXXX, KC_L, KC_J, KC_F, KC_PSCR, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
79 KC_DIABLO_CLEAR, SFT_T(KC_SPACE), ALT_T(KC_Q), KC_PGDN, KC_DEL, KC_ENT 79 KC_DIABLO_CLEAR, SFT_T(KC_SPACE), ALT_T(KC_Q), KC_PGDN, KC_DEL, KC_ENT
80 ), 80 ),
81 [_DIABLOII] = LAYOUT_moonlander_wrapper( 81 [_DIABLOII] = LAYOUT_moonlander_wrapper(
82 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_GRV, KC_NO, KC_TRNS, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO, 82 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_GRV, XXXXXXX, _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, KC_NO,
83 KC_TAB, KC_A, KC_T, KC_Q, KC_I, KC_M, TG(_DIABLOII), KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 83 KC_TAB, KC_A, KC_T, KC_Q, KC_I, KC_M, TG(_DIABLOII), _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
84 KC_S, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_NO, KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 84 KC_S, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
85 KC_LCTL, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_N, KC_M, KC_NO, KC_NO, KC_NO, KC_NO, 85 KC_LCTL, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
86 KC_NO, KC_NO, KC_G, KC_F, KC_L, KC_V, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, 86 XXXXXXX, XXXXXXX, KC_G, KC_F, KC_L, KC_V, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO,
87 KC_G, KC_LSFT, KC_LCTL, KC_PGDN, KC_DEL, KC_ENT 87 KC_G, KC_LSFT, KC_LCTL, KC_PGDN, KC_DEL, KC_ENT
88 ), 88 ),
89 89
@@ -164,7 +164,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
164} 164}
165 165
166#ifdef RGB_MATRIX_ENABLE 166#ifdef RGB_MATRIX_ENABLE
167void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { 167bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
168 if (layer_state_is(_GAMEPAD)) { 168 if (layer_state_is(_GAMEPAD)) {
169 RGB_MATRIX_INDICATOR_SET_COLOR(11, 0x00, 0xFF, 0x00); // Q 169 RGB_MATRIX_INDICATOR_SET_COLOR(11, 0x00, 0xFF, 0x00); // Q
170 RGB_MATRIX_INDICATOR_SET_COLOR(16, 0x00, 0xFF, 0xFF); // W 170 RGB_MATRIX_INDICATOR_SET_COLOR(16, 0x00, 0xFF, 0xFF); // W
@@ -180,37 +180,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
180 RGB_MATRIX_INDICATOR_SET_COLOR(20, 0x7A, 0x00, 0xFF); // 3 180 RGB_MATRIX_INDICATOR_SET_COLOR(20, 0x7A, 0x00, 0xFF); // 3
181 } 181 }
182 182
183 if (userspace_config.rgb_layer_change) { 183 return true;
184 switch (get_highest_layer(layer_state|default_layer_state)) {
185 case _DEFAULT_LAYER_1:
186 rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
187 break;
188 case _DEFAULT_LAYER_2:
189 rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
190 break;
191 case _DEFAULT_LAYER_3:
192 rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
193 break;
194 case _DEFAULT_LAYER_4:
195 rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
196 break;
197 case _GAMEPAD:
198 rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
199 break;
200 case _DIABLO:
201 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER, led_min, led_max);
202 break;
203 case _RAISE:
204 rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
205 break;
206 case _LOWER:
207 rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
208 break;
209 case _ADJUST:
210 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
211 break;
212 }
213 }
214} 184}
215#endif 185#endif
216 186
diff --git a/keyboards/moonlander/keymaps/drashna/rules.mk b/keyboards/moonlander/keymaps/drashna/rules.mk
index 2a6d20bed..feb91c774 100644
--- a/keyboards/moonlander/keymaps/drashna/rules.mk
+++ b/keyboards/moonlander/keymaps/drashna/rules.mk
@@ -1,4 +1,6 @@
1TAP_DANCE_ENABLE = yes 1TAP_DANCE_ENABLE = yes
2BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite 2BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
3UNICODE_ENABLE = yes 3UNICODE_ENABLE = yes
4UNICODEMAP_ENABLE = no 4UNICODEMAP_ENABLE = no
5AUTOCORRECTION_ENABLE = yes
6CAPS_WORD_ENABLE = yes
diff --git a/keyboards/splitkb/kyria/keymaps/drashna/rules.mk b/keyboards/splitkb/kyria/keymaps/drashna/rules.mk
index 2f4f4d091..3cdfe1bec 100644
--- a/keyboards/splitkb/kyria/keymaps/drashna/rules.mk
+++ b/keyboards/splitkb/kyria/keymaps/drashna/rules.mk
@@ -1,20 +1,27 @@
1BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite 1BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
2MOUSEKEY_ENABLE = yes # Mouse keys 2MOUSEKEY_ENABLE = no # Mouse keys
3EXTRAKEY_ENABLE = yes # Audio control and System control 3EXTRAKEY_ENABLE = yes # Audio control and System control
4CONSOLE_ENABLE = yes # Console for debug 4CONSOLE_ENABLE = no # Console for debug
5COMMAND_ENABLE = no # Commands for debug and configuration 5COMMAND_ENABLE = no # Commands for debug and configuration
6NKRO_ENABLE = yes # USB Nkey Rollover 6NKRO_ENABLE = yes # USB Nkey Rollover
7UNICODE_ENABLE = yes # Unicode
8OLED_ENABLE = yes 7OLED_ENABLE = yes
9OLED_DRIVER = SSD1306 # Enables the use of OLED displays
10ENCODER_ENABLE = yes # Enables the use of one or more encoders 8ENCODER_ENABLE = yes # Enables the use of one or more encoders
11
12RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow 9RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
13RGBLIGHT_STARTUP_ANIMATION = yes
14RGB_MATRIX_ENABLE = yes
15TAP_DANCE_ENABLE = yes
16KEY_LOCK_ENABLE = no 10KEY_LOCK_ENABLE = no
17WPM_ENABLE = yes 11WPM_ENABLE = yes
18SWAP_HANDS_ENABLE = yes 12
19LTO_ENABLE = no 13ifeq ($(strip $(KEYBOARD)), splitkb/kyria/rev1/proton_c)
20CTPC = yes 14 RGB_MATRIX_ENABLE = yes
15 CONSOLE_ENABLE = yes # Console for debug
16 MOUSEKEY_ENABLE = yes # Mouse keys
17 TAP_DANCE_ENABLE = yes
18 SWAP_HANDS_ENABLE = yes
19 LTO_ENABLE = no
20 CTPC = yes
21 AUTOCORRECTION_ENABLE = yes
22 CAPS_WORD_ENABLE = yes
23else
24 LTO_ENABLE = yes
25 BOOTLOADER = qmk-hid
26 BOOTLOADER_SIZE = 512
27endif
diff --git a/keyboards/work_louder/work_board/keymaps/drashna/config.h b/keyboards/work_louder/work_board/keymaps/drashna/config.h
index 5ea4dc7e4..b3bcaca25 100644
--- a/keyboards/work_louder/work_board/keymaps/drashna/config.h
+++ b/keyboards/work_louder/work_board/keymaps/drashna/config.h
@@ -15,3 +15,8 @@
15 */ 15 */
16 16
17#pragma once 17#pragma once
18
19#define RGBLIGHT_EFFECT_KNIGHT_LED_NUM 12
20
21#undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
22#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255
diff --git a/keyboards/work_louder/work_board/keymaps/drashna/keymap.c b/keyboards/work_louder/work_board/keymaps/drashna/keymap.c
index 3bbb81bf0..3b0f4921a 100644
--- a/keyboards/work_louder/work_board/keymaps/drashna/keymap.c
+++ b/keyboards/work_louder/work_board/keymaps/drashna/keymap.c
@@ -126,45 +126,12 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
126 126
127#endif 127#endif
128 128
129void rgb_matrix_indicators_user(void) {} 129bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
130
131void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
132 uint8_t this_mod = get_mods(); 130 uint8_t this_mod = get_mods();
133 uint8_t this_led = host_keyboard_leds(); 131 uint8_t this_led = host_keyboard_leds();
134 uint8_t this_osm = get_oneshot_mods(); 132 uint8_t this_osm = get_oneshot_mods();
135#define THUMB_LED 6 133#define THUMB_LED 6
136#define RGB_MATRIX_INDICATOR_SET_COLOR_wrapper(...) RGB_MATRIX_INDICATOR_SET_COLOR(__VA_ARGS__) 134#define RGB_MATRIX_INDICATOR_SET_COLOR_wrapper(...) RGB_MATRIX_INDICATOR_SET_COLOR(__VA_ARGS__)
137 if (!userspace_config.rgb_layer_change) {
138 switch (get_highest_layer(layer_state | default_layer_state)) {
139 case _GAMEPAD:
140 rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
141 break;
142 case _DIABLO:
143 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER, led_min, led_max);
144 break;
145 case _RAISE:
146 rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
147 break;
148 case _LOWER:
149 rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
150 break;
151 case _ADJUST:
152 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
153 break;
154 case _DEFAULT_LAYER_1:
155 rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
156 break;
157 case _DEFAULT_LAYER_2:
158 rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
159 break;
160 case _DEFAULT_LAYER_3:
161 rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
162 break;
163 case _DEFAULT_LAYER_4:
164 rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
165 break;
166 }
167 }
168 135
169 extern bool host_driver_disabled; 136 extern bool host_driver_disabled;
170 if (host_driver_disabled) { 137 if (host_driver_disabled) {
@@ -214,4 +181,6 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
214 RGB_MATRIX_INDICATOR_SET_COLOR(4, 0xFF, 0xFF, 0x00); 181 RGB_MATRIX_INDICATOR_SET_COLOR(4, 0xFF, 0xFF, 0x00);
215 RGB_MATRIX_INDICATOR_SET_COLOR(5, 0xFF, 0xFF, 0x00); 182 RGB_MATRIX_INDICATOR_SET_COLOR(5, 0xFF, 0xFF, 0x00);
216 } 183 }
184
185 return true;
217} 186}
diff --git a/keyboards/work_louder/work_board/keymaps/drashna/rules.mk b/keyboards/work_louder/work_board/keymaps/drashna/rules.mk
index 363f2d0ed..6cccd5f8d 100644
--- a/keyboards/work_louder/work_board/keymaps/drashna/rules.mk
+++ b/keyboards/work_louder/work_board/keymaps/drashna/rules.mk
@@ -1,6 +1,10 @@
1BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite 1BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
2EXTRAKEY_ENABLE = yes 2EXTRAKEY_ENABLE = yes
3MOUSEKEY_ENABLE = yes
3TAP_DANCE_ENABLE = no 4TAP_DANCE_ENABLE = no
4NKRO_ENABLE = yes 5NKRO_ENABLE = yes
5RGBLIGHT_STARTUP_ANIMATION = yes 6RGBLIGHT_STARTUP_ANIMATION = yes
6ENCODER_MAP_ENABLE = yes 7ENCODER_MAP_ENABLE = yes
8
9AUTOCORRECTION_ENABLE = no
10CUSTOM_UNICODE_ENABLE = no
diff --git a/layouts/community/ergodox/drashna/config.h b/layouts/community/ergodox/drashna/config.h
index f9daf277f..d669f2729 100644
--- a/layouts/community/ergodox/drashna/config.h
+++ b/layouts/community/ergodox/drashna/config.h
@@ -45,6 +45,7 @@
45# endif 45# endif
46#endif 46#endif
47 47
48#define PIMORONI_TRACKBALL_INVERT_X 48#ifdef TAPPING_TERM
49#define PIMORONI_TRACKBALL_INVERT_Y 49# undef TAPPING_TERM
50#define PIMORONI_TRACKBALL_CLICK 50#endif
51#define TAPPING_TERM 185
diff --git a/layouts/community/ergodox/drashna/keymap.c b/layouts/community/ergodox/drashna/keymap.c
index 3c9bcfeaa..798680628 100644
--- a/layouts/community/ergodox/drashna/keymap.c
+++ b/layouts/community/ergodox/drashna/keymap.c
@@ -317,7 +317,7 @@ void suspend_power_down_keymap(void) { rgb_matrix_set_suspend_state(true); }
317 317
318void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); } 318void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); }
319 319
320void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { 320bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
321 if (layer_state_is(_GAMEPAD)) { 321 if (layer_state_is(_GAMEPAD)) {
322 RGB_MATRIX_INDICATOR_SET_COLOR(32, 0x00, 0xFF, 0x00); // Q 322 RGB_MATRIX_INDICATOR_SET_COLOR(32, 0x00, 0xFF, 0x00); // Q
323 RGB_MATRIX_INDICATOR_SET_COLOR(31, 0x00, 0xFF, 0xFF); // W 323 RGB_MATRIX_INDICATOR_SET_COLOR(31, 0x00, 0xFF, 0xFF); // W
@@ -332,43 +332,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
332 RGB_MATRIX_INDICATOR_SET_COLOR((userspace_config.swapped_numbers ? 27 : 26), 0x00, 0xFF, 0x00); // 2 332 RGB_MATRIX_INDICATOR_SET_COLOR((userspace_config.swapped_numbers ? 27 : 26), 0x00, 0xFF, 0x00); // 2
333 RGB_MATRIX_INDICATOR_SET_COLOR(25, 0x7A, 0x00, 0xFF); // 3 333 RGB_MATRIX_INDICATOR_SET_COLOR(25, 0x7A, 0x00, 0xFF); // 3
334 } 334 }
335 335 return true;
336# if defined(RGBLIGHT_ENABLE)
337 if (!userspace_config.rgb_layer_change)
338# else
339 if (userspace_config.rgb_layer_change)
340# endif
341 {
342 switch (get_highest_layer(layer_state | default_layer_state)) {
343 case _GAMEPAD:
344 rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
345 break;
346 case _DIABLO:
347 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER, led_min, led_max);
348 break;
349 case _RAISE:
350 rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
351 break;
352 case _LOWER:
353 rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
354 break;
355 case _ADJUST:
356 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
357 break;
358 case _DEFAULT_LAYER_1:
359 rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
360 break;
361 case _DEFAULT_LAYER_2:
362 rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
363 break;
364 case _DEFAULT_LAYER_3:
365 rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
366 break;
367 case _DEFAULT_LAYER_4:
368 rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
369 break;
370 }
371 }
372} 336}
373 337
374#endif // RGB_MATRIX_INIT 338#endif // RGB_MATRIX_INIT
diff --git a/layouts/community/ortho_4x12/drashna/keymap.c b/layouts/community/ortho_4x12/drashna/keymap.c
index 3ba9cf64f..ce241fd76 100644
--- a/layouts/community/ortho_4x12/drashna/keymap.c
+++ b/layouts/community/ortho_4x12/drashna/keymap.c
@@ -201,17 +201,8 @@ led_config_t g_led_config = {
201// clange-format on 201// clange-format on
202# endif 202# endif
203 203
204// clang-format off
205void suspend_power_down_keymap(void) {
206 rgb_matrix_set_suspend_state(true);
207}
208 204
209void suspend_wakeup_init_keymap(void) { 205bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
210 rgb_matrix_set_suspend_state(false);
211}
212// clang-format on
213
214void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
215 uint8_t this_mod = get_mods(); 206 uint8_t this_mod = get_mods();
216 uint8_t this_led = host_keyboard_leds(); 207 uint8_t this_led = host_keyboard_leds();
217 uint8_t this_osm = get_oneshot_mods(); 208 uint8_t this_osm = get_oneshot_mods();
@@ -221,48 +212,6 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
221# define THUMB_LED 42 212# define THUMB_LED 42
222# endif 213# endif
223# define RGB_MATRIX_INDICATOR_SET_COLOR_wrapper(...) RGB_MATRIX_INDICATOR_SET_COLOR(__VA_ARGS__) 214# define RGB_MATRIX_INDICATOR_SET_COLOR_wrapper(...) RGB_MATRIX_INDICATOR_SET_COLOR(__VA_ARGS__)
224# if defined(RGBLIGHT_ENABLE)
225 if (!userspace_config.rgb_layer_change)
226# else
227 if (userspace_config.rgb_layer_change)
228# endif
229 {
230 switch (get_highest_layer(layer_state)) {
231 case _GAMEPAD:
232 rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
233 break;
234 case _DIABLO:
235 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER, led_min, led_max);
236 break;
237 case _RAISE:
238 rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
239 break;
240 case _LOWER:
241 rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
242 break;
243 case _ADJUST:
244 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
245 break;
246 default:
247 {
248 switch (get_highest_layer(default_layer_state)) {
249 case _DEFAULT_LAYER_1:
250 rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
251 break;
252 case _DEFAULT_LAYER_2:
253 rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
254 break;
255 case _DEFAULT_LAYER_3:
256 rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
257 break;
258 case _DEFAULT_LAYER_4:
259 rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
260 break;
261 }
262 break;
263 }
264 }
265 }
266 215
267 switch (get_highest_layer(default_layer_state)) { 216 switch (get_highest_layer(default_layer_state)) {
268 case _DEFAULT_LAYER_1: 217 case _DEFAULT_LAYER_1:
@@ -296,6 +245,8 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
296 if ((this_mod | this_osm) & MOD_MASK_ALT) { 245 if ((this_mod | this_osm) & MOD_MASK_ALT) {
297 RGB_MATRIX_INDICATOR_SET_COLOR(38, 0x00, 0x00, 0xFF); 246 RGB_MATRIX_INDICATOR_SET_COLOR(38, 0x00, 0x00, 0xFF);
298 } 247 }
248
249 return true;
299} 250}
300 251
301void matrix_init_keymap(void) { 252void matrix_init_keymap(void) {
diff --git a/layouts/community/ortho_4x12/drashna/rules.mk b/layouts/community/ortho_4x12/drashna/rules.mk
index d76624526..2905fb0fd 100644
--- a/layouts/community/ortho_4x12/drashna/rules.mk
+++ b/layouts/community/ortho_4x12/drashna/rules.mk
@@ -1,33 +1,35 @@
1BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite 1BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
2MOUSEKEY_ENABLE = no # Mouse keys(+4700) 2MOUSEKEY_ENABLE = no # Mouse keys
3EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 3EXTRAKEY_ENABLE = yes # Audio control and System control
4TAP_DANCE_ENABLE = no 4TAP_DANCE_ENABLE = no
5SPACE_CADET_ENABLE = no 5SPACE_CADET_ENABLE = no
6NKRO_ENABLE = yes 6NKRO_ENABLE = yes
7CAPS_WORD_ENABLE = no
7 8
8ifneq ($(strip $(KEYBOARD)), planck/rev6) 9ifneq ($(strip $(KEYBOARD)), planck/rev6)
9 CONSOLE_ENABLE = no 10 CONSOLE_ENABLE = no
10 COMMAND_ENABLE = no 11 COMMAND_ENABLE = no
11 ifeq ($(strip $(LAYOUT_HAS_RGB)), yes) 12 ifeq ($(strip $(LAYOUT_HAS_RGB)), yes)
12 RGBLIGHT_ENABLE = yes 13 RGBLIGHT_ENABLE = yes
13 INDICATOR_LIGHTS = yes 14 INDICATOR_LIGHTS = yes
14 RGBLIGHT_STARTUP_ANIMATION = yes 15 RGBLIGHT_STARTUP_ANIMATION = yes
15 endif 16 endif
16else 17else
17 CONSOLE_ENABLE = yes 18 CONSOLE_ENABLE = yes
18 COMMAND_ENABLE = yes
19 RGBLIGHT_ENABLE = yes 19 RGBLIGHT_ENABLE = yes
20 RGBLIGHT_STARTUP_ANIMATION = yes 20 RGBLIGHT_STARTUP_ANIMATION = yes
21 RGB_MATRIX_ENABLE = no 21 RGB_MATRIX_ENABLE = no
22 AUDIO_ENABLE = yes 22 AUDIO_ENABLE = yes
23 EEPROM_DRIVER = i2c 23 EEPROM_DRIVER = i2c
24 ENCODER_MAP_ENABLE = yes 24 ENCODER_MAP_ENABLE = yes
25 AUTOCORRECTION_ENABLE = yes
26 CAPS_WORD_ENABLE = yes
25endif 27endif
26ifeq ($(strip $(KEYBOARD)), planck/light) 28ifeq ($(strip $(KEYBOARD)), planck/light)
27 RGB_MATRIX_ENABLE = yes 29 RGB_MATRIX_ENABLE = yes
28 RGBLIGHT_ENABLE = yes 30 RGBLIGHT_ENABLE = yes
29 RGBLIGHT_STARTUP_ANIMATION = yes 31 RGBLIGHT_STARTUP_ANIMATION = yes
30 AUDIO_ENABLE = yes 32 AUDIO_ENABLE = yes
31endif 33endif
32ifeq ($(strip $(KEYBOARD)), planck/ez) 34ifeq ($(strip $(KEYBOARD)), planck/ez)
33 RGBLIGHT_ENABLE = no 35 RGBLIGHT_ENABLE = no
@@ -39,4 +41,6 @@ ifeq ($(strip $(KEYBOARD)), planck/ez)
39 CONSOLE_ENABLE = yes 41 CONSOLE_ENABLE = yes
40 COMMAND_ENABLE = yes 42 COMMAND_ENABLE = yes
41 AUDIO_ENABLE = yes 43 AUDIO_ENABLE = yes
44 AUTOCORRECTION_ENABLE = yes
45 CAPS_WORD_ENABLE = yes
42endif 46endif
diff --git a/layouts/community/split_3x6_3/drashna/config.h b/layouts/community/split_3x6_3/drashna/config.h
index b86448c67..cfcb873a8 100644
--- a/layouts/community/split_3x6_3/drashna/config.h
+++ b/layouts/community/split_3x6_3/drashna/config.h
@@ -93,3 +93,7 @@
93#endif 93#endif
94 94
95#define TAPPING_TERM_PER_KEY 95#define TAPPING_TERM_PER_KEY
96#ifdef TAPPING_TERM
97# undef TAPPING_TERM
98#endif
99#define TAPPING_TERM 200
diff --git a/layouts/community/split_3x6_3/drashna/keymap.c b/layouts/community/split_3x6_3/drashna/keymap.c
index 7c31972e3..476ca5fce 100644
--- a/layouts/community/split_3x6_3/drashna/keymap.c
+++ b/layouts/community/split_3x6_3/drashna/keymap.c
@@ -90,7 +90,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
90 KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET, 90 KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET,
91 VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST, 91 VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST,
92 KEYLOCK, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL, 92 KEYLOCK, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL,
93 HPT_TOG, KC_NUKE, _______, _______, TG_MODS, HPT_FBK 93 AUTO_CTN,KC_NUKE, _______, _______, TG_MODS, HPT_FBK
94 ) 94 )
95}; 95};
96// clang-format on 96// clang-format on
@@ -265,7 +265,7 @@ void check_default_layer(uint8_t mode, uint8_t type, uint8_t led_min, uint8_t le
265 } 265 }
266} 266}
267 267
268void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { 268bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
269 if (userspace_config.rgb_layer_change) { 269 if (userspace_config.rgb_layer_change) {
270 switch (get_highest_layer(layer_state)) { 270 switch (get_highest_layer(layer_state)) {
271 case _GAMEPAD: 271 case _GAMEPAD:
@@ -291,5 +291,6 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
291 } 291 }
292 check_default_layer(0, LED_FLAG_MODIFIER, led_min, led_max); 292 check_default_layer(0, LED_FLAG_MODIFIER, led_min, led_max);
293 } 293 }
294 return false;
294} 295}
295#endif 296#endif
diff --git a/layouts/community/split_3x6_3/drashna/rules.mk b/layouts/community/split_3x6_3/drashna/rules.mk
index cf2dfbdc8..9164dcdeb 100644
--- a/layouts/community/split_3x6_3/drashna/rules.mk
+++ b/layouts/community/split_3x6_3/drashna/rules.mk
@@ -1,9 +1,8 @@
1
2# Build Options 1# Build Options
3# change to "no" to disable the options, or define them in the Makefile in 2# change to "no" to disable the options
4# the appropriate keymap folder that will get included automatically
5# 3#
6BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite 4
5BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
7MOUSEKEY_ENABLE = no # Mouse keys 6MOUSEKEY_ENABLE = no # Mouse keys
8EXTRAKEY_ENABLE = yes # Audio control and System control 7EXTRAKEY_ENABLE = yes # Audio control and System control
9CONSOLE_ENABLE = no # Console for debug 8CONSOLE_ENABLE = no # Console for debug
@@ -12,27 +11,25 @@ NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see her
12BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
13AUDIO_ENABLE = no # Audio output 12AUDIO_ENABLE = no # Audio output
14UNICODE_ENABLE = no # Unicode 13UNICODE_ENABLE = no # Unicode
15BLUETOOTH_ENABLE = no # Enable Bluetooth
16RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. 14RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
17SWAP_HANDS_ENABLE = no # Enable one-hand typing 15SWAP_HANDS_ENABLE = no # Enable one-hand typing
18 16
19# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
20SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
21
22ifeq ($(strip $(KEYBOARD)), crkbd/rev1) 17ifeq ($(strip $(KEYBOARD)), crkbd/rev1)
23 OLED_ENABLE = yes 18 OLED_ENABLE = yes
24 RGB_MATRIX_ENABLE = yes 19 RGB_MATRIX_ENABLE = yes
25 HAPTIC_ENABLE = no 20 HAPTIC_ENABLE = no
26endif 21endif
27 22
28ifeq ($(strip $(CTPC)), yes) 23ifeq ($(strip $(CTPC)), yes)
29 HAPTIC_ENABLE = no 24 HAPTIC_ENABLE = no
30 WS2812_DRIVER = pwm # won't work without a patch to the ctpc mk file 25 WS2812_DRIVER = pwm # won't work without a patch to the ctpc mk file
31 SERIAL_DRIVER = usart 26 SERIAL_DRIVER = usart
32 SWAP_HANDS_ENABLE = yes 27 SWAP_HANDS_ENABLE = yes
33 WPM_ENABLE = yes 28 WPM_ENABLE = yes
29 AUTOCORRECTION_ENABLE = yes
30 CAPS_WORD_ENABLE = yes
34else 31else
35 CUSTOM_UNICODE_ENABLE = no 32 CUSTOM_UNICODE_ENABLE = no
36 BOOTLOADER = qmk-hid 33 BOOTLOADER = qmk-hid
37 BOOTLOADER_SIZE = 512 34 BOOTLOADER_SIZE = 512
38endif 35endif
diff --git a/users/drashna/callbacks.c b/users/drashna/callbacks.c
new file mode 100644
index 000000000..48b076b6b
--- /dev/null
+++ b/users/drashna/callbacks.c
@@ -0,0 +1,215 @@
1// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "drashna.h"
5
6__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
7void keyboard_pre_init_user(void) {
8 userspace_config.raw = eeconfig_read_user();
9 keyboard_pre_init_keymap();
10}
11// Add reconfigurable functions here, for keymap customization
12// This allows for a global, userspace functions, and continued
13// customization of the keymap. Use _keymap instead of _user
14// functions in the keymaps
15// Call user matrix init, set default RGB colors and then
16// call the keymap's init function
17__attribute__((weak)) void matrix_init_keymap(void) {}
18__attribute__((weak)) void matrix_init_secret(void) {}
19void matrix_init_user(void) {
20#if defined(BOOTLOADER_CATERINA) && defined(__AVR__) && defined(__AVR_ATmega32U4__)
21 DDRD &= ~(1 << 5);
22 PORTD &= ~(1 << 5);
23
24 DDRB &= ~(1 << 0);
25 PORTB &= ~(1 << 0);
26#endif
27#ifdef CUSTOM_UNICODE_ENABLE
28 matrix_init_unicode();
29#endif
30 matrix_init_secret();
31 matrix_init_keymap();
32}
33
34__attribute__((weak)) void keyboard_post_init_keymap(void) {}
35void keyboard_post_init_user(void) {
36#if defined(RGBLIGHT_ENABLE)
37 keyboard_post_init_rgb_light();
38#endif
39#if defined(RGB_MATRIX_ENABLE)
40 keyboard_post_init_rgb_matrix();
41#endif
42#if defined(SPLIT_KEYBOARD) && defined(SPLIT_TRANSACTION_IDS_USER)
43 keyboard_post_init_transport_sync();
44#endif
45 keyboard_post_init_keymap();
46}
47
48#ifdef RGB_MATRIX_ENABLE
49void rgb_matrix_update_pwm_buffers(void);
50#endif
51
52__attribute__((weak)) void shutdown_keymap(void) {}
53void shutdown_user(void) {
54#ifdef RGBLIGHT_ENABLE
55 rgblight_enable_noeeprom();
56 rgblight_mode_noeeprom(1);
57 rgblight_setrgb_red();
58#endif // RGBLIGHT_ENABLE
59#ifdef RGB_MATRIX_ENABLE
60 rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
61 rgb_matrix_update_pwm_buffers();
62#endif // RGB_MATRIX_ENABLE
63#ifdef OLED_ENABLE
64 oled_off();
65#endif
66
67 shutdown_keymap();
68}
69
70__attribute__((weak)) void suspend_power_down_keymap(void) {}
71
72void suspend_power_down_user(void) {
73#ifdef OLED_ENABLE
74 oled_off();
75#endif
76 suspend_power_down_keymap();
77}
78
79__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
80void suspend_wakeup_init_user(void) {
81 if (layer_state_is(_GAMEPAD)) {
82 layer_off(_GAMEPAD);
83 }
84 if (layer_state_is(_DIABLO)) {
85 layer_off(_DIABLO);
86 }
87 suspend_wakeup_init_keymap();
88}
89
90// No global matrix scan code, so just run keymap's matrix
91// scan function
92__attribute__((weak)) void matrix_scan_keymap(void) {}
93__attribute__((weak)) void matrix_scan_secret(void) {}
94void matrix_scan_user(void) {
95 static bool has_ran_yet;
96 if (!has_ran_yet) {
97 has_ran_yet = true;
98 startup_user();
99 }
100
101#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
102 run_diablo_macro_check();
103#endif // TAP_DANCE_ENABLE
104
105#if defined(RGBLIGHT_ENABLE)
106 matrix_scan_rgb_light();
107#endif // RGBLIGHT_ENABLE
108#if defined(RGB_MATRIX_ENABLE)
109 matrix_scan_rgb_matrix();
110#endif
111#if defined(POINTING_DEVICE_ENABLE)
112 matrix_scan_pointing();
113#endif
114
115 matrix_scan_secret();
116
117 matrix_scan_keymap();
118}
119
120#ifdef AUDIO_ENABLE
121float doom_song[][2] = SONG(E1M1_DOOM);
122#endif
123
124// on layer change, no matter where the change was initiated
125// Then runs keymap's layer change check
126__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
127layer_state_t layer_state_set_user(layer_state_t state) {
128 if (!is_keyboard_master()) {
129 return state;
130 }
131
132 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
133#if defined(POINTING_DEVICE_ENABLE)
134 state = layer_state_set_pointing(state);
135#endif
136#if defined(RGBLIGHT_ENABLE)
137 state = layer_state_set_rgb_light(state);
138#endif // RGBLIGHT_ENABLE
139#if defined(AUDIO_ENABLE) && !defined(__arm__)
140 static bool is_gamepad_on = false;
141 if (layer_state_cmp(state, _GAMEPAD) != is_gamepad_on) {
142 is_gamepad_on = layer_state_cmp(state, _GAMEPAD);
143 if (is_gamepad_on) {
144 PLAY_LOOP(doom_song);
145 } else {
146 stop_all_notes();
147 }
148 }
149#endif
150 state = layer_state_set_keymap(state);
151 return state;
152}
153
154// Runs state check and changes underglow color and animation
155__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
156layer_state_t default_layer_state_set_user(layer_state_t state) {
157 if (!is_keyboard_master()) {
158 return state;
159 }
160
161 state = default_layer_state_set_keymap(state);
162#if 0
163# if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
164 state = default_layer_state_set_rgb(state);
165# endif // RGBLIGHT_ENABLE
166#endif
167 return state;
168}
169
170__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
171void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
172
173__attribute__((weak)) void eeconfig_init_keymap(void) {}
174void eeconfig_init_user(void) {
175 userspace_config.raw = 0;
176 userspace_config.rgb_layer_change = true;
177 eeconfig_update_user(userspace_config.raw);
178 eeconfig_init_keymap();
179}
180
181#ifdef SPLIT_KEYBOARD
182__attribute__((weak)) void matrix_slave_scan_keymap(void) {}
183void matrix_slave_scan_user(void) {
184# if defined(AUDIO_ENABLE)
185# if !defined(NO_MUSIC_MODE)
186 music_task();
187# endif
188# ifdef AUDIO_INIT_DELAY
189 if (!is_keyboard_master()) {
190 static bool delayed_tasks_run = false;
191 static uint16_t delayed_task_timer = 0;
192 if (!delayed_tasks_run) {
193 if (!delayed_task_timer) {
194 delayed_task_timer = timer_read();
195 } else if (timer_elapsed(delayed_task_timer) > 300) {
196 audio_startup();
197 delayed_tasks_run = true;
198 }
199 }
200 }
201# endif
202# endif
203# ifdef SEQUENCER_ENABLE
204 sequencer_task();
205# endif
206# ifdef LED_MATRIX_ENABLE
207 led_matrix_task();
208# endif
209# ifdef HAPTIC_ENABLE
210 haptic_task();
211# endif
212
213 matrix_slave_scan_keymap();
214}
215#endif
diff --git a/users/drashna/callbacks.h b/users/drashna/callbacks.h
new file mode 100644
index 000000000..f6ac6b88d
--- /dev/null
+++ b/users/drashna/callbacks.h
@@ -0,0 +1,25 @@
1// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "quantum.h"
7
8void matrix_init_keymap(void);
9void matrix_init_secret(void);
10void shutdown_keymap(void);
11void suspend_power_down_keymap(void);
12void suspend_wakeup_init_keymap(void);
13void matrix_scan_keymap(void);
14void matrix_scan_secret(void);
15layer_state_t layer_state_set_keymap(layer_state_t state);
16layer_state_t default_layer_state_set_keymap(layer_state_t state);
17void led_set_keymap(uint8_t usb_led);
18void eeconfig_init_keymap(void);
19
20#ifdef CUSTOM_UNICODE_ENABLE
21void matrix_init_unicode(void);
22#endif
23#ifdef SPLIT_KEYBOARD
24void matrix_slave_scan_keymap(void);
25#endif
diff --git a/users/drashna/callbacks.md b/users/drashna/callbacks.md
new file mode 100644
index 000000000..a0f0d9fda
--- /dev/null
+++ b/users/drashna/callbacks.md
@@ -0,0 +1,71 @@
1# Custom Userspace Callback Functions
2
3Specifically QMK works by using customized callback functions for everything. This allows for multiple levels of customization.
4
5`matrix_scan` calls `matrix_scan_quantum`, which calls `matrix_scan_kb`, which calls `matrix_scan_user`.
6`process_record` calls a bunch of stuff, but eventually calls `process_record_kb` which calls `process_record_user`
7The same goes for `matrix_init`, `layer_state_set`, `led_set`, and a few other functions.
8
9All (most) `_user` functions are handled here, in the userspace instead. To allow keyboard specific configuration, I've created `_keymap` functions that can be called by the keymap.c files instead.
10
11This allows for keyboard specific configuration while maintaining the ability to customize the board.
12
13My [Ergodox EZ Keymap](https://github.com/qmk/qmk_firmware/blob/master/layouts/community/ergodox/drashna/keymap.c) is a good example of this, as it uses the LEDs as modifier indicators.
14
15You can see a list of these files in [callbacks.c](callbacks.c), or a shortend list here
16
17```c
18__attribute__((weak)) void matrix_init_keymap(void) {}
19void matrix_init_user(void) {
20 matrix_init_keymap();
21}
22
23__attribute__((weak)) void keyboard_post_init_keymap(void) {}
24void keyboard_post_init_user(void) {
25 keyboard_post_init_keymap();
26}
27
28__attribute__((weak)) void matrix_scan_keymap(void) {}
29void matrix_scan_user(void) {
30 matrix_scan_keymap();
31}
32
33__attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
34bool process_record_user(uint16_t keycode, keyrecord_t *record) {
35 if (!process_record_keymap(keycode, record)) { return false; }
36 return true;
37}
38
39__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
40layer_state_t layer_state_set_user(layer_state_t state) {
41 state = layer_state_set_keymap(state);
42 return state;
43}
44
45__attribute__ ((weak)) void led_set_keymap(uint8_t usb_led) {}
46void led_set_user(uint8_t usb_led) {
47 led_set_keymap(usb_led);
48}
49
50__attribute__ ((weak)) void suspend_power_down_keymap(void) {}
51void suspend_power_down_user(void) {
52 suspend_power_down_keymap();
53}
54
55__attribute__ ((weak)) void suspend_wakeup_init_keymap(void) {}
56void suspend_wakeup_init_user(void) {
57 suspend_wakeup_init_keymap();
58}
59
60
61__attribute__ ((weak)) void shutdown_keymap(void) {}
62void shutdown_user (void) {
63 shutdown_keymap();
64}
65
66__attribute__ ((weak)) void eeconfig_init_keymap(void) {}
67void eeconfig_init_user(void) {
68 eeconfig_update_user(0);
69 eeconfig_init_keymap();
70}
71```
diff --git a/users/drashna/config.h b/users/drashna/config.h
index cc8f9ac83..46cd276dd 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -1,24 +1,16 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18 5
19// Use custom magic number so that when switching branches, EEPROM always gets reset 6// Use custom magic number so that when switching branches, EEPROM always gets reset
20#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1339 7#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1339
21 8
9#ifdef IS_COMMAND
10#undef IS_COMMAND
11#endif
12#define IS_COMMAND() (((get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) == MOD_MASK_SHIFT)
13
22/* Set Polling rate to 1000Hz */ 14/* Set Polling rate to 1000Hz */
23#define USB_POLLING_INTERVAL_MS 1 15#define USB_POLLING_INTERVAL_MS 1
24 16
@@ -37,7 +29,7 @@
37# define SELECT_SOFT_SERIAL_SPEED 1 29# define SELECT_SOFT_SERIAL_SPEED 1
38# endif 30# endif
39# ifdef CUSTOM_SPLIT_TRANSPORT_SYNC 31# ifdef CUSTOM_SPLIT_TRANSPORT_SYNC
40# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC 32# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC, RPC_ID_USER_WATCHDOG_SYNC
41# endif 33# endif
42#endif 34#endif
43 35
@@ -251,17 +243,6 @@
251# define TAPPING_TOGGLE 1 243# define TAPPING_TOGGLE 1
252#endif 244#endif
253 245
254#ifdef TAPPING_TERM
255# undef TAPPING_TERM
256#endif // TAPPING_TERM
257#if defined(KEYBOARD_ergodox_ez)
258# define TAPPING_TERM 185
259#elif defined(KEYBOARD_crkbd)
260# define TAPPING_TERM 200
261#else
262# define TAPPING_TERM 175
263#endif
264
265#define TAP_CODE_DELAY 5 246#define TAP_CODE_DELAY 5
266 247
267/* Disable unused and unneeded features to reduce on firmware size */ 248/* Disable unused and unneeded features to reduce on firmware size */
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 9c1233ed9..9128a89bc 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "drashna.h" 4#include "drashna.h"
18 5
@@ -49,182 +36,6 @@ bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this
49 return false; 36 return false;
50} 37}
51 38
52__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
53void keyboard_pre_init_user(void) {
54 userspace_config.raw = eeconfig_read_user();
55 keyboard_pre_init_keymap();
56}
57// Add reconfigurable functions here, for keymap customization
58// This allows for a global, userspace functions, and continued
59// customization of the keymap. Use _keymap instead of _user
60// functions in the keymaps
61// Call user matrix init, set default RGB colors and then
62// call the keymap's init function
63__attribute__((weak)) void matrix_init_keymap(void) {}
64__attribute__((weak)) void matrix_init_secret(void) {}
65void matrix_init_user(void) {
66#if defined(BOOTLOADER_CATERINA) && defined(__AVR__)
67 DDRD &= ~(1 << 5);
68 PORTD &= ~(1 << 5);
69
70 DDRB &= ~(1 << 0);
71 PORTB &= ~(1 << 0);
72#endif
73#ifdef CUSTOM_UNICODE_ENABLE
74 matrix_init_unicode();
75#endif
76 matrix_init_secret();
77 matrix_init_keymap();
78}
79
80__attribute__((weak)) void keyboard_post_init_keymap(void) {}
81void keyboard_post_init_user(void) {
82#if defined(RGBLIGHT_ENABLE)
83 keyboard_post_init_rgb_light();
84#endif
85#if defined(RGB_MATRIX_ENABLE)
86 keyboard_post_init_rgb_matrix();
87#endif
88#if defined(SPLIT_KEYBOARD) && defined(SPLIT_TRANSACTION_IDS_USER)
89 keyboard_post_init_transport_sync();
90#endif
91 keyboard_post_init_keymap();
92}
93
94#ifdef RGB_MATRIX_ENABLE
95void rgb_matrix_update_pwm_buffers(void);
96#endif
97
98__attribute__((weak)) void shutdown_keymap(void) {}
99void shutdown_user(void) {
100#ifdef RGBLIGHT_ENABLE
101 rgblight_enable_noeeprom();
102 rgblight_mode_noeeprom(1);
103 rgblight_setrgb_red();
104#endif // RGBLIGHT_ENABLE
105#ifdef RGB_MATRIX_ENABLE
106 rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
107 rgb_matrix_update_pwm_buffers();
108#endif // RGB_MATRIX_ENABLE
109#ifdef OLED_ENABLE
110 oled_off();
111#endif
112
113 shutdown_keymap();
114}
115
116__attribute__((weak)) void suspend_power_down_keymap(void) {}
117
118void suspend_power_down_user(void) {
119#ifdef OLED_ENABLE
120 oled_off();
121#endif
122 suspend_power_down_keymap();
123}
124
125__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
126void suspend_wakeup_init_user(void) {
127 if (layer_state_is(_GAMEPAD)) {
128 layer_off(_GAMEPAD);
129 }
130 if (layer_state_is(_DIABLO)) {
131 layer_off(_DIABLO);
132 }
133 suspend_wakeup_init_keymap();
134}
135
136// No global matrix scan code, so just run keymap's matrix
137// scan function
138__attribute__((weak)) void matrix_scan_keymap(void) {}
139__attribute__((weak)) void matrix_scan_secret(void) {}
140void matrix_scan_user(void) {
141 static bool has_ran_yet;
142 if (!has_ran_yet) {
143 has_ran_yet = true;
144 startup_user();
145 }
146
147#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
148 run_diablo_macro_check();
149#endif // TAP_DANCE_ENABLE
150
151#if defined(RGBLIGHT_ENABLE)
152 matrix_scan_rgb_light();
153#endif // RGBLIGHT_ENABLE
154#if defined(RGB_MATRIX_ENABLE)
155 matrix_scan_rgb_matrix();
156#endif
157#if defined(POINTING_DEVICE_ENABLE)
158 matrix_scan_pointing();
159#endif
160
161 matrix_scan_secret();
162
163 matrix_scan_keymap();
164}
165
166#ifdef AUDIO_ENABLE
167float doom_song[][2] = SONG(E1M1_DOOM);
168#endif
169
170// on layer change, no matter where the change was initiated
171// Then runs keymap's layer change check
172__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
173layer_state_t layer_state_set_user(layer_state_t state) {
174 if (!is_keyboard_master()) {
175 return state;
176 }
177
178 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
179#if defined(POINTING_DEVICE_ENABLE)
180 state = layer_state_set_pointing(state);
181#endif
182#if defined(RGBLIGHT_ENABLE)
183 state = layer_state_set_rgb_light(state);
184#endif // RGBLIGHT_ENABLE
185#if defined(AUDIO_ENABLE) && !defined(__arm__)
186 static bool is_gamepad_on = false;
187 if (layer_state_cmp(state, _GAMEPAD) != is_gamepad_on) {
188 is_gamepad_on = layer_state_cmp(state, _GAMEPAD);
189 if (is_gamepad_on) {
190 PLAY_LOOP(doom_song);
191 } else {
192 stop_all_notes();
193 }
194 }
195#endif
196 state = layer_state_set_keymap(state);
197 return state;
198}
199
200// Runs state check and changes underglow color and animation
201__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
202layer_state_t default_layer_state_set_user(layer_state_t state) {
203 if (!is_keyboard_master()) {
204 return state;
205 }
206
207 state = default_layer_state_set_keymap(state);
208#if 0
209# if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
210 state = default_layer_state_set_rgb(state);
211# endif // RGBLIGHT_ENABLE
212#endif
213 return state;
214}
215
216__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
217void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
218
219__attribute__((weak)) void eeconfig_init_keymap(void) {}
220void eeconfig_init_user(void) {
221 userspace_config.raw = 0;
222 userspace_config.rgb_layer_change = true;
223 eeconfig_update_user(userspace_config.raw);
224 eeconfig_init_keymap();
225 keyboard_init();
226}
227
228bool hasAllBitsInMask(uint8_t value, uint8_t mask) { 39bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
229 value &= 0xF; 40 value &= 0xF;
230 mask &= 0xF; 41 mask &= 0xF;
@@ -232,96 +43,10 @@ bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
232 return (value & mask) == mask; 43 return (value & mask) == mask;
233} 44}
234 45
235#ifdef SPLIT_KEYBOARD 46void tap_code16_nomods(uint8_t kc) {
236__attribute__((weak)) void matrix_slave_scan_keymap(void) {} 47 uint8_t temp_mod = get_mods();
237void matrix_slave_scan_user(void) { 48 clear_mods();
238# if defined(AUDIO_ENABLE) 49 clear_oneshot_mods();
239# if !defined(NO_MUSIC_MODE) 50 tap_code16(kc);
240 music_task(); 51 set_mods(temp_mod);
241# endif
242# ifdef AUDIO_INIT_DELAY
243 if (!is_keyboard_master()) {
244 static bool delayed_tasks_run = false;
245 static uint16_t delayed_task_timer = 0;
246 if (!delayed_tasks_run) {
247 if (!delayed_task_timer) {
248 delayed_task_timer = timer_read();
249 } else if (timer_elapsed(delayed_task_timer) > 300) {
250 audio_startup();
251 delayed_tasks_run = true;
252 }
253 }
254 }
255# endif
256# endif
257# ifdef SEQUENCER_ENABLE
258 sequencer_task();
259# endif
260# ifdef LED_MATRIX_ENABLE
261 led_matrix_task();
262# endif
263# ifdef HAPTIC_ENABLE
264 haptic_task();
265# endif
266
267 matrix_slave_scan_keymap();
268}
269#endif
270
271__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
272 switch (keycode) {
273 default:
274 return TAPPING_TERM;
275 }
276}
277
278__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) {
279 // Immediately select the hold action when another key is tapped:
280 // return true;
281 // Do not select the hold action when another key is tapped.
282 // return false;
283 switch (keycode) {
284 default:
285 return false;
286 }
287}
288
289__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
290 // Immediately select the hold action when another key is pressed.
291 // return true;
292 // Do not select the hold action when another key is pressed.
293 // return false;
294 switch (keycode) {
295 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
296 return true;
297 default:
298 return false;
299 }
300}
301
302__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
303 // Do not force the mod-tap key press to be handled as a modifier
304 // if any other key was pressed while the mod-tap key is held down.
305 // return true;
306 // Force the mod-tap key press to be handled as a modifier if any
307 // other key was pressed while the mod-tap key is held down.
308 // return false;
309 switch (keycode) {
310 default:
311 return true;
312 }
313}
314
315__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
316 switch (keycode) {
317 default:
318 return false;
319 }
320}
321
322__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
323 switch (keycode) {
324 default:
325 return false;
326 }
327} 52}
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index 7bcae881e..5a9da1627 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18#include QMK_KEYBOARD_H 5#include QMK_KEYBOARD_H
@@ -20,6 +7,8 @@
20#include "eeprom.h" 7#include "eeprom.h"
21#include "keyrecords/wrappers.h" 8#include "keyrecords/wrappers.h"
22#include "keyrecords/process_records.h" 9#include "keyrecords/process_records.h"
10#include "callbacks.h"
11
23#ifdef TAP_DANCE_ENABLE 12#ifdef TAP_DANCE_ENABLE
24# include "keyrecords/tap_dances.h" 13# include "keyrecords/tap_dances.h"
25#endif // TAP_DANCE_ENABLE 14#endif // TAP_DANCE_ENABLE
@@ -58,7 +47,7 @@ enum userspace_layers {
58 _ADJUST, 47 _ADJUST,
59}; 48};
60 49
61#define _MACROS _MOUSE 50#define _MACROS _MOUSE
62#define _DEFAULT_LAYER_1 FIRST_DEFAULT_LAYER 51#define _DEFAULT_LAYER_1 FIRST_DEFAULT_LAYER
63#define _DEFAULT_LAYER_2 (FIRST_DEFAULT_LAYER + 1) 52#define _DEFAULT_LAYER_2 (FIRST_DEFAULT_LAYER + 1)
64#define _DEFAULT_LAYER_3 (FIRST_DEFAULT_LAYER + 2) 53#define _DEFAULT_LAYER_3 (FIRST_DEFAULT_LAYER + 2)
@@ -86,23 +75,10 @@ enum userspace_layers {
86#define DEFAULT_LAYER_3_RGB RGB_MAGENTA 75#define DEFAULT_LAYER_3_RGB RGB_MAGENTA
87#define DEFAULT_LAYER_4_RGB RGB_GOLDENROD 76#define DEFAULT_LAYER_4_RGB RGB_GOLDENROD
88 77
89bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed); 78bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed);
90bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer); 79bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer);
91void matrix_init_keymap(void); 80bool hasAllBitsInMask(uint8_t value, uint8_t mask);
92void matrix_init_secret(void); 81void tap_code16_nomods(uint8_t kc);
93void shutdown_keymap(void);
94void suspend_power_down_keymap(void);
95void suspend_wakeup_init_keymap(void);
96void matrix_scan_keymap(void);
97void matrix_scan_secret(void);
98layer_state_t layer_state_set_keymap(layer_state_t state);
99layer_state_t default_layer_state_set_keymap(layer_state_t state);
100void led_set_keymap(uint8_t usb_led);
101void eeconfig_init_keymap(void);
102bool hasAllBitsInMask(uint8_t value, uint8_t mask);
103#ifdef SPLIT_KEYBOARD
104void matrix_slave_scan_keymap(void);
105#endif
106 82
107// clang-format off 83// clang-format off
108typedef union { 84typedef union {
@@ -119,20 +95,3 @@ typedef union {
119// clang-format on 95// clang-format on
120 96
121extern userspace_config_t userspace_config; 97extern userspace_config_t userspace_config;
122
123/*
124Custom Keycodes for Diablo 3 layer
125But since TD() doesn't work when tap dance is disabled
126We use custom codes here, so we can substitute the right stuff
127*/
128#ifdef TAP_DANCE_ENABLE
129# define KC_D3_1 TD(TD_D3_1)
130# define KC_D3_2 TD(TD_D3_2)
131# define KC_D3_3 TD(TD_D3_3)
132# define KC_D3_4 TD(TD_D3_4)
133#else // TAP_DANCE_ENABLE
134# define KC_D3_1 KC_1
135# define KC_D3_2 KC_2
136# define KC_D3_3 KC_3
137# define KC_D3_4 KC_4
138#endif // TAP_DANCE_ENABLE
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c
index 7c8c28c67..e56122437 100644
--- a/users/drashna/keyrecords/autocorrection/autocorrection.c
+++ b/users/drashna/keyrecords/autocorrection/autocorrection.c
@@ -1,5 +1,5 @@
1// Copyright 2021 Google LLC 1// Copyright 2021 Google LLC
2// Copyright 2022 @filterpaper 2// Copyright 2021 @filterpaper
3// SPDX-License-Identifier: Apache-2.0 3// SPDX-License-Identifier: Apache-2.0
4// Original source: https://getreuer.info/posts/keyboards/autocorrection 4// Original source: https://getreuer.info/posts/keyboards/autocorrection
5 5
@@ -7,10 +7,15 @@
7#include <string.h> 7#include <string.h>
8 8
9#if __has_include("autocorrection_data.h") 9#if __has_include("autocorrection_data.h")
10# pragma GCC push_options
11# pragma GCC optimize("O0")
10# include "autocorrection_data.h" 12# include "autocorrection_data.h"
11# if AUTOCORRECTION_MIN_LENGTH < 4 13# if AUTOCORRECTION_MIN_LENGTH < 4
12# error Minimum Length is too short and may cause overflows 14# error Minimum Length is too short and may cause overflows
13# endif 15# endif
16# if DICTIONARY_SIZE > SIZE_MAX
17# error Dictionary size excees maximum size permitted
18# endif
14 19
15bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { 20bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
16 static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC}; 21 static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC};
@@ -55,11 +60,17 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
55 } 60 }
56# endif 61# endif
57 default: 62 default:
63 // Disable autocorrection while a mod other than shift is active.
64 if (((get_mods() | get_oneshot_mods()) & ~MOD_MASK_SHIFT) != 0) {
65 typo_buffer_size = 0;
66 return true;
67 }
58 if (!record->event.pressed) { 68 if (!record->event.pressed) {
59 return true; 69 return true;
60 } 70 }
61 } 71 }
62 72
73
63 // Subtract buffer for Backspace key, reset for other non-alpha. 74 // Subtract buffer for Backspace key, reset for other non-alpha.
64 if (!(KC_A <= keycode && keycode <= KC_Z)) { 75 if (!(KC_A <= keycode && keycode <= KC_Z)) {
65 if (keycode == KC_BSPC) { 76 if (keycode == KC_BSPC) {
@@ -137,6 +148,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
137 } 148 }
138 return true; 149 return true;
139} 150}
151# pragma GCC pop_options
140#else 152#else
141# pragma message "Warning!!! Autocorrect is not corretly setup!" 153# pragma message "Warning!!! Autocorrect is not corretly setup!"
142bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { return true; } 154bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { return true; }
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.h b/users/drashna/keyrecords/autocorrection/autocorrection.h
index 57685eb4b..cea93159a 100644
--- a/users/drashna/keyrecords/autocorrection/autocorrection.h
+++ b/users/drashna/keyrecords/autocorrection/autocorrection.h
@@ -1,5 +1,5 @@
1// Copyright 2021 Google LLC 1// Copyright 2021 Google LLC
2// Copyright 2022 @filterpaper 2// Copyright 2021 @filterpaper
3// SPDX-License-Identifier: Apache-2.0 3// SPDX-License-Identifier: Apache-2.0
4// Original source: https://getreuer.info/posts/keyboards/autocorrection 4// Original source: https://getreuer.info/posts/keyboards/autocorrection
5 5
diff --git a/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py b/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py
index 27383b895..54fd9ba59 100755
--- a/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py
+++ b/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py
@@ -252,8 +252,9 @@ def write_generated_code(autocorrections: List[Tuple[str, str]],
252 for typo, correction in autocorrections)), 252 for typo, correction in autocorrections)),
253 f'\n#define AUTOCORRECTION_MIN_LENGTH {len(min_typo)} // "{min_typo}"\n', 253 f'\n#define AUTOCORRECTION_MIN_LENGTH {len(min_typo)} // "{min_typo}"\n',
254 f'#define AUTOCORRECTION_MAX_LENGTH {len(max_typo)} // "{max_typo}"\n\n', 254 f'#define AUTOCORRECTION_MAX_LENGTH {len(max_typo)} // "{max_typo}"\n\n',
255 textwrap.fill('static const uint8_t autocorrection_data[%d] PROGMEM = {%s};' % ( 255 f'#define DICTIONARY_SIZE {len(data)}\n\n',
256 len(data), ', '.join(map(str, data))), width=80, subsequent_indent=' '), 256 textwrap.fill('static const uint8_t autocorrection_data[DICTIONARY_SIZE] PROGMEM = {%s};' % (
257 ', '.join(map(str, data))), width=120, subsequent_indent=' '),
257 '\n\n']) 258 '\n\n'])
258 259
259 with open(file_name, 'wt') as f: 260 with open(file_name, 'wt') as f:
diff --git a/users/drashna/keyrecords/autocorrection/readme.md b/users/drashna/keyrecords/autocorrection/readme.md
new file mode 100644
index 000000000..d92050879
--- /dev/null
+++ b/users/drashna/keyrecords/autocorrection/readme.md
@@ -0,0 +1,301 @@
1# Autocorrection
2
3This is taken from [Pascal Getreuer's implemenation](https://getreuer.info/posts/keyboards/autocorrection/index.html), with a number of modifications.
4
5To enabled Autocorrection, add `AUTOCORRECTION_ENABLE = yes` to your `rules.mk` file.
6
7This is mostly a reproduction of Pascal's docs:
8
9## Overview
10Some words are more prone to typos than others. I have a habit of typo-ing *ouput* and *fitler*. This post describes a rudimentary autocorrection implementation that runs on your keyboard with QMK.
11
12The animation below shows the effect as I type *aparent*. As I press the final t, the autocorrection feature detects the typo and automatically sends keys to correct it:
13
14Example: Autocorrecting *aparent* → apparent.
15
16**Features**:
17* It runs on your keyboard, so it is always active no matter what software.
18* Low resource cost: for an autocorrection dictionary of 70 entries, firmware size cost is 1620 bytes and average CPU cost per key press is about 20 µs.
19* It is case insensitive. It corrects Fitler to Filter and FITLER to FILTER.
20* It works within words. It corrects fitlered, fitlering, and useful for programming, within longer identifiers like DesignButterworthFitle*r.
21
22**Limitations**: Running autocorrection on the keyboard comes with some constraints. It is rudimentary like I said:
23* It is limited to alphabet characters a–z. No accented or Unicode letters; I’m sorry this probably isn’t useful for languages besides English.
24* It does not follow mouse or hotkey driven cursor movement.
25
26## Taking autocorrection for a test drive
27With the above flashed to your keyboard, try for instance typing the misspelled word ouput. The instant you type the final t, the word should be speedily autocorrected to output. As further tests, try becuase and invliad.
28
29Here is the full list of typos corrected using the provided autocorrection_data.h file. : is a special character denoting a word break. See below for how to change the autocorrection dictionary.
30
31```
32:guage -> gauge
33:the:the: -> the
34:thier -> their
35:ture -> true
36accomodate -> accommodate
37acommodate -> accommodate
38aparent -> apparent
39aparrent -> apparent
40apparant -> apparent
41apparrent -> apparent
42aquire -> acquire
43becuase -> because
44cauhgt -> caught
45cheif -> chief
46choosen -> chosen
47cieling -> ceiling
48collegue -> colleague
49concensus -> consensus
50contians -> contains
51cosnt -> const
52dervied -> derived
53fales -> false
54fasle -> false
55fitler -> filter
56flase -> false
57foward -> forward
58frequecy -> frequency
59gaurantee -> guarantee
60guaratee -> guarantee
61heigth -> height
62heirarchy -> hierarchy
63inclued -> include
64interator -> iterator
65intput -> input
66invliad -> invalid
67lenght -> length
68liasion -> liaison
69libary -> library
70listner -> listener
71looses: -> loses
72looup -> lookup
73manefist -> manifest
74namesapce -> namespace
75namespcae -> namespace
76occassion -> occasion
77occured -> occurred
78ouptut -> output
79ouput -> output
80overide -> override
81postion -> position
82priviledge -> privilege
83psuedo -> pseudo
84recieve -> receive
85refered -> referred
86relevent -> relevant
87repitition -> repetition
88reuslt -> result
89retrun -> return
90retun -> return
91reutrn -> return
92saftey -> safety
93seperate -> separate
94singed -> signed
95stirng -> string
96strign -> string
97swithc -> switch
98swtich -> switch
99thresold -> threshold
100udpate -> update
101widht -> width
102```
103
104## Firmware size and CPU costs
105I am anxiously aware that a keyboard microcontroller has limited resources. So I was sure to measure how much memory and CPU time autocorrection consumes during development. These measurements are for the example autocorrection dictionary as used above, which has 70 entries:
106* **Firmware size**: Autocorrection increases my firmware size by a total of 1620 bytes. Breaking that down, 1104 bytes are for the autocorrection_data array and 516 bytes for the autocorrection code.
107* **CPU time**: On my Elite-C microcontrollers, the average CPU time for process_autocorrection to process an alpha key press is around 20 µs. Consider this a rough order-of-magnitude cost. Processing cost increases (more trie nodes are visited) when recent input is close to a known typo, with the max being when a long typo is matched.
108
109The costs are not free but reasonable. For reference, the firmware size cost for mouse keys is 2124 bytes and the CPU time to process a layer switch is about 70 µs, so autocorrection is cheaper than those things. Of course, the cost scales with the size of the autocorrection dictionary, so keep that in mind if you add a lot more entries.
110
111## How does it work?
112The function process_autocorrection maintains a small buffer of recent key presses. On each key press, it checks whether the buffer ends in a recognized typo, and if so, automatically sends keystrokes to correct it.
113
114The tricky part is how to efficiently check the buffer for typos. We don’t want to spend too much memory or time on storing or searching the typos. A good solution is to represent the typos with a trie data structure. A trie is a tree data structure where each node is a letter, and words are formed by following a path to one of the leaves.
115
116
117An example trie.
118Since we search whether the buffer ends in a typo, we store the trie writing in reverse. The trie is queried starting from the last letter, then second to last letter, and so on, until either a letter doesn’t match or we reach a leaf, meaning a typo was found.
119
120## Changing the autocorrection dictionary
121The file autocorrection_data.h encodes the typos to correct. While you could simply use the version of this file provided above for a practical configuration, you can make your own to personalize the autocorrection to your most troublesome typos:
122
1231. First, create an autocorrection dictionary autocorrection_dict.txt, like
124
125 ```
126:thier -> their
127fitler -> filter
128lenght -> length
129ouput -> output
130widht -> width
131```
132 For a practical 70-entry example, see autocorrection_dict.txt. And for a yet larger 400-entry example, see autocorrection_dict_extra.txt.
133
134 The syntax is `typo -> correction`. Typos and corrections are case insensitive, and any whitespace before or after the typo and correction is ignored. The typo must be only the letters a–z, or the special character : representing a word break. The correction may have any characters.
135
1362. Use the make_autocorrection_data.py Python script to process the dictionary
137
138```
139$ python3 make_autocorrection_data.py
140Processed 70 autocorrection entries to table with 1104 bytes.
141```
142The script arranges the entries in autocorrection_dict.txt into a trie and generates autocorrection_data.h with the serialized trie embedded as an array.
143
1443. Finally, recompile and flash your keymap.
145
146The generated C header looks like this:
147
148autocorrection_data.h
149```c
150// Generated code.
151
152#define AUTOCORRECTION_MIN_LENGTH 5 // "cheif"
153#define AUTOCORRECTION_MAX_LENGTH 10 // "accomodate"
154
155static const uint8_t autocorrection_data[1104] PROGMEM = {108, 43, 0, 6,
156 71, 0, 7, 81, 0, 8, 199, 0, 9, 240, 1, 10, 250, 1, 11, 26, 2, 17, 53, 2,
157 18, 190, 2, 19, 202, 2, 21, 212, 2, 22, 20, 3, 23, 67, 3, 28, 16, 4, 0,
158 72, 50, 0, 22, 60, 0, 0, 11, 23, 44, 8, 11, 23, 44, 0, 132, 0, 8, 22, 18,
159 18, 15, 0, 132, 115, 101, 115, 0, 11, 23, 12, 26, 22, 0, 129, 99, 104, 0,
160 68, 94, 0, 8, 106, 0, 15, 174, 0, 21, 187, 0, 0, 12, 15, 25, 17, 12, 0,
161 131, 97, 108, 105, 100, 0, 74, 119, 0, 12, 129, 0, 21, 140, 0, 24, 165,
162 0, 0, 17, 12, 22, 0, 131, 103, 110, 101, 100, 0, 25, 21, 8, 7, 0, 131,
163 105, 118, 101, 100, 0, 72, 147, 0, 24, 156, 0, 0, 9, 8, 21, 0, 129, 114,
164 101, 100, 0, 6, 6, 18, 0, 129, 114, 101, 100, 0, 15, 6, 17, 12, 0, 129,
165 100, 101, 0, 18, 22, 8, 21, 11, 23, 0, 130, 104, 111, 108, 100, 0, 4, 26,
166 18, 9, 0, 131, 114, 119, 97, 114, 100, 0, 68, 233, 0, 6, 246, 0, 7, 4, 1,
167 8, 16, 1, 10, 52, 1, 15, 81, 1, 21, 90, 1, 22, 117, 1, 23, 144, 1, 24,
168 215, 1, 25, 228, 1, 0, 6, 19, 22, 8, 16, 4, 17, 0, 130, 97, 99, 101, 0,
169 19, 4, 22, 8, 16, 4, 17, 0, 131, 112, 97, 99, 101, 0, 12, 21, 8, 25, 18,
170 0, 130, 114, 105, 100, 101, 0, 23, 0, 68, 25, 1, 17, 36, 1, 0, 21, 4, 24,
171 10, 0, 130, 110, 116, 101, 101, 0, 4, 21, 24, 4, 10, 0, 135, 117, 97,
172 114, 97, 110, 116, 101, 101, 0, 68, 59, 1, 7, 69, 1, 0, 24, 10, 44, 0,
173 131, 97, 117, 103, 101, 0, 8, 15, 12, 25, 12, 21, 19, 0, 130, 103, 101,
174 0, 22, 4, 9, 0, 130, 108, 115, 101, 0, 76, 97, 1, 24, 109, 1, 0, 24, 20,
175 4, 0, 132, 99, 113, 117, 105, 114, 101, 0, 23, 44, 0, 130, 114, 117, 101,
176 0, 4, 0, 79, 126, 1, 24, 134, 1, 0, 9, 0, 131, 97, 108, 115, 101, 0, 6,
177 8, 5, 0, 131, 97, 117, 115, 101, 0, 4, 0, 71, 156, 1, 19, 193, 1, 21,
178 203, 1, 0, 18, 16, 0, 80, 166, 1, 18, 181, 1, 0, 18, 6, 4, 0, 135, 99,
179 111, 109, 109, 111, 100, 97, 116, 101, 0, 6, 6, 4, 0, 132, 109, 111, 100,
180 97, 116, 101, 0, 7, 24, 0, 132, 112, 100, 97, 116, 101, 0, 8, 19, 8, 22,
181 0, 132, 97, 114, 97, 116, 101, 0, 10, 8, 15, 15, 18, 6, 0, 130, 97, 103,
182 117, 101, 0, 8, 12, 6, 8, 21, 0, 131, 101, 105, 118, 101, 0, 12, 8, 11,
183 6, 0, 130, 105, 101, 102, 0, 17, 0, 76, 3, 2, 21, 16, 2, 0, 15, 8, 12, 6,
184 0, 133, 101, 105, 108, 105, 110, 103, 0, 12, 23, 22, 0, 131, 114, 105,
185 110, 103, 0, 70, 33, 2, 23, 44, 2, 0, 12, 23, 26, 22, 0, 131, 105, 116,
186 99, 104, 0, 10, 12, 8, 11, 0, 129, 104, 116, 0, 72, 69, 2, 10, 80, 2, 18,
187 89, 2, 21, 156, 2, 24, 167, 2, 0, 22, 18, 18, 11, 6, 0, 131, 115, 101,
188 110, 0, 12, 21, 23, 22, 0, 129, 110, 103, 0, 12, 0, 86, 98, 2, 23, 124,
189 2, 0, 68, 105, 2, 22, 114, 2, 0, 12, 15, 0, 131, 105, 115, 111, 110, 0,
190 4, 6, 6, 18, 0, 131, 105, 111, 110, 0, 76, 131, 2, 22, 146, 2, 0, 23, 12,
191 19, 8, 21, 0, 134, 101, 116, 105, 116, 105, 111, 110, 0, 18, 19, 0, 131,
192 105, 116, 105, 111, 110, 0, 23, 24, 8, 21, 0, 131, 116, 117, 114, 110, 0,
193 85, 174, 2, 23, 183, 2, 0, 23, 8, 21, 0, 130, 117, 114, 110, 0, 8, 21, 0,
194 128, 114, 110, 0, 7, 8, 24, 22, 19, 0, 131, 101, 117, 100, 111, 0, 24,
195 18, 18, 15, 0, 129, 107, 117, 112, 0, 72, 219, 2, 18, 3, 3, 0, 76, 229,
196 2, 15, 238, 2, 17, 248, 2, 0, 11, 23, 44, 0, 130, 101, 105, 114, 0, 23,
197 12, 9, 0, 131, 108, 116, 101, 114, 0, 23, 22, 12, 15, 0, 130, 101, 110,
198 101, 114, 0, 23, 4, 21, 8, 23, 17, 12, 0, 135, 116, 101, 114, 97, 116,
199 111, 114, 0, 72, 30, 3, 17, 38, 3, 24, 51, 3, 0, 15, 4, 9, 0, 129, 115,
200 101, 0, 4, 12, 23, 17, 18, 6, 0, 131, 97, 105, 110, 115, 0, 22, 17, 8, 6,
201 17, 18, 6, 0, 133, 115, 101, 110, 115, 117, 115, 0, 74, 86, 3, 11, 96, 3,
202 15, 118, 3, 17, 129, 3, 22, 218, 3, 24, 232, 3, 0, 11, 24, 4, 6, 0, 130,
203 103, 104, 116, 0, 71, 103, 3, 10, 110, 3, 0, 12, 26, 0, 129, 116, 104, 0,
204 17, 8, 15, 0, 129, 116, 104, 0, 22, 24, 8, 21, 0, 131, 115, 117, 108,
205 116, 0, 68, 139, 3, 8, 150, 3, 22, 210, 3, 0, 21, 4, 19, 19, 4, 0, 130,
206 101, 110, 116, 0, 85, 157, 3, 25, 200, 3, 0, 68, 164, 3, 21, 175, 3, 0,
207 19, 4, 0, 132, 112, 97, 114, 101, 110, 116, 0, 4, 19, 0, 68, 185, 3, 19,
208 193, 3, 0, 133, 112, 97, 114, 101, 110, 116, 0, 4, 0, 131, 101, 110, 116,
209 0, 8, 15, 8, 21, 0, 130, 97, 110, 116, 0, 18, 6, 0, 130, 110, 115, 116,
210 0, 12, 9, 8, 17, 4, 16, 0, 132, 105, 102, 101, 115, 116, 0, 83, 239, 3,
211 23, 6, 4, 0, 87, 246, 3, 24, 254, 3, 0, 17, 12, 0, 131, 112, 117, 116, 0,
212 18, 0, 130, 116, 112, 117, 116, 0, 19, 24, 18, 0, 131, 116, 112, 117,
213 116, 0, 70, 29, 4, 8, 41, 4, 11, 51, 4, 21, 69, 4, 0, 8, 24, 20, 8, 21,
214 9, 0, 129, 110, 99, 121, 0, 23, 9, 4, 22, 0, 130, 101, 116, 121, 0, 6,
215 21, 4, 21, 12, 8, 11, 0, 135, 105, 101, 114, 97, 114, 99, 104, 121, 0, 4,
216 5, 12, 15, 0, 130, 114, 97, 114, 121, 0};
217```
218
219## Troubleshooting
220### Avoiding false triggers
221By default, typos are searched within words, to find typos within longer identifiers like maxFitlerOuput. While this is useful, a consequence is that autocorrection will falsely trigger when a typo happens to be a substring of a correctly-spelled word. For instance, if we had thier -> their as an entry, it would falsely trigger on (correct, though relatively uncommon) words like “wealthier” and “filthier.”
222
223The solution is to set a word break : before and/or after the typo to constrain matching. : matches space, period, comma, underscore, digits, and most other non-alpha characters.
224
225| Text | thier | :thier | thier: | :thier: |
226|------|-------|--------|--------|---------|
227|see thier typo|matches|matches|matches|matches|
228it’s thiers |matches|matches|no|no|
229wealthier words|matches|no|matches|no|
230
231:thier: is most restrictive, matching only when thier is a whole word.
232
233The make_autocorrection_data.py script makes an effort to check for entries that would false trigger as substrings of correct words. It searches each typo against a dictionary of 25K English words from the english_words Python package, provided it’s installed.
234
235### Overriding autocorrection
236Occasionally you might actually want to type a typo (for instance, while editing autocorrection_dict.txt) without being autocorrected. Here is a way to do that:
237
2381. Begin typing the typo.
2392. Before typing the last letter, press and release the Ctrl or Alt key.
2403. Type the remaining letters.
241
242This works because the autocorrection implementation doesn’t understand hotkeys, so it resets itself whenever a modifier other than shift is held.
243
244Alternatively, the `AUTO_CTN` keycode will toggle autocorrection on and off.
245
246## Closing thoughts
247Based on my own use, an autocorrection dictionary of a few dozen entries is enough to help in day-to-day writing. On the other hand, it is of course far from comprehensively checking that every word is spelled correctly. Keyboard microcontrollers might not have the resources check against a full English dictionary any time soon, but a lot of editors and other software have good integrated spell check features.
248
249I suggest to enable and use spell check in combination with autocorrection:
250* Sublime: Open the View menu and enable “Spell Check.”
251* Eclipse: Open the Window menu, click Preferences, and search for “Spelling.”
252* Vim: Type :set spell, and misspellings will be highlighted. Use ]s to jump to the next misspelled word and z= to get suggested corrections for the word under the cursor. See the :help spell documentation. Vim also has an abbreviations feature that can autocorrect misspellings (see :help abbreviations).
253* Emacs: Use M-x flyspell-mode to enable Flyspell mode in the current buffer. Or for programming, use M-x flyspell-prog-mode to check comments and strings only. See the spelling documentation. There is also an abbreviations feature that can do autocorrection.
254
255Some useful resources:
256
257* Wikipedia has a [large list of common typos](https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines).
258* EmacsWiki has another [list of typos](https://www.emacswiki.org/emacs/autocorrection_abbrev_defs).
259* You can find data on English word frequencies at https://www.wordfrequency.info/samples.asp.
260
261# Appendix: Trie binary data format
262This section details how the trie is serialized to byte data in autocorrection_data. You don’t need to care about this to use this autocorrection implementation. But I document it for the record in case anyone is interested in modifying the implementation, or just curious how it works.
263
264What I did here is fairly arbitrary, but it is simple to decode and gets the job done.
265
266## Encoding
267All autocorrection data is stored in a single flat array autocorrection_data. Each trie node is associated with a byte offset into this array, where data for that node is encoded, beginning with root at offset 0. There are three kinds of nodes. The highest two bits of the first byte of the node indicate what kind:
268
269* 00 ⇒ chain node: a trie node with a single child.
270* 01 ⇒ branching node: a trie node with multiple children.
271* 10 ⇒ leaf node: a leaf, corresponding to a typo and storing its correction.
272
273An example trie.
274Branching node. Each branch is encoded with one byte for the keycode (KC_A–KC_Z) followed by a link to the child node. Links between nodes are 16-bit byte offsets relative to the beginning of the array, serialized in little endian order.
275
276All branches are serialized this way, one after another, and terminated with a zero byte. As described above, the node is identified as a branch by setting the two high bits of the first byte to 01, done by bitwise ORing the first keycode with 64. keycode. The root node for the above figure would be serialized like:
277
278 +-------+-------+-------+-------+-------+-------+-------+
279 | R|64 | node 2 | T | node 3 | 0 |
280 +-------+-------+-------+-------+-------+-------+-------+
281
282Chain node. Tries tend to have long chains of single-child nodes, as seen in the example above with f-i-t-l in fitler. So to save space, we use a different format to encode chains than branching nodes. A chain is encoded as a string of keycodes, beginning with the node closest to the root, and terminated with a zero byte. The child of the last node in the chain is encoded immediately after. That child could be either a branching node or a leaf.
283
284In the figure above, the f-i-t-l chain is encoded as
285
286 +-------+-------+-------+-------+-------+
287 | L | T | I | F | 0 |
288 +-------+-------+-------+-------+-------+
289If we were to encode this chain using the same format used for branching nodes, we would encode a 16-bit node link with every node, costing 8 more bytes in this example. Across the whole trie, this adds up. Conveniently, we can point to intermediate points in the chain and interpret the bytes in the same way as before. E.g. starting at the i instead of the l, and the subchain has the same format.
290
291Leaf node. A leaf node corresponds to a particular typo and stores data to correct the typo. The leaf begins with a byte for the number of backspaces to type, and is followed by a null-terminated ASCII string of the replacement text. The idea is, after tapping backspace the indicated number of times, we can simply pass this string to QMK’s send_string_P function. For fitler, we need to tap backspace 3 times (not 4, because we catch the typo as the final ‘r’ is pressed) and replace it with lter. To identify the node as a leaf, the two high bits are set to 10 by ORing the backspace count with 128:
292
293 +-------+-------+-------+-------+-------+-------+
294 | 3|128 | 'l' | 't' | 'e' | 'r' | 0 |
295 +-------+-------+-------+-------+-------+-------+
296## Decoding
297This format is by design decodable with fairly simple logic. A 16-bit variable state represents our current position in the trie, initialized with 0 to start at the root node. Then, for each keycode, test the highest two bits in the byte at state to identify the kind of node.
298
299* 00 ⇒ chain node: If the node’s byte matches the keycode, increment state by one to go to the next byte. If the next byte is zero, increment again to go to the following node.
300* 01 ⇒ branching node: Search the branches for one that matches the keycode, and follow its node link.
301* 10 ⇒ leaf node: a typo has been found! We read its first byte for the number of backspaces to type, then pass its following bytes to send_string_P to type the correction.
diff --git a/users/drashna/keyrecords/caps_word.c b/users/drashna/keyrecords/caps_word.c
index 731568328..cc9ca93b7 100644
--- a/users/drashna/keyrecords/caps_word.c
+++ b/users/drashna/keyrecords/caps_word.c
@@ -3,13 +3,17 @@
3 3
4#include "caps_word.h" 4#include "caps_word.h"
5 5
6#ifndef IS_COMMAND
7# define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)
8#endif
9
6bool caps_word_enabled = false; 10bool caps_word_enabled = false;
7bool caps_word_shifted = false; 11bool caps_word_shifted = false;
8 12
9bool process_caps_word(uint16_t keycode, keyrecord_t* record) { 13bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
10 if (!caps_word_enabled) { 14 if (!caps_word_enabled) {
11 // Pressing both shift keys at the same time enables caps word. 15 // Pressing both shift keys at the same time enables caps word.
12 if (((get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) == MOD_MASK_SHIFT) { 16 if (IS_COMMAND()) {
13 clear_mods(); 17 clear_mods();
14 clear_oneshot_mods(); 18 clear_oneshot_mods();
15 caps_word_shifted = false; 19 caps_word_shifted = false;
diff --git a/users/drashna/keyrecords/capwords.md b/users/drashna/keyrecords/capwords.md
new file mode 100644
index 000000000..1ca01ed85
--- /dev/null
+++ b/users/drashna/keyrecords/capwords.md
@@ -0,0 +1,36 @@
1# Cap Words
2
3This is taken from [Pascal Getreuer's implemenation](https://getreuer.info/posts/keyboards/caps-word/index.html), with a number of modifications.
4
5To enable Caps Word, add `CAPS_WORD_ENABLE = yes` to your `rules.mk`.
6
7This is mostly a reproduction of Pascal's docs:
8
9## Overview
10
11All-caps identifiers like “MOD_MASK_ALT” are awkward to type.
12
13Caps Lock would be the standard solution to this problem, but it is awkward: it needs a dedicated key to toggle it (an imposition on smaller keyboards), and we need to remember to toggle it off after typing the word. Or with normal shifting, we either perform finger gymnastics or need to stop typing in the middle of the word to release shift with one hand to switch to holding shift with the other hand. In my experience, this is a nuisance especially if your shift keys are mod-taps, as in home row mods.
14
15Caps Word, implemented here, is a modern alternative to Caps Lock:
16
17* Caps Word is activated by pressing the left and right shift keys at the same time. This way you don’t need a dedicated key for using Caps Word.
18* Caps Word automatically disables itself at the end of the word.
19
20**Compatibility**: I’ve tested that this implementation works with one-shot mods and Space Cadet Shift, and it predictably handles key repeating.
21
22Unlike some other QMK Caps Word implementations, this library does not use the Caps Lock (KC_CAPS) keycode. It works even if the OS remaps Caps Lock to Ctrl or something else, as Emacs and Vim users often do.
23
24## Using Caps Word
25With the above flashed to your keyboard:
26
271. **Activating**: Press and release both left and right shift keys at the same time. If your shift keys are mod-taps, activate Caps Word by holding both shift mod-tap keys until the tapping term, then release them.
282. Then begin typing to get capitalized letters.
293. **Disabling**: Caps Word disables itself when the next word breaking key is typed.
30
31If you want to explicitly stop Caps Word, press and release Ctrl or another non-shift modifier or layer key. This also disables Caps Word.
32
33## Explanation
34The code checks the mod bits on each key event, enabling Caps Word when both left and right shifts are active.
35
36While enabled, Caps Word automatically presses and releases left shift (KC_LSFT) as needed so that letters are shifted and other keys are not. The word continues while typing a–z, 0–9, -, _, and backspace. Any other key is considered “word breaking” and disables Caps Word. You can edit the switch statement at the end of the process_caps_word() function to adjust which keys count as word breaking.
diff --git a/users/drashna/keyrecords/keycodes.md b/users/drashna/keyrecords/keycodes.md
new file mode 100644
index 000000000..348c68e46
--- /dev/null
+++ b/users/drashna/keyrecords/keycodes.md
@@ -0,0 +1,18 @@
1
2# Custom Keycodes
3
4Keycodes are defined in the `process_record.h` file and need to be included in the keymap.c files, so that they can be used there.
5
6A bunch of macros are present and are only included on boards that are not the Ergodox EZ or Orthodox, as they are not needed for those boards.
7
8* `KC_MAKE` - outputs `qmk compile -kb (keyboard) -km (keymap)` and enter, to start compiling the currenct keyboard. This uses generated variables to always use the current keyboard and keymap. Will work with any keyboard and any keymap.
9 * If you are holding shift, it will use `qmk flash` instead of `qmk compile`.
10 * If `MAKE_BOOTLOADER` is defined, it will always use `qmk flash` instead of `qmk compile`.
11* `DEFAULT_LAYER_1` ... `DEFAULT_LAYER_4` - This sets layer 0-3 as the default layer, and writes that to eeprom, and plays a chime.
12* `VRSN`, outputs the keyboard, keymap, commit and date info. Eg:
13 * `handwired/tractyl_manuform/5x6_right/f411/drashna @ 0.15.9-162-g087d08, Built on: 2021-12-19-21:10:26`
14* `KC_DIABLO_CLEAR` - clears the diablo tapdance status.
15* `KC_CCCV` - Copy on hold, paste on tap.
16* `KEYLOCK` - This unloads the host driver, and prevents any data from being sent to the host. Hitting it again loads the driver, back.
17* `REBOOT` - Uses watchdog timer on AVR, and `NVIC_SystemReset()` on ChibiOS to reset the board, without jumping to the bootloader.
18* `EEP_RST` - Overrides the default behavior, disables EEPROM (which will trigger a reset on init), and reboots the keyboard as per `REBOOT` keycode.
diff --git a/users/drashna/keyrecords/process_records.c b/users/drashna/keyrecords/process_records.c
index c7d4a925b..f49ac6ef6 100644
--- a/users/drashna/keyrecords/process_records.c
+++ b/users/drashna/keyrecords/process_records.c
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "drashna.h" 4#include "drashna.h"
18#include "version.h" 5#include "version.h"
@@ -22,6 +9,9 @@
22#ifdef AUTOCORRECTION_ENABLE 9#ifdef AUTOCORRECTION_ENABLE
23# include "autocorrection/autocorrection.h" 10# include "autocorrection/autocorrection.h"
24#endif 11#endif
12#ifdef __AVR__
13#include <avr/wdt.h>
14#endif
25 15
26uint16_t copy_paste_timer; 16uint16_t copy_paste_timer;
27bool host_driver_disabled = false; 17bool host_driver_disabled = false;
@@ -212,6 +202,28 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re
212 } 202 }
213 break; 203 break;
214 } 204 }
205 case EEP_RST:
206 if (record->event.pressed) {
207 eeconfig_disable();
208 shutdown_user();
209#ifdef __AVR__
210 wdt_enable(WDTO_250MS);
211#else
212 NVIC_SystemReset();
213#endif
214 }
215 return false;
216 case REBOOT:
217 if (record->event.pressed) {
218 shutdown_user();
219#ifdef __AVR__
220 wdt_enable(WDTO_250MS);
221#else
222 NVIC_SystemReset();
223#endif
224 }
225 return false;
226
215 } 227 }
216 return true; 228 return true;
217} 229}
diff --git a/users/drashna/keyrecords/process_records.h b/users/drashna/keyrecords/process_records.h
index df506b364..d7a81d460 100644
--- a/users/drashna/keyrecords/process_records.h
+++ b/users/drashna/keyrecords/process_records.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18#include "drashna.h" 5#include "drashna.h"
@@ -58,6 +45,7 @@ enum userspace_custom_keycodes {
58 KC_ZALGO, 45 KC_ZALGO,
59 KC_ACCEL, 46 KC_ACCEL,
60 AUTO_CTN, // Toggle Autocorrect status 47 AUTO_CTN, // Toggle Autocorrect status
48 REBOOT,
61 NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes 49 NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes
62}; 50};
63 51
@@ -66,7 +54,6 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
66void post_process_record_keymap(uint16_t keycode, keyrecord_t *record); 54void post_process_record_keymap(uint16_t keycode, keyrecord_t *record);
67#ifdef CUSTOM_UNICODE_ENABLE 55#ifdef CUSTOM_UNICODE_ENABLE
68bool process_record_unicode(uint16_t keycode, keyrecord_t *record); 56bool process_record_unicode(uint16_t keycode, keyrecord_t *record);
69void matrix_init_unicode(void);
70#endif 57#endif
71 58
72#define LOWER MO(_LOWER) 59#define LOWER MO(_LOWER)
@@ -140,3 +127,21 @@ void matrix_init_unicode(void);
140#define ALT_APP ALT_T(KC_APP) 127#define ALT_APP ALT_T(KC_APP)
141 128
142#define MG_NKRO MAGIC_TOGGLE_NKRO 129#define MG_NKRO MAGIC_TOGGLE_NKRO
130
131
132/*
133Custom Keycodes for Diablo 3 layer
134But since TD() doesn't work when tap dance is disabled
135We use custom codes here, so we can substitute the right stuff
136*/
137#ifdef TAP_DANCE_ENABLE
138# define KC_D3_1 TD(TD_D3_1)
139# define KC_D3_2 TD(TD_D3_2)
140# define KC_D3_3 TD(TD_D3_3)
141# define KC_D3_4 TD(TD_D3_4)
142#else // TAP_DANCE_ENABLE
143# define KC_D3_1 KC_1
144# define KC_D3_2 KC_2
145# define KC_D3_3 KC_3
146# define KC_D3_4 KC_4
147#endif // TAP_DANCE_ENABLE
diff --git a/users/drashna/keyrecords/readme.md b/users/drashna/keyrecords/readme.md
new file mode 100644
index 000000000..5f708f9ed
--- /dev/null
+++ b/users/drashna/keyrecords/readme.md
@@ -0,0 +1,9 @@
1# Keycode handling and interception
2
3 * [Autocorrection](autocorrection/readme.md)
4 * [Cap Words](capwords.md)
5 * [Diablo Tap Dancing](tap_dance.md)
6 * [Keymap Wrappers](wrappers.md)
7 * [Secret Macros](secrets.md)
8 * [Custom Keycodes](keycodes.md)
9 * [Unicode Input](unicode.md)
diff --git a/users/drashna/readme/secrets.md b/users/drashna/keyrecords/secrets.md
index a9408dc2e..a9408dc2e 100644
--- a/users/drashna/readme/secrets.md
+++ b/users/drashna/keyrecords/secrets.md
diff --git a/users/drashna/readme/tap_dance.md b/users/drashna/keyrecords/tap_dance.md
index a61dd1f2b..0bf67cbd5 100644
--- a/users/drashna/readme/tap_dance.md
+++ b/users/drashna/keyrecords/tap_dance.md
@@ -1,6 +1,8 @@
1# Diablo Tap Dances 1# Diablo Tap Dances
2 2
3My [Tap Dance](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/tap_dances.c) file includes the tap dance declarations, and everything needed for them. 3My [Tap Dance](tap_dances.c) file includes the tap dance declarations, and everything needed for them.
4
5To disable, add `CUSTOM_TAP_DANCE = no` to your `rules.mk`.
4 6
5This is used for making Diablo 3 much easier to plan, especially at high rift levels. 7This is used for making Diablo 3 much easier to plan, especially at high rift levels.
6 8
diff --git a/users/drashna/keyrecords/tap_dances.c b/users/drashna/keyrecords/tap_dances.c
index 01873489d..63eb0c334 100644
--- a/users/drashna/keyrecords/tap_dances.c
+++ b/users/drashna/keyrecords/tap_dances.c
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "tap_dances.h" 4#include "tap_dances.h"
18 5
diff --git a/users/drashna/keyrecords/tap_dances.h b/users/drashna/keyrecords/tap_dances.h
index 81e462ce2..d9baedc86 100644
--- a/users/drashna/keyrecords/tap_dances.h
+++ b/users/drashna/keyrecords/tap_dances.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18#include "drashna.h" 5#include "drashna.h"
diff --git a/users/drashna/keyrecords/tapping.c b/users/drashna/keyrecords/tapping.c
new file mode 100644
index 000000000..9c4892b33
--- /dev/null
+++ b/users/drashna/keyrecords/tapping.c
@@ -0,0 +1,64 @@
1// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "drashna.h"
5
6__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
7 switch (keycode) {
8 case BK_LWER:
9 return TAPPING_TERM + 25;
10 default:
11 return TAPPING_TERM;
12 }
13}
14
15__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) {
16 // Immediately select the hold action when another key is tapped:
17 // return true;
18 // Do not select the hold action when another key is tapped.
19 // return false;
20 switch (keycode) {
21 default:
22 return false;
23 }
24}
25
26__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
27 // Immediately select the hold action when another key is pressed.
28 // return true;
29 // Do not select the hold action when another key is pressed.
30 // return false;
31 switch (keycode) {
32 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
33 return true;
34 default:
35 return false;
36 }
37}
38
39__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
40 // Do not force the mod-tap key press to be handled as a modifier
41 // if any other key was pressed while the mod-tap key is held down.
42 // return true;
43 // Force the mod-tap key press to be handled as a modifier if any
44 // other key was pressed while the mod-tap key is held down.
45 // return false;
46 switch (keycode) {
47 default:
48 return true;
49 }
50}
51
52__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
53 switch (keycode) {
54 default:
55 return false;
56 }
57}
58
59__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
60 switch (keycode) {
61 default:
62 return false;
63 }
64}
diff --git a/users/drashna/keyrecords/unicode.c b/users/drashna/keyrecords/unicode.c
index 88df2c9df..4010b9c1c 100644
--- a/users/drashna/keyrecords/unicode.c
+++ b/users/drashna/keyrecords/unicode.c
@@ -1,34 +1,13 @@
1/* Copyright 2020 @ridingqwerty 1// Copyright 2020 @ridingqwerty
2 * Copyright 2020 @tzarc 2// Copyright 2020 @tzarc
3 * Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 3// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
4 * 4// SPDX-License-Identifier: GPL-2.0-or-later
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 5
19#include "drashna.h" 6#include "drashna.h"
20#include "process_unicode_common.h" 7#include "process_unicode_common.h"
21 8
22uint16_t typing_mode; 9uint16_t typing_mode;
23 10
24void tap_code16_nomods(uint8_t kc) {
25 uint8_t temp_mod = get_mods();
26 clear_mods();
27 clear_oneshot_mods();
28 tap_code16(kc);
29 set_mods(temp_mod);
30}
31
32void tap_unicode_glyph_nomods(uint32_t glyph) { 11void tap_unicode_glyph_nomods(uint32_t glyph) {
33 uint8_t temp_mod = get_mods(); 12 uint8_t temp_mod = get_mods();
34 clear_mods(); 13 clear_mods();
@@ -188,6 +167,7 @@ bool process_record_aussie(uint16_t keycode, keyrecord_t *record) {
188bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) { 167bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) {
189 if ((KC_A <= keycode) && (keycode <= KC_0)) { 168 if ((KC_A <= keycode) && (keycode <= KC_0)) {
190 if (record->event.pressed) { 169 if (record->event.pressed) {
170
191 tap_code16_nomods(keycode); 171 tap_code16_nomods(keycode);
192 172
193 int number = (rand() % (8 + 1 - 2)) + 2; 173 int number = (rand() % (8 + 1 - 2)) + 2;
@@ -247,9 +227,12 @@ bool process_record_unicode(uint16_t keycode, keyrecord_t *record) {
247 } 227 }
248 } 228 }
249 break; 229 break;
230 }
250 231
251 break; 232 if (((get_mods() | get_oneshot_mods()) & ~MOD_MASK_SHIFT) != 0) {
233 return true;
252 } 234 }
235
253 if (((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) && record->tap.count) { 236 if (((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) && record->tap.count) {
254 keycode &= 0xFF; 237 keycode &= 0xFF;
255 } 238 }
diff --git a/users/drashna/keyrecords/unicode.md b/users/drashna/keyrecords/unicode.md
new file mode 100644
index 000000000..1b3f696a8
--- /dev/null
+++ b/users/drashna/keyrecords/unicode.md
@@ -0,0 +1,27 @@
1# Custom Unicode
2
3To disable, add `CUSTOM_UNICODE_ENABLE = no` to the keymap's `rules.mk`.
4
5This disables all of the various implementations of unicode, enables the common unicode core, and allows usage.
6
7In addition to a number of unicode keycodes:
8
9* `UC_FLIP` - `(ノಠ痊ಠ)ノ彡┻━┻`
10* `UC_TABL` - `┬─┬ノ( º _ ºノ)`
11* `UC_SHRG` - `¯\_(ツ)_/¯`
12* `UC_DISA` - `ಠ_ಠ`
13* `UC_IRNY` - `⸮`
14* `UC_CLUE` - `‽`
15
16There are a number of unicode typing modes. This replaces the normal alpha keys with special unicodes.
17
18* `KC_WIDE` - this is wide mode
19* `KC_SCRIPT` - 𝓽𝓱𝓲𝓼 𝓲𝓼 𝓼𝓬𝓻𝓲𝓹𝓽 𝓶𝓸𝓭𝓮
20* `KC_BLOCKS` - 🆃🅷🅸🆂 🅸🆂 🅱🅻🅾🅲🅺 🅼🅾🅳🅴
21* `KC_REGIONAL` - 🇹‌‌🇭‌‌🇮‌‌🇸‌‌ ‌‌🇮‌‌🇸‌‌ ‌‌🇷‌‌🇪‌‌🇬‌‌🇮‌‌🇴‌‌🇳‌‌🇦‌‌🇱‌‌ ‌‌🇲‌‌🇴‌‌🇩‌‌🇪‌‌
22* `KC_AUSSIE` - ǝpoɯ ǝᴉssnɐ sᴉ sᴉɥʇ
23* `KC_ZALGO` - t̨͕͙̺͍͐̾ĥ̻ï̳̻̗̜͔ͦs͎̠͈͓͗̀ i̶̫ͭ̆s̛̫̻̜̝͑͡ z̩͈̠͗a͚̜̓͜l͈̟g͋͢͝ò͚ͥ͘͡͞ ḿ̴̡̻̼̔ͪò͔̭̿ͪ̍ḏ̻̊̄̈e̳͕̤ͣͯ
24* `KC_NOMODE` - this is the normal typing mode with no unicode glyphs
25
26
27Credit goes to ridingqwerty and tzarc for the unicode typing modes.
diff --git a/users/drashna/keyrecords/wrappers.h b/users/drashna/keyrecords/wrappers.h
index c1ae81557..cb8dc6189 100644
--- a/users/drashna/keyrecords/wrappers.h
+++ b/users/drashna/keyrecords/wrappers.h
@@ -1,18 +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 2020 @jola5
3 * This program is free software: you can redistribute it and/or modify 3// SPDX-License-Identifier: GPL-2.0-or-later
4 * 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 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 4
17#pragma once 5#pragma once
18#include "drashna.h" 6#include "drashna.h"
diff --git a/users/drashna/readme/wrappers.md b/users/drashna/keyrecords/wrappers.md
index fd62ff160..fd62ff160 100644
--- a/users/drashna/readme/wrappers.md
+++ b/users/drashna/keyrecords/wrappers.md
diff --git a/users/drashna/oled/drashna_font.h b/users/drashna/oled/drashna_font.h
index 844292a53..7ba03c4c1 100644
--- a/users/drashna/oled/drashna_font.h
+++ b/users/drashna/oled/drashna_font.h
@@ -3,8 +3,8 @@
3// additional fonts from 3// additional fonts from
4// https://github.com/datacute/TinyOLED-Fonts 4// https://github.com/datacute/TinyOLED-Fonts
5 5
6#if __has_include("../../../../Documents/qmk/oled_font.h") 6#if __has_include("oled_font.h")
7# include "../../../../Documents/qmk/oled_font.h" 7# include "oled_font.h"
8#else 8#else
9 9
10// additional fonts from 10// additional fonts from
diff --git a/users/drashna/oled/oled_stuff.c b/users/drashna/oled/oled_stuff.c
index 9ee2cbfed..de8476672 100644
--- a/users/drashna/oled/oled_stuff.c
+++ b/users/drashna/oled/oled_stuff.c
@@ -162,15 +162,8 @@ void render_keylock_status(uint8_t led_usb_state) {
162 162
163void render_matrix_scan_rate(void) { 163void render_matrix_scan_rate(void) {
164#ifdef DEBUG_MATRIX_SCAN_RATE 164#ifdef DEBUG_MATRIX_SCAN_RATE
165 char matrix_rate[5];
166 uint16_t n = get_matrix_scan_rate();
167 matrix_rate[4] = '\0';
168 matrix_rate[3] = '0' + n % 10;
169 matrix_rate[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
170 matrix_rate[1] = n / 10 ? '0' + n / 10 : ' ';
171 matrix_rate[0] = ' ';
172 oled_write_P(PSTR("MS:"), false); 165 oled_write_P(PSTR("MS:"), false);
173 oled_write(matrix_rate, false); 166 oled_write(get_u16_str(get_matrix_scan_rate(), ' '), false);
174#endif 167#endif
175} 168}
176 169
diff --git a/users/drashna/oled/readme.md b/users/drashna/oled/readme.md
new file mode 100644
index 000000000..dbb8187d4
--- /dev/null
+++ b/users/drashna/oled/readme.md
@@ -0,0 +1,42 @@
1# OLED Display
2
3To disable the pre genrated oled display, add `CUSTOM_OLED_DRIVER = no` to your `rules.mk`.
4
5<!-- to do: add all the stuff -->
6## OLED Font
7
8My font file has multiple fonts and multiple logs integrated into the one file. And it uses the full 255 possible characters.
9
10In addition to the default font and logos:
11
12```c
13# define OLED_FONT_5X5
14# define OLED_FONT_AZTECH
15# define OLED_FONT_BMPLAIN
16# define OLED_FONT_CRACKERS
17# define OLED_FONT_EIN
18# define OLED_FONT_HISKYF21
19# define OLED_FONT_SQUASH
20# define OLED_FONT_SUPER_DIGG
21# define OLED_FONT_ZXPIX
22```
23
24```c
25# define OLED_LOGO_CORNE
26# define OLED_LOGO_GMK_BAD
27# define OLED_LOGO_GOTHAM
28# define OLED_LOGO_HUE_MANITEE
29# define OLED_LOGO_LOOSE
30# define OLED_LOGO_SETS3N
31# define OLED_LOGO_SKEEB
32```
33
34Additionally, the font file allows for external oled font files, instead. This allows for additional files that cannot be hosted in the QMK Repo.
35
36## Display
37
38A picture is worth a thousand words. So here are two:
39
40![Right](https://i.imgur.com/4XFOVKBl.jpg)
41
42![Left](https://i.imgur.com/W5RX4pAl.jpg)
diff --git a/users/drashna/pointing/pointing.c b/users/drashna/pointing/pointing.c
index 0198a8ae2..0bd14e477 100644
--- a/users/drashna/pointing/pointing.c
+++ b/users/drashna/pointing/pointing.c
@@ -1,18 +1,5 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 1// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * 2// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "pointing.h" 4#include "pointing.h"
18 5
diff --git a/users/drashna/pointing/pointing.h b/users/drashna/pointing/pointing.h
index 4ad16eeff..8b00ffc0e 100644
--- a/users/drashna/pointing/pointing.h
+++ b/users/drashna/pointing/pointing.h
@@ -1,18 +1,5 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 1// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * 2// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "drashna.h" 4#include "drashna.h"
18 5
diff --git a/users/drashna/pointing/readme.md b/users/drashna/pointing/readme.md
new file mode 100644
index 000000000..777075505
--- /dev/null
+++ b/users/drashna/pointing/readme.md
@@ -0,0 +1,19 @@
1# User Pointing Device customization
2
3To disable the customized pointing device code and implement it at the keymap, add `CUSTOM_POINTING_DEVICE = no` to your `rules.mk`.
4
5## Automatic Mouse Layer
6
7Movement on the optical sensor triggers a layer that has all of the mouse keys on that layer. After a set time, the layer will automatically turn itself off after 650ms.
8
9Also, using mousekeys will extend the amount of time that the layer will stay active.
10
11Additionally, layer keys for the mouse layer will lock the layer on.
12
13## Gaming
14
15When the gamepad or diablo layers are enabled, the mouse layer is locked on, as well.
16
17## Keycodes
18
19The only custom keycode for Pointing devices here is `KC_ACCEL`. This allow the mouse report to have an acceleration curve (exponential).
diff --git a/users/drashna/post_config.h b/users/drashna/post_config.h
index b9d934c42..0c9bda2ee 100644
--- a/users/drashna/post_config.h
+++ b/users/drashna/post_config.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18 5
@@ -137,3 +124,7 @@
137#ifndef DYNAMIC_KEYMAP_LAYER_COUNT 124#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
138# define DYNAMIC_KEYMAP_LAYER_COUNT 11 125# define DYNAMIC_KEYMAP_LAYER_COUNT 11
139#endif 126#endif
127
128#ifndef TAPPING_TERM
129# define TAPPING_TERM 175
130#endif
diff --git a/users/drashna/readme.md b/users/drashna/readme.md
index b8d10aada..e52b67e83 100644
--- a/users/drashna/readme.md
+++ b/users/drashna/readme.md
@@ -2,14 +2,16 @@
2 2
3This is my personal userspace file. Most of my code exists here, as it's heavily shared. 3This is my personal userspace file. Most of my code exists here, as it's heavily shared.
4 4
5* [RGB Customization](readme/rgb.md) 5* [Callback (keymap+misc)](callbacks.md)
6* [Diablo Tap Dancing](readme/tap_dance.md) 6* [Keycode Handling](keyrecords/readme.md)
7* [Keymap Wrappers](readme/wrappers.md) 7 * [Autocorrection](keyrecords/autocorrection/readme.md)
8* [Custom Function Handlers](readme/handlers.md) 8 * [Cap Words](keyrecords/capwords.md)
9* [Secret Macros](readme/secrets.md) 9 * [Diablo Tap Dancing](keyrecords/tap_dance.md)
10* [Custom Keycodes](readme/keycodes.md) 10 * [Keymap Wrappers](keyrecords/wrappers.md)
11 11 * [Secret Macros](keyrecords/secrets.md)
12 12 * [Custom Keycodes](keyrecords/keycodes.md)
13## Pro Micro Hacking 13 * [Unicode Input](keyrecords/unicode.md)
14 14* [OLED Display](oled/readme.md)
15See [this thread](https://www.reddit.com/r/olkb/comments/8sxgzb/replace_pro_micro_bootloader_with_qmk_dfu/) for details on how to flash QMK DFU to Pro Micros. 15* [Pointing Devices](pointing/readme.md)
16* [RGB Customization](rgb/readme.md)
17* [Split Transport](split/readme.md)
diff --git a/users/drashna/readme/handlers.md b/users/drashna/readme/handlers.md
deleted file mode 100644
index 4abaf5147..000000000
--- a/users/drashna/readme/handlers.md
+++ /dev/null
@@ -1,97 +0,0 @@
1# Custom Userspace Function handlers
2
3Specifically QMK works by using customized handlers for everything. This allows for multiple levels of customization.
4
5`matrix_scan` calls `matrix_scan_quantum`, which calls `matrix_scan_kb`, which calls `matrix_scan_user`.
6`process_record` calls a bunch of stuff, but eventually calls `process_record_kb` which calls `process_record_user`
7The same goes for `matrix_init`, `layer_state_set`, `led_set`, and a few other functions.
8
9All (most) `_user` functions are handled here, in the userspace instead. To allow keyboard specific configuration, I've created `_keymap` functions that can be called by the keymap.c files instead.
10
11This allows for keyboard specific configuration while maintaining the ability to customize the board.
12
13My [Ergodox EZ Keymap](https://github.com/qmk/qmk_firmware/blob/master/layouts/community/ergodox/drashna/keymap.c) is a good example of this, as it uses the LEDs as modifier indicators.
14
15But for a list:
16
17```c
18__attribute__ ((weak))
19void matrix_init_keymap(void) {}
20
21void matrix_init_user(void) {
22 matrix_init_keymap();
23}
24
25__attribute__((weak))
26void keyboard_post_init_keymap(void){ }
27
28void keyboard_post_init_user(void){
29 keyboard_post_init_keymap();
30}
31
32__attribute__ ((weak))
33void matrix_scan_keymap(void) {}
34
35void matrix_scan_user(void) {
36 matrix_scan_keymap();
37}
38
39
40__attribute__ ((weak))
41bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
42 return true;
43}
44
45bool process_record_user(uint16_t keycode, keyrecord_t *record) {
46 return process_record_keymap(keycode, record);
47}
48
49
50__attribute__ ((weak))
51layer_state_t layer_state_set_keymap (layer_state_t state) {
52 return state;
53}
54
55layer_state_t layer_state_set_user (layer_state_t state) {
56 return layer_state_set_keymap (state);
57}
58
59
60__attribute__ ((weak))
61void led_set_keymap(uint8_t usb_led) {}
62
63void led_set_user(uint8_t usb_led) {
64 led_set_keymap(usb_led);
65}
66
67
68__attribute__ ((weak))
69void suspend_power_down_keymap(void) {}
70
71void suspend_power_down_user(void) {
72 suspend_power_down_keymap();
73}
74
75
76__attribute__ ((weak))
77void suspend_wakeup_init_keymap(void) {}
78
79void suspend_wakeup_init_user(void) {
80 suspend_wakeup_init_keymap();
81}
82
83
84__attribute__ ((weak))
85void shutdown_keymap(void) {}
86
87void shutdown_user (void) {
88 shutdown_keymap();
89}
90
91__attribute__ ((weak))
92void eeconfig_init_keymap(void) {}
93
94void eeconfig_init_user(void) {
95 eeconfig_init_keymap();
96}
97```
diff --git a/users/drashna/readme/keycodes.md b/users/drashna/readme/keycodes.md
deleted file mode 100644
index af4dd54bc..000000000
--- a/users/drashna/readme/keycodes.md
+++ /dev/null
@@ -1,10 +0,0 @@
1
2# Custom Keycodes
3
4Keycodes are defined in the drashna.h file and need to be included in the keymap.c files, so that they can be used there.
5
6A bunch of macros are present and are only included on boards that are not the Ergodox EZ or Orthodox, as they are not needed for those boards.
7
8Included is a custom macro for compiling my keyboards. This includes the bootloader target (`:teensy`, `:avrdude`, or `:dfu`), and keeps RGBLIGHT, AUDIO enabled, if it previously was (regardless of the rules file).
9
10This also includes a modified RESET keycode as well, that sets the underglow to red.
diff --git a/users/drashna/readme/rgb.md b/users/drashna/rgb/readme.md
index acf01b051..4deaa0a46 100644
--- a/users/drashna/readme/rgb.md
+++ b/users/drashna/rgb/readme.md
@@ -1,4 +1,10 @@
1# Layer Indication Code 1# RGB
2
3Custom RGB code can be disabled by setting `CUSTOM_RGBLIGHT = no` or `CUSTOM_RGB_MATRIX = no` in your `rules.mk`
4
5## RGB Light
6
7### Layer Indication Code
2 8
3At least for RGB Light, the `layer_state_set` function is used to detect the current highest layer, and change the underglow based on that layer. 9At least for RGB Light, the `layer_state_set` function is used to detect the current highest layer, and change the underglow based on that layer.
4 10
@@ -8,7 +14,7 @@ I use the sethsv variants of the commands, so that different modes can be used,
8 14
9RGB Matrix uses a custom, per board implementation, at the moment. 15RGB Matrix uses a custom, per board implementation, at the moment.
10 16
11# RGB Light Startup Animation 17### RGB Light Startup Animation
12 18
13On startup, if enabled, the board will cycle through the entire hue wheel, starting and ending on the default layer color. 19On startup, if enabled, the board will cycle through the entire hue wheel, starting and ending on the default layer color.
14 20
@@ -33,11 +39,14 @@ void keyboard_post_init_rgb(void) {
33 39
34This could probably benefit from some cleanup and better handling. 40This could probably benefit from some cleanup and better handling.
35 41
42## RGB Matrix
43
44### Idle Animation
36 45
37# RGB Light Twinkling 46This feature can be toggled with the `RGB_IDL` keycode.
38 47
39This enables random twinkling of the LEDs when typing. 48This sets the mode to the Heatmap Animation when typing, but will switch to the cycle in animations when idle.
40 49
41# RGB Light Mod Indicators 50### Layer Indication
42 51
43Allows feedback of which mods (oneshot or otherwise) are enabled. 52This sets the modifier keys to indicate the current layer state, with the option to override the behavior.
diff --git a/users/drashna/rgb/rgb_matrix_stuff.c b/users/drashna/rgb/rgb_matrix_stuff.c
index 97811092c..e6d631466 100644
--- a/users/drashna/rgb/rgb_matrix_stuff.c
+++ b/users/drashna/rgb/rgb_matrix_stuff.c
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "drashna.h" 4#include "drashna.h"
18#include "rgb_matrix.h" 5#include "rgb_matrix.h"
@@ -29,27 +16,27 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode
29 16
30 switch (mode) { 17 switch (mode) {
31 case 1: // breathing 18 case 1: // breathing
32 { 19 {
33 uint16_t time = scale16by8(g_rgb_timer, speed / 8); 20 uint16_t time = scale16by8(g_rgb_timer, speed / 8);
34 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); 21 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
35 RGB rgb = hsv_to_rgb(hsv); 22 RGB rgb = hsv_to_rgb(hsv);
36 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { 23 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
37 if (HAS_FLAGS(g_led_config.flags[i], led_type)) { 24 if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
38 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b); 25 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
39 }
40 } 26 }
41 break;
42 } 27 }
28 break;
29 }
43 default: // Solid Color 30 default: // Solid Color
44 { 31 {
45 RGB rgb = hsv_to_rgb(hsv); 32 RGB rgb = hsv_to_rgb(hsv);
46 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { 33 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
47 if (HAS_FLAGS(g_led_config.flags[i], led_type)) { 34 if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
48 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b); 35 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
49 }
50 } 36 }
51 break;
52 } 37 }
38 break;
39 }
53 } 40 }
54} 41}
55 42
@@ -95,3 +82,48 @@ bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
95 } 82 }
96 return true; 83 return true;
97} 84}
85
86__attribute__((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { return true; }
87void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
88 if (!rgb_matrix_indicators_advanced_keymap(led_min, led_max)) { return; }
89
90#if defined(RGBLIGHT_ENABLE)
91 if (!userspace_config.rgb_layer_change)
92#else
93 if (userspace_config.rgb_layer_change)
94#endif
95 {
96 switch (get_highest_layer(layer_state | default_layer_state)) {
97 case _DEFAULT_LAYER_1:
98 rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
99 break;
100 case _DEFAULT_LAYER_2:
101 rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
102 break;
103 case _DEFAULT_LAYER_3:
104 rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
105 break;
106 case _DEFAULT_LAYER_4:
107 rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
108 break;
109 case _GAMEPAD:
110 rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
111 break;
112 case _DIABLO:
113 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER, led_min, led_max);
114 break;
115 case _RAISE:
116 rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
117 break;
118 case _LOWER:
119 rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
120 break;
121 case _ADJUST:
122 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
123 break;
124 }
125 }
126}
127
128__attribute__((weak)) bool rgb_matrix_indicators_keymap(void) { return true; }
129void rgb_matrix_indicators_user(void) { rgb_matrix_indicators_keymap(); }
diff --git a/users/drashna/rgb/rgb_matrix_stuff.h b/users/drashna/rgb/rgb_matrix_stuff.h
index b86f2f651..7c6f6c271 100644
--- a/users/drashna/rgb/rgb_matrix_stuff.h
+++ b/users/drashna/rgb/rgb_matrix_stuff.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18#include "quantum.h" 5#include "quantum.h"
@@ -23,3 +10,6 @@ void matrix_scan_rgb_matrix(void);
23 10
24void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue); 11void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
25void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type, uint8_t led_min, uint8_t led_max); 12void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type, uint8_t led_min, uint8_t led_max);
13
14bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max);
15bool rgb_matrix_indicators_keymap(void);
diff --git a/users/drashna/rgb/rgb_stuff.c b/users/drashna/rgb/rgb_stuff.c
index 15108bde0..e0422334a 100644
--- a/users/drashna/rgb/rgb_stuff.c
+++ b/users/drashna/rgb/rgb_stuff.c
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#ifdef RGBLIGHT_ENABLE 4#ifdef RGBLIGHT_ENABLE
18 5
diff --git a/users/drashna/rgb/rgb_stuff.h b/users/drashna/rgb/rgb_stuff.h
index af1acdde7..d720275b6 100644
--- a/users/drashna/rgb/rgb_stuff.h
+++ b/users/drashna/rgb/rgb_stuff.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18#include "quantum.h" 5#include "quantum.h"
diff --git a/users/drashna/rgblight_breathe_table.h b/users/drashna/rgblight_breathe_table.h
index b6f7a13ac..d40639597 100644
--- a/users/drashna/rgblight_breathe_table.h
+++ b/users/drashna/rgblight_breathe_table.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE 4#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE
18#define RGBLIGHT_EFFECT_BREATHE_TABLE 5#define RGBLIGHT_EFFECT_BREATHE_TABLE
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index 32afae22c..445d1cf5a 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -1,5 +1,7 @@
1SRC += $(USER_PATH)/drashna.c \ 1SRC += $(USER_PATH)/drashna.c \
2 $(USER_PATH)/keyrecords/process_records.c 2 $(USER_PATH)/callbacks.c \
3 $(USER_PATH)/keyrecords/process_records.c \
4 $(USER_PATH)/keyrecords/tapping.c
3 5
4ifneq ($(PLATFORM),CHIBIOS) 6ifneq ($(PLATFORM),CHIBIOS)
5 ifneq ($(strip $(LTO_SUPPORTED)), no) 7 ifneq ($(strip $(LTO_SUPPORTED)), no)
@@ -8,6 +10,7 @@ ifneq ($(PLATFORM),CHIBIOS)
8endif 10endif
9SPACE_CADET_ENABLE = no 11SPACE_CADET_ENABLE = no
10GRAVE_ESC_ENABLE = no 12GRAVE_ESC_ENABLE = no
13# DEBUG_MATRIX_SCAN_RATE_ENABLE = api
11 14
12ifneq ($(strip $(NO_SECRETS)), yes) 15ifneq ($(strip $(NO_SECRETS)), yes)
13 ifneq ("$(wildcard $(USER_PATH)/keyrecords/secrets.c)","") 16 ifneq ("$(wildcard $(USER_PATH)/keyrecords/secrets.c)","")
@@ -18,12 +21,23 @@ ifneq ($(strip $(NO_SECRETS)), yes)
18 endif 21 endif
19endif 22endif
20 23
24ifeq ($(strip $(MAKE_BOOTLOADER)), yes)
25 OPT_DEFS += -DMAKE_BOOTLOADER
26endif
27
28# At least until build.mk or the like drops, this is here to prevent
29# VUSB boards from enabling NKRO, as they do not support it. Ideally
30# this should be handled per keyboard, but until that happens ...
31ifeq ($(strip $(PROTOCOL)), VUSB)
32 NKRO_ENABLE := no
33endif
34
21CUSTOM_UNICODE_ENABLE ?= yes 35CUSTOM_UNICODE_ENABLE ?= yes
22ifeq ($(strip $(CUSTOM_UNICODE_ENABLE)), yes) 36ifeq ($(strip $(CUSTOM_UNICODE_ENABLE)), yes)
23 UNICODE_ENABLE = no 37 UNICODE_ENABLE := no
24 UNICODEMAP_ENABLE = no 38 UNICODEMAP_ENABLE := no
25 UCIS_ENABLE = no 39 UCIS_ENABLE := no
26 UNICODE_COMMON = yes 40 UNICODE_COMMON := yes
27 OPT_DEFS += -DCUSTOM_UNICODE_ENABLE 41 OPT_DEFS += -DCUSTOM_UNICODE_ENABLE
28 SRC += $(USER_PATH)/keyrecords/unicode.c 42 SRC += $(USER_PATH)/keyrecords/unicode.c
29endif 43endif
@@ -62,17 +76,6 @@ ifdef CONSOLE_ENABLE
62 endif 76 endif
63endif 77endif
64 78
65ifeq ($(strip $(MAKE_BOOTLOADER)), yes)
66 OPT_DEFS += -DMAKE_BOOTLOADER
67endif
68
69# At least until build.mk or the like drops, this is here to prevent
70# VUSB boards from enabling NKRO, as they do not support it. Ideally
71# this should be handled per keyboard, but until that happens ...
72ifeq ($(strip $(PROTOCOL)), VUSB)
73 NKRO_ENABLE = no
74endif
75
76CUSTOM_OLED_DRIVER ?= yes 79CUSTOM_OLED_DRIVER ?= yes
77ifeq ($(strip $(OLED_ENABLE)), yes) 80ifeq ($(strip $(OLED_ENABLE)), yes)
78 ifeq ($(strip $(CUSTOM_OLED_DRIVER)), yes) 81 ifeq ($(strip $(CUSTOM_OLED_DRIVER)), yes)
@@ -96,15 +99,13 @@ ifeq ($(strip $(CUSTOM_SPLIT_TRANSPORT_SYNC)), yes)
96 endif 99 endif
97endif 100endif
98 101
99# DEBUG_MATRIX_SCAN_RATE_ENABLE = api 102AUTOCORRECTION_ENABLE ?= no
100
101AUTOCORRECTION_ENABLE ?= yes
102ifeq ($(strip $(AUTOCORRECTION_ENABLE)), yes) 103ifeq ($(strip $(AUTOCORRECTION_ENABLE)), yes)
103 SRC += $(USER_PATH)/keyrecords/autocorrection/autocorrection.c 104 SRC += $(USER_PATH)/keyrecords/autocorrection/autocorrection.c
104 OPT_DEFS += -DAUTOCORRECTION_ENABLE 105 OPT_DEFS += -DAUTOCORRECTION_ENABLE
105endif 106endif
106 107
107CAPS_WORD_ENABLE ?= yes 108CAPS_WORD_ENABLE ?= no
108ifeq ($(strip $(CAPS_WORD_ENABLE)), yes) 109ifeq ($(strip $(CAPS_WORD_ENABLE)), yes)
109 SRC += $(USER_PATH)/keyrecords/caps_word.c 110 SRC += $(USER_PATH)/keyrecords/caps_word.c
110 OPT_DEFS += -DCAPS_WORD_ENABLE 111 OPT_DEFS += -DCAPS_WORD_ENABLE
diff --git a/users/drashna/split/readme.md b/users/drashna/split/readme.md
new file mode 100644
index 000000000..5dad34012
--- /dev/null
+++ b/users/drashna/split/readme.md
@@ -0,0 +1,29 @@
1# Custom Split Transport
2
3To disable the customized split transport, add `CUSTOM_SPLIT_TRANSPORT_SYNC = no` to your `rules.mk`.
4
5This syncs a number of additional settings, such as the keymap_config (magic settings), user eeprom configs, and misc firmware settings.
6
7Additionally, this supports a watchdog timer reset for the secondary split side.
8
9## User State Config
10
11The User states that it sync are:
12
13* Audio Enable status
14* Audio Clicky states
15* Unicode mode
16* Pointing Device tap toggle status
17* Swap Hands status
18* Host Driver status
19
20## Userspace Config
21
22The userspace config states that are synced are:
23
24* RGB layer indication
25* "is overwatch" status
26* nuke switch
27* Swapped numbers
28* RGB Matrix idle animation
29* Autocorrect enable status
diff --git a/users/drashna/split/transport_sync.c b/users/drashna/split/transport_sync.c
index cee3f04c8..794664293 100644
--- a/users/drashna/split/transport_sync.c
+++ b/users/drashna/split/transport_sync.c
@@ -1,22 +1,12 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "transport_sync.h" 4#include "transport_sync.h"
18#include "transactions.h" 5#include "transactions.h"
19#include <string.h> 6#include <string.h>
7#ifdef __AVR__
8# include <avr/wdt.h>
9#endif
20 10
21#ifdef CUSTOM_UNICODE_ENABLE 11#ifdef CUSTOM_UNICODE_ENABLE
22#include "process_unicode_common.h" 12#include "process_unicode_common.h"
@@ -33,6 +23,10 @@ extern bool tap_toggling;
33#ifdef SWAP_HANDS_ENABLE 23#ifdef SWAP_HANDS_ENABLE
34extern bool swap_hands; 24extern bool swap_hands;
35#endif 25#endif
26
27static bool watchdog_ping_done = false;
28static uint32_t watchdog_timer = 0;
29
36extern userspace_config_t userspace_config; 30extern userspace_config_t userspace_config;
37extern bool host_driver_disabled; 31extern bool host_driver_disabled;
38 32
@@ -57,11 +51,20 @@ void user_config_sync(uint8_t initiator2target_buffer_size, const void* initiato
57 } 51 }
58} 52}
59 53
54void watchdog_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) { watchdog_ping_done = true; }
55
56
60void keyboard_post_init_transport_sync(void) { 57void keyboard_post_init_transport_sync(void) {
61 // Register keyboard state sync split transaction 58 // Register keyboard state sync split transaction
62 transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync); 59 transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync);
63 transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync); 60 transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync);
64 transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync); 61 transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync);
62
63#ifdef __AVR__
64 wdt_disable();
65#endif
66 transaction_register_rpc(RPC_ID_USER_WATCHDOG_SYNC, watchdog_handler);
67 watchdog_timer = timer_read32();
65} 68}
66 69
67void user_transport_update(void) { 70void user_transport_update(void) {
@@ -163,6 +166,30 @@ void user_transport_sync(void) {
163 } 166 }
164 } 167 }
165 } 168 }
169
170 if (!watchdog_ping_done) {
171 if (is_keyboard_master()) {
172 if (timer_elapsed32(watchdog_timer) > 100) {
173 uint8_t any_data = 1;
174 if (transaction_rpc_send(RPC_ID_USER_WATCHDOG_SYNC, sizeof(any_data), &any_data)) {
175 watchdog_ping_done = true; // successful ping
176 } else {
177 dprint("Watchdog ping failed!\n");
178 }
179 watchdog_timer = timer_read32();
180 }
181 } else {
182 if (timer_elapsed32(watchdog_timer) > 3500) {
183#ifdef __AVR__
184 wdt_enable(WDTO_250MS);
185#else
186 NVIC_SystemReset();
187#endif
188 while (1) {
189 }
190 }
191 }
192 }
166} 193}
167 194
168void housekeeping_task_user(void) { 195void housekeeping_task_user(void) {
diff --git a/users/drashna/split/transport_sync.h b/users/drashna/split/transport_sync.h
index 70b6ea522..6b6f0c388 100644
--- a/users/drashna/split/transport_sync.h
+++ b/users/drashna/split/transport_sync.h
@@ -1,19 +1,5 @@
1 1// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 2// SPDX-License-Identifier: GPL-2.0-or-later
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 3
18#pragma once 4#pragma once
19 5
diff --git a/users/drashna/template.c b/users/drashna/template.c
index f98964ae4..c4a62c644 100644
--- a/users/drashna/template.c
+++ b/users/drashna/template.c
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "template.h" 4#include "template.h"
18 5
diff --git a/users/drashna/template.h b/users/drashna/template.h
index cb1ad75d8..26ac98edb 100644
--- a/users/drashna/template.h
+++ b/users/drashna/template.h
@@ -1,18 +1,5 @@
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// SPDX-License-Identifier: GPL-2.0-or-later
3 * 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 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#pragma once 4#pragma once
18 5