2 #include "action_layer.h"
5 extern keymap_config_t keymap_config;
7 // Each layer gets a name for readability, which is then used in the keymap matrix below.
8 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
9 // Layer names don't all need to be of the same length, obviously, and you can also skip them
10 // entirely and just use numbers.
18 enum custom_keycodes {
19 KC_DIABLO_CLEAR = SAFE_RANGE,
33 // Fillers to make layering more clear
34 #define _______ KC_TRNS
36 #define MACROS TG(_MACROS)
37 #define DIABLO TG(_DIABLO)
38 #define GAMEPAD TG(_GAMEPAD)
39 #define MEDIA TG(_MEDIA)
42 bool is_overwatch = false;
44 //This is both for underglow, and Diablo 3 macros
45 static uint8_t current_layer = 0;
46 bool has_layer_changed = true;
49 #define rgblight_set_blue rgblight_sethsv (0xFF, 0xFF, 0xFF);
50 #define rgblight_set_red rgblight_sethsv(0x00, 0xFF, 0xFF);
51 #define rgblight_set_green rgblight_sethsv (0x78, 0xFF, 0xFF);
52 #define rgblight_set_orange rgblight_sethsv (0x1E, 0xFF, 0xFF);
53 #define rgblight_set_teal rgblight_sethsv (0xC3, 0xFF, 0xFF);
54 #define rgblight_set_magenta rgblight_sethsv (0x12C, 0xFF, 0xFF);
55 #define rgblight_set_urine rgblight_sethsv (0x3C, 0xFF, 0xFF);
56 #define rgblight_set_purple rgblight_sethsv (0x10E, 0xFF, 0xFF);
58 #ifdef TAP_DANCE_ENABLE
59 //define diablo macro timer variables
60 static uint16_t diablo_timer[4];
61 static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
62 static uint8_t diablo_key_time[4];
65 bool check_dtimer(uint8_t dtimer) {
66 // has the correct number of seconds elapsed (as defined by diablo_times)
67 return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true;
79 // Cycle through the times for the macro, starting at 0, for disabled.
80 // Max of six values, so don't exceed
81 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
82 if (state->count >= 7) {
83 diablo_key_time[diablo_key] = diablo_times[0];
84 reset_tap_dance(state);
87 diablo_key_time[diablo_key] = diablo_times[state->count - 1];
92 // Would rather have one function for all of this, but no idea how to do that...
93 void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) {
94 diablo_tapdance_master(state, user_data, 0);
97 void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) {
98 diablo_tapdance_master(state, user_data, 1);
101 void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) {
102 diablo_tapdance_master(state, user_data, 2);
105 void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) {
106 diablo_tapdance_master(state, user_data, 3);
111 //Tap Dance Definitions
112 qk_tap_dance_action_t tap_dance_actions[] = {
113 // tap once to disable, and more to enable timed micros
114 [TD_DIABLO_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
115 [TD_DIABLO_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
116 [TD_DIABLO_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
117 [TD_DIABLO_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
123 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
126 * ,------------------------------------------------. ,------------------------------------------------.
127 * | Ins | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp | Del |
128 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
129 * | - | Tab | Q | W | E | R | T | | Y | U | I | O | P | [ | ] |
130 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
131 * | = | Esc | A | S | D | F | G | | H | J | K | L | ; | " |Enter |
132 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
133 * | Pg Up| Shift| Z | X | C | V | B | | N | M | , | . | / | Home | End |
134 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
135 * | Pg Dn|Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | Left | Down | Up | Right| \ |
136 * `------------------------------------------------' `------------------------------------------------'
139 MACROS, DIABLO, GAMEPAD, KC_NLCK, KC_SCLK, KC_PTSC, KC_PSLS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
140 MEDIA, XXXXXXX, XXXXXXX, KC_P7, KC_P8, KC_P9, KC_PAST, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
141 KC_HOME, KC_DEL, KC_PGUP, KC_P4, KC_P5, KC_P6, KC_PMNS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
142 KC_END, KC_UP, KC_PGDN, KC_P1, KC_P2, KC_P3, KC_PPLS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
143 KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_P00, KC_PDOT, KC_PENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
147 * ,------------------------------------------------. ,------------------------------------------------.
148 * | | ~ | F1 | F3 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
149 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
150 * | _ | | ! | @ | # | $ | % | | ^ | & | * | ( | ) | { | } |
151 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
152 * | + | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
153 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
154 * | | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | | | |
155 * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
156 * | | | | | | | | | | | Next | Vol- | Vol+ | Play | |
157 * `------------------------------------------------' `------------------------------------------------'
160 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
161 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
162 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
163 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
164 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
169 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
170 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
171 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
172 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
173 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
177 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
178 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
179 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
180 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
181 _______, _______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
188 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
197 #ifdef TAP_DANCE_ENABLE
198 case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them
199 if (record->event.pressed) {
202 for (dtime = 0; dtime < 4; dtime++) {
203 diablo_key_time[dtime] = diablo_times[0];
210 if (!record->event.pressed) {
211 register_code(KC_P0);
212 unregister_code(KC_P0);
213 register_code(KC_P0);
214 unregister_code(KC_P0);
218 case KC_OVERWATCH: // reset all Diable timers, disabling them
219 if (record->event.pressed) {
220 is_overwatch = !is_overwatch;
221 has_layer_changed = true;
226 if (!record->event.pressed) {
230 SEND_STRING("Salt, salt, salt...");
231 register_code(KC_ENTER);
232 unregister_code(KC_ENTER);
237 if (!record->event.pressed) {
241 SEND_STRING("Please sir, can I have some more salt?!");
242 register_code(KC_ENTER);
243 unregister_code(KC_ENTER);
248 if (!record->event.pressed) {
252 SEND_STRING("Your salt only makes my penis that much harder, and even more aggressive!");
253 register_code(KC_ENTER);
254 unregister_code(KC_ENTER);
259 if (!record->event.pressed) {
263 SEND_STRING("Good game, everyone!");
264 register_code(KC_ENTER);
265 unregister_code(KC_ENTER);
270 if (!record->event.pressed) {
274 SEND_STRING("Good luck, have fun!!!");
275 register_code(KC_ENTER);
276 unregister_code(KC_ENTER);
281 if (!record->event.pressed) {
285 SEND_STRING("Left click to win!");
286 register_code(KC_ENTER);
287 unregister_code(KC_ENTER);
292 if (!record->event.pressed) {
296 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!");
297 register_code(KC_ENTER);
298 unregister_code(KC_ENTER);
304 if (!record->event.pressed) {
308 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.");
309 register_code(KC_ENTER);
310 unregister_code(KC_ENTER);
316 if (!record->event.pressed) {
320 SEND_STRING("That was positively riveting!");
321 register_code(KC_ENTER);
322 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);
369 void matrix_scan_user(void) { // runs frequently to update info
370 uint8_t layer = biton32(layer_state);
372 if (layer != current_layer) {
373 has_layer_changed = true;
374 current_layer = layer;
376 // Check layer, and apply color if its changed since last check
377 if (has_layer_changed) {
406 has_layer_changed = false;
409 #ifdef TAP_DANCE_ENABLE
410 // Run Diablo 3 macro checking code.
411 run_diablo_macro_check();