keymap.c (6637B)
1 /* Copyright 2020 monksoffunk 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 18 // Defines names for use in layer keycodes and the keymap 19 enum layer_names { 20 _QWERTY, 21 _LOWER, 22 _RAISE, 23 _ADJUST, 24 }; 25 26 // Defines the keycodes used by our macros in process_record_user 27 enum custom_keycodes { 28 QWERTY = SAFE_RANGE, 29 LOWER, 30 RAISE, 31 ADJUST, 32 }; 33 34 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 35 /* Default Layer 36 * ,-----------------------------------------------------------. 37 * | Esc| Q | W | E | R | T | Y | U | I | O | P | BS | 38 * |-----------------------------------------------------------| 39 * | Tab | A | S | D | F | G | H | J | K | L | Ent | 40 * |-----------------------------------------------------------| 41 * | LSft | Z | X | C | V | B | N | M | , | . |fn(/)| 42 * |-----------------------------------------------------------| 43 * | LCtl | LAlt| LGui| spc fn0 | spc fn1 |RGui|RAlt|RCtl| 44 * `-----------------------------------------------------------' 45 */ 46 [_QWERTY] = LAYOUT( 47 KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, 48 KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_ENT, 49 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, LT(_ADJUST, KC_SLSH), 50 KC_LCTL, KC_LALT , KC_LGUI, LT(_LOWER, KC_SPC), LT(_RAISE, KC_SPC), KC_RGUI, KC_RALT, KC_RCTL 51 ), 52 53 /* Lower Layer 54 * ,-----------------------------------------------------------. 55 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del| 56 * |-----------------------------------------------------------| 57 * | | | | | | | _ | + | { | } | Pipe | 58 * |-----------------------------------------------------------| 59 * | | | | | | | | ; | ' | Up | | 60 * |-----------------------------------------------------------| 61 * | | | | | |Left|Down|Right | 62 * `-----------------------------------------------------------' 63 */ 64 [_LOWER] = LAYOUT( 65 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, 66 _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, 67 _______, _______, _______, _______, _______, _______, _______, KC_SCLN, KC_QUOT, KC_UP, _______, 68 _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT 69 ), 70 71 /* Raise Layer 72 * ,-----------------------------------------------------------. 73 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del| 74 * |-----------------------------------------------------------| 75 * | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | Pipe | 76 * |-----------------------------------------------------------| 77 * | F7 | F8 | F9 | F10| F11| F12| \ | \ | | | | 78 * |-----------------------------------------------------------| 79 * | | | | | | | | | 80 * `-----------------------------------------------------------' 81 */ 82 [_RAISE] = LAYOUT( 83 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, 84 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, 85 KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, 86 _______, _______, _______, _______, _______, _______, _______, _______ 87 ), 88 89 /* Adjust Layer 90 * ,-----------------------------------------------------------. 91 * |Mute| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10|F11 | 92 * |-----------------------------------------------------------| 93 * | |BTOG |BSTP|BINC| MAC|RGBTOG|HUI|WIN|SAI|VAI| F12 | 94 * |-----------------------------------------------------------| 95 * | Caps |Reset|BBRE|BDEC| |RMOD|HUD | |SAD|VAD | | 96 * |-----------------------------------------------------------| 97 * |SLEEP| | | | | | | | 98 * `-----------------------------------------------------------' 99 */ 100 [_ADJUST] = LAYOUT( 101 KC_MUTE, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, 102 _______, BL_TOGG, BL_STEP, BL_UP, AG_NORM, UG_TOGG, UG_HUEU, AG_SWAP, UG_SATU, UG_VALU, KC_F12, 103 KC_CAPS, QK_BOOT, BL_BRTG, BL_DOWN, _______, UG_NEXT, UG_HUED, _______, UG_SATD, UG_VALD, _______, 104 KC_SLEP, _______, _______, _______, _______, _______, _______, _______ 105 ), 106 }; 107 108 bool encoder_update_user(uint8_t index, bool clockwise) { 109 if (index == 0) { /* Left encoder */ 110 switch (get_highest_layer(layer_state)) { 111 case _QWERTY: 112 if (clockwise) { 113 tap_code(KC_TAB); 114 } else { 115 tap_code16(S(KC_TAB)); 116 } 117 break; 118 case _RAISE: 119 if (clockwise) { 120 // tap_code(KC_VOLU); 121 if(keymap_config.swap_lalt_lgui==false){ 122 tap_code(KC_LNG2); 123 }else { 124 tap_code16(A(KC_GRV)); 125 } 126 } else { 127 if(keymap_config.swap_lalt_lgui==false){ 128 tap_code(KC_LNG1); 129 } else { 130 tap_code16(A(KC_GRV)); 131 } 132 } 133 break; 134 case _ADJUST: 135 if (clockwise) { 136 tap_code(KC_VOLU); 137 } else { 138 tap_code(KC_VOLD); 139 } 140 } 141 142 } else if (index == 1) { /* Right encoder */ 143 if (clockwise) { 144 tap_code(KC_PGDN); 145 } else { 146 tap_code(KC_PGUP); 147 } 148 } 149 return true; 150 }