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 TAP_DANCE_ENABLE
34 //define diablo macro timer variables
35 static uint16_t diablo_timer[4];
36 static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
37 static uint8_t diablo_key_time[4];
40 bool check_dtimer(uint8_t dtimer) {
41 // has the correct number of seconds elapsed (as defined by diablo_times)
42 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
48 // Cycle through the times for the macro, starting at 0, for disabled.
49 // Max of six values, so don't exceed
50 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
51 if (state->count >= 7) {
52 diablo_key_time[diablo_key] = diablo_times[0];
53 reset_tap_dance(state);
56 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
61 // Would rather have one function for all of this, but no idea how to do that...
62 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
63 diablo_tapdance_master(state, user_data, 0);
66 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
67 diablo_tapdance_master(state, user_data, 1);
70 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
71 diablo_tapdance_master(state, user_data, 2);
74 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
75 diablo_tapdance_master(state, user_data, 3);
80 //Tap Dance Definitions
81 qk_tap_dance_action_t tap_dance_actions[] = {
82 // tap once to disable, and more to enable timed micros
83 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
84 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
85 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
86 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
92 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
93 float tone_dvorak[][2] = SONG(DVORAK_SOUND);
94 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
95 float tone_workman[][2] = SONG(PLOVER_SOUND);
96 float tone_hackstartup[][2] = SONG(ONE_UP_SOUND);
100 // Add reconfigurable functions here, for keymap customization
101 // This allows for a global, userspace functions, and continued
102 // customization of the keymap. Use _keymap instead of _user
103 // functions in the keymaps
104 __attribute__ ((weak))
105 void matrix_init_keymap(void) {}
107 __attribute__ ((weak))
108 void matrix_scan_keymap(void) {}
110 __attribute__ ((weak))
111 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
115 __attribute__ ((weak))
116 uint32_t layer_state_set_keymap (uint32_t state) {
120 __attribute__ ((weak))
121 void led_set_keymap(uint8_t usb_led) {}
123 bool is_overwatch = false;
124 #ifdef RGBLIGHT_ENABLE
125 bool rgb_layer_change = true;
131 // Call user matrix init, set default RGB colors and then
132 // call the keymap's init function
133 void matrix_init_user(void) {
134 #ifdef RGBLIGHT_ENABLE
135 uint8_t default_layer = eeconfig_read_default_layer();
140 if (default_layer & (1UL << _COLEMAK)) {
141 rgblight_set_magenta;
143 else if (default_layer & (1UL << _DVORAK)) {
146 else if (default_layer & (1UL << _WORKMAN)) {
160 // _delay_ms(21); // gets rid of tick
162 // PLAY_SONG(tone_hackstartup);
164 matrix_init_keymap();
166 #ifdef TAP_DANCE_ENABLE
168 // Sends the key press to system, but only if on the Diablo layer
169 void send_diablo_keystroke(uint8_t diablo_key) {
170 if (biton32(layer_state) == _DIABLO) {
171 switch (diablo_key) {
188 // Checks each of the 4 timers/keys to see if enough time has elapsed
189 // Runs the "send string" command if enough time has passed, and resets the timer.
190 void run_diablo_macro_check(void) {
193 for (dtime = 0; dtime < 4; dtime++) {
194 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
195 diablo_timer[dtime] = timer_read();
196 send_diablo_keystroke(dtime);
202 // No global matrix scan code, so just run keymap's matix
204 void matrix_scan_user(void) {
205 #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
206 run_diablo_macro_check();
208 matrix_scan_keymap();
211 void led_set_user(uint8_t usb_led) {
212 led_set_keymap(usb_led);
217 void persistent_default_layer_set(uint16_t default_layer) {
218 eeconfig_update_default_layer(default_layer);
219 default_layer_set(default_layer);
222 // Defines actions tor my global custom keycodes. Defined in drashna.h file
223 // Then runs the _keymap's recod handier if not processed here
224 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
226 #ifdef CONSOLE_ENABLE
227 xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed);
232 if (record->event.pressed) {
234 PLAY_SONG(tone_qwerty);
236 persistent_default_layer_set(1UL << _QWERTY);
241 if (record->event.pressed) {
243 PLAY_SONG(tone_colemak);
245 persistent_default_layer_set(1UL << _COLEMAK);
250 if (record->event.pressed) {
252 PLAY_SONG(tone_dvorak);
254 persistent_default_layer_set(1UL << _DVORAK);
259 if (record->event.pressed) {
261 PLAY_SONG(tone_workman);
263 persistent_default_layer_set(1UL << _WORKMAN);
268 if (record->event.pressed) {
270 update_tri_layer(_LOWER, _RAISE, _ADJUST);
274 update_tri_layer(_LOWER, _RAISE, _ADJUST);
279 if (record->event.pressed) {
281 update_tri_layer(_LOWER, _RAISE, _ADJUST);
285 update_tri_layer(_LOWER, _RAISE, _ADJUST);
290 if (record->event.pressed) {
298 #if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_ergodox_ez))
300 if (record->event.pressed) {
301 is_overwatch = !is_overwatch;
303 #ifdef RGBLIGHT_ENABLE
304 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
309 if (!record->event.pressed) {
310 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
311 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
313 SEND_STRING("Salt, salt, salt...");
314 register_code(KC_ENTER);
315 unregister_code(KC_ENTER);
320 if (!record->event.pressed) {
321 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
322 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
324 SEND_STRING("Please sir, can I have some more salt?!");
325 register_code(KC_ENTER);
326 unregister_code(KC_ENTER);
331 if (!record->event.pressed) {
332 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
333 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
335 SEND_STRING("Your salt only makes me harder, and even more aggressive!");
336 register_code(KC_ENTER);
337 unregister_code(KC_ENTER);
342 if (!record->event.pressed) {
343 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
344 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
346 SEND_STRING("Good game, everyone!");
347 register_code(KC_ENTER);
348 unregister_code(KC_ENTER);
353 if (!record->event.pressed) {
354 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
355 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
357 SEND_STRING("Good luck, have fun!!!");
358 register_code(KC_ENTER);
359 unregister_code(KC_ENTER);
364 if (!record->event.pressed) {
365 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
366 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
368 SEND_STRING("Left click to win!");
369 register_code(KC_ENTER);
370 unregister_code(KC_ENTER);
375 if (!record->event.pressed) {
376 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
377 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
379 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.");
380 register_code(KC_ENTER);
381 unregister_code(KC_ENTER);
386 if (!record->event.pressed) {
387 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
388 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
390 SEND_STRING("That was positively riveting!");
391 register_code(KC_ENTER);
392 unregister_code(KC_ENTER);
397 if (!record->event.pressed) {
398 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
399 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
401 SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER));
403 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
404 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
405 SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER));
410 if (!record->event.pressed) {
411 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
412 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
414 SEND_STRING("OMG!!! C9!!!");
415 register_code(KC_ENTER);
416 unregister_code(KC_ENTER);
421 if (!record->event.pressed) {
422 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
423 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
425 SEND_STRING("That was a fantastic game, though it was a bit easy. Try harder next time!");
426 register_code(KC_ENTER);
427 unregister_code(KC_ENTER);
432 #ifdef TAP_DANCE_ENABLE
433 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
434 if (record->event.pressed) {
437 for (dtime = 0; dtime < 4; dtime++) {
438 diablo_key_time[dtime] = diablo_times[0];
445 if (!record->event.pressed) {
446 SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
447 #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
449 #elif defined(BOOTLOADER_HALFKAY)
451 //#elif defined(BOOTLOADER_CATERINA)
454 #ifdef RGBLIGHT_ENABLE
455 " RGBLIGHT_ENABLE=yes"
457 " RGBLIGHT_ENABLE=no"
464 #ifdef FAUXCLICKY_ENABLE
465 " FAUXCLICKY_ENABLE=yes"
467 " FAUXCLICKY_ENABLE=no"
474 if (!record->event.pressed) {
475 #ifdef RGBLIGHT_ENABLE
478 rgblight_setrgb(0xff, 0x00, 0x00);
485 if (record->event.pressed) {
491 if (record->event.pressed) {
492 SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
496 case KC_SECRET_1 ... KC_SECRET_5:
497 if (!record->event.pressed) {
498 send_string_P(secret[keycode - KC_SECRET_1]);
502 case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication
503 #ifdef RGBLIGHT_ENABLE
504 if (record->event.pressed) {
505 rgb_layer_change = !rgb_layer_change;
510 #ifdef RGBLIGHT_ENABLE
511 case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
512 if (record->event.pressed) { //This disrables layer indication, as it's assumed that if you're changing this ... you want that disabled
513 rgb_layer_change = false;
519 return process_record_keymap(keycode, record);
522 // Runs state check and changes underglow color and animation
523 // on layer change, no matter where the change was initiated
524 // Then runs keymap's layer change check
525 uint32_t layer_state_set_user(uint32_t state) {
526 #ifdef RGBLIGHT_ENABLE
527 uint8_t default_layer = eeconfig_read_default_layer();
528 if (rgb_layer_change) {
529 switch (biton32(state)) {
544 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
575 if (default_layer & (1UL << _COLEMAK)) {
576 rgblight_set_magenta;
578 else if (default_layer & (1UL << _DVORAK)) {
581 else if (default_layer & (1UL << _WORKMAN)) {
592 return layer_state_set_keymap (state);