2 Copyright 2017 Christopher Courtney <drashna@live.com> @drashna
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.
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.
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/>.
21 #if (__has_include("secrets.h"))
24 PROGMEM const char secret[][64] = {
33 #ifdef FAUXCLICKY_ENABLE
34 float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A6, 2); // (_D4, 0.25);
35 float fauxclicky_released_note[2] = MUSICAL_NOTE(_A6, 2); // (_C4, 0.125);
37 float fauxclicky_pressed[][2] = SONG(E__NOTE(_A6)); // change to your tastes
38 float fauxclicky_released[][2] = SONG(E__NOTE(_A6)); // change to your tastes
40 bool faux_click_enabled = true;
42 #ifdef TAP_DANCE_ENABLE
43 //define diablo macro timer variables
44 static uint16_t diablo_timer[4];
45 static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
46 static uint8_t diablo_key_time[4];
49 bool check_dtimer(uint8_t dtimer) {
50 // has the correct number of seconds elapsed (as defined by diablo_times)
51 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
57 // Cycle through the times for the macro, starting at 0, for disabled.
58 // Max of six values, so don't exceed
59 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
60 if (state->count >= 7) {
61 diablo_key_time[diablo_key] = diablo_times[0];
62 reset_tap_dance(state);
65 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
70 // Would rather have one function for all of this, but no idea how to do that...
71 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
72 diablo_tapdance_master(state, user_data, 0);
75 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
76 diablo_tapdance_master(state, user_data, 1);
79 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
80 diablo_tapdance_master(state, user_data, 2);
83 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
84 diablo_tapdance_master(state, user_data, 3);
89 //Tap Dance Definitions
90 qk_tap_dance_action_t tap_dance_actions[] = {
91 // tap once to disable, and more to enable timed micros
92 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
93 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
94 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
95 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
101 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
102 float tone_dvorak[][2] = SONG(DVORAK_SOUND);
103 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
104 float tone_workman[][2] = SONG(PLOVER_SOUND);
105 float tone_hackstartup[][2] = SONG(ONE_UP_SOUND);
109 // Add reconfigurable functions here, for keymap customization
110 // This allows for a global, userspace functions, and continued
111 // customization of the keymap. Use _keymap instead of _user
112 // functions in the keymaps
113 __attribute__ ((weak))
114 void matrix_init_keymap(void) {}
116 __attribute__ ((weak))
117 void matrix_scan_keymap(void) {}
119 __attribute__ ((weak))
120 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
124 __attribute__ ((weak))
125 uint32_t layer_state_set_keymap (uint32_t state) {
129 __attribute__ ((weak))
130 void led_set_keymap(uint8_t usb_led) {}
132 bool is_overwatch = false;
133 #ifdef RGBLIGHT_ENABLE
134 bool rgb_layer_change = true;
140 // Call user matrix init, set default RGB colors and then
141 // call the keymap's init function
142 void matrix_init_user(void) {
143 #ifdef RGBLIGHT_ENABLE
144 uint8_t default_layer = eeconfig_read_default_layer();
149 if (default_layer & (1UL << _COLEMAK)) {
150 rgblight_set_magenta;
152 else if (default_layer & (1UL << _DVORAK)) {
155 else if (default_layer & (1UL << _WORKMAN)) {
169 // _delay_ms(21); // gets rid of tick
171 // PLAY_SONG(tone_hackstartup);
173 matrix_init_keymap();
175 #ifdef TAP_DANCE_ENABLE
177 // Sends the key press to system, but only if on the Diablo layer
178 void send_diablo_keystroke(uint8_t diablo_key) {
179 if (biton32(layer_state) == _DIABLO) {
180 switch (diablo_key) {
197 // Checks each of the 4 timers/keys to see if enough time has elapsed
198 // Runs the "send string" command if enough time has passed, and resets the timer.
199 void run_diablo_macro_check(void) {
202 for (dtime = 0; dtime < 4; dtime++) {
203 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
204 diablo_timer[dtime] = timer_read();
205 send_diablo_keystroke(dtime);
211 // No global matrix scan code, so just run keymap's matix
213 void matrix_scan_user(void) {
214 #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
215 run_diablo_macro_check();
217 matrix_scan_keymap();
220 void led_set_user(uint8_t usb_led) {
221 led_set_keymap(usb_led);
226 void persistent_default_layer_set(uint16_t default_layer) {
227 eeconfig_update_default_layer(default_layer);
228 default_layer_set(default_layer);
231 // Defines actions tor my global custom keycodes. Defined in drashna.h file
232 // Then runs the _keymap's recod handier if not processed here
233 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
235 #ifdef CONSOLE_ENABLE
236 xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed);
240 if (faux_click_enabled) {
241 if (record->event.pressed) {
242 PLAY_SONG(fauxclicky_pressed);
245 PLAY_SONG(fauxclicky_released);
252 if (record->event.pressed) {
254 PLAY_SONG(tone_qwerty);
256 persistent_default_layer_set(1UL << _QWERTY);
261 if (record->event.pressed) {
263 PLAY_SONG(tone_colemak);
265 persistent_default_layer_set(1UL << _COLEMAK);
270 if (record->event.pressed) {
272 PLAY_SONG(tone_dvorak);
274 persistent_default_layer_set(1UL << _DVORAK);
279 if (record->event.pressed) {
281 PLAY_SONG(tone_workman);
283 persistent_default_layer_set(1UL << _WORKMAN);
288 if (record->event.pressed) {
290 update_tri_layer(_LOWER, _RAISE, _ADJUST);
294 update_tri_layer(_LOWER, _RAISE, _ADJUST);
299 if (record->event.pressed) {
301 update_tri_layer(_LOWER, _RAISE, _ADJUST);
305 update_tri_layer(_LOWER, _RAISE, _ADJUST);
310 if (record->event.pressed) {
318 #if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez))
320 if (record->event.pressed) {
321 is_overwatch = !is_overwatch;
323 #ifdef RGBLIGHT_ENABLE
324 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
329 if (!record->event.pressed) {
330 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
331 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
333 SEND_STRING("Salt, salt, salt...");
334 register_code(KC_ENTER);
335 unregister_code(KC_ENTER);
340 if (!record->event.pressed) {
341 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
342 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
344 SEND_STRING("Please sir, can I have some more salt?!");
345 register_code(KC_ENTER);
346 unregister_code(KC_ENTER);
351 if (!record->event.pressed) {
352 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
353 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
355 SEND_STRING("Your salt only makes me harder, and even more aggressive!");
356 register_code(KC_ENTER);
357 unregister_code(KC_ENTER);
362 if (!record->event.pressed) {
363 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
364 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
366 SEND_STRING("Good game, everyone!");
367 register_code(KC_ENTER);
368 unregister_code(KC_ENTER);
373 if (!record->event.pressed) {
374 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
375 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
377 SEND_STRING("Good luck, have fun!!!");
378 register_code(KC_ENTER);
379 unregister_code(KC_ENTER);
384 if (!record->event.pressed) {
385 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
386 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
388 SEND_STRING("Left click to win!");
389 register_code(KC_ENTER);
390 unregister_code(KC_ENTER);
395 if (!record->event.pressed) {
396 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
397 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
399 SEND_STRING("It may be a game, but if you don't want to actually try, please go play AI, so that people that actually want to take the game seriously and \"get good\" have a place to do so without trolls like you throwing games.");
400 register_code(KC_ENTER);
401 unregister_code(KC_ENTER);
406 if (!record->event.pressed) {
407 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
408 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
410 SEND_STRING("That was positively riveting!");
411 register_code(KC_ENTER);
412 unregister_code(KC_ENTER);
417 if (!record->event.pressed) {
418 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
419 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
421 SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER));
423 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
424 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
425 SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER));
430 if (!record->event.pressed) {
431 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
432 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
434 SEND_STRING("OMG!!! C9!!!");
435 register_code(KC_ENTER);
436 unregister_code(KC_ENTER);
441 if (!record->event.pressed) {
442 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
443 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
445 SEND_STRING("That was a fantastic game, though it was a bit easy. Try harder next time!");
446 register_code(KC_ENTER);
447 unregister_code(KC_ENTER);
452 #ifdef TAP_DANCE_ENABLE
453 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
454 if (record->event.pressed) {
457 for (dtime = 0; dtime < 4; dtime++) {
458 diablo_key_time[dtime] = diablo_times[0];
465 if (!record->event.pressed) {
466 SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
467 #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
469 #elif defined(BOOTLOADER_HALFKAY)
471 //#elif defined(BOOTLOADER_CATERINA)
474 #ifdef RGBLIGHT_ENABLE
475 " RGBLIGHT_ENABLE=yes"
477 " RGBLIGHT_ENABLE=no"
489 if (!record->event.pressed) {
490 #ifdef RGBLIGHT_ENABLE
493 rgblight_setrgb(0xff, 0x00, 0x00);
500 if (record->event.pressed) {
506 if (record->event.pressed) {
507 SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
511 case KC_SECRET_1 ... KC_SECRET_5:
512 if (!record->event.pressed) {
513 send_string_P(secret[keycode - KC_SECRET_1]);
518 if (!record->event.pressed) {
519 faux_click_enabled = !faux_click_enabled;
523 case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication
524 #ifdef RGBLIGHT_ENABLE
525 if (record->event.pressed) {
526 rgb_layer_change = !rgb_layer_change;
531 #ifdef RGBLIGHT_ENABLE
532 case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
533 if (record->event.pressed) { //This disrables layer indication, as it's assumed that if you're changing this ... you want that disabled
534 rgb_layer_change = false;
540 return process_record_keymap(keycode, record);
543 // Runs state check and changes underglow color and animation
544 // on layer change, no matter where the change was initiated
545 // Then runs keymap's layer change check
546 uint32_t layer_state_set_user(uint32_t state) {
547 #ifdef RGBLIGHT_ENABLE
548 uint8_t default_layer = eeconfig_read_default_layer();
549 if (rgb_layer_change) {
550 switch (biton32(state)) {
565 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
596 if (default_layer & (1UL << _COLEMAK)) {
597 rgblight_set_magenta;
599 else if (default_layer & (1UL << _DVORAK)) {
602 else if (default_layer & (1UL << _WORKMAN)) {
613 return layer_state_set_keymap (state);