aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dz60/keymaps/jdelkins/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/dz60/keymaps/jdelkins/keymap.c')
-rw-r--r--keyboards/dz60/keymaps/jdelkins/keymap.c279
1 files changed, 279 insertions, 0 deletions
diff --git a/keyboards/dz60/keymaps/jdelkins/keymap.c b/keyboards/dz60/keymaps/jdelkins/keymap.c
new file mode 100644
index 000000000..c0bf4445a
--- /dev/null
+++ b/keyboards/dz60/keymaps/jdelkins/keymap.c
@@ -0,0 +1,279 @@
1/*
2 Copyright 2020 Joel Elkins <joel@elkins.com>
3
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.
8
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.
13
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/>.
16*/
17
18#include "jdelkins.h"
19
20#undef LAYOUT
21#define LAYOUT LAYOUT_directional_nosplitspace
22
23#define IDLE_TIMEOUT 360
24uint16_t rgb_idle_seconds = 0;
25uint16_t rgb_timer;
26bool rgb_was_enabled;
27
28// Tap Dance
29
30int ctl_state = 0;
31
32void ctl_finished(qk_tap_dance_state_t *state, void *user_data) {
33 ctl_state = cur_dance(state);
34 switch(ctl_state) {
35 case SINGLE_TAP: qk_leader_start(); break;
36 case SINGLE_HOLD: register_code(KC_LCTL); break;
37 case DOUBLE_TAP: tap_code(KC_RCTL); break;
38 case DOUBLE_HOLD: register_code(KC_RCTL); break;
39 case TRIPLE_TAP: tap_code(KC_RCTL); tap_code(KC_RCTL); break;
40 case TRIPLE_HOLD: tap_code(KC_RCTL); register_code(KC_RCTL); break;
41 }
42}
43
44void ctl_reset(qk_tap_dance_state_t *state, void *user_data) {
45 switch(ctl_state) {
46 case SINGLE_HOLD: unregister_code(KC_LCTL); break;
47 case DOUBLE_HOLD:
48 case TRIPLE_HOLD: unregister_code(KC_RCTL); break;
49 }
50 ctl_state = 0;
51}
52
53void g_finished(qk_tap_dance_state_t *state, void *user_data) {
54 switch (cur_dance(state)) {
55 case SINGLE_TAP:
56 tap_code16(C(KC_END));
57 break;
58 case DOUBLE_TAP:
59 tap_code16(C(KC_HOME));
60 break;
61 }
62}
63
64enum {
65 TD_LDCTL,
66 TD_G,
67};
68
69qk_tap_dance_action_t tap_dance_actions[] = {
70 [TD_LDCTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctl_finished, ctl_reset),
71 [TD_G] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, g_finished, NULL),
72};
73
74// Layers
75
76const uint16_t PROGMEM keymaps[_LAYER_MAX][MATRIX_ROWS][MATRIX_COLS] = {
77 [_QWERTY] = LAYOUT(
78 KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
79 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
80 MY_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
81 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_BSPC, MO(_ADJUST),
82 TD(TD_LDCTL), MY_GUI, MY_ALT, MY_SPC, KC_RALT, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
83 ),
84 [_GAME] = LAYOUT(
85 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
86 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
87 KC_LCTL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
88 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
89 _______, _______, KC_LALT, KC_SPC, _______, _______, _______, _______, _______
90 ),
91 [_FUNC] = LAYOUT(
92 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
93 _______, _______, FW_WRD, KB_EOL, _______, _______, KB_COPY, KC_PGUP, _______, _______, KB_PASTE, KC_SLCK, _______, MY_CALC,
94 _______, KB_BOL, _______, KC_PGDN, _______, TD(TD_G), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______,
95 _______, _______, KC_DEL, _______, _______, BK_WRD, _______, _______, _______, _______, _______, _______, KC_INS, _______,
96 _______, MY_RGUI, MY_RALT, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
97 ),
98 [_KP] = LAYOUT(
99 _______, _______, _______, _______, _______, _______, _______, _______, KC_KP_ASTERISK, _______, _______, _______, _______, _______,
100 KC_NUMLOCK, _______, KC_BTN1, KC_MS_U, KC_BTN2, KC_WH_U, _______, KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_MINUS, _______, _______, _______,
101 _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_D, _______, KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_PLUS, _______, _______,
102 _______, _______, _______, _______, _______, _______, _______, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_SLASH, _______, _______, TG(_KP),
103 _______, _______, _______, KC_KP_0, KC_KP_DOT, _______, _______, _______, _______
104 ),
105 [_ADJUST] = LAYOUT(
106 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
107 _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, _______, _______, _______, KC_PSCR, KC_SLCK, _______, KC_MUTE,
108 _______, RGB_RMOD, RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, TG(_KP), _______, _______, _______, KC_MPLY,
109 _______, RGB_TOG, KB_MAKE, KB_FLSH, KB_VRSN, KB_BOOT, _______, TG_SYS, _______, _______, _______, _______, KC_DEL, _______,
110 _______, MY_RGUI, MY_RALT, _______, _______, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT
111 ),
112};
113
114const rgblight_segment_t PROGMEM game_layer[] = RGBLIGHT_LAYER_SEGMENTS(
115 {0, 1, HSV_RED},
116 {7, 2, HSV_RED},
117 {15, 1, HSV_RED}
118);
119
120const rgblight_segment_t PROGMEM func_layer[] = RGBLIGHT_LAYER_SEGMENTS(
121 {0, 8, HSV_GREEN}
122);
123
124const rgblight_segment_t PROGMEM kp_layer[] = RGBLIGHT_LAYER_SEGMENTS(
125 {0, 16, HSV_ORANGE}
126);
127
128const rgblight_segment_t PROGMEM adjust_layer[] = RGBLIGHT_LAYER_SEGMENTS(
129 {0, 16, HSV_BLUE}
130);
131
132const rgblight_segment_t PROGMEM capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
133 {10, 4, HSV_WHITE}
134);
135
136const rgblight_segment_t PROGMEM numlock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
137 {0, 2, HSV_PURPLE},
138 {14, 2, HSV_PURPLE}
139);
140
141
142enum rgb_layer_index {
143 L_GAME,
144 L_FUNC,
145 L_KP,
146 L_ADJUST,
147 L_CAPSLOCK,
148 L_NUMLOCK,
149};
150
151const rgblight_segment_t * const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
152 [L_GAME] = game_layer,
153 [L_FUNC] = func_layer,
154 [L_KP] = kp_layer,
155 [L_ADJUST] = adjust_layer,
156 [L_CAPSLOCK] = capslock_layer,
157 [L_NUMLOCK] = numlock_layer
158);
159
160layer_state_t layer_state_set_keymap(layer_state_t state) {
161 rgblight_set_layer_state(L_GAME, layer_state_cmp(state, _GAME));
162 rgblight_set_layer_state(L_FUNC, layer_state_cmp(state, _FUNC));
163 rgblight_set_layer_state(L_KP, layer_state_cmp(state, _KP));
164 rgblight_set_layer_state(L_ADJUST, layer_state_cmp(state, _ADJUST));
165 rgblight_set_layer_state(L_CAPSLOCK, CAPSLOCK_ON);
166 rgblight_set_layer_state(L_NUMLOCK, NUMLOCK_ON && layer_state_cmp(state, _KP));
167 if (layer_state_cmp(state, _GAME))
168 autoshift_disable();
169 else
170 autoshift_enable();
171 return state;
172}
173
174bool led_update_user(led_t led_state) {
175 rgblight_set_layer_state(L_CAPSLOCK, led_state.caps_lock);
176 rgblight_set_layer_state(L_NUMLOCK, led_state.num_lock && layer_state_is(_KP));
177 return true;
178}
179
180void keyboard_post_init_keymap(void) {
181 rgblight_layers = my_rgb_layers;
182 rgb_was_enabled = rgblight_is_enabled();
183}
184
185LEADER_EXTERNS();
186
187void matrix_scan_keymap(void) {
188 if (rgblight_is_enabled() && timer_elapsed(rgb_timer) > 1000) {
189 rgb_idle_seconds++;
190 rgb_timer = timer_read();
191 }
192 if (rgb_idle_seconds > IDLE_TIMEOUT) {
193 rgb_was_enabled = rgblight_is_enabled();
194 rgblight_disable_noeeprom();
195 rgb_idle_seconds = 0;
196 }
197 LEADER_DICTIONARY() {
198 leading = false;
199 leader_end();
200
201 SEQ_ONE_KEY(KC_K) {
202 layer_invert(_KP);
203 }
204 SEQ_ONE_KEY(KC_G) {
205 layer_invert(_GAME);
206 }
207 SEQ_ONE_KEY(KC_KP_5) {
208 layer_invert(_KP);
209 }
210 SEQ_TWO_KEYS(KC_SCLN, KC_1) {
211 send_secret_string(0);
212 }
213 SEQ_TWO_KEYS(KC_SCLN, KC_2) {
214 send_secret_string(1);
215 }
216 SEQ_TWO_KEYS(KC_SCLN, KC_3) {
217 send_secret_string(2);
218 }
219 SEQ_TWO_KEYS(KC_SCLN, KC_4) {
220 send_secret_string(3);
221 }
222 SEQ_TWO_KEYS(KC_SCLN, KC_5) {
223 send_secret_string(4);
224 }
225 SEQ_TWO_KEYS(KC_SCLN, KC_6) {
226 send_secret_string(5);
227 }
228 SEQ_TWO_KEYS(KC_SCLN, KC_M) {
229 send_secret_string(0);
230 }
231 SEQ_TWO_KEYS(KC_SCLN, KC_COMM) {
232 send_secret_string(1);
233 }
234 SEQ_TWO_KEYS(KC_SCLN, KC_DOT) {
235 send_secret_string(2);
236 }
237 SEQ_TWO_KEYS(KC_SCLN, KC_J) {
238 send_secret_string(3);
239 }
240 SEQ_TWO_KEYS(KC_SCLN, KC_K) {
241 send_secret_string(4);
242 }
243 SEQ_TWO_KEYS(KC_SCLN, KC_L) {
244 send_secret_string(5);
245 }
246 SEQ_ONE_KEY(KC_C) {
247 tap_code16(C(KC_C));
248 }
249 }
250}
251
252bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
253 static uint16_t gesc_timer;
254
255 rgb_idle_seconds = 0;
256 if (!rgblight_is_enabled() && rgb_was_enabled)
257 rgblight_enable_noeeprom();
258
259 switch (keycode) {
260 // custom handle KC_GESC to emulate auto shift on it
261 case KC_GESC:
262 if (get_autoshift_state()) {
263 if (record->event.pressed)
264 gesc_timer = timer_read();
265 else {
266 if (timer_elapsed(gesc_timer) > AUTO_SHIFT_TIMEOUT || MODS_SHIFT) {
267 tap_code16(S(KC_GRV));
268 } else if (MODS_GUI)
269 tap_code(KC_GRV);
270 else
271 tap_code(KC_ESC);
272 }
273 return false;
274 }
275 return false;
276 }
277
278 return true;
279}