qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

keymap.c (7237B)


      1 /* Copyright 2020 marksard
      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 enum layer_number {
     19     _BASE,
     20     _LOWER,
     21     _RAISE,
     22     _ADJUST,
     23 };
     24 
     25 enum custom_keycodes {
     26     RGBRST = SAFE_RANGE,
     27     LOWER,
     28     RAISE,
     29     KANJI,
     30 };
     31 
     32 // #define KC_ESAD  LT(_ADJUST, KC_ESC)
     33 // #define KC_BSLO  LT(_LOWER, KC_BSPC)
     34 #define KC_LOWR  MO(_LOWER)
     35 #define KC_SPRA  LT(_RAISE, KC_SPC)
     36 #define KC_AJST  MO(_ADJUST)
     37 
     38 #define KC_Q_AL  LALT_T(KC_Q)
     39 #define KC_A_CT  LCTL_T(KC_A)
     40 #define KC_Z_SF  LSFT_T(KC_Z)
     41 #define KC_X_AL  LALT_T(KC_X)
     42 #define KC_ENSF  RSFT_T(KC_ENT)
     43 #define KC_SLSF  RSFT_T(KC_SLSH)
     44 
     45 #define KC_F1AL  LALT_T(KC_F1)
     46 #define KC_F6CT  LCTL_T(KC_F6)
     47 #define KC_11SF  LSFT_T(KC_F11)
     48 #define KC_12AL  LALT_T(KC_F12)
     49 #define KC_QUSF  RCTL_T(KC_QUOT)
     50 #define KC_ROSF  RSFT_T(KC_INT1)
     51 
     52 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     53   [_BASE] = LAYOUT_isoenter(
     54   //,-----------------------------------------------------------------------------------------------------------.
     55                KC_Q_AL,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P, KC_BSPC,
     56   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     57                KC_A_CT,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,     KC_ENSF,
     58   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     59                KC_Z_SF, KC_X_AL,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M, KC_COMM,  KC_DOT,
     60   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     61       KC_LCTL, KC_LGUI,                                KC_SPRA,                                 KC_LOWR, KC_RCTL
     62   //`-----------------------------------------------------------------------------------------------------------'
     63   ),
     64 
     65   [_LOWER] = LAYOUT_isoenter(
     66   //,-----------------------------------------------------------------------------------------------------------.
     67                KC_F1AL,   KC_F2,   KC_F3,   KC_F4,   KC_F5, KC_MINS,  KC_EQL, KC_INT3, KC_LBRC, KC_RBRC, KC_BSLS,
     68   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     69                KC_F6CT,   KC_F7,   KC_F8,   KC_F9,  KC_F10, XXXXXXX, XXXXXXX, XXXXXXX, KC_SCLN,     KC_QUSF,
     70   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     71                KC_11SF, KC_12AL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,  KC_GRV, KC_INT1, KC_SLSH,
     72   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     73       _______, _______,                                KC_AJST,                                 _______, _______
     74   //`-----------------------------------------------------------------------------------------------------------'
     75   ),
     76 
     77   [_RAISE] = LAYOUT_isoenter(
     78   //,-----------------------------------------------------------------------------------------------------------.
     79                   KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0, KC_MINS,
     80   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     81                KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN,   KC_UP, KC_RGHT,     _______,
     82   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     83                KC_LSFT, XXXXXXX,  KC_ESC,  KC_TAB,   KANJI,  KC_DEL, KC_COMM,  KC_DOT, KC_BSLS,
     84   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     85       _______, _______,                                _______,                                 KC_AJST, _______
     86   //`-----------------------------------------------------------------------------------------------------------'
     87   ),
     88 
     89   [_ADJUST] = LAYOUT_isoenter(
     90   //,-----------------------------------------------------------------------------------------------------------.
     91                QK_BOOT,  RGBRST, AG_NORM, AG_SWAP, XXXXXXX, KC_HOME, KC_PGDN, KC_PGUP,  KC_END,  KC_INS, KC_PSCR,
     92   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     93                UG_TOGG, UG_HUEU, UG_SATU, UG_VALU, XXXXXXX, MS_LEFT, MS_DOWN,   MS_UP, MS_RGHT,     KC_NUM,
     94   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     95                UG_NEXT, UG_HUED, UG_SATD, UG_VALD, XXXXXXX, MS_BTN1, MS_BTN2, XXXXXXX, XXXXXXX,
     96   //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
     97       _______, _______,                                _______,                                 _______, KC_CAPS
     98   //`-----------------------------------------------------------------------------------------------------------'
     99   )
    100 };
    101 
    102 uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
    103   switch (keycode) {
    104     case KC_SPRA:
    105       return TAPPING_LAYER_TERM;
    106     default:
    107       return TAPPING_TERM;
    108   }
    109 }
    110 
    111 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    112 
    113   bool result = false;
    114   switch (keycode) {
    115     case KANJI:
    116       if (record->event.pressed) {
    117           register_code16(keymap_config.swap_lalt_lgui ? A(KC_GRV) : KC_LNG2);
    118       } else {
    119           unregister_code16(keymap_config.swap_lalt_lgui ? A(KC_GRV) : KC_LNG2);
    120       }
    121     break;
    122 #ifdef RGBLIGHT_ENABLE
    123     case RGBRST:
    124         if (record->event.pressed) {
    125           eeconfig_update_rgblight_default();
    126           rgblight_enable();
    127         }
    128     break;
    129 #endif
    130     default:
    131       result = true;
    132       break;
    133   }
    134 
    135   return result;
    136 }
    137 
    138 bool encoder_update_user(uint8_t index, bool clockwise) {
    139     if (index == 0) {
    140         if (IS_LAYER_ON(_ADJUST)) {
    141           if (clockwise) {
    142               rgblight_increase_hue_noeeprom();
    143           } else {
    144               rgblight_decrease_hue_noeeprom();
    145           }
    146         } else if (IS_LAYER_ON(_LOWER)) {
    147           tap_code16((clockwise == true) ? LCTL(KC_Y) : LCTL(KC_Z));
    148         } else if (IS_LAYER_ON(_RAISE)) {
    149           tap_code16((clockwise == true) ? S(KC_DOWN) : S(KC_UP));
    150         } else {
    151           tap_code((clockwise == true) ? MS_WHLD : MS_WHLU);
    152         }
    153     }
    154     return true;
    155 }
    156 
    157 // for exsample customize of LED inducator
    158 // bool led_update_user(led_t led_state) {
    159 //     gpio_write_pin(D2, IS_LAYER_ON(_LOWER));
    160 //     gpio_write_pin(D1, IS_LAYER_ON(_RAISE));
    161 //     return false;
    162 // }