keymap.c (3624B)
1 /* Copyright 2021 yushakobo 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 "quick17_prefs.h" 18 19 // Defines the keycodes used by our macros in process_record_user 20 enum custom_keycodes { 21 KC_LANG 22 }; 23 24 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 25 [_CONTROL] = LAYOUT( 26 KC_TAB, KC_PGUP,KC_UP, KC_PGDN,KC_HOME,KC_INS, 27 KC_LCTL,KC_LEFT,KC_DOWN,KC_RGHT,KC_END, KC_DEL, 28 KC_LSFT,KC_LGUI,KC_ESC, KC_LALT,LT(3,KC_SPC),TO(1) 29 ), 30 [_EDIT1] = LAYOUT( 31 KC_ESC, KC_W, KC_E, KC_R, KC_Y, KC_BSPC, 32 KC_LCTL,KC_A, KC_D, KC_F, KC_H, LCTL(KC_Z), 33 KC_LSFT,KC_X, KC_V, KC_B, LT(2,KC_SPC),LCTL(KC_S) 34 ), 35 [_EDIT2] = LAYOUT( 36 KC_ESC, KC_Q, MS_BTN3,KC_INS, KC_ENT, KC_DEL, 37 KC_LCTL,KC_LBRC,KC_RBRC,KC_PGDN,KC_PGUP,LCTL(KC_Y), 38 KC_LSFT,TO(3), RM_TOGG,TO(0), _______,KC_NO 39 ), 40 [_FN] = LAYOUT( 41 KC_ESC, KC_LANG,KC_NO, RM_TOGG,KC_MNXT,KC_VOLU, 42 KC_CAPS,KC_NUM, KC_NO, RM_NEXT,KC_MPRV,KC_VOLD, 43 CG_NORM,CG_LSWP,EE_CLR, QK_BOOT,TO(0), KC_MUTE 44 ) 45 }; 46 47 bool process_record_user(uint16_t keycode, keyrecord_t *record) { 48 switch (keycode) { 49 case KC_LANG: 50 if (record->event.pressed){ 51 if (keymap_config.swap_lctl_lgui == false){ 52 tap_code16(LALT(KC_GRV)); 53 } else { 54 if(input_mode()){ 55 register_code(KC_LNG2); 56 set_input_mode(false); 57 } else { 58 register_code(KC_LNG1); 59 set_input_mode(true); 60 } 61 } 62 } else { 63 unregister_code(KC_LNG1); 64 unregister_code(KC_LNG2); 65 } 66 break; 67 default: 68 break; 69 } 70 return true; 71 } 72 73 bool encoder_update_user(uint8_t index, bool clockwise){ 74 if (index == 0) { 75 if (IS_LAYER_ON(_EDIT2)){ 76 if (clockwise) { 77 tap_code(KC_LBRC); 78 } else { 79 tap_code(KC_RBRC); 80 } 81 } else if (IS_LAYER_ON(_EDIT1)){ 82 if (clockwise) { 83 tap_code(KC_VOLU); 84 } else { 85 tap_code(KC_VOLD); 86 } 87 } else if (IS_LAYER_ON(_FN)){ 88 if (clockwise) { 89 tap_code(KC_MNXT); 90 } else { 91 tap_code(KC_MPRV); 92 } 93 } else { // IS_LAYER_ON(_CONTROL) 94 if (clockwise) { 95 tap_code(MS_WHLU); 96 } else { 97 tap_code(MS_WHLD); 98 } 99 } 100 } 101 return false; 102 } 103 104 #ifdef RGB_MATRIX_ENABLE 105 void keyboard_post_init_user(void){ 106 rgb_matrix_mode(RGB_MATRIX_CUSTOM_quick17_rgbm_effect); 107 set_input_mode(false); 108 } 109 #else 110 void keyboard_post_init_user(void){ 111 rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); 112 set_input_mode(false); 113 } 114 #endif