aboutsummaryrefslogtreecommitdiff
path: root/users/drashna
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-05-31 22:11:06 -0700
committerJack Humbert <jack.humb@gmail.com>2018-06-01 01:11:06 -0400
commit3d1349b280d9c0a57e37b5347a405426de6dba10 (patch)
tree0b8c989d0c902115e2ce51c8bb9dc201b0e2eb0c /users/drashna
parent8eaf23ae8146766615cc1cec3fc8e04111e8ef49 (diff)
downloadqmk_firmware-3d1349b280d9c0a57e37b5347a405426de6dba10.tar.gz
qmk_firmware-3d1349b280d9c0a57e37b5347a405426de6dba10.zip
Big overhaul to Drashna keymaps and userspace (#3097)
* Optimize secrets code * Orthodox tweaks * rules.mk features * Minor cleanup * Revert mod bits * Force Hold breaks One Shot Tap Toggle * Cleanup * Moke keymaps more consistent * minor ergodox tweak * More OSM for the Orthodox * Cleanup of userspace * Toggle Secrets * Add hidden process record for super secret macros * Make sure secret macros always compiles * finish up making them super secret * Add ColinTA's rgb twinkle as WIP * Optimize RGB Twinkling for typing Also, tweak RGB indicators. AND WTF, I HAVE NO IDEA WHY THE INDICATORS ONLY WORK AS IS. The logical method for getting them working doesn't ... and it's beyond bizarre * Make console logging more configurable * Indicator travisty * Clean up userspace rgb code * Optimize RGB Twinking to work on default layer only, and to base it's color on the curent hue * Eff it... rgblight_sethsv_at runs at every matrix scan * RGB Twinkle cleanup * Update Iris code for new board * Move RGB Indicator and RGB Twinkle into userspace * Move RGB Indicator code to rgb_stuff.c * Major cleanup of RGB Code in userspace * Additional cleanup of RGB code in userspace * Use noeeprom functions to save my boards! * Enable RGB Sleep on all boards now * Add old iris board * tapping tweak * Use byte 19 for eeprom to prepare for possible merge of eeconfig function pr * Add code to fix default layer after eeprom reset
Diffstat (limited to 'users/drashna')
-rw-r--r--users/drashna/config.h11
-rw-r--r--users/drashna/drashna.c340
-rw-r--r--users/drashna/drashna.h30
-rw-r--r--users/drashna/readme.md4
-rw-r--r--users/drashna/rgb_stuff.c261
-rw-r--r--users/drashna/rgb_stuff.h16
-rw-r--r--users/drashna/rules.mk29
-rw-r--r--users/drashna/tap_dances.c65
-rw-r--r--users/drashna/tap_dances.h7
9 files changed, 462 insertions, 301 deletions
diff --git a/users/drashna/config.h b/users/drashna/config.h
index ef1860778..26c989d7f 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -11,12 +11,13 @@
11 SONG(DVORAK_SOUND), \ 11 SONG(DVORAK_SOUND), \
12 SONG(OVERWATCH_THEME) \ 12 SONG(OVERWATCH_THEME) \
13 } 13 }
14
15#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.0f
16
14#endif 17#endif
15 18
16#ifdef RGBLIGHT_ENABLE 19#ifdef RGBLIGHT_ENABLE
17 #ifndef KEYBOARD_ergodox_ez 20#define RGBLIGHT_SLEEP
18 #define RGBLIGHT_SLEEP
19 #endif // !KEYBOARD_ergodox_ez
20#endif // RGBLIGHT_ENABLE 21#endif // RGBLIGHT_ENABLE
21 22
22 23
@@ -42,7 +43,7 @@
42#define IGNORE_MOD_TAP_INTERRUPT 43#define IGNORE_MOD_TAP_INTERRUPT
43#undef PERMISSIVE_HOLD 44#undef PERMISSIVE_HOLD
44#undef PREVENT_STUCK_MODIFIERS 45#undef PREVENT_STUCK_MODIFIERS
45#define TAPPING_FORCE_HOLD 46// #define TAPPING_FORCE_HOLD
46//#define RETRO_TAPPING 47//#define RETRO_TAPPING
47 48
48#define FORCE_NKRO 49#define FORCE_NKRO
@@ -54,7 +55,7 @@
54#ifdef TAPPING_TERM 55#ifdef TAPPING_TERM
55#undef TAPPING_TERM 56#undef TAPPING_TERM
56#endif // TAPPING_TERM 57#endif // TAPPING_TERM
57#define TAPPING_TERM 200 58#define TAPPING_TERM 175
58 59
59 60
60// Disable action_get_macro and fn_actions, since we don't use these 61// Disable action_get_macro and fn_actions, since we don't use these
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 6ce541bfb..8efd99f80 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -17,119 +17,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#include "drashna.h" 18#include "drashna.h"
19#include "version.h" 19#include "version.h"
20 20#include "eeprom.h"
21#if (__has_include("secrets.h") && !defined(NO_SECRETS)) 21#include "tap_dances.h"
22#include "secrets.h" 22#include "rgb_stuff.h"
23#else
24// `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware
25// And I'm not familiar enough to know which is better or why...
26PROGMEM const char secret[][64] = {
27 "test1",
28 "test2",
29 "test3",
30 "test4",
31 "test5"
32};
33#endif
34 23
35 24
36float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND); 25float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND);
37float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND); 26float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
38 27
39
40static uint16_t copy_paste_timer; 28static uint16_t copy_paste_timer;
41userspace_config_t userspace_config; 29userspace_config_t userspace_config;
42 30
43// Helper Functions 31// Helper Functions
44void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
45
46#ifdef RGBLIGHT_ENABLE
47void rgblight_sethsv_default_helper(uint8_t index) {
48 uint8_t default_layer = eeconfig_read_default_layer();
49 if (default_layer & (1UL << _COLEMAK)) {
50 rgblight_sethsv_at(300, 255, 255, index);
51 rgblight_sethsv_at(300, 255, 255, index);
52 }
53 else if (default_layer & (1UL << _DVORAK)) {
54 rgblight_sethsv_at(120, 255, 255, index);
55 rgblight_sethsv_at(120, 255, 255, index);
56 }
57 else if (default_layer & (1UL << _WORKMAN)) {
58 rgblight_sethsv_at(43, 255, 255, index);
59 rgblight_sethsv_at(43, 255, 255, index);
60 }
61 else {
62 rgblight_sethsv_at(180, 255, 255, index);
63 rgblight_sethsv_at(180, 255, 255, index);
64 }
65}
66#endif // RGBLIGHT_ENABLE
67
68 32
69// ========================================= TAP DANCE =========================================
70#ifdef TAP_DANCE_ENABLE
71//define diablo macro timer variables
72static uint16_t diablo_timer[4];
73static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
74static uint8_t diablo_key_time[4];
75
76// has the correct number of seconds elapsed (as defined by diablo_times)
77bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true; };
78
79// Cycle through the times for the macro, starting at 0, for disabled.
80// Max of six values, so don't exceed
81void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
82 if (state->count >= 7) {
83 diablo_key_time[diablo_key] = diablo_times[0];
84 reset_tap_dance(state);
85 } else {
86 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
87 }
88}
89 33
90// Would rather have one function for all of this, but no idea how to do that... 34// This block is for all of the gaming macros, as they were all doing
91void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 0); } 35// the same thing, but with differring text sent.
92void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 1); } 36bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
93void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 2); } 37 if (!record->event.pressed || override) {
94void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 3); } 38 clear_keyboard();
95 39 tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER);
96//Tap Dance Definitions 40 wait_ms(50);
97qk_tap_dance_action_t tap_dance_actions[] = { 41 send_string(str);
98 // tap once to disable, and more to enable timed micros 42 wait_ms(50);
99 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1), 43 tap(KC_ENTER);
100 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
101 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
102 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
103};
104
105// Sends the key press to system, but only if on the Diablo layer
106void send_diablo_keystroke(uint8_t diablo_key) {
107 if (biton32(layer_state) == _DIABLO) {
108 switch (diablo_key) {
109 case 0:
110 tap(KC_1); break;
111 case 1:
112 tap(KC_2); break;
113 case 2:
114 tap(KC_3); break;
115 case 3:
116 tap(KC_4); break;
117 }
118 } 44 }
45 if (override) wait_ms(3000);
46 return false;
119} 47}
120 48
121// Checks each of the 4 timers/keys to see if enough time has elapsed 49void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
122// Runs the "send string" command if enough time has passed, and resets the timer.
123void run_diablo_macro_check(void) {
124 uint8_t dtime;
125 for (dtime = 0; dtime < 4; dtime++) {
126 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
127 diablo_timer[dtime] = timer_read();
128 send_diablo_keystroke(dtime);
129 }
130 }
131}
132#endif // TAP_DANCE_ENABLE
133 50
134 51
135// Add reconfigurable functions here, for keymap customization 52// Add reconfigurable functions here, for keymap customization
@@ -148,6 +65,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
148} 65}
149 66
150__attribute__ ((weak)) 67__attribute__ ((weak))
68bool process_record_secrets(uint16_t keycode, keyrecord_t *record) {
69 return true;
70}
71
72__attribute__ ((weak))
151uint32_t layer_state_set_keymap (uint32_t state) { 73uint32_t layer_state_set_keymap (uint32_t state) {
152 return state; 74 return state;
153} 75}
@@ -159,9 +81,12 @@ void led_set_keymap(uint8_t usb_led) {}
159// Call user matrix init, set default RGB colors and then 81// Call user matrix init, set default RGB colors and then
160// call the keymap's init function 82// call the keymap's init function
161void matrix_init_user(void) { 83void matrix_init_user(void) {
162 uint8_t default_layer = eeconfig_read_default_layer();
163 userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); 84 userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE);
164 85
86#ifdef AUDIO_CLICKY
87 clicky_enable = userspace_config.clicky_enable;
88#endif
89
165#ifdef BOOTLOADER_CATERINA 90#ifdef BOOTLOADER_CATERINA
166 DDRD &= ~(1<<5); 91 DDRD &= ~(1<<5);
167 PORTD &= ~(1<<5); 92 PORTD &= ~(1<<5);
@@ -170,39 +95,15 @@ void matrix_init_user(void) {
170 PORTB &= ~(1<<0); 95 PORTB &= ~(1<<0);
171#endif 96#endif
172 97
173 if (userspace_config.rgb_layer_change) {
174#ifdef RGBLIGHT_ENABLE
175 rgblight_enable();
176#endif // RGBLIGHT_ENABLE
177 if (default_layer & (1UL << _COLEMAK)) {
178 #ifdef RGBLIGHT_ENABLE
179 rgblight_sethsv_magenta();
180 #endif // RGBLIGHT_ENABLE
181 } else if (default_layer & (1UL << _DVORAK)) {
182 #ifdef RGBLIGHT_ENABLE
183 rgblight_sethsv_green();
184 #endif // RGBLIGHT_ENABLE
185 } else if (default_layer & (1UL << _WORKMAN)) {
186 #ifdef RGBLIGHT_ENABLE
187 rgblight_sethsv_goldenrod();
188 #endif // RGBLIGHT_ENABLE
189 } else {
190 #ifdef RGBLIGHT_ENABLE
191 rgblight_sethsv_teal();
192 #endif // RGBLIGHT_ENABLE
193 }
194 }
195 98
196#ifdef AUDIO_CLICKY 99#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
197 clicky_enable = userspace_config.clicky_enable;
198#endif
199
200#if ( defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) )
201 set_unicode_input_mode(UC_WINC); 100 set_unicode_input_mode(UC_WINC);
202#endif //UNICODE_ENABLE 101#endif //UNICODE_ENABLE
203 102 matrix_init_rgb();
204 matrix_init_keymap(); 103 matrix_init_keymap();
205} 104}
105
106
206// No global matrix scan code, so just run keymap's matrix 107// No global matrix scan code, so just run keymap's matrix
207// scan function 108// scan function
208void matrix_scan_user(void) { 109void matrix_scan_user(void) {
@@ -211,24 +112,14 @@ void matrix_scan_user(void) {
211 run_diablo_macro_check(); 112 run_diablo_macro_check();
212#endif // TAP_DANCE_ENABLE 113#endif // TAP_DANCE_ENABLE
213 114
115#ifdef RGBLIGHT_ENABLE
116 matrix_scan_rgb();
117#endif // RGBLIGHT_ENABLE
118
214 matrix_scan_keymap(); 119 matrix_scan_keymap();
215} 120}
216 121
217 122
218// This block is for all of the gaming macros, as they were all doing
219// the same thing, but with differring text sent.
220bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
221 if (!record->event.pressed || override) {
222 clear_keyboard();
223 tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER);
224 wait_ms(50);
225 send_string(str);
226 wait_ms(50);
227 tap(KC_ENTER);
228 }
229 if (override) wait_ms(3000);
230 return false;
231}
232 123
233 124
234// Defines actions tor my global custom keycodes. Defined in drashna.h file 125// Defines actions tor my global custom keycodes. Defined in drashna.h file
@@ -236,10 +127,9 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
236bool process_record_user(uint16_t keycode, keyrecord_t *record) { 127bool process_record_user(uint16_t keycode, keyrecord_t *record) {
237 128
238 // If console is enabled, it will print the matrix position and status of each key pressed 129 // If console is enabled, it will print the matrix position and status of each key pressed
239#ifdef CONSOLE_ENABLE 130#ifdef KEYLOGGER_ENABLE
240 xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); 131 xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed);
241#endif //CONSOLE_ENABLE 132#endif //KEYLOGGER_ENABLE
242
243 133
244 switch (keycode) { 134 switch (keycode) {
245 case KC_QWERTY: 135 case KC_QWERTY:
@@ -287,8 +177,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
287 case KC_RESET: // Custom RESET code that sets RGBLights to RED 177 case KC_RESET: // Custom RESET code that sets RGBLights to RED
288 if (!record->event.pressed) { 178 if (!record->event.pressed) {
289#ifdef RGBLIGHT_ENABLE 179#ifdef RGBLIGHT_ENABLE
290 rgblight_enable(); 180 rgblight_enable_noeeprom();
291 rgblight_mode(1); 181 rgblight_mode_noeeprom(1);
292 rgblight_setrgb_red(); 182 rgblight_setrgb_red();
293#endif // RGBLIGHT_ENABLE 183#endif // RGBLIGHT_ENABLE
294 reset_keyboard(); 184 reset_keyboard();
@@ -300,6 +190,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
300 case EPRM: // Resets EEPROM 190 case EPRM: // Resets EEPROM
301 if (record->event.pressed) { 191 if (record->event.pressed) {
302 eeconfig_init(); 192 eeconfig_init();
193 default_layer_set(1UL<<eeconfig_read_default_layer());
194 layer_state_set(layer_state);
303 } 195 }
304 return false; 196 return false;
305 break; 197 break;
@@ -310,24 +202,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
310 return false; 202 return false;
311 break; 203 break;
312 204
313 205/* Code has been depreciated
314 case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo 206 case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo
315 if (!record->event.pressed) { 207 if (!record->event.pressed) {
316 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); 208 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
317 send_string_P(secret[keycode - KC_SECRET_1]); 209 send_string(decoy_secret[keycode - KC_SECRET_1]);
318 } 210 }
319 return false; 211 return false;
320 break; 212 break;
321 213*/
322 214
323// These are a serious of gaming macros. 215// These are a serious of gaming macros.
324// Only enables for the viterbi, basically, 216// Only enables for the viterbi, basically,
325// to save on firmware space, since it's limited. 217// to save on firmware space, since it's limited.
326#if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_iris_rev2)) 218#ifdef MACROS_ENABLED
327 case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros 219 case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros
328 if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); } 220 if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); }
329#ifdef RGBLIGHT_ENABLE 221#ifdef RGBLIGHT_ENABLE
330 userspace_config.is_overwatch ? rgblight_mode(17) : rgblight_mode(18); 222 userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18);
331#endif //RGBLIGHT_ENABLE 223#endif //RGBLIGHT_ENABLE
332 return false; break; 224 return false; break;
333 case KC_SALT: 225 case KC_SALT:
@@ -353,40 +245,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
353 return send_game_macro("OMG!!! C9!!!", record, false); 245 return send_game_macro("OMG!!! C9!!!", record, false);
354 case KC_GGEZ: 246 case KC_GGEZ:
355 return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false); 247 return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false);
356#endif // !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez)) 248#endif // MACROS_ENABLED
357 249
358 250
359#ifdef TAP_DANCE_ENABLE
360 case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them 251 case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them
252#ifdef TAP_DANCE_ENABLE
361 if (record->event.pressed) { 253 if (record->event.pressed) {
362 uint8_t dtime; 254 uint8_t dtime;
363 for (dtime = 0; dtime < 4; dtime++) { 255 for (dtime = 0; dtime < 4; dtime++) {
364 diablo_key_time[dtime] = diablo_times[0]; 256 diablo_key_time[dtime] = diablo_times[0];
365 } 257 }
366 } 258 }
259#endif // TAP_DANCE_ENABLE#endif
367 return false; break; 260 return false; break;
368#endif // TAP_DANCE_ENABLE
369
370
371 case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
372#ifdef RGBLIGHT_ENABLE
373 if (record->event.pressed) {
374 userspace_config.rgb_layer_change ^= 1;
375 eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw);
376 if (userspace_config.rgb_layer_change) {
377 layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
378 }
379 }
380#endif // RGBLIGHT_ENABLE
381 return false; break;
382#ifdef RGBLIGHT_ENABLE
383 case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
384 if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
385 userspace_config.rgb_layer_change = false;
386 eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw);
387 }
388 return true; break;
389#endif // RGBLIGHT_ENABLE
390 261
391 262
392 case KC_CCCV: // One key copy/paste 263 case KC_CCCV: // One key copy/paste
@@ -443,7 +314,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
443#endif // UNICODE_ENABLE 314#endif // UNICODE_ENABLE
444 315
445 } 316 }
446 return process_record_keymap(keycode, record); 317 return process_record_keymap(keycode, record) && process_record_secrets(keycode, record) && process_record_user_rgb(keycode, record);
447} 318}
448 319
449 320
@@ -452,111 +323,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
452// on layer change, no matter where the change was initiated 323// on layer change, no matter where the change was initiated
453// Then runs keymap's layer change check 324// Then runs keymap's layer change check
454uint32_t layer_state_set_user(uint32_t state) { 325uint32_t layer_state_set_user(uint32_t state) {
455 uint8_t default_layer = eeconfig_read_default_layer();
456 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); 326 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
457
458 switch (biton32(state)) {
459 case _MACROS:
460#ifdef RGBLIGHT_ENABLE
461 if (userspace_config.rgb_layer_change) {
462 rgblight_sethsv_orange();
463 userspace_config.is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
464 }
465#endif // RGBLIGHT_ENABLE
466
467 break;
468 case _MEDIA:
469#ifdef RGBLIGHT_ENABLE
470 if (userspace_config.rgb_layer_change) {
471 rgblight_sethsv_chartreuse();
472 rgblight_mode(22);
473 }
474#endif // RGBLIGHT_ENABLE
475
476 break;
477 case _GAMEPAD:
478#ifdef RGBLIGHT_ENABLE
479 if (userspace_config.rgb_layer_change) {
480 rgblight_sethsv_orange();
481 rgblight_mode(17);
482 }
483#endif // RGBLIGHT_ENABLE
484
485 break;
486 case _DIABLO:
487#ifdef RGBLIGHT_ENABLE
488 if (userspace_config.rgb_layer_change) {
489 rgblight_sethsv_red();
490 rgblight_mode(5);
491 }
492#endif // RGBLIGHT_ENABLE
493
494 break;
495 case _RAISE:
496#ifdef RGBLIGHT_ENABLE 327#ifdef RGBLIGHT_ENABLE
497 if (userspace_config.rgb_layer_change) { 328 state = layer_state_set_rgb(state);
498 rgblight_sethsv_yellow();
499 rgblight_mode(5);
500 }
501#endif // RGBLIGHT_ENABLE
502
503 break;
504 case _LOWER:
505#ifdef RGBLIGHT_ENABLE
506 if (userspace_config.rgb_layer_change) {
507 rgblight_sethsv_orange();
508 rgblight_mode(5);
509 }
510#endif // RGBLIGHT_ENABLE
511
512 break;
513 case _ADJUST:
514#ifdef RGBLIGHT_ENABLE
515 if (userspace_config.rgb_layer_change) {
516 rgblight_sethsv_red();
517 rgblight_mode(23);
518 }
519#endif // RGBLIGHT_ENABLE
520
521 break;
522 default: // for any other layers, or the default layer
523 if (default_layer & (1UL << _COLEMAK)) {
524#ifdef RGBLIGHT_ENABLE
525 if (userspace_config.rgb_layer_change) { rgblight_sethsv_magenta(); }
526#endif // RGBLIGHT_ENABLE
527
528 }
529 else if (default_layer & (1UL << _DVORAK)) {
530#ifdef RGBLIGHT_ENABLE
531 if (userspace_config.rgb_layer_change) { rgblight_sethsv_green(); }
532#endif // RGBLIGHT_ENABLE 329#endif // RGBLIGHT_ENABLE
533
534 }
535 else if (default_layer & (1UL << _WORKMAN)) {
536#ifdef RGBLIGHT_ENABLE
537 if (userspace_config.rgb_layer_change) { rgblight_sethsv_goldenrod(); }
538#endif // RGBLIGHT_ENABLE
539
540 }
541 else {
542#ifdef RGBLIGHT_ENABLE
543 if (userspace_config.rgb_layer_change) { rgblight_sethsv_teal(); }
544#endif // RGBLIGHT_ENABLE
545
546 }
547 if (biton32(state) == _MODS) { // If the non-OSM layer is enabled, then breathe
548#ifdef RGBLIGHT_ENABLE
549 if (userspace_config.rgb_layer_change) { rgblight_mode(2); }
550#endif // RGBLIGHT_ENABLE
551
552 } else { // otherwise, stay solid
553#ifdef RGBLIGHT_ENABLE
554 if (userspace_config.rgb_layer_change) { rgblight_mode(1); }
555#endif // RGBLIGHT_ENABLE
556
557 }
558 break;
559 }
560 return layer_state_set_keymap (state); 330 return layer_state_set_keymap (state);
561} 331}
562 332
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index 87a72f528..e035b86fb 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -42,6 +42,7 @@ enum userspace_layers {
42#define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)) 42#define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
43#define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)) 43#define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))
44 44
45
45// RGB color codes are no longer located here anymore. Instead, you will want to 46// RGB color codes are no longer located here anymore. Instead, you will want to
46// head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h 47// head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h
47 48
@@ -51,7 +52,11 @@ extern bool clicky_enable;
51void rgblight_sethsv_default_helper(uint8_t index); 52void rgblight_sethsv_default_helper(uint8_t index);
52#endif // RGBLIGHT_ENABLE 53#endif // RGBLIGHT_ENABLE
53 54
54#define EECONFIG_USERSPACE (uint8_t *)20 55void tap(uint16_t keycode);
56bool process_record_secrets(uint16_t keycode, keyrecord_t *record);
57
58
59#define EECONFIG_USERSPACE (uint8_t *)19
55 60
56typedef union { 61typedef union {
57 uint8_t raw; 62 uint8_t raw;
@@ -59,6 +64,7 @@ typedef union {
59 bool clicky_enable :1; 64 bool clicky_enable :1;
60 bool rgb_layer_change :1; 65 bool rgb_layer_change :1;
61 bool is_overwatch :1; 66 bool is_overwatch :1;
67 bool nuke_switch :1;
62 }; 68 };
63} userspace_config_t; 69} userspace_config_t;
64 70
@@ -91,6 +97,8 @@ enum userspace_custom_keycodes {
91 KC_SECRET_4, 97 KC_SECRET_4,
92 KC_SECRET_5, 98 KC_SECRET_5,
93 KC_CCCV, 99 KC_CCCV,
100 KC_NUKE,
101
94#ifdef UNICODE_ENABLE 102#ifdef UNICODE_ENABLE
95 UC_FLIP, 103 UC_FLIP,
96#endif //UNICODE_ENABLE 104#endif //UNICODE_ENABLE
@@ -112,8 +120,8 @@ enum userspace_custom_keycodes {
112#define DVORAK KC_DVORAK 120#define DVORAK KC_DVORAK
113#define COLEMAK KC_COLEMAK 121#define COLEMAK KC_COLEMAK
114#define WORKMAN KC_WORKMAN 122#define WORKMAN KC_WORKMAN
115#define KC_RST KC_RESET
116 123
124#define KC_RST KC_RESET
117 125
118#ifdef SWAP_HANDS_ENABLE 126#ifdef SWAP_HANDS_ENABLE
119#define KC_C1R3 SH_TT 127#define KC_C1R3 SH_TT
@@ -125,6 +133,16 @@ enum userspace_custom_keycodes {
125#define KC_MLSF OSM(MOD_LSFT) 133#define KC_MLSF OSM(MOD_LSFT)
126#define KC_MRSF OSM(MOD_RSFT) 134#define KC_MRSF OSM(MOD_RSFT)
127 135
136#define OS_LGUI OSM(MOD_LGUI)
137#define OS_RGUI OSM(MOD_RGUI)
138#define OS_LSFT OSM(MOD_LSFT)
139#define OS_RSFT OSM(MOD_RSFT)
140#define OS_LCTL OSM(MOD_LCTL)
141#define OS_RCTL OSM(MOD_RCTL)
142#define OS_LALT OSM(MOD_LALT)
143#define OS_RALT OSM(MOD_RALT)
144#define ALT_APP ALT_T(KC_APP)
145
128#define MG_NKRO MAGIC_TOGGLE_NKRO 146#define MG_NKRO MAGIC_TOGGLE_NKRO
129 147
130 148
@@ -200,8 +218,8 @@ enum {
200#define ______________COLEMAK_MOD_DH_L3____________ CTL_T(KC_Z), KC_X, KC_C, KC_D, KC_V 218#define ______________COLEMAK_MOD_DH_L3____________ CTL_T(KC_Z), KC_X, KC_C, KC_D, KC_V
201 219
202#define ______________COLEMAK_MOD_DH_R1____________ KC_J, KC_L, KC_U, KC_Y, KC_SCLN 220#define ______________COLEMAK_MOD_DH_R1____________ KC_J, KC_L, KC_U, KC_Y, KC_SCLN
203#define ______________COLEMAK_MOD_DH_R2____________ KC_K, KC_N, KC_E, KC_I, KC_O 221#define ______________COLEMAK_MOD_DH_R2____________ KC_M, KC_N, KC_E, KC_I, KC_O
204#define ______________COLEMAK_MOD_DH_R3____________ KC_M, KC_H, KC_COMM, KC_DOT, CTL_T(KC_SLASH) 222#define ______________COLEMAK_MOD_DH_R3____________ KC_K, KC_H, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
205 223
206 224
207#define _________________DVORAK_L1_________________ KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y 225#define _________________DVORAK_L1_________________ KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y
@@ -227,7 +245,7 @@ enum {
227#define _________________NORMAN_L3_________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B 245#define _________________NORMAN_L3_________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B
228 246
229#define _________________NORMAN_R1_________________ KC_J, KC_U, KC_R, KC_L, KC_SCLN 247#define _________________NORMAN_R1_________________ KC_J, KC_U, KC_R, KC_L, KC_SCLN
230#define _________________NORMAN_R2_________________ KC_J, KC_N, KC_I, KC_O, KC_U 248#define _________________NORMAN_R2_________________ KC_Y, KC_N, KC_I, KC_O, KC_U
231#define _________________NORMAN_R3_________________ KC_P, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH) 249#define _________________NORMAN_R3_________________ KC_P, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH)
232 250
233#define ________________NUMBER_LEFT________________ KC_1, KC_2, KC_3, KC_4, KC_5 251#define ________________NUMBER_LEFT________________ KC_1, KC_2, KC_3, KC_4, KC_5
@@ -243,7 +261,7 @@ enum {
243#define ___________ERGODOX_BOTTOM_RIGHT____________ KC_LEFT, KC_DOWN, KC_UP, KC_RGHT 261#define ___________ERGODOX_BOTTOM_RIGHT____________ KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
244 262
245 263
246#define __________________ERGODOX_THUMB_CLUSTER_____________________ ALT_T(KC_APP), KC_LGUI, KC_RGUI, CTL_T(KC_ESCAPE), \ 264#define __________________ERGODOX_THUMB_CLUSTER_____________________ ALT_T(KC_APP), OSM(MOD_LGUI), OSM(MOD_RGUI), CTL_T(KC_ESCAPE), \
247 KC_HOME, KC_PGUP, \ 265 KC_HOME, KC_PGUP, \
248 LT(_LOWER, KC_SPACE),KC_BSPC, KC_END, KC_PGDN, KC_DEL, LT(_RAISE, KC_ENTER) 266 LT(_LOWER, KC_SPACE),KC_BSPC, KC_END, KC_PGDN, KC_DEL, LT(_RAISE, KC_ENTER)
249 267
diff --git a/users/drashna/readme.md b/users/drashna/readme.md
index ddf24b24f..0aa73ece9 100644
--- a/users/drashna/readme.md
+++ b/users/drashna/readme.md
@@ -96,7 +96,7 @@ Then you can create this file and add your macro strings to it:
96 96
97###### secrets.h 97###### secrets.h
98```c 98```c
99PROGMEM const char secret[][64] = { 99static const char * const secrets[] = {
100 "secret1", 100 "secret1",
101 "secret2", 101 "secret2",
102 "secret3", 102 "secret3",
@@ -116,7 +116,7 @@ In the `<name>.c` file, you will want to add this to the top:
116#else 116#else
117// `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware 117// `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware
118// And I'm not familiar enough to know which is better or why... 118// And I'm not familiar enough to know which is better or why...
119PROGMEM const char secret[][64] = { 119static const char * const secrets[] = {
120 "test1", 120 "test1",
121 "test2", 121 "test2",
122 "test3", 122 "test3",
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
new file mode 100644
index 000000000..af7190cc3
--- /dev/null
+++ b/users/drashna/rgb_stuff.c
@@ -0,0 +1,261 @@
1#include "drashna.h"
2#include "rgb_stuff.h"
3
4extern rgblight_config_t rgblight_config;
5extern userspace_config_t userspace_config;
6
7#ifdef RGBLIGHT_ENABLE
8void rgblight_sethsv_default_helper(uint8_t index) {
9 rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index);
10}
11#endif // RGBLIGHT_ENABLE
12
13#ifdef INDICATOR_LIGHTS
14uint8_t last_mod;
15uint8_t last_led;
16uint8_t last_osm;
17uint8_t current_mod;
18uint8_t current_led;
19uint8_t current_osm;
20
21
22void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
23 if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) {
24 if (this_mod & MODS_SHIFT_MASK || this_led & (1<<USB_LED_CAPS_LOCK) || this_osm & MODS_SHIFT_MASK) {
25 rgblight_sethsv_at(0, 255, 255, SHFT_LED1);
26 rgblight_sethsv_at(0, 255, 255, SHFT_LED2);
27 } else {
28 rgblight_sethsv_default_helper(SHFT_LED1);
29 rgblight_sethsv_default_helper(SHFT_LED2);
30 }
31 if (this_mod & MODS_CTRL_MASK || this_osm & MODS_CTRL_MASK) {
32 rgblight_sethsv_at(51, 255, 255, CTRL_LED1);
33 rgblight_sethsv_at(51, 255, 255, CTRL_LED2);
34 } else {
35 rgblight_sethsv_default_helper(CTRL_LED1);
36 rgblight_sethsv_default_helper(CTRL_LED2);
37 }
38 if (this_mod & MODS_GUI_MASK || this_osm & MODS_GUI_MASK) {
39 rgblight_sethsv_at(120, 255, 255, GUI_LED1);
40 rgblight_sethsv_at(120, 255, 255, GUI_LED2);
41 } else {
42 rgblight_sethsv_default_helper(GUI_LED1);
43 rgblight_sethsv_default_helper(GUI_LED2);
44 }
45 }
46}
47
48void matrix_scan_indicator(void) {
49 current_mod = get_mods();
50 current_led = host_keyboard_leds();
51 current_osm = get_oneshot_mods();
52
53 set_rgb_indicators(current_mod, current_led, current_osm);
54
55 last_mod = current_mod;
56 last_led = current_led;
57 last_osm = current_osm;
58
59}
60#endif //INDICATOR_LIGHTS
61
62#ifdef RGBLIGHT_TWINKLE
63static rgblight_fadeout lights[RGBLED_NUM];
64
65__attribute__ ((weak))
66bool indicator_is_this_led_used(uint8_t index) { return false; }
67
68void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
69 bool litup = false;
70 for (uint8_t light_index = 0 ; light_index < RGBLED_NUM ; ++light_index ) {
71 if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) {
72 rgblight_fadeout *light = &lights[light_index];
73 litup = true;
74
75 if (light->life) {
76 light->life -= 1;
77 if (biton32(layer_state) == 0) {
78 sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
79 }
80 light->timer = timer_read();
81 }
82 else {
83 if (light->enabled && biton32(layer_state) == 0) { rgblight_sethsv_default_helper(light_index); }
84 litup = light->enabled = false;
85 }
86 }
87 }
88 if (litup && biton32(layer_state) == 0) {
89 rgblight_set();
90 }
91}
92
93void start_rgb_light(void) {
94
95 uint8_t indices[RGBLED_NUM];
96 uint8_t indices_count = 0;
97 uint8_t min_life = 0xFF;
98 uint8_t min_life_index = -1;
99 for (uint8_t index = 0 ; index < RGBLED_NUM ; ++index ) {
100 if (indicator_is_this_led_used(index)) { continue; }
101 if (lights[index].enabled) {
102 if (min_life_index == -1 ||
103 lights[index].life < min_life)
104 {
105 min_life = lights[index].life;
106 min_life_index = index;
107 }
108 continue;
109 }
110
111 indices[indices_count] = index;
112 ++indices_count;
113 }
114
115 uint8_t light_index;
116 if (!indices_count) {
117 light_index = min_life_index;
118 }
119 else {
120 light_index = indices[rand() % indices_count];
121 }
122
123 rgblight_fadeout *light = &lights[light_index];
124 light->enabled = true;
125 light->timer = timer_read();
126 light->life = 0xC0 + rand() % 0x40;
127
128 light->hue = rgblight_config.hue + (rand() % 0xB4) - 0x54;
129
130 rgblight_sethsv_at(light->hue, 255, light->life, light_index);
131}
132#endif
133
134
135bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
136 switch (keycode) {
137#ifdef RGBLIGHT_TWINKLE
138 case KC_A ... KC_SLASH:
139 case KC_F1 ... KC_F12:
140 case KC_INSERT ... KC_UP:
141 case KC_KP_SLASH ... KC_KP_DOT:
142 case KC_F13 ... KC_F24:
143 case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
144 if (record->event.pressed) { start_rgb_light(); }
145 return true; break;
146#endif // RGBLIGHT_TWINKLE
147 case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
148#ifdef RGBLIGHT_ENABLE
149 if (record->event.pressed) {
150 userspace_config.rgb_layer_change ^= 1;
151 xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
152 eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw);
153 if (userspace_config.rgb_layer_change) {
154 layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
155 }
156 }
157#endif // RGBLIGHT_ENABLE
158 return false; break;
159#ifdef RGBLIGHT_ENABLE
160 case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
161 if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
162 if (userspace_config.rgb_layer_change) {
163 userspace_config.rgb_layer_change = false;
164 xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
165 eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw);
166 }
167 }
168 return true; break;
169#endif // RGBLIGHT_ENABLE
170 }
171 return true;
172}
173
174
175
176void matrix_init_rgb(void) {
177#ifdef INDICATOR_LIGHTS
178 current_mod = last_mod = get_mods();
179 current_led = last_led = host_keyboard_leds();
180 current_osm = last_osm = get_oneshot_mods();
181#endif
182
183 if (userspace_config.rgb_layer_change) {
184 uint8_t default_layer = eeconfig_read_default_layer();
185 rgblight_enable_noeeprom();
186 if (default_layer & (1UL << _COLEMAK)) {
187 rgblight_sethsv_magenta();
188 } else if (default_layer & (1UL << _DVORAK)) {
189 rgblight_sethsv_green();
190 } else if (default_layer & (1UL << _WORKMAN)) {
191 rgblight_sethsv_goldenrod();
192 } else {
193 rgblight_sethsv_cyan();
194 }
195 }
196}
197
198void matrix_scan_rgb(void) {
199#ifdef RGBLIGHT_TWINKLE
200 scan_rgblight_fadeout();
201#endif // RGBLIGHT_ENABLE
202
203#ifdef INDICATOR_LIGHTS
204 matrix_scan_indicator();
205#endif
206
207}
208
209
210uint32_t layer_state_set_rgb(uint32_t state) {
211#ifdef RGBLIGHT_ENABLE
212 uint8_t default_layer = eeconfig_read_default_layer();
213 if (userspace_config.rgb_layer_change) {
214 switch (biton32(state)) {
215 case _MACROS:
216 rgblight_sethsv_noeeprom_orange();
217 userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18);
218 break;
219 case _MEDIA:
220 rgblight_sethsv_noeeprom_chartreuse();
221 rgblight_mode_noeeprom(22);
222 break;
223 case _GAMEPAD:
224 rgblight_sethsv_noeeprom_orange();
225 rgblight_mode_noeeprom(17);
226 break;
227 case _DIABLO:
228 rgblight_sethsv_noeeprom_red();
229 rgblight_mode_noeeprom(5);
230 break;
231 case _RAISE:
232 rgblight_sethsv_noeeprom_yellow();
233 rgblight_mode_noeeprom(5);
234 break;
235 case _LOWER:
236 rgblight_sethsv_noeeprom_orange();
237 rgblight_mode_noeeprom(5);
238 break;
239 case _ADJUST:
240 rgblight_sethsv_noeeprom_red();
241 rgblight_mode_noeeprom(23);
242 break;
243 default: // for any other layers, or the default layer
244 if (default_layer & (1UL << _COLEMAK)) {
245 rgblight_sethsv_noeeprom_magenta();
246 } else if (default_layer & (1UL << _DVORAK)) {
247 rgblight_sethsv_noeeprom_green();
248 } else if (default_layer & (1UL << _WORKMAN)) {
249 rgblight_sethsv_noeeprom_goldenrod();
250 } else {
251 rgblight_sethsv_noeeprom_cyan();
252 }
253 biton32(state) == _MODS ? rgblight_mode_noeeprom(2) : rgblight_mode_noeeprom(1); // if _MODS layer is on, then breath to denote it
254 break;
255 }
256// layer_state_set_indicator(); // Runs every scan, so need to call this here .... since I can't get it working "right" anyhow
257 }
258#endif // RGBLIGHT_ENABLE
259
260 return state;
261}
diff --git a/users/drashna/rgb_stuff.h b/users/drashna/rgb_stuff.h
new file mode 100644
index 000000000..6426ea266
--- /dev/null
+++ b/users/drashna/rgb_stuff.h
@@ -0,0 +1,16 @@
1#include "quantum.h"
2
3typedef struct {
4 bool enabled;
5 uint8_t hue;
6 uint16_t timer;
7 uint8_t life;
8} rgblight_fadeout;
9
10bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record);
11void scan_rgblight_fadeout(void);
12void matrix_init_rgb(void);
13void matrix_scan_rgb(void);
14uint32_t layer_state_set_rgb(uint32_t state);
15
16
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index e2c5a2995..18df665c0 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -1,11 +1,34 @@
1 1
2SRC += drashna.c 2SRC += drashna.c secrets.c rgb_stuff.c
3
4ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
5 SRC += tap_dances.c
6endif
7
3EXTRAFLAGS += -flto 8EXTRAFLAGS += -flto
4 9
5ifeq ($(strip $(NO_SECRETS)), yes) 10ifeq ($(strip $(NO_SECRETS)), yes)
6 OPT_DEFS += -DNO_SECRETS 11 OPT_DEFS += -DNO_SECRETS
7endif 12endif
8 13
9ifeq ($(strip $(INDICATOR_LIGHTS)), yes) 14ifdef RGBLIGHT_ENABLE
10 OPT_DEFS += -DINDICATOR_LIGHTS 15 ifeq ($(strip $(INDICATOR_LIGHTS)), yes)
16 OPT_DEFS += -DINDICATOR_LIGHTS
17 endif
18 ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes)
19 OPT_DEFS += -DRGBLIGHT_TWINKLE
20 endif
21 ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes)
22 OPT_DEFS += -DRGBLIGHT_NOEEPROM
23 endif
24endif
25
26ifeq ($(strip $(MACROS_ENABLED)), yes)
27 OPT_DEFS += -DMACROS_ENABLED
28endif
29
30ifdef CONSOLE_ENABLE
31 ifeq ($(strip $(KEYLOGGER_ENABLE)), yes)
32 OPT_DEFS += -DKEYLOGGER_ENABLE
33 endif
11endif 34endif
diff --git a/users/drashna/tap_dances.c b/users/drashna/tap_dances.c
new file mode 100644
index 000000000..c9e4b1d0f
--- /dev/null
+++ b/users/drashna/tap_dances.c
@@ -0,0 +1,65 @@
1#include "drashna.h"
2#include "tap_dances.h"
3
4
5//define diablo macro timer variables
6uint16_t diablo_timer[4];
7uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
8uint8_t diablo_key_time[4];
9
10// has the correct number of seconds elapsed (as defined by diablo_times)
11bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true; };
12
13// Cycle through the times for the macro, starting at 0, for disabled.
14// Max of six values, so don't exceed
15void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
16 if (state->count >= 7) {
17 diablo_key_time[diablo_key] = diablo_times[0];
18 reset_tap_dance(state);
19 } else {
20 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
21 }
22}
23
24// Would rather have one function for all of this, but no idea how to do that...
25void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 0); }
26void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 1); }
27void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 2); }
28void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 3); }
29
30//Tap Dance Definitions
31qk_tap_dance_action_t tap_dance_actions[] = {
32 // tap once to disable, and more to enable timed micros
33 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
34 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
35 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
36 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
37};
38
39// Sends the key press to system, but only if on the Diablo layer
40void send_diablo_keystroke(uint8_t diablo_key) {
41 if (biton32(layer_state) == _DIABLO) {
42 switch (diablo_key) {
43 case 0:
44 tap(KC_1); break;
45 case 1:
46 tap(KC_2); break;
47 case 2:
48 tap(KC_3); break;
49 case 3:
50 tap(KC_4); break;
51 }
52 }
53}
54
55// Checks each of the 4 timers/keys to see if enough time has elapsed
56// Runs the "send string" command if enough time has passed, and resets the timer.
57void run_diablo_macro_check(void) {
58 uint8_t dtime;
59 for (dtime = 0; dtime < 4; dtime++) {
60 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
61 diablo_timer[dtime] = timer_read();
62 send_diablo_keystroke(dtime);
63 }
64 }
65}
diff --git a/users/drashna/tap_dances.h b/users/drashna/tap_dances.h
new file mode 100644
index 000000000..8935753f6
--- /dev/null
+++ b/users/drashna/tap_dances.h
@@ -0,0 +1,7 @@
1//define diablo macro timer variables
2extern uint16_t diablo_timer[4];
3extern uint8_t diablo_times[];
4extern uint8_t diablo_key_time[4];
5
6
7void run_diablo_macro_check(void);