aboutsummaryrefslogtreecommitdiff
path: root/users/drashna
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2017-11-17 11:59:54 -0800
committerJack Humbert <jack.humb@gmail.com>2017-11-17 20:48:26 -0500
commitdbd33782f25ce1e0855add21cd92183336670213 (patch)
treea6b49a4fa70cb605e7f25cf1ddd68e1aa20f9954 /users/drashna
parent1d703a476aa2cea2302c3d672b05b7e252e62c44 (diff)
downloadqmk_firmware-dbd33782f25ce1e0855add21cd92183336670213.tar.gz
qmk_firmware-dbd33782f25ce1e0855add21cd92183336670213.zip
Update to drashna keymaps (#4)
* Minor updates to keymaps * Minor updates to keymaps
Diffstat (limited to 'users/drashna')
-rw-r--r--users/drashna/drashna.c317
-rw-r--r--users/drashna/drashna.h38
2 files changed, 292 insertions, 63 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 30da7414e..31f58a430 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -1,8 +1,84 @@
1/*
2Copyright 2017 Christopher Courtney <drashna@live.com> @drashna
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
1#include "drashna.h" 18#include "drashna.h"
2#include "quantum.h" 19#include "quantum.h"
3#include "action.h" 20#include "action.h"
4#include "version.h" 21#include "version.h"
5 22
23#ifdef TAP_DANCE_ENABLE
24//define diablo macro timer variables
25static uint16_t diablo_timer[4];
26static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
27static uint8_t diablo_key_time[4];
28
29
30bool check_dtimer(uint8_t dtimer) {
31 // has the correct number of seconds elapsed (as defined by diablo_times)
32 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
33};
34
35
36
37
38// Cycle through the times for the macro, starting at 0, for disabled.
39// Max of six values, so don't exceed
40void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
41 if (state->count >= 7) {
42 diablo_key_time[diablo_key] = diablo_times[0];
43 reset_tap_dance(state);
44 }
45 else {
46 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
47 }
48}
49
50
51// Would rather have one function for all of this, but no idea how to do that...
52void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
53 diablo_tapdance_master(state, user_data, 0);
54}
55
56void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
57 diablo_tapdance_master(state, user_data, 1);
58}
59
60void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
61 diablo_tapdance_master(state, user_data, 2);
62}
63
64void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
65 diablo_tapdance_master(state, user_data, 3);
66}
67
68
69
70//Tap Dance Definitions
71qk_tap_dance_action_t tap_dance_actions[] = {
72 // tap once to disable, and more to enable timed micros
73 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
74 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
75 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
76 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
77
78};
79#endif
80
81
6// Add reconfigurable functions here, for keymap customization 82// Add reconfigurable functions here, for keymap customization
7// This allows for a global, userspace functions, and continued 83// This allows for a global, userspace functions, and continued
8// customization of the keymap. Use _keymap instead of _user 84// customization of the keymap. Use _keymap instead of _user
@@ -17,12 +93,22 @@ __attribute__ ((weak))
17bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { 93bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
18 return true; 94 return true;
19} 95}
96
20__attribute__ ((weak)) 97__attribute__ ((weak))
21uint32_t layer_state_set_keymap (uint32_t state) { 98uint32_t layer_state_set_keymap (uint32_t state) {
22 return state; 99 return state;
23} 100}
24 101
102__attribute__ ((weak))
103void led_set_keymap(uint8_t usb_led) {}
104
25bool is_overwatch = false; 105bool is_overwatch = false;
106#ifdef RGBLIGHT_ENABLE
107bool rgb_layer_change = true;
108#endif
109
110
111
26 112
27// Call user matrix init, set default RGB colors and then 113// Call user matrix init, set default RGB colors and then
28// call the keymap's init function 114// call the keymap's init function
@@ -54,13 +140,56 @@ void matrix_init_user(void) {
54#endif 140#endif
55 matrix_init_keymap(); 141 matrix_init_keymap();
56} 142}
143#ifdef TAP_DANCE_ENABLE
57 144
145// Sends the key press to system, but only if on the Diablo layer
146void send_diablo_keystroke(uint8_t diablo_key) {
147 if (biton32(layer_state) == _DIABLO) {
148 switch (diablo_key) {
149 case 0:
150 SEND_STRING("1");
151 break;
152 case 1:
153 SEND_STRING("2");
154 break;
155 case 2:
156 SEND_STRING("3");
157 break;
158 case 3:
159 SEND_STRING("4");
160 break;
161 }
162 }
163}
164
165// Checks each of the 4 timers/keys to see if enough time has elapsed
166// Runs the "send string" command if enough time has passed, and resets the timer.
167void run_diablo_macro_check(void) {
168 uint8_t dtime;
169
170 for (dtime = 0; dtime < 4; dtime++) {
171 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
172 diablo_timer[dtime] = timer_read();
173 send_diablo_keystroke(dtime);
174 }
175 }
176
177}
178#endif
58// No global matrix scan code, so just run keymap's matix 179// No global matrix scan code, so just run keymap's matix
59// scan function 180// scan function
60void matrix_scan_user(void) { 181void matrix_scan_user(void) {
182#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
183 run_diablo_macro_check();
184#endif
61 matrix_scan_keymap(); 185 matrix_scan_keymap();
62} 186}
63 187
188void led_set_user(uint8_t usb_led) {
189 led_set_keymap(usb_led);
190}
191
192
64#ifdef AUDIO_ENABLE 193#ifdef AUDIO_ENABLE
65float tone_qwerty[][2] = SONG(QWERTY_SOUND); 194float tone_qwerty[][2] = SONG(QWERTY_SOUND);
66float tone_dvorak[][2] = SONG(DVORAK_SOUND); 195float tone_dvorak[][2] = SONG(DVORAK_SOUND);
@@ -201,7 +330,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
201 SEND_STRING("Good game, everyone!"); 330 SEND_STRING("Good game, everyone!");
202 register_code(KC_ENTER); 331 register_code(KC_ENTER);
203 unregister_code(KC_ENTER); 332 unregister_code(KC_ENTER);
204 } 333 }
205 return false; 334 return false;
206 break; 335 break;
207 case KC_GLHF: 336 case KC_GLHF:
@@ -254,11 +383,47 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
254 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); 383 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
255 _delay_ms(50); 384 _delay_ms(50);
256 SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER)); 385 SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER));
257 _delay_ms(50); 386 _delay_ms(3000);
387 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
388 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
258 SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER)); 389 SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER));
259 } 390 }
260 return false; 391 return false;
261 break; 392 break;
393 case KC_C9:
394 if (!record->event.pressed) {
395 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
396 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
397 _delay_ms(50);
398 SEND_STRING("OMG!!! C9!!!");
399 register_code(KC_ENTER);
400 unregister_code(KC_ENTER);
401 }
402 return false;
403 break;
404 case KC_GGEZ:
405 if (!record->event.pressed) {
406 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
407 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
408 _delay_ms(50);
409 SEND_STRING("That was a fantastic game, though it was a bit easy. Try harder next time!");
410 register_code(KC_ENTER);
411 unregister_code(KC_ENTER);
412 }
413 return false;
414 break;
415#endif
416#ifdef TAP_DANCE_ENABLE
417 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
418 if (record->event.pressed) {
419 uint8_t dtime;
420
421 for (dtime = 0; dtime < 4; dtime++) {
422 diablo_key_time[dtime] = diablo_times[0];
423 }
424 }
425 return false;
426 break;
262#endif 427#endif
263 case KC_MAKE: 428 case KC_MAKE:
264 if (!record->event.pressed) { 429 if (!record->event.pressed) {
@@ -310,6 +475,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
310 } 475 }
311 return false; 476 return false;
312 break; 477 break;
478 case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication
479 if (record->event.pressed) {
480 rgb_layer_change = !rgb_layer_change;
481 }
482 return false;
483 break;
484 case RGB_MOD:
485 case RGB_SMOD:
486 case RGB_HUI:
487 case RGB_HUD:
488 case RGB_SAI:
489 case RGB_SAD:
490 case RGB_VAI:
491 case RGB_VAD:
492 case RGB_MODE_PLAIN:
493 case RGB_MODE_BREATHE:
494 case RGB_MODE_RAINBOW:
495 case RGB_MODE_SWIRL:
496 case RGB_MODE_SNAKE:
497 case RGB_MODE_KNIGHT:
498 case RGB_MODE_XMAS:
499 case RGB_MODE_GRADIENT:
500 if (record->event.pressed) {
501 rgb_layer_change = false;
502 }
503 return true;
504 break;
313 } 505 }
314 return process_record_keymap(keycode, record); 506 return process_record_keymap(keycode, record);
315} 507}
@@ -317,70 +509,73 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
317// Runs state check and changes underglow color and animation 509// Runs state check and changes underglow color and animation
318// on layer change, no matter where the change was initiated 510// on layer change, no matter where the change was initiated
319// Then runs keymap's layer change check 511// Then runs keymap's layer change check
320uint32_t layer_state_set_user (uint32_t state) { 512uint32_t layer_state_set_user(uint32_t state) {
321#ifdef RGBLIGHT_ENABLE 513#ifdef RGBLIGHT_ENABLE
322 uint8_t default_layer = eeconfig_read_default_layer(); 514 uint8_t default_layer = eeconfig_read_default_layer();
323 515 if (rgb_layer_change) {
324 switch (biton32(state)) { 516 switch (biton32(state)) {
325 case _NAV: 517 case _NAV:
326 rgblight_set_blue; 518 rgblight_set_blue;
327 rgblight_mode(1); 519 rgblight_mode(1);
328 break; 520 break;
329 case _SYMB: 521 case _SYMB:
330 rgblight_set_blue; 522 rgblight_set_blue;
331 rgblight_mode(2); 523 rgblight_mode(2);
332 break; 524 break;
333 case _MOUS: 525 case _MOUS:
334 rgblight_set_yellow; 526 rgblight_set_yellow;
335 rgblight_mode(1); 527 rgblight_mode(1);
336 break; 528 break;
337 case _MACROS: 529 case _MACROS:
338 rgblight_set_orange; 530 rgblight_set_orange;
339 is_overwatch ? rgblight_mode(17) : rgblight_mode(18); 531 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
340 break; 532 break;
341 case _MEDIA: 533 case _MEDIA:
342 rgblight_set_green;
343 rgblight_mode(22);
344 break;
345 case _OVERWATCH:
346 rgblight_set_orange;
347 rgblight_mode(17);
348 break;
349 case _DIABLO:
350 rgblight_set_red;
351 rgblight_mode(5);
352 break;
353 case _RAISE:
354 rgblight_set_yellow;
355 rgblight_mode(5);
356 break;
357 case _LOWER:
358 rgblight_set_orange;
359 rgblight_mode(5);
360 break;
361 case _ADJUST:
362 rgblight_set_red;
363 rgblight_mode(23);
364 break;
365 case _COVECUBE:
366 rgblight_set_green;
367 rgblight_mode(2);
368 default:
369 if (default_layer & (1UL << _COLEMAK)) {
370 rgblight_set_magenta;
371 }
372 else if (default_layer & (1UL << _DVORAK)) {
373 rgblight_set_green; 534 rgblight_set_green;
535 rgblight_mode(22);
536 break;
537 case _OVERWATCH:
538 rgblight_set_orange;
539 rgblight_mode(17);
540 break;
541 case _DIABLO:
542 rgblight_set_red;
543 rgblight_mode(5);
544 break;
545 case _RAISE:
546 rgblight_set_yellow;
547 rgblight_mode(5);
548 break;
549 case _LOWER:
550 rgblight_set_orange;
551 rgblight_mode(5);
552 break;
553 case _ADJUST:
554 rgblight_set_red;
555 rgblight_mode(23);
556 break;
557 case _COVECUBE:
558 rgblight_set_green;
559 rgblight_mode(2);
560 default:
561 if (default_layer & (1UL << _COLEMAK)) {
562 rgblight_set_magenta;
563 }
564 else if (default_layer & (1UL << _DVORAK)) {
565 rgblight_set_green;
566 }
567 else if (default_layer & (1UL << _WORKMAN)) {
568 rgblight_set_purple;
569 }
570 else {
571 rgblight_set_teal;
572 }
573 rgblight_mode(1);
574 break;
374 } 575 }
375 else if (default_layer & (1UL << _WORKMAN)) {
376 rgblight_set_purple;
377 }
378 else {
379 rgblight_set_teal;
380 }
381 rgblight_mode(1);
382 break;
383 } 576 }
384#endif 577#endif
385 return layer_state_set_keymap (state); 578 return layer_state_set_keymap (state);
386} 579}
580
581
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index 6e897ad99..002af3dd4 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -1,3 +1,20 @@
1/*
2Copyright 2017 Christopher Courtney <drashna@live.com> @drashna
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
1#ifndef USERSPACE 18#ifndef USERSPACE
2#define USERSPACE 19#define USERSPACE
3 20
@@ -26,6 +43,7 @@
26#define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)) 43#define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
27#define MODS_CTRL_MASK (MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTRL)) 44#define MODS_CTRL_MASK (MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTRL))
28#define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)) 45#define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
46#define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))
29 47
30#ifdef RGBLIGHT_ENABLE 48#ifdef RGBLIGHT_ENABLE
31#define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF); 49#define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF);
@@ -39,8 +57,9 @@
39#endif 57#endif
40 58
41extern bool is_overwatch; 59extern bool is_overwatch;
60extern bool rgb_layer_change;
42 61
43enum custom_keycodes { 62enum userrpace_custom_keycodes {
44 PLACEHOLDER = SAFE_RANGE, // can always be here 63 PLACEHOLDER = SAFE_RANGE, // can always be here
45 EPRM, 64 EPRM,
46 VRSN, 65 VRSN,
@@ -62,9 +81,24 @@ enum custom_keycodes {
62 KC_GLHF, 81 KC_GLHF,
63 KC_TORB, 82 KC_TORB,
64 KC_AIM, 83 KC_AIM,
84 KC_C9,
85 KC_GGEZ,
65 KC_MAKE, 86 KC_MAKE,
66 KC_RESET, 87 KC_RESET,
67 NEWPLACEHOLDER //use "NEWPLACEHOLDER for keymap specific codes 88 KC_RGB_T,
89 NEW_SAFE_RANGE //use "NEWPLACEHOLDER for keymap specific codes
90};
91
92#ifdef TAP_DANCE_ENABLE
93enum {
94 TD_D3_1 = 0,
95 TD_D3_2,
96 TD_D3_3,
97 TD_D3_4
68}; 98};
99#endif
100
101
102
69 103
70#endif 104#endif