qmk_firmware

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

keymap.c (6238B)


      1 /* Copyright 2017 Fabian Topfstedt
      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 
     17 #include QMK_KEYBOARD_H
     18 
     19 enum layer_names {
     20     _QWERTY,
     21     _LOWER,
     22     _RAISE,
     23     _ADJUST,
     24 };
     25 
     26 enum custom_keycodes {
     27     QWERTY = SAFE_RANGE,
     28     LOWER,
     29     RAISE,
     30     ADJUST,
     31 };
     32 
     33 #define LT1_SPC LT(_LOWER,KC_SPC)
     34 #define LT2_SPC LT(_RAISE,KC_SPC)
     35 #define LT3_LGU LT(_ADJUST,KC_LGUI)
     36 
     37 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     38     /* Default Layer
     39      * ,-----------------------------------------------.
     40      * |Esc| Q | W | E | R | T | Y | U | I | O | P |BS |
     41      * |-----------------------------------------------|
     42      * |Tab | A | S | D | F | G | H | J | K | L |Enter |
     43      * |-----------------------------------------------|
     44      * | LSft | Z | X | C | V | B | N | M | , | .  |/? |
     45      * |-----------------------------------------------|
     46      * |LCtl|GUI|LAlt|Spc/Fn0 | Spc/Fn1  |Fn2 |Alt|RCtl|
     47      * `-----------------------------------------------'
     48      */
     49     [_QWERTY] = LAYOUT(
     50         KC_ESC,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC,
     51         KC_TAB,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,             KC_ENT,
     52         KC_LSFT,          KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH,
     53         KC_LCTL, KC_LGUI, KC_LALT,                   LT1_SPC, LT2_SPC,                   LT3_LGU, KC_RALT, KC_RCTL
     54     ),
     55 
     56     /* Function Layer 1 HHKB style
     57      * ,-----------------------------------------------.
     58      * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) |BS |
     59      * |-----------------------------------------------|
     60      * | F1 |F2 |F3 |F4 |F5 |F6 | _ | + | { | } | Pipe |
     61      * |-----------------------------------------------|
     62      * |  F7  |F8 |F9 |F10|F11|F12| ~ | | |BL±|BL+ |BL-|
     63      * |-----------------------------------------------|
     64      * |    |   |    |        |   Left   |Down|Up |Rght|
     65      * `-----------------------------------------------'
     66      */
     67     [_LOWER] = LAYOUT(
     68         KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR,    KC_ASTR,    KC_LPRN, KC_RPRN, KC_BSPC,
     69         KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS,    KC_LCBR,    KC_RCBR,          KC_PIPE,
     70         KC_F7,            KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  S(KC_NUHS), S(KC_NUBS), BL_TOGG, BL_UP,   BL_DOWN,
     71         _______, _______, _______,                   _______, KC_LEFT,                         KC_DOWN, KC_UP,   KC_RGHT
     72     ),
     73 
     74     /* Function Layer 1 HHKB style
     75      * ,-----------------------------------------------.
     76      * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |BS |
     77      * |-----------------------------------------------|
     78      * | F1 |F2 |F3 |F4 |F5 |F6 | - | = | [ | ] |  \   |
     79      * |-----------------------------------------------|
     80      * |  F7  |F8 |F9 |F10|F11|F12| # | \ |   |    |Del|
     81      * |-----------------------------------------------|
     82      * |    |   |    |        |          |    |   |RGB±|
     83      * `-----------------------------------------------'
     84      */
     85     [_RAISE] = LAYOUT(
     86         KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC,
     87         KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC,          KC_BSLS,
     88         KC_F7,            KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_NUHS, KC_NUBS, _______, _______, KC_DEL,
     89         _______, _______, _______,                   _______, _______,                   _______, _______, UG_TOGG
     90     ),
     91 
     92     /* Function Layer 1 HHKB style
     93      * ,-----------------------------------------------.
     94      * |   |RST|   |   |   |   |   |   |   |   |   |Del|
     95      * |-----------------------------------------------|
     96      * |    |   |   |Au1|Au0|AGN|AGS|   |   |   |      |
     97      * |-----------------------------------------------|
     98      * |      |   |   |RTg|RMd|RH+|RH-|RS+|RS-|RV+ |RV-|
     99      * |-----------------------------------------------|
    100      * |SLP |   |    |        |          |    |   |RTg |
    101      * `-----------------------------------------------'
    102      */
    103     [_ADJUST] = LAYOUT(
    104         _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL,
    105         _______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, AG_SWAP, _______, _______, _______,          _______,
    106         _______,          _______, _______, UG_TOGG, UG_NEXT, UG_HUEU, UG_HUED, UG_SATU, UG_SATD, UG_VALU, UG_VALD,
    107         KC_SLEP, _______, _______,                   _______, _______,                   _______, _______, _______
    108     ),
    109 };
    110 
    111 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    112     switch (keycode) {
    113         case LOWER:
    114             if (record->event.pressed) {
    115                 layer_on(_LOWER);
    116                 update_tri_layer(_LOWER, _RAISE, _ADJUST);
    117             } else {
    118                 layer_off(_LOWER);
    119                 update_tri_layer(_LOWER, _RAISE, _ADJUST);
    120             }
    121             return false;
    122             break;
    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             break;
    133         case ADJUST:
    134             if (record->event.pressed) {
    135                 layer_on(_ADJUST);
    136             } else {
    137                 layer_off(_ADJUST);
    138             }
    139             return false;
    140             break;
    141     }
    142     return true;
    143 }