keymap.c (4266B)
1 /* 2 Copyright 2023 QVEX Tech 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 2 of the License, or 7 (at your option) any later version. 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 #define RGB_HUE_LAYER0 0 //default layer 20 #define RGB_HUE_LAYER1 50 21 #define RGB_HUE_LAYER2 100 22 #define RGB_HUE_LAYER3 150 23 #define RGB_HUE_LAYER4 200 24 25 26 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 27 [0] = LAYOUT //Default 28 ( 29 G(KC_D), G(KC_TAB), C(G(KC_LEFT)), C(G(KC_RIGHT)), 30 G(KC_E), XXXXXXX, C(KC_C), C(KC_V), 31 KC_LGUI, XXXXXXX, XXXXXXX, 32 33 KC_VOLU, KC_VOLD, KC_MPRV, KC_MNXT, //joystick up, down, left, right 34 KC_MPLY, MO(4) //joystick center push, thumbwheel push 35 ), 36 37 [1] = LAYOUT //KiCad 38 ( 39 KC_ESC, KC_R, KC_M, KC_DEL, 40 KC_V, KC_G, KC_D, KC_X, 41 MO(3), KC_B, C(KC_V), 42 43 KC_PLUS, KC_MINUS, C(KC_Y), C(KC_Z), //joystick up, down, left, right 44 KC_PGDN, MO(4) //joystick center push, thumbwheel push 45 ), 46 47 [2] = LAYOUT 48 ( 49 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 50 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 51 XXXXXXX, XXXXXXX, XXXXXXX, 52 53 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right 54 XXXXXXX, MO(4) //joystick center push, thumbwheel push 55 ), 56 57 [3] = LAYOUT 58 ( 59 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 60 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 61 XXXXXXX, XXXXXXX, XXXXXXX, 62 63 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right 64 XXXXXXX, MO(4) //joystick center push, thumbwheel push 65 ), 66 67 [4] = LAYOUT 68 ( 69 TO(0), TO(1), TO(2), TO(3), 70 BL_TOGG, BL_STEP, XXXXXXX, XXXXXXX, 71 QK_RBT, EE_CLR, QK_BOOT, 72 73 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right 74 UG_TOGG, XXXXXXX //joystick center push, thumbwheel push 75 ) 76 }; 77 78 #if defined(ENCODER_MAP_ENABLE) 79 const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { 80 [0] = { 81 ENCODER_CCW_CW(KC_VOLD, KC_VOLU), 82 ENCODER_CCW_CW(KC_VOLD, KC_VOLU) 83 }, 84 85 [1] = { 86 ENCODER_CCW_CW(LSFT(KC_W), KC_W), 87 ENCODER_CCW_CW(KC_N, LSFT(KC_N)) 88 }, 89 90 [2] = { 91 ENCODER_CCW_CW(XXXXXXX, XXXXXXX), 92 ENCODER_CCW_CW(XXXXXXX, XXXXXXX) 93 }, 94 95 [3] = { 96 ENCODER_CCW_CW(XXXXXXX, XXXXXXX), 97 ENCODER_CCW_CW(XXXXXXX, XXXXXXX) 98 }, 99 100 [4] = { 101 ENCODER_CCW_CW(UG_VALD, UG_VALU), 102 ENCODER_CCW_CW(XXXXXXX, XXXXXXX) 103 } 104 }; 105 #endif 106 107 //set only hue, retain saturation, and value 108 void rgblight_sethue_noeeprom(uint8_t hue){ 109 //only if rgb led ring is on 110 if (rgblight_get_mode()) { 111 rgblight_sethsv_noeeprom(hue,rgblight_get_sat(),rgblight_get_val()); 112 } 113 } 114 115 //set correct layer hue on layer change 116 layer_state_t layer_state_set_user(layer_state_t state) { 117 switch (get_highest_layer(state)) { 118 case 1: 119 rgblight_sethue_noeeprom(RGB_HUE_LAYER1); 120 break; 121 case 2: 122 rgblight_sethue_noeeprom(RGB_HUE_LAYER2); 123 break; 124 case 3: 125 rgblight_sethue_noeeprom(RGB_HUE_LAYER3); 126 break; 127 case 4: 128 rgblight_sethue_noeeprom(RGB_HUE_LAYER4); 129 break; 130 default: 131 rgblight_sethue_noeeprom(RGB_HUE_LAYER0); 132 break; 133 134 } 135 return state; 136 } 137 138 //set default layer hue upon init 139 void keyboard_post_init_user(void) { 140 rgblight_init(); 141 rgblight_sethue_noeeprom(RGB_HUE_LAYER0); 142 }