qmk_firmware

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

keymap.c (5096B)


      1 /* Copyright 2017 Paul James (paul@peej.co.uk)
      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     _LAYER,
     22     _MOD_LAYER,
     23     _FUNCT
     24 };
     25 
     26 #define SFT_A SFT_T(KC_A)
     27 #define SFT_F1 SFT_T(KC_F1)
     28 #define SFT_Z SFT_T(KC_Z)
     29 #define SFT_F6 SFT_T(KC_F6)
     30 #define LAY_X LT(_LAYER, KC_X)
     31 #define LAY_F7 LT(_LAYER, KC_F7)
     32 #define LAY_SLS LT(_LAYER, KC_SLSH)
     33 #define LAY_SPC LT(_LAYER, KC_SPACE)
     34 
     35 #define LOCK LGUI(KC_L)
     36 #define MAC_LCK LGUI(LCTL(KC_Q))
     37 
     38 #define LAYER MO(_LAYER)
     39 #define FUNCT MO(_FUNCT)
     40 
     41 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     42 
     43 /*
     44  * ,----------------------------------------   ----------------------------------------.
     45  * |  Tab  |  Esc  |   (   |   {   |   [   |   |   ]   |   }   |   )   |   '   | BkSp  |
     46  * |   ~   |   `   |   <   |   _   |   -   |   |   +   |   =   |   >   |   \   |  Del  |
     47  * |-------+-------+-------+-------+-------+   |-------+-------+-------+-------+-------|
     48  * |   Q   |   W   |   E   |   R   |   T   |   |   Y   |   U   |   I   |   O   |   P   |
     49  * |   1   |   2   |   3   |   4   |   5   |   |   6   |   7   |   8   |   9   |   0   |
     50  * |-------+-------+-------+-------+-------+   |-------+-------+-------+-------+-------|
     51  * |   A   |   S   |   D   |   F   |   G   |   |   H   |   J   |   K   |   L   | Enter |
     52  * |  F1   |  F2      F3   |  F4   |  F5   |   | PgUp  | Home  |  Up   |  End  |   ;   |
     53  * |-Shift-+-------+-------+-------+-------+   |-------+-------+-------+-------+-------|
     54  * |   Z   |   X   |   C   |   V   |   B   |   |   N   |   M   |   ,   |   .   |   /   |
     55  * |  F6   |  F7   |  F8   |  F9   |  F10  |   | PgDn  | Left  | Down  | Right |       |
     56  * `-Shift---Layer-+-------+-------+-------+   |-------+-------+-------+---------Layer-'
     57  *                 | Ctrl  |  Gui  |  Alt  |   | Space | Layer | Shift |
     58  *                 |       |       |       |   | Funct |       |       |
     59  *                 `------------------------   `-Layer-----------------'
     60  */
     61 
     62 [_BASE] = LAYOUT_split_4x5_3(
     63     KC_TAB,  KC_ESC,  KC_LPRN, KC_LCBR, KC_LBRC,    KC_RBRC, KC_RCBR, KC_RPRN, KC_QUOT, KC_BSPC,
     64     KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,       KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,
     65     SFT_A,   KC_S,    KC_D,    KC_F,    KC_G,       KC_H,    KC_J,    KC_K,    KC_L,    KC_ENT,
     66     SFT_Z,   LAY_X,   KC_C,    KC_V,    KC_B,       KC_N,    KC_M,    KC_COMM, KC_DOT,  LAY_SLS,
     67                       KC_LCTL, KC_LGUI, KC_LALT,    LAY_SPC, LAYER,   KC_RSFT
     68 ),
     69 
     70 [_LAYER] = LAYOUT_split_4x5_3(
     71     KC_TILD, KC_GRV,  KC_LABK, KC_UNDS, KC_MINS,    KC_PLUS, KC_EQL,  KC_RABK, KC_BSLS, KC_DEL,
     72     KC_1,    KC_2,    KC_3,    KC_4,    KC_5,       KC_6,    KC_7,    KC_8,    KC_9,    KC_0,
     73     SFT_F1,  KC_F2,   KC_F3,   KC_F4,   KC_F5,      KC_PGUP, KC_HOME, KC_UP,   KC_END,  KC_SCLN,
     74     SFT_F6,  LAY_F7,  KC_F8,   KC_F9,   KC_F10,     KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, _______,
     75                       _______, _______, _______,    FUNCT,   _______, _______
     76 ),
     77 
     78 [_MOD_LAYER] = LAYOUT_split_4x5_3(
     79     KC_TILD, _______, _______, _______, _______,    KC_Q,    _______, _______, _______, _______,
     80     KC_TAB,  _______, _______, _______, _______,    _______, _______, _______, _______, _______,
     81     _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______,
     82     _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______,
     83                       _______, _______, _______,    _______, _______, _______
     84 ),
     85 
     86 [_FUNCT] = LAYOUT_split_4x5_3(
     87     QK_BOOT, _______, _______, _______, LOCK,       MAC_LCK, _______, _______, _______, AG_LSWP,
     88     _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______,
     89     _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______,
     90     _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______,
     91                       _______, _______, _______,    _______, _______, _______
     92 ),
     93 
     94 };
     95 
     96 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     97     if (get_mods() & MOD_MASK_CAG) {
     98         if (record->event.pressed) {
     99             layer_on(_MOD_LAYER);
    100         } else {
    101             layer_off(_MOD_LAYER);
    102         }
    103     }
    104 
    105     if (record->event.pressed) {
    106         if (keycode == KC_BSPC && (get_mods() & MOD_MASK_ALT)) {
    107             tap_code(KC_DEL);
    108             return false;
    109         }
    110     }
    111 
    112     return true;
    113 };