keymap.c (3809B)
1 /* Copyright 2020 sotoba 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 // Defines names for use in layer keycodes and the keymap 19 enum layer_names { 20 _BASE, 21 _UNRULY, 22 _FUNCTION 23 }; 24 25 // Defines the keycodes used by our macros in process_record_user 26 enum custom_keycodes { 27 DOUBLE_ZERO = SAFE_RANGE 28 }; 29 30 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 31 /* Base */ 32 [_BASE] = LAYOUT( 33 KC_ESCAPE, KC_LSFT, KC_TAB, KC_BSPC, 34 KC_NUM, KC_KP_SLASH, KC_KP_ASTERISK, KC_EQUAL, 35 KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_MINUS, 36 MO(_FUNCTION), KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_PLUS, 37 UG_TOGG, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_ENTER, 38 TG(_UNRULY), KC_KP_0, DOUBLE_ZERO, KC_KP_DOT 39 ), 40 /* Lightning */ 41 [_UNRULY] = LAYOUT( 42 KC_ESCAPE, KC_LSFT, KC_TAB, KC_BSPC, 43 KC_NUM, KC_KP_SLASH, KC_KP_ASTERISK, KC_EQUAL, 44 KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_MINUS, 45 KC_TRNS, KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_PLUS, 46 KC_TRNS, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_ENTER, 47 KC_TRNS, KC_KP_0, DOUBLE_ZERO, KC_KP_DOT 48 ), 49 /* Function */ 50 [_FUNCTION] = LAYOUT( 51 QK_BOOT, KC_NO, KC_NO, KC_NO, 52 KC_NO, KC_NO, KC_NO, KC_NO, 53 KC_NO, KC_NO, KC_NO, KC_NO, 54 KC_TRNS, UG_PREV, UG_NEXT, KC_NO, KC_NO, 55 KC_TRNS, UG_HUEU, UG_SATU, UG_VALU, KC_NO, 56 KC_TRNS, UG_HUED, UG_SATD, UG_VALD 57 ) 58 }; 59 60 bool process_record_user(uint16_t keycode, keyrecord_t *record) { 61 switch (keycode) { 62 case DOUBLE_ZERO: 63 if (record->event.pressed) { 64 // when keycode DOUBLE_ZERO is pressed 65 SEND_STRING("00"); 66 } 67 break; 68 } 69 return true; 70 } 71 72 #ifdef RGBLIGHT_LAYERS 73 const rgblight_segment_t PROGMEM num_layer[] = RGBLIGHT_LAYER_SEGMENTS( 74 {26, 7, HSV_SPRINGGREEN} 75 ); 76 77 const rgblight_segment_t PROGMEM unruly_layer[] = RGBLIGHT_LAYER_SEGMENTS( 78 {0, 4, HSV_OFF}, 79 {4, 2, HSV_WHITE}, 80 {6, 2, HSV_PURPLE}, 81 {8, 2, HSV_RED}, 82 {10, 2, HSV_BLUE}, 83 {12, 2, HSV_YELLOW}, 84 {14, 2, HSV_GREEN}, 85 {16, 3, HSV_ORANGE}, 86 {19, 1, HSV_OFF}, 87 {20, 3, HSV_PINK}, 88 {23, 10, HSV_GREEN} 89 ); 90 91 const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST( 92 num_layer, 93 unruly_layer 94 ); 95 96 void keyboard_post_init_user(void) { 97 // Enable the LED layers 98 rgblight_layers = rgb_layers; 99 } 100 101 layer_state_t layer_state_set_user(layer_state_t state) { 102 rgblight_set_layer_state(1, layer_state_cmp(state, _UNRULY)); 103 return state; 104 } 105 106 bool led_update_user(led_t led_state) { 107 rgblight_set_layer_state(0, led_state.num_lock); 108 return true; 109 } 110 111 #endif