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
32 #ifdef RGBLIGHT_ENABLE
33 #define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF);
34 #define rgblight_set_red rgblight_sethsv (0x00, 0xFF, 0xFF);
35 #define rgblight_set_green rgblight_sethsv (0x78, 0xFF, 0xFF);
36 #define rgblight_set_orange rgblight_sethsv (0x1E, 0xFF, 0xFF);
37 #define rgblight_set_teal rgblight_sethsv (0xC3, 0xFF, 0xFF);
38 #define rgblight_set_magenta rgblight_sethsv (0x12C, 0xFF, 0xFF);
39 #define rgblight_set_yellow rgblight_sethsv (0x3C, 0xFF, 0xFF);
40 #define rgblight_set_purple rgblight_sethsv (0x10E, 0xFF, 0xFF);
43 //define layer change stuff for underglow indicator
44 bool skip_leds = false;
46 bool is_overwatch = false;
49 #ifdef TAP_DANCE_ENABLE
50 //define diablo macro timer variables
51 static uint16_t diablo_timer[4];
52 static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
53 static uint8_t diablo_key_time[4];
56 bool check_dtimer(uint8_t dtimer) {
57 // has the correct number of seconds elapsed (as defined by diablo_times)
58 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
63 enum custom_keycodes {
64 PLACEHOLDER = SAFE_RANGE, // can always be here
79 #ifdef TAP_DANCE_ENABLE
88 // Cycle through the times for the macro, starting at 0, for disabled.
89 // Max of six values, so don't exceed
90 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
91 if (state->count >= 7) {
92 diablo_key_time[diablo_key] = diablo_times[0];
93 reset_tap_dance(state);
96 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
101 // Would rather have one function for all of this, but no idea how to do that...
102 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
103 diablo_tapdance_master(state, user_data, 0);
106 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
107 diablo_tapdance_master(state, user_data, 1);
110 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
111 diablo_tapdance_master(state, user_data, 2);
114 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
115 diablo_tapdance_master(state, user_data, 3);
120 //Tap Dance Definitions
121 qk_tap_dance_action_t tap_dance_actions[] = {
122 // tap once to disable, and more to enable timed micros
123 [TD_DIABLO_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
124 [TD_DIABLO_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
125 [TD_DIABLO_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
126 [TD_DIABLO_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
131 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
132 [_NUMLOCK] = KEYMAP( /* Base */
133 TG(_NAV), TG(_DIABLO), TG(_MACROS), KC_PSLS,\
134 KC_P7, KC_P8, KC_P9, KC_PAST, \
135 KC_P4, KC_P5, KC_P6, KC_PMNS, \
136 KC_P1, KC_P2, KC_P3, KC_PPLS, \
137 LT(_MEDIA,KC_P0), KC_PDOT, KC_COLN, KC_PENT \
139 [_NAV] = KEYMAP( /* Base */
140 _______, _______, _______, _______,\
141 KC_HOME, KC_UP, KC_PGUP, _______, \
142 KC_LEFT, XXXXXXX, KC_RIGHT, _______, \
143 KC_END, KC_DOWN, KC_PGDN, _______, \
144 KC_INS, KC_DEL, _______, _______ \
146 #ifdef TAP_DANCE_ENABLE
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 TD(TD_DIABLO_1), TD(TD_DIABLO_2), TD(TD_DIABLO_3), TD(TD_DIABLO_4), \
152 _______, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \
155 [_DIABLO] = KEYMAP( /* Base */
156 KC_ESC, _______, _______, _______,\
157 KC_S, KC_F, KC_I, KC_M, \
158 KC_1, KC_2, KC_3, KC_4, \
159 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
160 _______, KC_DIABLO_CLEAR, KC_Q, SFT_T(KC_SPACE) \
165 [_MACROS] = KEYMAP( /* Base */
166 KC_OVERWATCH, _______, _______, XXXXXXX,\
167 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
168 XXXXXXX, XXXXXXX, XXXXXXX, KC_JUSTGAME, \
169 KC_SYMM, KC_DOOMFIST, KC_TORB, KC_GOODGAME, \
170 KC_SALT, KC_MORESALT, KC_SALTHARD, KC_GLHF \
172 [_MEDIA] = KEYMAP( /* Base */
173 RESET, KC_MUTE, KC_VOLD, KC_VOLU,\
174 KC_MAKE, _______, RGB_HUI, RGB_HUD, \
175 KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, \
176 RGB_TOG, RGB_MOD, RGB_SAI, RGB_VAI, \
177 _______, _______, RGB_SAD, RGB_VAD \
183 void numlock_led_on(void) {
187 void numlock_led_off(void) {
192 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
200 #ifdef TAP_DANCE_ENABLE
201 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
202 if (record->event.pressed) {
205 for (dtime = 0; dtime < 4; dtime++) {
206 diablo_key_time[dtime] = diablo_times[0];
213 if (record->event.pressed) {
214 is_overwatch = !is_overwatch;
216 #ifdef RGBLIGHT_ENABLE
217 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
222 if (!record->event.pressed) {
226 SEND_STRING("Salt, salt, salt...");
227 register_code(KC_ENTER);
228 unregister_code(KC_ENTER);
233 if (!record->event.pressed) {
237 SEND_STRING("Please sir, can I have some more salt?!");
238 register_code(KC_ENTER);
239 unregister_code(KC_ENTER);
244 if (!record->event.pressed) {
248 SEND_STRING("Your salt only makes my penis that much harder, and even more aggressive!");
249 register_code(KC_ENTER);
250 unregister_code(KC_ENTER);
255 if (!record->event.pressed) {
259 SEND_STRING("Good game, everyone!");
260 register_code(KC_ENTER);
261 unregister_code(KC_ENTER);
266 if (!record->event.pressed) {
270 SEND_STRING("Good luck, have fun!!!");
271 register_code(KC_ENTER);
272 unregister_code(KC_ENTER);
277 if (!record->event.pressed) {
281 SEND_STRING("Left click to win!");
282 register_code(KC_ENTER);
283 unregister_code(KC_ENTER);
288 if (!record->event.pressed) {
292 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!");
293 register_code(KC_ENTER);
294 unregister_code(KC_ENTER);
300 if (!record->event.pressed) {
304 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.");
305 register_code(KC_ENTER);
306 unregister_code(KC_ENTER);
312 if (!record->event.pressed) {
316 SEND_STRING("That was positively riveting!");
317 register_code(KC_ENTER);
318 unregister_code(KC_ENTER);
323 if (!record->event.pressed) {
324 SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP SS_TAP(X_ENTER));
333 #ifdef TAP_DANCE_ENABLE
335 // Sends the key press to system, but only if on the Diablo layer
336 void send_diablo_keystroke(uint8_t diablo_key) {
337 if (biton32(layer_state) == _DIABLO) {
338 switch (diablo_key) {
355 // Checks each of the 4 timers/keys to see if enough time has elapsed
356 // Runs the "send string" command if enough time has passed, and resets the timer.
357 void run_diablo_macro_check(void) {
360 for (dtime = 0; dtime < 4; dtime++) {
361 if (check_dtimer(dtime) && diablo_key_time[dtime]) {
362 diablo_timer[dtime] = timer_read();
363 send_diablo_keystroke(dtime);
369 void matrix_init_user(void) {
370 // set Numlock LED to output and low
374 #ifdef RGBLIGHT_ENABLE
380 if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) ){
381 register_code(KC_NUMLOCK);
382 unregister_code(KC_NUMLOCK);
386 void matrix_scan_user(void) {
388 if (is_overwatch && biton32(layer_state) == _MACROS) {
392 // Run Diablo 3 macro checking code.
393 #ifdef TAP_DANCE_ENABLE
394 run_diablo_macro_check();
398 uint32_t layer_state_set_kb(uint32_t state) {
399 #ifdef RGBLIGHT_ENABLE
400 // Check layer, and apply color if its changed since last check
401 switch (biton32(state)) {
408 is_overwatch ? rgblight_mode(17) : rgblight_mode(18);
427 void led_set_user(uint8_t usb_led) {