diff options
Diffstat (limited to 'keyboards/handwired/woodpad/keymaps/drashna/keymap.c')
-rw-r--r-- | keyboards/handwired/woodpad/keymaps/drashna/keymap.c | 440 |
1 files changed, 440 insertions, 0 deletions
diff --git a/keyboards/handwired/woodpad/keymaps/drashna/keymap.c b/keyboards/handwired/woodpad/keymaps/drashna/keymap.c new file mode 100644 index 000000000..a33a7ab46 --- /dev/null +++ b/keyboards/handwired/woodpad/keymaps/drashna/keymap.c | |||
@@ -0,0 +1,440 @@ | |||
1 | /* Copyright 2017 REPLACE_WITH_YOUR_NAME | ||
2 | * | ||
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. | ||
7 | * | ||
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. | ||
12 | * | ||
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/>. | ||
15 | */ | ||
16 | #include "woodpad.h" | ||
17 | |||
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. | ||
22 | #define _NUMLOCK 0 | ||
23 | #define _NAV 1 | ||
24 | #define _DIABLO 2 | ||
25 | #define _MACROS 3 | ||
26 | #define _MEDIA 4 | ||
27 | |||
28 | // Fillers to make layering more clear | ||
29 | #define _______ KC_TRNS | ||
30 | #define XXXXXXX KC_NO | ||
31 | |||
32 | |||
33 | //define layer change stuff for underglow indicator | ||
34 | bool skip_leds = false; | ||
35 | |||
36 | bool is_overwatch = false; | ||
37 | |||
38 | //This is both for underglow, and Diablo 3 macros | ||
39 | bool has_layer_changed = false; | ||
40 | static uint8_t current_layer; | ||
41 | |||
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]; | ||
47 | |||
48 | |||
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; | ||
52 | }; | ||
53 | #endif | ||
54 | |||
55 | |||
56 | enum custom_keycodes { | ||
57 | PLACEHOLDER = SAFE_RANGE, // can always be here | ||
58 | KC_DIABLO_CLEAR, | ||
59 | KC_OVERWATCH, | ||
60 | KC_SALT, | ||
61 | KC_MORESALT, | ||
62 | KC_SALTHARD, | ||
63 | KC_GOODGAME, | ||
64 | KC_SYMM, | ||
65 | KC_DOOMFIST, | ||
66 | KC_JUSTGAME, | ||
67 | KC_GLHF, | ||
68 | KC_TORB | ||
69 | }; | ||
70 | |||
71 | #ifdef TAP_DANCE_ENABLE | ||
72 | enum { | ||
73 | TD_DIABLO_1 = 0, | ||
74 | TD_DIABLO_2, | ||
75 | TD_DIABLO_3, | ||
76 | TD_DIABLO_4 | ||
77 | }; | ||
78 | |||
79 | |||
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); | ||
86 | } | ||
87 | else { | ||
88 | diablo_key_time[diablo_key] = diablo_times[state->count - 1]; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | |||
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); | ||
96 | } | ||
97 | |||
98 | void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) { | ||
99 | diablo_tapdance_master(state, user_data, 1); | ||
100 | } | ||
101 | |||
102 | void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) { | ||
103 | diablo_tapdance_master(state, user_data, 2); | ||
104 | } | ||
105 | |||
106 | void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) { | ||
107 | diablo_tapdance_master(state, user_data, 3); | ||
108 | } | ||
109 | |||
110 | |||
111 | |||
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), | ||
119 | |||
120 | }; | ||
121 | #endif | ||
122 | |||
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 \ | ||
130 | ), | ||
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, _______, _______ \ | ||
137 | ), | ||
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) \ | ||
145 | ), | ||
146 | #else | ||
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) \ | ||
153 | ), | ||
154 | |||
155 | #endif | ||
156 | |||
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 \ | ||
163 | ), | ||
164 | [_MEDIA] = KEYMAP( /* Base */ | ||
165 | _______, 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 \ | ||
170 | ), | ||
171 | |||
172 | }; | ||
173 | |||
174 | const uint16_t PROGMEM fn_actions[] = { | ||
175 | |||
176 | }; | ||
177 | |||
178 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
179 | { | ||
180 | switch (id) { | ||
181 | case 0: | ||
182 | if (record->event.pressed) { | ||
183 | // Output Keyboard Firmware info | ||
184 | SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP ); | ||
185 | return false; | ||
186 | } | ||
187 | } | ||
188 | return MACRO_NONE; | ||
189 | }; | ||
190 | void numlock_led_on(void) { | ||
191 | PORTF |= (1<<7); | ||
192 | } | ||
193 | |||
194 | void numlock_led_off(void) { | ||
195 | PORTF &= ~(1<<7); | ||
196 | } | ||
197 | |||
198 | |||
199 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
200 | uint16_t kc; | ||
201 | if (is_overwatch) { | ||
202 | kc = KC_BSPC; | ||
203 | } else { | ||
204 | kc = KC_ENTER; | ||
205 | } | ||
206 | switch (keycode) { | ||
207 | #ifdef TAP_DANCE_ENABLE | ||
208 | case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them | ||
209 | if (record->event.pressed) { | ||
210 | uint8_t dtime; | ||
211 | |||
212 | for (dtime = 0; dtime < 4; dtime++) { | ||
213 | diablo_key_time[dtime] = diablo_times[0]; | ||
214 | } | ||
215 | } | ||
216 | return false; | ||
217 | break; | ||
218 | #endif | ||
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; | ||
223 | } | ||
224 | return false; | ||
225 | break; | ||
226 | case KC_SALT: | ||
227 | if (!record->event.pressed) { | ||
228 | register_code(kc); | ||
229 | unregister_code(kc); | ||
230 | _delay_ms(50); | ||
231 | SEND_STRING("Salt, salt, salt..."); | ||
232 | register_code(KC_ENTER); | ||
233 | unregister_code(KC_ENTER); | ||
234 | } | ||
235 | return false; | ||
236 | break; | ||
237 | case KC_MORESALT: | ||
238 | if (!record->event.pressed) { | ||
239 | register_code(kc); | ||
240 | unregister_code(kc); | ||
241 | _delay_ms(50); | ||
242 | SEND_STRING("Please sir, can I have some more salt?!"); | ||
243 | register_code(KC_ENTER); | ||
244 | unregister_code(KC_ENTER); | ||
245 | } | ||
246 | return false; | ||
247 | break; | ||
248 | case KC_SALTHARD: | ||
249 | if (!record->event.pressed) { | ||
250 | register_code(kc); | ||
251 | unregister_code(kc); | ||
252 | _delay_ms(50); | ||
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); | ||
256 | } | ||
257 | return false; | ||
258 | break; | ||
259 | case KC_GOODGAME: | ||
260 | if (!record->event.pressed) { | ||
261 | register_code(kc); | ||
262 | unregister_code(kc); | ||
263 | _delay_ms(50); | ||
264 | SEND_STRING("Good game, everyone!"); | ||
265 | register_code(KC_ENTER); | ||
266 | unregister_code(KC_ENTER); | ||
267 | } | ||
268 | return false; | ||
269 | break; | ||
270 | case KC_GLHF: | ||
271 | if (!record->event.pressed) { | ||
272 | register_code(kc); | ||
273 | unregister_code(kc); | ||
274 | _delay_ms(50); | ||
275 | SEND_STRING("Good luck, have fun!!!"); | ||
276 | register_code(KC_ENTER); | ||
277 | unregister_code(KC_ENTER); | ||
278 | } | ||
279 | return false; | ||
280 | break; | ||
281 | case KC_SYMM: | ||
282 | if (!record->event.pressed) { | ||
283 | register_code(kc); | ||
284 | unregister_code(kc); | ||
285 | _delay_ms(50); | ||
286 | SEND_STRING("Left click to win!"); | ||
287 | register_code(KC_ENTER); | ||
288 | unregister_code(KC_ENTER); | ||
289 | } | ||
290 | return false; | ||
291 | break; | ||
292 | case KC_DOOMFIST: | ||
293 | if (!record->event.pressed) { | ||
294 | register_code(kc); | ||
295 | unregister_code(kc); | ||
296 | _delay_ms(50); | ||
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); | ||
300 | } | ||
301 | return false; | ||
302 | break; | ||
303 | case KC_JUSTGAME: | ||
304 | |||
305 | if (!record->event.pressed) { | ||
306 | register_code(kc); | ||
307 | unregister_code(kc); | ||
308 | _delay_ms(50); | ||
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); | ||
312 | } | ||
313 | return false; | ||
314 | break; | ||
315 | case KC_TORB: | ||
316 | |||
317 | if (!record->event.pressed) { | ||
318 | register_code(kc); | ||
319 | unregister_code(kc); | ||
320 | _delay_ms(50); | ||
321 | SEND_STRING("That was positively riveting!"); | ||
322 | register_code(KC_ENTER); | ||
323 | unregister_code(KC_ENTER); | ||
324 | } | ||
325 | return false; | ||
326 | break; | ||
327 | |||
328 | } | ||
329 | return true; | ||
330 | } | ||
331 | #ifdef TAP_DANCE_ENABLE | ||
332 | |||
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) { | ||
337 | case 0: | ||
338 | SEND_STRING("1"); | ||
339 | break; | ||
340 | case 1: | ||
341 | SEND_STRING("2"); | ||
342 | break; | ||
343 | case 2: | ||
344 | SEND_STRING("3"); | ||
345 | break; | ||
346 | case 3: | ||
347 | SEND_STRING("4"); | ||
348 | break; | ||
349 | } | ||
350 | } | ||
351 | } | ||
352 | |||
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) { | ||
356 | uint8_t dtime; | ||
357 | |||
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); | ||
362 | } | ||
363 | } | ||
364 | |||
365 | } | ||
366 | #endif | ||
367 | void matrix_init_user(void) { | ||
368 | has_layer_changed = true; | ||
369 | // set Numlock LED to output and low | ||
370 | DDRF |= (1<<7); | ||
371 | PORTF &= ~(1<<7); | ||
372 | } | ||
373 | |||
374 | void matrix_scan_user(void) { | ||
375 | uint8_t layer = biton32(layer_state); | ||
376 | #ifdef RGBLIGHT_ENABLE | ||
377 | |||
378 | numlock_led_off(); | ||
379 | // Check layer, and apply color if its changed since last check | ||
380 | switch (layer) { | ||
381 | case _NAV: | ||
382 | if (has_layer_changed) { | ||
383 | rgblight_sethsv(240, 255, 255); | ||
384 | rgblight_mode(1); | ||
385 | } | ||
386 | break; | ||
387 | case _MACROS: | ||
388 | if (has_layer_changed) { | ||
389 | rgblight_sethsv(30, 255, 255); | ||
390 | if (is_overwatch) { | ||
391 | rgblight_mode(17); | ||
392 | } else { | ||
393 | rgblight_mode(18); | ||
394 | } | ||
395 | } | ||
396 | if (is_overwatch) { | ||
397 | numlock_led_on(); | ||
398 | } | ||
399 | break; | ||
400 | case _DIABLO: | ||
401 | if (has_layer_changed) { | ||
402 | rgblight_sethsv(0, 255, 255); | ||
403 | rgblight_mode(5); | ||
404 | } | ||
405 | break; | ||
406 | case _MEDIA: | ||
407 | if (has_layer_changed) { | ||
408 | rgblight_sethsv(120, 255, 255); | ||
409 | rgblight_mode(22); | ||
410 | } | ||
411 | break; | ||
412 | default: | ||
413 | if (has_layer_changed) { | ||
414 | rgblight_sethsv(195, 255, 255); | ||
415 | rgblight_mode(1); | ||
416 | } | ||
417 | break; | ||
418 | } | ||
419 | |||
420 | #endif | ||
421 | // Update layer status at the end, so this sets the default color | ||
422 | // rather than relying on the init, which was unreliably... | ||
423 | // Probably due to a timing issue, but this requires no additional code | ||
424 | if (current_layer == layer) { | ||
425 | has_layer_changed = false; | ||
426 | } | ||
427 | else { | ||
428 | has_layer_changed = true; | ||
429 | current_layer = layer; | ||
430 | } | ||
431 | // Run Diablo 3 macro checking code. | ||
432 | #ifdef TAP_DANCE_ENABLE | ||
433 | run_diablo_macro_check(); | ||
434 | #endif | ||
435 | } | ||
436 | |||
437 | |||
438 | void led_set_user(uint8_t usb_led) { | ||
439 | |||
440 | } | ||