keymap.c (2515B)
1 /* Copyright 2020 William Ehman 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 // clang-format off 19 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 20 [0] = LAYOUT_ortho_4x4( 21 KC_F1, KC_F2, KC_F3, KC_F4, 22 KC_F5, KC_F6, KC_F7, KC_F8, 23 KC_F9, KC_F10, KC_F11, KC_F12, 24 KC_F13, KC_F14, KC_F15, TO(1) 25 ), 26 [1] = LAYOUT_ortho_4x4( 27 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 28 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 29 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 30 KC_TRNS, KC_TRNS, KC_TRNS, TO(2) 31 ), 32 [2] = LAYOUT_ortho_4x4( 33 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 34 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 35 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 36 KC_TRNS, KC_TRNS, KC_TRNS, TO(0) 37 ), 38 }; 39 // clang-format on 40 41 layer_state_t layer_state_set_user(layer_state_t state) { 42 switch (get_highest_layer(state)) { 43 case 0: 44 rgblight_sethsv_at(HSV_WHITE, 0); 45 break; 46 case 1: 47 rgblight_sethsv_at(HSV_GREEN, 0); 48 break; 49 case 2: 50 rgblight_sethsv_at(HSV_BLUE, 0); 51 break; 52 } 53 return state; 54 } 55 56 bool encoder_update_user(uint8_t index, bool clockwise) { 57 /* With an if statement we can check which encoder was turned. */ 58 if (index == 0) { /* First encoder */ 59 /* And with another if statement we can check the direction. */ 60 if (clockwise) { 61 /* This is where the actual magic happens: this bit of code taps on the 62 Page Down key. You can do anything QMK allows you to do here. 63 You'll want to replace these lines with the things you want your 64 encoders to do. */ 65 tap_code(KC_AUDIO_VOL_UP); 66 } else { 67 /* And likewise for the other direction, this time Vol Down is pressed. */ 68 tap_code(KC_AUDIO_VOL_DOWN); 69 } 70 } 71 return true; 72 }