aboutsummaryrefslogtreecommitdiff
path: root/keyboards/splitkb/kyria/keymaps/plattfot/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/splitkb/kyria/keymaps/plattfot/keymap.c')
-rw-r--r--keyboards/splitkb/kyria/keymaps/plattfot/keymap.c480
1 files changed, 480 insertions, 0 deletions
diff --git a/keyboards/splitkb/kyria/keymaps/plattfot/keymap.c b/keyboards/splitkb/kyria/keymaps/plattfot/keymap.c
new file mode 100644
index 000000000..78e30c156
--- /dev/null
+++ b/keyboards/splitkb/kyria/keymaps/plattfot/keymap.c
@@ -0,0 +1,480 @@
1/* Copyright 2020-2021 Fredrik Salomonsson <plattfot@gmail.com>
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 QMK_KEYBOARD_H
17#include "version.h"
18
19enum custom_keycodes {
20 PLACEHOLDER = SAFE_RANGE, // can always be here
21 // New keys
22 CLO_TAP, // Close the next key press
23};
24
25// Close tap feature based on a post from drashna
26// https://www.reddit.com/r/olkb/comments/citkbx/double_key_press_modifier_qmkwould_work_like/ev9cue8/
27// Will insert the closing equivalent key and move the cursor inside.
28// For example clo_tap and then ( will result in (|), where | is the
29// cursor. For " it will be "|" as the close equivalent key is the
30// same key.
31enum close_tap_modes {
32 CLO_DISABLED = 0b000,
33 CLO_PRESSED = 0b001, // Close tap key is pressed
34 CLO_ACTIVE = 0b010, // Close tap next keypress
35 CLO_USED = 0b100, // Turn off when close tap key is released
36};
37
38#define CLO_RELEASE(flag) flag & ~CLO_PRESSED
39
40static enum close_tap_modes close_tap_it = CLO_DISABLED;
41
42enum layers {
43 _DEFAULT,
44 _LOWER,
45 _RAISE,
46 _NAV,
47 _ADJUST,
48};
49
50#define MO_ADJT MO(_ADJUST)
51#define L_RAISE OSL(_RAISE)
52#define L_LOWER OSL(_LOWER)
53#define L_NAV MO(_NAV)
54#define EU_TDOT RSA(KC_SLSH)
55#define EU_CDOT RALT(KC_EQUAL)
56#define EU_DEG RALT(KC_SCLN)
57
58// clang-format off
59const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
60/*
61 * Base Layer: Default
62 *
63 * ,-------------------------------------------. ,-------------------------------------------.
64 * | Esc | Q | W | E | R | T | | Y | U | I | O | P | Del |
65 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
66 * | Tab | A | S | D | F | G | | H | J | K | L | ; | ' |
67 * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
68 * | LShift | Z | X | C | V | B | Lead | RAISE| | LOWER|BSpace| N | M | , | . | / | RShift |
69 * `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
70 * | MPlay| GUI | LCtrl| Space| LALT | | RCtrl| Enter| NAV | RALT |Scroll|
71 * | | | | | | | | | | | Lock |
72 * `----------------------------------' `----------------------------------'
73 */
74 [_DEFAULT] = LAYOUT(
75 KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
76 KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
77 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LEAD, L_RAISE, L_LOWER, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
78 KC_MPLY,KC_LGUI,KC_LCTL, KC_SPACE, KC_LALT, KC_RCTL, KC_ENT, L_NAV, KC_RALT, KC_SLCK
79 ),
80
81/*
82 * Lower Layer: Left symbols
83 *
84 * ,-------------------------------------------. ,-------------------------------------------.
85 * | | ! | @ | # | $ | % | | F6 | F7 | F8 | F9 | F10 | |
86 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
87 * | | | | _ | \ | - | + | | F12 | | | | | |
88 * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
89 * | | ° | : | ( | ) | × | |ADJUST| | | |CLOTAP| | | | | |
90 * `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
91 * | | | | | | | | | | | |
92 * | | | | | | | | | | | |
93 * `----------------------------------' `----------------------------------'
94 */
95 [_LOWER] = LAYOUT(
96 _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______,
97 _______, KC_PIPE, KC_UNDS, KC_BSLS, KC_MINS, KC_PLUS, KC_F12, _______, _______, _______, _______, _______,
98 _______, EU_DEG, KC_COLN, KC_LPRN, KC_RPRN, EU_CDOT, _______, MO_ADJT, _______, _______, CLO_TAP, _______, _______, _______, _______, _______,
99 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
100 ),
101/*
102 * Raise Layer: Right symbols + state
103 *
104 * ,-------------------------------------------. ,-------------------------------------------.
105 * | | F1 | F2 | F3 | F4 | F5 | | ^ | & | * | ~ | ? | |
106 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
107 * | | | | | | F11 | | = | { | } | [ | ] | ` |
108 * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
109 * | | | | | |CLOTAP| | | |ADJUST| | … | " | < | > | / |CapsLock|
110 * `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
111 * | Mute | | | | | | | | | |Insert|
112 * | | | | | | | | | | | |
113 * `----------------------------------' `----------------------------------'
114 */
115 [_RAISE] = LAYOUT(
116 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_CIRC, KC_AMPR, KC_ASTR, KC_TILDE,KC_QUES, _______,
117 _______, _______, _______, _______, _______, KC_F11, KC_EQUAL,KC_LCBR, KC_RCBR, KC_LBRC, KC_RBRC, KC_GRV,
118 _______, _______, _______, _______, _______, CLO_TAP, _______, _______, MO_ADJT, _______, EU_TDOT, KC_DQUO, KC_LT, KC_GT, _______, KC_CAPS,
119 KC_MUTE, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS
120
121 ),
122/*
123 * Navigation Layer: Number/Function keys, navigation
124 *
125 * ,-------------------------------------------. ,-------------------------------------------.
126 * | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
127 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
128 * | | | | | | | | | Left | Up | Down | Right| |
129 * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
130 * | | | | | | | | | | | | | | | | | |
131 * `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
132 * | | | | | | | | | | | |
133 * | | | | | | | | | | | |
134 * `----------------------------------' `----------------------------------'
135 */
136 [_NAV] = LAYOUT(
137 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
138 _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_UP, KC_DOWN, KC_RGHT, _______,
139 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
140 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
141 ),
142/*
143 * Adjust Layer: RGB
144 *
145 * ,-------------------------------------------. ,-------------------------------------------.
146 * | | | | | | | | | | | | | |
147 * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
148 * | | TOG | SAI | HUI | VAI | MOD | | | | | | | |
149 * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
150 * | | | SAD | HUD | VAD | RMOD | | | | | | | | | | | |
151 * `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
152 * | | | | | | | | | | | |
153 * | | | | | | | | | | | |
154 * `----------------------------------' `----------------------------------'
155 */
156 [_ADJUST] = LAYOUT(
157 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
158 _______, RGB_TOG, RGB_SAI, RGB_HUI, RGB_VAI, RGB_MOD, _______, _______, _______, _______, _______, _______,
159 _______, _______, RGB_SAD, RGB_HUD, RGB_VAD, RGB_RMOD,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
160 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
161 ),
162// /*
163// * Layer template
164// *
165// * ,-------------------------------------------. ,-------------------------------------------.
166// * | | | | | | | | | | | | | |
167// * |--------+------+------+------+------+------| |------+------+------+------+------+--------|
168// * | | | | | | | | | | | | | |
169// * |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
170// * | | | | | | | | | | | | | | | | | |
171// * `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
172// * | | | | | | | | | | | |
173// * | | | | | | | | | | | |
174// * `----------------------------------' `----------------------------------'
175// */
176// [_LAYERINDEX] = LAYOUT(
177// _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
178// _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
179// _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
180// _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
181// ),
182};
183// clang-format on
184
185/* void keyboard_post_init_user(void) { */
186/* rgblight_setrgb(51, 135, 204); */
187/* } */
188bool process_record_user(uint16_t keycode, keyrecord_t *record) {
189 if (record->event.pressed) {
190 switch (keycode) {
191 case CLO_TAP:
192 close_tap_it = close_tap_it & CLO_ACTIVE?
193 CLO_USED:
194 CLO_ACTIVE|CLO_PRESSED;
195 return false;
196 case KC_LEAD:
197 close_tap_it = CLO_DISABLED;
198 return true;
199 }
200 } else if (close_tap_it & CLO_ACTIVE &&
201 keycode != CLO_TAP &&
202 keycode != OSL(_RAISE) &&
203 keycode != OSL(_LOWER) &&
204 keycode != MO(_NAV)) {
205
206 close_tap_it = close_tap_it & CLO_PRESSED?
207 close_tap_it | CLO_USED:
208 CLO_DISABLED;
209 switch(keycode)
210 {
211 case KC_LPRN:
212 tap_code16(KC_RPRN);
213 tap_code16(KC_LEFT);
214 break;
215 case KC_RPRN:
216 tap_code16(KC_LEFT);
217 tap_code16(KC_LPRN);
218 break;
219 case KC_LCBR:
220 tap_code16(KC_RCBR);
221 tap_code16(KC_LEFT);
222 break;
223 case KC_RCBR:
224 tap_code16(KC_LEFT);
225 tap_code16(KC_LCBR);
226 break;
227 case KC_LBRC:
228 tap_code16(KC_RBRC);
229 tap_code16(KC_LEFT);
230 break;
231 case KC_RBRC:
232 tap_code16(KC_LEFT);
233 tap_code16(KC_LBRC);
234 break;
235 case KC_LT:
236 tap_code16(KC_GT);
237 tap_code16(KC_LEFT);
238 break;
239 case KC_GT:
240 tap_code16(KC_LEFT);
241 tap_code16(KC_LT);
242 break;
243 default:
244 tap_code16(keycode);
245 tap_code16(KC_LEFT);
246 break;
247 }
248 } else {
249 switch (keycode) {
250 case CLO_TAP:
251 close_tap_it = close_tap_it & CLO_USED?
252 CLO_DISABLED:
253 CLO_RELEASE(close_tap_it);
254 }
255 }
256
257 return true;
258}
259
260//layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); }
261
262#ifdef OLED_DRIVER_ENABLE
263oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_180; }
264
265// clang-format off
266static void render_qmk_logo(void) {
267 static const char PROGMEM qmk_logo[] = {
268 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
269 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
270 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
271
272 oled_write_P(qmk_logo, false);
273}
274// clang-format on
275static void render_static_info(void) {
276 render_qmk_logo();
277 oled_write_P(PSTR("Kyria rev1.0\n"), false);
278 oled_write_P(PSTR("Keymap: plattfot v2\n"), false);
279}
280
281static void render_status(void) {
282 // QMK Logo and version information
283 render_qmk_logo();
284 oled_write_P(PSTR("Kyria rev1.0\n"), false);
285 oled_write_P(PSTR("v" QMK_VERSION "\n"), false);
286
287 // Host Keyboard Layer Status
288 oled_write_P(PSTR("Layer: "), false);
289 switch (get_highest_layer(layer_state)) {
290 case _DEFAULT:
291 oled_write_P(PSTR("base\n"), false);
292 break;
293 case _LOWER:
294 oled_write_P(PSTR("<-sym/fun->\n"), false);
295 break;
296 case _RAISE:
297 oled_write_P(PSTR("<-fun/sym->\n"), false);
298 break;
299 case _NAV:
300 oled_write_P(PSTR("num/nav\n"), false);
301 break;
302 case _ADJUST:
303 oled_write_P(PSTR("adjust\n"), false);
304 break;
305 default:
306 oled_write_P(PSTR("undefined\n"), false);
307 }
308
309 // Host Keyboard LED Status and Double tap
310 led_t led_state = host_keyboard_led_state();
311 if (led_state.num_lock) {
312 oled_write_P(PSTR("NUMLCK "), false);
313 } else if (close_tap_it) {
314 oled_write_P(PSTR("Close "), false);
315 } else {
316 oled_write_P(PSTR(" "), false);
317 }
318
319 if (led_state.caps_lock) {
320 oled_write_P(PSTR("CAPLCK "), false);
321 } else if (close_tap_it) {
322 oled_write_P(PSTR("Tap "), false);
323 } else {
324 oled_write_P(PSTR(" "), false);
325 }
326
327 oled_write_P(led_state.scroll_lock ? PSTR("SCRLCK ") : PSTR(" "), false);
328}
329
330void oled_task_user(void) {
331 if (is_keyboard_master()) {
332 render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
333 } else {
334 render_static_info();
335 }
336}
337#endif
338
339#ifdef ENCODER_ENABLE
340bool encoder_update_user(uint8_t index, bool clockwise) {
341 if (index == 0) {
342 switch (get_highest_layer(layer_state)) {
343 case _LOWER:
344 // Skip/Prev song
345 if (clockwise) {
346 tap_code(KC_MNXT);
347 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
348 } else {
349 tap_code(KC_MPRV);
350 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
351 }
352 break;
353 case _NAV:
354 // Brightness control
355 if (clockwise) {
356 tap_code(KC_BRIU);
357 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
358 } else {
359 tap_code(KC_BRID);
360 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
361 }
362 break;
363 default:
364 // Volume control
365 if (clockwise) {
366 tap_code(KC_VOLU);
367 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
368 } else {
369 tap_code(KC_VOLD);
370 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
371 }
372 break;
373 }
374 } else if (index == 1) {
375 switch (get_highest_layer(layer_state)) {
376 case _RAISE:
377 // Scroll through the workspaces
378 if (clockwise) {
379 tap_code16(G(KC_GT));
380 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
381 } else {
382 tap_code16(G(KC_LT));
383 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
384 }
385 break;
386 default:
387 // Scrolling
388 if (clockwise) {
389 tap_code(KC_PGDN);
390 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
391 } else {
392 tap_code(KC_PGUP);
393 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
394 }
395 break;
396 }
397 }
398 return true;
399}
400#endif
401
402LEADER_EXTERNS();
403
404void matrix_scan_user(void) {
405 LEADER_DICTIONARY() {
406 leading = false;
407 leader_end();
408 // Sway navigation
409 SEQ_ONE_KEY(KC_Q) { // Jump to workspace 1
410 SEND_STRING(SS_LGUI("1"));
411 }
412 SEQ_ONE_KEY(KC_W) { // Jump to workspace 2
413 SEND_STRING(SS_LGUI("2"));
414 }
415 SEQ_ONE_KEY(KC_E) { // Jump to workspace 3
416 SEND_STRING(SS_LGUI("3"));
417 }
418 SEQ_ONE_KEY(KC_R) { // Jump to workspace 4
419 SEND_STRING(SS_LGUI("4"));
420 }
421 SEQ_ONE_KEY(KC_T) { // Jump to workspace 5
422 SEND_STRING(SS_LGUI("5"));
423 }
424
425 SEQ_ONE_KEY(KC_Y) { // Jump to workspace 6
426 SEND_STRING(SS_LGUI("6"));
427 }
428 SEQ_ONE_KEY(KC_U) { // Jump to workspace 7
429 SEND_STRING(SS_LGUI("7"));
430 }
431 SEQ_ONE_KEY(KC_I) { // Jump to workspace 8
432 SEND_STRING(SS_LGUI("8"));
433 }
434 SEQ_ONE_KEY(KC_O) { // Jump to workspace 9
435 SEND_STRING(SS_LGUI("9"));
436 }
437 SEQ_ONE_KEY(KC_P) { // Jump to workspace 0
438 SEND_STRING(SS_LGUI("0"));
439 }
440 SEQ_ONE_KEY(KC_G) { // View scratch pad
441 SEND_STRING(SS_LGUI("-"));
442 }
443
444 // Sway move window
445 SEQ_TWO_KEYS(KC_M, KC_Q) { // Move to workspace 1
446 SEND_STRING(SS_LSFT(SS_LGUI("1")));
447 }
448 SEQ_TWO_KEYS(KC_M, KC_W) { // Move to workspace 2
449 SEND_STRING(SS_LSFT(SS_LGUI("2")));
450 }
451 SEQ_TWO_KEYS(KC_M, KC_E) { // Move to workspace 3
452 SEND_STRING(SS_LSFT(SS_LGUI("3")));
453 }
454 SEQ_TWO_KEYS(KC_M, KC_R) { // Move to workspace 4
455 SEND_STRING(SS_LSFT(SS_LGUI("4")));
456 }
457 SEQ_TWO_KEYS(KC_M, KC_T) { // Move to workspace 5
458 SEND_STRING(SS_LSFT(SS_LGUI("5")));
459 }
460
461 SEQ_TWO_KEYS(KC_M, KC_Y) { // Move to workspace 6
462 SEND_STRING(SS_LSFT(SS_LGUI("6")));
463 }
464 SEQ_TWO_KEYS(KC_M, KC_U) { // Move to workspace 7
465 SEND_STRING(SS_LSFT(SS_LGUI("7")));
466 }
467 SEQ_TWO_KEYS(KC_M, KC_I) { // Move to workspace 8
468 SEND_STRING(SS_LSFT(SS_LGUI("8")));
469 }
470 SEQ_TWO_KEYS(KC_M, KC_O) { // Move to workspace 9
471 SEND_STRING(SS_LSFT(SS_LGUI("9")));
472 }
473 SEQ_TWO_KEYS(KC_M, KC_P) { // Move to workspace 0
474 SEND_STRING(SS_LSFT(SS_LGUI("0")));
475 }
476 SEQ_TWO_KEYS(KC_M, KC_G) { // Move to scratch pad
477 SEND_STRING(SS_LSFT(SS_LGUI("-")));
478 }
479 }
480}