1 /* Copyright 2017 REPLACE_WITH_YOUR_NAME
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 // Each layer gets a name for readability, which is then used in the keymap matrix below.
19 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
20 // Layer names don't all need to be of the same length, obviously, and you can also skip them
21 // entirely and just use numbers.
28 // Fillers to make layering more clear
29 #define _______ KC_TRNS
33 //define layer change stuff for underglow indicator
34 bool skip_leds = false;
36 bool is_overwatch = false;
38 //This is both for underglow, and Diablo 3 macros
39 bool has_layer_changed = false;
40 static uint8_t current_layer;
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;
56 enum custom_keycodes {
57 PLACEHOLDER = SAFE_RANGE, // can always be here
71 #ifdef TAP_DANCE_ENABLE
80 // Cycle through the times for the macro, starting at 0, for disabled.
81 // Max of six values, so don't exceed
82 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
83 if (state->count >= 7) {
84 diablo_key_time[diablo_key] = diablo_times[0];
85 reset_tap_dance(state);
88 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
93 // Would rather have one function for all of this, but no idea how to do that...
94 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
95 diablo_tapdance_master(state, user_data, 0);
98 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
99 diablo_tapdance_master(state, user_data, 1);
102 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
103 diablo_tapdance_master(state, user_data, 2);
106 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
107 diablo_tapdance_master(state, user_data, 3);
112 //Tap Dance Definitions
113 qk_tap_dance_action_t tap_dance_actions[] = {
114 // tap once to disable, and more to enable timed micros
115 [TD_DIABLO_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
116 [TD_DIABLO_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
117 [TD_DIABLO_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
118 [TD_DIABLO_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
123 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
124 [_NUMLOCK] = KEYMAP( /* Base */
125 TG(_NAV), TG(_DIABLO), TG(_MACROS), KC_PSLS,\
126 KC_P7, KC_P8, KC_P9, KC_PAST, \
127 KC_P4, KC_P5, KC_P6, KC_PMNS, \
128 KC_P1, KC_P2, KC_P3, KC_PPLS, \
129 LT(_MEDIA,KC_P0), KC_PDOT, KC_COLN, KC_PENT \
131 [_NAV] = KEYMAP( /* Base */
132 _______, _______, _______, _______,\
133 KC_HOME, KC_UP, KC_PGUP, _______, \
134 KC_LEFT, XXXXXXX, KC_RIGHT, _______, \
135 KC_END, KC_DOWN, KC_PGDN, _______, \
136 KC_INS, KC_DEL, _______, _______ \
138 #ifdef TAP_DANCE_ENABLE
139 [_DIABLO] = KEYMAP( /* Base */
140 KC_ESC, _______, _______, _______,\
141 KC_S, KC_F, KC_I, KC_M, \
142 KC_1, KC_2, KC_3, KC_4, \
143 TD(TD_DIABLO_1), TD(TD_DIABLO_2), TD(TD_DIABLO_3), TD(TD_DIABLO_4), \
144 _______, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \
147 [_DIABLO] = KEYMAP( /* Base */
148 KC_ESC, _______, _______, _______,\
149 KC_S, KC_F, KC_I, KC_M, \
150 KC_1, KC_2, KC_3, KC_4, \
151 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
152 _______, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \
157 [_MACROS] = KEYMAP( /* Base */
158 KC_OVERWATCH, _______, _______, XXXXXXX,\
159 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
160 XXXXXXX, XXXXXXX, XXXXXXX, KC_JUSTGAME, \
161 KC_SYMM, KC_DOOMFIST, KC_TORB, KC_GOODGAME, \
162 KC_SALT, KC_MORESALT, KC_SALTHARD, KC_GLHF \
164 [_MEDIA] = KEYMAP( /* Base */
165 RESET, KC_MUTE, KC_VOLD, KC_VOLU,\
166 _______, _______, RGB_HUI, RGB_HUD, \
167 KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, \
168 RGB_TOG, RGB_MOD, RGB_SAI, RGB_VAI, \
169 _______, _______, RGB_SAD, RGB_VAD \
174 const uint16_t PROGMEM fn_actions[] = {
178 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
182 if (record->event.pressed) {
183 // Output Keyboard Firmware info
184 SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP );
190 void numlock_led_on(void) {
194 void numlock_led_off(void) {
199 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
207 #ifdef TAP_DANCE_ENABLE
208 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
209 if (record->event.pressed) {
212 for (dtime = 0; dtime < 4; dtime++) {
213 diablo_key_time[dtime] = diablo_times[0];
219 case KC_OVERWATCH: // reset all Diable timers, disabling them
220 if (record->event.pressed) {
221 is_overwatch = !is_overwatch;
222 has_layer_changed = true;
227 if (!record->event.pressed) {
231 SEND_STRING("Salt, salt, salt...");
232 register_code(KC_ENTER);
233 unregister_code(KC_ENTER);
238 if (!record->event.pressed) {
242 SEND_STRING("Please sir, can I have some more salt?!");
243 register_code(KC_ENTER);
244 unregister_code(KC_ENTER);
249 if (!record->event.pressed) {
253 SEND_STRING("Your salt only makes my penis that much harder, and even more aggressive!");
254 register_code(KC_ENTER);
255 unregister_code(KC_ENTER);
260 if (!record->event.pressed) {
264 SEND_STRING("Good game, everyone!");
265 register_code(KC_ENTER);
266 unregister_code(KC_ENTER);
271 if (!record->event.pressed) {
275 SEND_STRING("Good luck, have fun!!!");
276 register_code(KC_ENTER);
277 unregister_code(KC_ENTER);
282 if (!record->event.pressed) {
286 SEND_STRING("Left click to win!");
287 register_code(KC_ENTER);
288 unregister_code(KC_ENTER);
293 if (!record->event.pressed) {
297 SEND_STRING("Hey, look at me. I'm Doomfist, and I'm overpowered! All I do is spam punches all day! I'm DPS, tank and defense, rolled into one! All I need is team healing to be complete!");
298 register_code(KC_ENTER);
299 unregister_code(KC_ENTER);
305 if (!record->event.pressed) {
309 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.");
310 register_code(KC_ENTER);
311 unregister_code(KC_ENTER);
317 if (!record->event.pressed) {
321 SEND_STRING("That was positively riveting!");
322 register_code(KC_ENTER);
323 unregister_code(KC_ENTER);
331 #ifdef TAP_DANCE_ENABLE
333 // Sends the key press to system, but only if on the Diablo layer
334 void send_diablo_keystroke(uint8_t diablo_key) {
335 if (current_layer == _DIABLO) {
336 switch (diablo_key) {
353 // Checks each of the 4 timers/keys to see if enough time has elapsed
354 // Runs the "send string" command if enough time has passed, and resets the timer.
355 void run_diablo_macro_check(void) {
358 for (dtime = 0; dtime < 4; dtime++) {
359 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
360 diablo_timer[dtime] = timer_read();
361 send_diablo_keystroke(dtime);
367 void matrix_init_user(void) {
368 has_layer_changed = true;
369 // set Numlock LED to output and low
372 if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) ){
373 register_code(KC_NUMLOCK);
374 unregister_code(KC_NUMLOCK);
378 void matrix_scan_user(void) {
379 uint8_t layer = biton32(layer_state);
380 #ifdef RGBLIGHT_ENABLE
383 // Check layer, and apply color if its changed since last check
386 if (has_layer_changed) {
387 rgblight_sethsv(240, 255, 255);
392 if (has_layer_changed) {
393 rgblight_sethsv(30, 255, 255);
405 if (has_layer_changed) {
406 rgblight_sethsv(0, 255, 255);
411 if (has_layer_changed) {
412 rgblight_sethsv(120, 255, 255);
417 if (has_layer_changed) {
418 rgblight_sethsv(195, 255, 255);
425 // Update layer status at the end, so this sets the default color
426 // rather than relying on the init, which was unreliably...
427 // Probably due to a timing issue, but this requires no additional code
428 if (current_layer == layer) {
429 has_layer_changed = false;
432 has_layer_changed = true;
433 current_layer = layer;
435 // Run Diablo 3 macro checking code.
436 #ifdef TAP_DANCE_ENABLE
437 run_diablo_macro_check();
442 void led_set_user(uint8_t usb_led) {