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] = {
36 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
37 float tone_dvorak[][2] = SONG(DVORAK_SOUND);
38 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
39 float tone_workman[][2] = SONG(PLOVER_SOUND);
40 float tone_hackstartup[][2] = SONG(ONE_UP_SOUND);
43 #ifdef FAUXCLICKY_ENABLE
44 float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A6, 2); // (_D4, 0.25);
45 float fauxclicky_released_note[2] = MUSICAL_NOTE(_A6, 2); // (_C4, 0.125);
47 float fauxclicky_pressed[][2] = SONG(E__NOTE(_A6)); // change to your tastes
48 float fauxclicky_released[][2] = SONG(E__NOTE(_A6)); // change to your tastes
51 bool faux_click_enabled = false;
52 bool is_overwatch = false;
53 #ifdef RGBLIGHT_ENABLE
54 bool rgb_layer_change = true;
57 #ifdef TAP_DANCE_ENABLE
58 //define diablo macro timer variables
59 static uint16_t diablo_timer[4];
60 static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
61 static uint8_t diablo_key_time[4];
63 bool check_dtimer(uint8_t dtimer) {
64 // has the correct number of seconds elapsed (as defined by diablo_times)
65 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
68 // Cycle through the times for the macro, starting at 0, for disabled.
69 // Max of six values, so don't exceed
70 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
71 if (state->count >= 7) {
72 diablo_key_time[diablo_key] = diablo_times[0];
73 reset_tap_dance(state);
76 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
80 // Would rather have one function for all of this, but no idea how to do that...
81 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
82 diablo_tapdance_master(state, user_data, 0);
84 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
85 diablo_tapdance_master(state, user_data, 1);
87 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
88 diablo_tapdance_master(state, user_data, 2);
90 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
91 diablo_tapdance_master(state, user_data, 3);
94 //Tap Dance Definitions
95 qk_tap_dance_action_t tap_dance_actions[] = {
96 // tap once to disable, and more to enable timed micros
97 [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
98 [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
99 [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
100 [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
104 // Sends the key press to system, but only if on the Diablo layer
105 void send_diablo_keystroke(uint8_t diablo_key) {
106 if (biton32(layer_state) == _DIABLO) {
107 switch (diablo_key) {
124 // Checks each of the 4 timers/keys to see if enough time has elapsed
125 // Runs the "send string" command if enough time has passed, and resets the timer.
126 void run_diablo_macro_check(void) {
129 for (dtime = 0; dtime < 4; dtime++) {
130 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
131 diablo_timer[dtime] = timer_read();
132 send_diablo_keystroke(dtime);
140 // Add reconfigurable functions here, for keymap customization
141 // This allows for a global, userspace functions, and continued
142 // customization of the keymap. Use _keymap instead of _user
143 // functions in the keymaps
144 __attribute__ ((weak))
145 void matrix_init_keymap(void) {}
147 __attribute__ ((weak))
148 void matrix_scan_keymap(void) {}
150 __attribute__ ((weak))
151 bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
155 __attribute__ ((weak))
156 uint32_t layer_state_set_keymap (uint32_t state) {
160 __attribute__ ((weak))
161 void led_set_keymap(uint8_t usb_led) {}
164 // Call user matrix init, set default RGB colors and then
165 // call the keymap's init function
166 void matrix_init_user(void) {
167 #ifdef RGBLIGHT_ENABLE
168 uint8_t default_layer = eeconfig_read_default_layer();
173 if (default_layer & (1UL << _COLEMAK)) {
174 rgblight_set_magenta;
176 else if (default_layer & (1UL << _DVORAK)) {
179 else if (default_layer & (1UL << _WORKMAN)) {
192 matrix_init_keymap();
194 // No global matrix scan code, so just run keymap's matix
196 void matrix_scan_user(void) {
197 #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
198 run_diablo_macro_check();
200 matrix_scan_keymap();
203 // This block is for all of the gaming macros, as they were all doing
204 // the same thing, but with differring text sent.
205 void send_game_macro(const char *str) {
207 register_code(is_overwatch ? KC_BSPC : KC_ENTER);
208 unregister_code(is_overwatch ? KC_BSPC : KC_ENTER);
211 register_code(KC_ENTER);
212 unregister_code(KC_ENTER);
216 // Sent the default layer
217 void persistent_default_layer_set(uint16_t default_layer) {
218 eeconfig_update_default_layer(default_layer);
219 default_layer_set(default_layer);
223 // Defines actions tor my global custom keycodes. Defined in drashna.h file
224 // Then runs the _keymap's recod handier if not processed here
225 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
227 // If console is enabled, it will print the matrix position and status of each key pressed
228 #ifdef CONSOLE_ENABLE
229 xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed);
230 #endif //CONSOLE_ENABLE
232 // Run custom faux click code, but only if faux clicky is enabled
234 if ( (faux_click_enabled && keycode != KC_FXCL) || (!faux_click_enabled && keycode == KC_FXCL) ) {
235 if (record->event.pressed) {
236 PLAY_SONG(fauxclicky_pressed);
239 PLAY_SONG(fauxclicky_released);
242 #endif //AUDIO_ENABLE
247 if (record->event.pressed) {
249 PLAY_SONG(tone_qwerty);
250 #endif //AUDIO_ENABLE
251 persistent_default_layer_set(1UL << _QWERTY);
256 if (record->event.pressed) {
258 PLAY_SONG(tone_colemak);
259 #endif //AUDIO_ENABLE
260 persistent_default_layer_set(1UL << _COLEMAK);
265 if (record->event.pressed) {
267 PLAY_SONG(tone_dvorak);
268 #endif //AUDIO_ENABLE
269 persistent_default_layer_set(1UL << _DVORAK);
274 if (record->event.pressed) {
276 PLAY_SONG(tone_workman);
277 #endif //AUDIO_ENABLE
278 persistent_default_layer_set(1UL << _WORKMAN);
285 if (record->event.pressed) {
287 update_tri_layer(_LOWER, _RAISE, _ADJUST);
291 update_tri_layer(_LOWER, _RAISE, _ADJUST);
296 if (record->event.pressed) {
298 update_tri_layer(_LOWER, _RAISE, _ADJUST);
302 update_tri_layer(_LOWER, _RAISE, _ADJUST);
307 if (record->event.pressed) {
317 case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
318 if (!record->event.pressed) {
319 SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
320 #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
322 #elif defined(BOOTLOADER_HALFKAY)
324 #elif defined(BOOTLOADER_CATERINA)
331 case KC_RESET: // Custom RESET code that setr RGBLights to RED
332 if (!record->event.pressed) {
333 #ifdef RGBLIGHT_ENABLE
336 rgblight_setrgb(0xff, 0x00, 0x00);
342 case EPRM: // Resets EEPROM
343 if (record->event.pressed) {
348 case VRSN: // Prints firmware version
349 if (record->event.pressed) {
350 SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
354 case KC_SECRET_1 ... KC_SECRET_5: // Custom
355 if (!record->event.pressed) {
356 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
357 send_string_P(secret[keycode - KC_SECRET_1]);
363 // These are a serious of gaming macros.
364 // Only enables for the viterbi, basically,
365 // to save on firmware space, since it's limited.
366 #if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez))
369 case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros
370 if (record->event.pressed) { is_overwatch = !is_overwatch; }
371 #ifdef RGBLIGHT_ENABLE
372 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
373 #endif //RGBLIGHT_ENABLE
378 if (!record->event.pressed) { send_game_macro("Salt, salt, salt..."); }
381 if (!record->event.pressed) { send_game_macro("Please sir, can I have some more salt?!"); }
384 if (!record->event.pressed) { send_game_macro("Your salt only makes me harder, and even more aggressive!"); }
387 if (!record->event.pressed) { send_game_macro("Good game, everyone!"); }
390 if (!record->event.pressed) { send_game_macro("Good luck, have fun!!!"); }
393 if (!record->event.pressed) { send_game_macro("Left click to win!"); }
396 if (!record->event.pressed) { 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."); }
399 if (!record->event.pressed) { send_game_macro("That was positively riveting!"); }
402 if (!record->event.pressed) {
403 send_game_macro("That aim is absolutely amazing. It's almost like you're a machine!");
405 send_game_macro("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!");
409 if (!record->event.pressed) { send_game_macro("OMG!!! C9!!!"); }
412 if (!record->event.pressed) { send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!"); }
414 #endif // !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez))
417 #ifdef TAP_DANCE_ENABLE
418 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
419 if (record->event.pressed) {
422 for (dtime = 0; dtime < 4; dtime++) {
423 diablo_key_time[dtime] = diablo_times[0];
427 #endif // TAP_DANCE_ENABLE
431 if (!record->event.pressed) { // Toggles the custom faux click code
432 faux_click_enabled = !faux_click_enabled;
435 case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
436 #ifdef RGBLIGHT_ENABLE
437 if (record->event.pressed) {
438 rgb_layer_change = !rgb_layer_change;
439 if (rgb_layer_change) {
440 layer_state_set(layer_state); // This is needed to immediately set the layer color (looks beetter)
443 #endif // RGBLIGHT_ENABLE
445 #ifdef RGBLIGHT_ENABLE
446 case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
447 if (record->event.pressed) { //This disrables layer indication, as it's assumed that if you're changing this ... you want that disabled
448 rgb_layer_change = false;
451 #endif // RGBLIGHT_ENABLE
453 return process_record_keymap(keycode, record);
457 // Runs state check and changes underglow color and animation
458 // on layer change, no matter where the change was initiated
459 // Then runs keymap's layer change check
460 uint32_t layer_state_set_user(uint32_t state) {
461 #ifdef RGBLIGHT_ENABLE
462 uint8_t default_layer = eeconfig_read_default_layer();
463 if (rgb_layer_change) {
464 switch (biton32(state)) {
479 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
482 rgblight_set_chartreuse;
509 default: // for any other layers, or the default layer
510 if (default_layer & (1UL << _COLEMAK)) {
511 rgblight_set_magenta;
513 else if (default_layer & (1UL << _DVORAK)) {
516 else if (default_layer & (1UL << _WORKMAN)) {
517 rgblight_set_goldenrod;
522 if (biton32(state) == _MODS) { // If the non-OSM layer is enabled, then breathe
524 } else { // otherwise, stay solid
531 return layer_state_set_keymap (state);
535 // Any custom LED code goes here.
536 // So far, I only have keyboard specific code,
537 // So nothing goes here.
538 void led_set_user(uint8_t usb_led) {
539 led_set_keymap(usb_led);