keymap.c (2461B)
1 /* Copyright 2021 Valdydesu_ 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 17 #include QMK_KEYBOARD_H 18 19 enum planck_layers { 20 _1, 21 _2, 22 _3, 23 _4 24 25 }; 26 27 #define L1 PDF(_1) 28 #define L2 PDF(_2) 29 #define L3 PDF(_3) 30 #define LOWER MO(_4) 31 32 #define IND_1 D4 33 #define IND_2 C6 34 #define IND_3 D7 35 36 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 37 38 [_1] = LAYOUT( 39 KC_ESC, KC_F1, KC_F2, 40 LOWER, KC_Z, KC_X), 41 42 [_2] = LAYOUT( 43 LALT(KC_TAB), LGUI(KC_TAB), LCTL(KC_S), 44 LOWER, LCTL(KC_C), LCTL(KC_V)), 45 46 [_3] = LAYOUT( 47 KC_TRNS, KC_TRNS, KC_TRNS, 48 KC_TRNS, KC_TRNS, KC_TRNS), 49 50 [_4] = LAYOUT( 51 L1, L2, L3, 52 _______, _______, _______), 53 54 }; 55 56 57 layer_state_t layer_state_set_user(layer_state_t state) { 58 state = update_tri_layer_state(state, _4, X_PAUSE, X_PAUSE); 59 gpio_write_pin(IND_1, layer_state_cmp(state, 1)); 60 gpio_write_pin(IND_2, layer_state_cmp(state, 2)); 61 gpio_write_pin(IND_3, layer_state_cmp(state, 3)); 62 return state; 63 } 64 65 void matrix_init_user(void) { 66 //init the Pro Micro on-board LEDs 67 gpio_set_pin_output(IND_1); 68 gpio_set_pin_output(IND_2); 69 gpio_set_pin_output(IND_3); 70 //set to off 71 gpio_write_pin_high(IND_1); 72 gpio_write_pin_high(IND_2); 73 gpio_write_pin_high(IND_3); 74 } 75 76 bool encoder_update_user(uint8_t index, bool clockwise) { 77 if (layer_state_is(_1)) { 78 if (clockwise) { 79 tap_code(KC_UP); 80 } else { 81 tap_code(KC_DOWN); 82 } 83 } else if (layer_state_is(_2)) { 84 if (clockwise) { 85 tap_code(KC_RGHT); 86 } else { 87 tap_code(KC_LEFT); 88 } 89 } else if (layer_state_is(_3)) { 90 if (clockwise) { 91 tap_code(KC_VOLU); 92 } else { 93 tap_code(KC_VOLD); 94 } 95 } 96 return true; 97 }