keymap.c (4882B)
1 /* Copyright 2021 ivndbt 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 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 19 /* 20 LAYER 0 - MUSIC 21 /-----------------------------` 22 | TO(1) | stop | mute | L ENC: prev/next song 23 |---------|---------|---------| 24 | prev | play | next | R ENC: vol up/down 25 \-----------------------------' 26 */ 27 [0] = LAYOUT( 28 TO(1), KC_MSTP, KC_MUTE, 29 KC_MPRV, KC_MPLY, KC_MNXT 30 ), 31 32 /* 33 LAYER 1 - MOVEMENT IN WINDOWS 34 /---------------------------------------` 35 | TO(2) | maximize | show desktop | L ENC: change desktop 36 |-------------|----------|--------------| 37 | move window | minimize | move window | R ENC: change browser tab + change explorer window 38 \---------------------------------------' 39 */ 40 [1] = LAYOUT( 41 TO(2), LGUI(KC_UP), LGUI(KC_D), 42 LGUI(KC_LEFT), LGUI(KC_DOWN), LGUI(KC_RIGHT) 43 ), 44 45 /* 46 LAYER 2 - SHORTCUT 47 /------------------------------` 48 | TO(3) | esc | task man | L ENC: redo/undo 49 |---------|---------|----------| 50 | cut | copy | paste | R ENC: mouse wheel up/down 51 \------------------------------' 52 */ 53 [2] = LAYOUT( 54 TO(3), KC_ESC, LCTL(LSFT(KC_ESC)), 55 LCTL(KC_X), LCTL(KC_C), LCTL(KC_V) 56 ), 57 58 /* 59 LAYER 3 - AUDACITY 60 /-----------------------------` 61 | TO(0) | REC | canc | L ENC: pan right/left 62 |---------|---------|---------| 63 | ctrl | play | pause | R ENC: mouse wheel up/down 64 \-----------------------------' 65 */ 66 [3] = LAYOUT( 67 TO(0), LSFT(KC_R), KC_DEL, 68 KC_LCTL, KC_SPC, KC_P 69 ), 70 71 }; 72 73 74 bool encoder_update_user(uint8_t index, bool clockwise) { 75 if (index == 0) { /* LEFT ENCODER */ 76 switch (get_highest_layer(layer_state)) { 77 case 0: 78 // layer 0 - next song (CW) and previous (CCW) 79 if (clockwise) { 80 tap_code(KC_MNXT); 81 } else { 82 tap_code(KC_MPRV); 83 } 84 break; 85 86 case 1: 87 // layer 1 - change desktop right (CW) and left (CCW) 88 if (clockwise) { 89 tap_code16(LCTL(LGUI(KC_RIGHT))); 90 } else { 91 tap_code16(LCTL(LGUI(KC_LEFT))); 92 } 93 break; 94 95 case 2: 96 // layer 2 - redo (CW) and undo (CCW) 97 if (clockwise) { 98 tap_code16(LCTL(KC_Y)); 99 } else { 100 tap_code16(LCTL(KC_Z)); 101 } 102 break; 103 104 case 3: 105 // layer 3 - pan right (CW) and left (CCW) 106 if (clockwise) { 107 tap_code(MS_WHLR); 108 } else { 109 tap_code(MS_WHLL); 110 } 111 break; 112 } 113 114 } else if (index == 1) { /* RIGHT ENCODER */ 115 switch (get_highest_layer(layer_state)) { 116 case 0: 117 // layer 0 - volume up (CW) and down (CCW) 118 if (clockwise) { 119 tap_code(KC_VOLU); 120 } else { 121 tap_code(KC_VOLD); 122 } 123 break; 124 125 case 1: 126 // layer 1 - change browser tab (CW) and change explorer window (CCW) 127 if (clockwise) { 128 tap_code16(LCTL(KC_TAB)); 129 } else { 130 tap_code16(LALT(LSFT(KC_TAB))); 131 } 132 break; 133 134 case 2: 135 // layer 2 - wheel up (CW) and down (CCW) 136 if (clockwise) { 137 tap_code(MS_WHLU); 138 } else { 139 tap_code(MS_WHLD); 140 } 141 break; 142 143 case 3: 144 // layer 3 - wheel up (CW) and down (CCW) 145 if (clockwise) { 146 tap_code(MS_WHLU); 147 } else { 148 tap_code(MS_WHLD); 149 } 150 break; 151 } 152 } 153 return true; 154 }