qmk_firmware

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

keymap.c (6401B)


      1 /* Copyright 2019 ENDO Katsuhiro <ka2hiro@kagizaraya.jp>
      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 the keycodes used by our macros in process_record_user
     19 enum layer_names {
     20     _QWERTY,
     21     _LOWER,
     22     _RAISE,
     23     _ADJUST,
     24 };
     25 
     26 // Defines the keycodes used by our macros in process_record_user
     27 enum custom_keycodes {
     28   LOWER = SAFE_RANGE,
     29   RAISE,
     30   ADJUST,
     31 };
     32 
     33 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     34 /* Qwerty
     35  *
     36  * ,----------------------------------------------------------------------------.
     37  * |   Q  |   W  |   E  |   R  |   T  |   Y  |   U  |   I  |   O  |   P  | BkSp |
     38  * |------+------+------+------+------|------+------+------+------+------|------|
     39  * |   A  |   S  |   D  |   F  |   G  |   H  |   J  |   K  |   L  |   ;  | Enter|
     40  * |------+------+------+------+------|------+------+------+------+------|------|
     41  * |   Z  |   X  |   C  |   V  |   B  |   N  |   M  |   ,  |   .  |   /  | Shift|
     42  * `-------------+------+------+------|------+------+------+------+------+------'
     43  *               | GUI  | LOWER|Ctrl/Esc|Space| RAISE| Alt | Tab  |
     44  *               `------------------------------------------------'
     45  */
     46 [_QWERTY] = LAYOUT(
     47   KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC,
     48   KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_ENT,
     49   KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_LSFT,
     50                     KC_LGUI, LOWER, MT(MOD_LCTL, KC_ESC),  KC_SPC, RAISE, KC_LALT, KC_TAB
     51 ),
     52 
     53 /* Raise
     54  *
     55  * ,----------------------------------------------------------------------------.
     56  * |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  |      |
     57  * |------+------+------+------+------|------+------+------+------+------|------|
     58  * |  Tab |   _  |   +  |  |   |  ~   |   :  |   "  |   >  |   {  |   }  |      |
     59  * |------+------+------+------+------|------+------+------+------+------|------|
     60  * |  Caps|   -  |   =  |  \   |  `   |   ;  |   '  |   <  |   [  |   ]  |      |
     61  * `-------------+------+------+------|------+------+------+------+------+------'
     62  *               |      |      |      |      |      |      |      |
     63  *               `------------------------------------------------'
     64  */
     65 [_RAISE] = LAYOUT( 
     66   KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
     67   KC_TAB,  KC_UNDS, KC_PLUS, KC_PIPE, KC_TILD, KC_COLN, KC_DQUO, KC_GT,   KC_LCBR, KC_RCBR, _______,
     68   KC_CAPS, KC_MINS, KC_EQL,  KC_BSLS, KC_GRV,  KC_SCLN, KC_QUOT, KC_LT,   KC_LBRC, KC_RBRC, _______,
     69                     _______, _______, _______, _______, _______,  _______, _______
     70 ),
     71 
     72 /* Lower
     73  *
     74  * ,----------------------------------------------------------------------------.
     75  * |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |      |
     76  * |------+------+------+------+------|------+------+------+------+------|------|
     77  * |  Tab |      |      |      |Enter | Left | Down |  Up  | Right| Enter|      |
     78  * |------+------+------+------+------|------+------+------+------+------|------|
     79  * |  Ctrl|      |  GUI |  Alt | Del  | BkSp | PgUp | PgDn |      |      |      |
     80  * `-------------+------+------+------|------+------+------+------+------+------'
     81  *               |      |      |      |      |      |      |      |
     82  *               `------------------------------------------------'
     83  */
     84 [_LOWER] = LAYOUT(
     85   KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    _______,
     86   KC_TAB,  _______, _______, _______, KC_ENT,  KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT, KC_ENT,  _______,
     87   KC_LCTL, _______, KC_LGUI, KC_LALT, KC_DEL,  KC_BSPC, KC_PGUP, KC_PGDN, _______, _______, _______,
     88                     _______, _______, _______, _______, _______, _______, _______
     89 ),
     90 
     91 
     92 /* Adjust (Lower + Raise)
     93  *
     94  * ,----------------------------------------------------------------------------.
     95  * |  F1  |  F2  |  F3  |  F4  |  F5  |   F6 |  F7  |  F8  |  F9  |  F10 |      |
     96  * |------+------+------+------+------|------+------+------+------+------|------|
     97  * |  F11 |  F12 |      |RGBSAI|RGBSAD|RGBVAI|RGBVAD|      |      |      |      |
     98  * |------+------+------+------+------|------+------+------+------+------|------|
     99  * | Reset|RGBTOG|RGBMOD|RGBHUI|RGBHUD| Prev | Next | Vol- | Vol+ | Play |      |
    100  * `-------------+------+------+------|------+------+------+------+------+------'
    101  *               |      |      |      |      |      |      |      |
    102  *               `------------------------------------------------'
    103  */
    104 [_ADJUST] =  LAYOUT(
    105   KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,    KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  _______,
    106   KC_F11,  KC_F12,  UG_PREV, UG_SATU, UG_SATD,  UG_VALU, UG_VALD, _______, _______, _______, _______,
    107   QK_BOOT, UG_TOGG, UG_NEXT, UG_HUEU, UG_HUED,  KC_MPRV, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______,
    108                     _______, _______, _______,  _______, _______,  _______, _______
    109 )
    110 };
    111 
    112 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    113   switch (keycode) {
    114     case LOWER:
    115       if (record->event.pressed) {
    116         layer_on(_LOWER);
    117         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    118       } else {
    119         layer_off(_LOWER);
    120         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    121       }
    122       return false;
    123     case RAISE:
    124       if (record->event.pressed) {
    125         layer_on(_RAISE);
    126         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    127       } else {
    128         layer_off(_RAISE);
    129         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    130       }
    131       return false;
    132     case ADJUST:
    133       if (record->event.pressed) {
    134         layer_on(_ADJUST);
    135       } else {
    136         layer_off(_ADJUST);
    137       }
    138       return false;
    139   }
    140   return true;
    141 }