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[][x]` may work better, but it takes up more space in the firmware
25 // And I'm not familar enough to know which is better or why...
26 PROGMEM const char secret[][64] = {
35 #ifdef FAUXCLICKY_ENABLE
36 float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A6, 2); // (_D4, 0.25);
37 float fauxclicky_released_note[2] = MUSICAL_NOTE(_A6, 2); // (_C4, 0.125);
39 float fauxclicky_pressed[][2] = SONG(E__NOTE(_A6)); // change to your tastes
40 float fauxclicky_released[][2] = SONG(E__NOTE(_A6)); // change to your tastes
42 bool faux_click_enabled = true;
44 #ifdef TAP_DANCE_ENABLE
45 //define diablo macro timer variables
46 static uint16_t diablo_timer[4];
47 static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
48 static uint8_t diablo_key_time[4];
51 bool check_dtimer(uint8_t dtimer) {
52 // has the correct number of seconds elapsed (as defined by diablo_times)
53 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
59 // Cycle through the times for the macro, starting at 0, for disabled.
60 // Max of six values, so don't exceed
61 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
62 if (state->count >= 7) {
63 diablo_key_time[diablo_key] = diablo_times[0];
64 reset_tap_dance(state);
67 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
72 // Would rather have one function for all of this, but no idea how to do that...
73 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
74 diablo_tapdance_master(state, user_data, 0);
77 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
78 diablo_tapdance_master(state, user_data, 1);
81 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
82 diablo_tapdance_master(state, user_data, 2);
85 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
86 diablo_tapdance_master(state, user_data, 3);
91 //Tap Dance Definitions
92 qk_tap_dance_action_t tap_dance_actions[] = {
93 // tap once to disable, and more to enable timed micros
94 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
95 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
96 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
97 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
103 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
104 float tone_dvorak[][2] = SONG(DVORAK_SOUND);
105 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
106 float tone_workman[][2] = SONG(PLOVER_SOUND);
107 float tone_hackstartup[][2] = SONG(ONE_UP_SOUND);
111 // Add reconfigurable functions here, for keymap customization
112 // This allows for a global, userspace functions, and continued
113 // customization of the keymap. Use _keymap instead of _user
114 // functions in the keymaps
115 __attribute__ ((weak))
116 void matrix_init_keymap(void) {}
118 __attribute__ ((weak))
119 void matrix_scan_keymap(void) {}
121 __attribute__ ((weak))
122 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
126 __attribute__ ((weak))
127 uint32_t layer_state_set_keymap (uint32_t state) {
131 __attribute__ ((weak))
132 void led_set_keymap(uint8_t usb_led) {}
134 bool is_overwatch = false;
135 #ifdef RGBLIGHT_ENABLE
136 bool rgb_layer_change = true;
142 // Call user matrix init, set default RGB colors and then
143 // call the keymap's init function
144 void matrix_init_user(void) {
145 #ifdef RGBLIGHT_ENABLE
146 uint8_t default_layer = eeconfig_read_default_layer();
151 if (default_layer & (1UL << _COLEMAK)) {
152 rgblight_set_magenta;
154 else if (default_layer & (1UL << _DVORAK)) {
157 else if (default_layer & (1UL << _WORKMAN)) {
171 // wait_ms(21); // gets rid of tick
173 // PLAY_SONG(tone_hackstartup);
175 matrix_init_keymap();
177 #ifdef TAP_DANCE_ENABLE
179 // Sends the key press to system, but only if on the Diablo layer
180 void send_diablo_keystroke(uint8_t diablo_key) {
181 if (biton32(layer_state) == _DIABLO) {
182 switch (diablo_key) {
199 // Checks each of the 4 timers/keys to see if enough time has elapsed
200 // Runs the "send string" command if enough time has passed, and resets the timer.
201 void run_diablo_macro_check(void) {
204 for (dtime = 0; dtime < 4; dtime++) {
205 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
206 diablo_timer[dtime] = timer_read();
207 send_diablo_keystroke(dtime);
213 // No global matrix scan code, so just run keymap's matix
215 void matrix_scan_user(void) {
216 #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
217 run_diablo_macro_check();
219 matrix_scan_keymap();
222 void led_set_user(uint8_t usb_led) {
223 led_set_keymap(usb_led);
226 void send_game_macro(const char *str) {
227 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
228 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
231 register_code(KC_ENTER);
232 unregister_code(KC_ENTER);
235 void persistent_default_layer_set(uint16_t default_layer) {
236 eeconfig_update_default_layer(default_layer);
237 default_layer_set(default_layer);
240 // Defines actions tor my global custom keycodes. Defined in drashna.h file
241 // Then runs the _keymap's recod handier if not processed here
242 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
244 #ifdef CONSOLE_ENABLE
245 xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed);
249 if (faux_click_enabled) {
250 if (record->event.pressed) {
251 PLAY_SONG(fauxclicky_pressed);
254 PLAY_SONG(fauxclicky_released);
261 if (record->event.pressed) {
263 PLAY_SONG(tone_qwerty);
265 persistent_default_layer_set(1UL << _QWERTY);
270 if (record->event.pressed) {
272 PLAY_SONG(tone_colemak);
274 persistent_default_layer_set(1UL << _COLEMAK);
279 if (record->event.pressed) {
281 PLAY_SONG(tone_dvorak);
283 persistent_default_layer_set(1UL << _DVORAK);
288 if (record->event.pressed) {
290 PLAY_SONG(tone_workman);
292 persistent_default_layer_set(1UL << _WORKMAN);
297 if (record->event.pressed) {
299 update_tri_layer(_LOWER, _RAISE, _ADJUST);
303 update_tri_layer(_LOWER, _RAISE, _ADJUST);
308 if (record->event.pressed) {
310 update_tri_layer(_LOWER, _RAISE, _ADJUST);
314 update_tri_layer(_LOWER, _RAISE, _ADJUST);
319 if (record->event.pressed) {
327 #if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez))
329 if (record->event.pressed) {
330 is_overwatch = !is_overwatch;
332 #ifdef RGBLIGHT_ENABLE
333 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
338 if (!record->event.pressed) {
339 send_game_macro("Salt, salt, salt...");
344 if (!record->event.pressed) {
345 send_game_macro("Please sir, can I have some more salt?!");
350 if (!record->event.pressed) {
351 send_game_macro("Your salt only makes me harder, and even more aggressive!");
356 if (!record->event.pressed) {
357 send_game_macro("Good game, everyone!");
362 if (!record->event.pressed) {
363 send_game_macro("Good luck, have fun!!!");
368 if (!record->event.pressed) {
369 send_game_macro("Left click to win!");
374 if (!record->event.pressed) {
375 send_game_macro("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 if (!record->event.pressed) {
381 send_game_macro("That was positively riveting!");
386 if (!record->event.pressed) {
387 send_game_macro("That aim is absolutely amazing. It's almost like you're a machine!");
389 send_game_macro("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!");
394 if (!record->event.pressed) {
395 send_game_macro("OMG!!! C9!!!");
400 if (!record->event.pressed) {
401 send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!");
406 #ifdef TAP_DANCE_ENABLE
407 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
408 if (record->event.pressed) {
411 for (dtime = 0; dtime < 4; dtime++) {
412 diablo_key_time[dtime] = diablo_times[0];
419 if (!record->event.pressed) {
420 SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
421 #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
423 #elif defined(BOOTLOADER_HALFKAY)
425 //#elif defined(BOOTLOADER_CATERINA)
433 if (!record->event.pressed) {
434 #ifdef RGBLIGHT_ENABLE
437 rgblight_setrgb(0xff, 0x00, 0x00);
444 if (record->event.pressed) {
450 if (record->event.pressed) {
451 SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
455 case KC_SECRET_1 ... KC_SECRET_5:
456 if (!record->event.pressed) {
457 send_string_P(secret[keycode - KC_SECRET_1]);
462 if (!record->event.pressed) {
463 faux_click_enabled = !faux_click_enabled;
467 case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication
468 #ifdef RGBLIGHT_ENABLE
469 if (record->event.pressed) {
470 rgb_layer_change = !rgb_layer_change;
475 #ifdef RGBLIGHT_ENABLE
476 case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
477 if (record->event.pressed) { //This disrables layer indication, as it's assumed that if you're changing this ... you want that disabled
478 rgb_layer_change = false;
484 return process_record_keymap(keycode, record);
487 // Runs state check and changes underglow color and animation
488 // on layer change, no matter where the change was initiated
489 // Then runs keymap's layer change check
490 uint32_t layer_state_set_user(uint32_t state) {
491 #ifdef RGBLIGHT_ENABLE
492 uint8_t default_layer = eeconfig_read_default_layer();
493 if (rgb_layer_change) {
494 switch (biton32(state)) {
509 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
512 rgblight_set_chartreuse;
540 if (default_layer & (1UL << _COLEMAK)) {
541 rgblight_set_magenta;
543 else if (default_layer & (1UL << _DVORAK)) {
546 else if (default_layer & (1UL << _WORKMAN)) {
547 rgblight_set_goldenrod;
552 if (biton32(state) == _MODS) {
561 return layer_state_set_keymap (state);