qmk_firmware

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

keymap.c (4333B)


      1 /* Copyright 2021 Danny Nguyen <danny@keeb.io>
      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 custom_layer {
     20     _QWERTY,
     21     _LOWER,
     22     _RAISE,
     23     _ADJUST,
     24 };
     25 
     26 enum custom_keycodes {
     27     LOWER = SAFE_RANGE,
     28     RAISE,
     29     ADJUST,
     30 };
     31 
     32 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     33     /* Default Layer
     34      * ,-----------------------------------------------------------.
     35      * | Esc|  Q |  W |  E |  R |  T |  Y |  U |  I |  O |  P | BS |
     36      * |-----------------------------------------------------------|
     37      * | Tab |  A |  S |  D |  F |  G |  H |  J |  K |  L | Ent    |
     38      * |-----------------------------------------------------------|
     39      * | LSft   |  Z |  X |  C |  V |  B |  N |  M |  ,  |  . | /? |
     40      * |-----------------------------------------------------------|
     41      * | LCtl | LGui| LAlt|  spc fn0  |  spc fn1    |fn2|RAlt|RCtl |
     42      * `-----------------------------------------------------------'
     43      */
     44     [_QWERTY] = LAYOUT(
     45         KC_ESC,  KC_Q,   KC_W,   KC_E,   KC_R,   KC_T,   KC_Y,   KC_U,   KC_I,    KC_O,    KC_P,   KC_BSPC,
     46         KC_TAB,  KC_A,   KC_S,   KC_D,   KC_F,   KC_G,   KC_H,   KC_J,   KC_K,    KC_L,    KC_ENT,
     47         KC_LSFT, KC_Z,   KC_X,   KC_C,   KC_V,   KC_B,   KC_N,   KC_M,   KC_COMM, KC_DOT,  KC_SLSH,
     48         KC_LCTL, KC_LGUI, KC_LALT, LT(_LOWER, KC_SPC), LT(_RAISE, KC_SPC), LT(_ADJUST, KC_LGUI), KC_RALT, KC_RCTL
     49     ),
     50 
     51     [_LOWER] = LAYOUT(
     52         KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
     53         KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
     54         KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,S(KC_NUHS),S(KC_NUBS),BL_TOGG, BL_UP,  BL_DOWN,
     55         _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
     56     ),
     57 
     58     [_RAISE] = LAYOUT(
     59         KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC,
     60         KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS,
     61         KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_NUHS, KC_NUBS, _______, _______, KC_DEL,
     62         _______, KC_TRNS, _______, KC_TRNS, KC_TRNS, _______, _______, UG_TOGG
     63     ),
     64 
     65     [_ADJUST] = LAYOUT(
     66         _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL,
     67         _______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, AG_SWAP, _______, _______, _______,  _______,
     68         _______, _______, _______, _______, _______, _______, _______, _______,  _______,  _______,  _______,
     69         _______, _______, _______, _______, _______, _______, _______, _______
     70     )
     71 };
     72 
     73 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     74   switch (keycode) {
     75     case LOWER:
     76     if (record->event.pressed) {
     77         layer_on(_LOWER);
     78         update_tri_layer(_LOWER, _RAISE, _ADJUST);
     79     } else {
     80         layer_off(_LOWER);
     81         update_tri_layer(_LOWER, _RAISE, _ADJUST);
     82     }
     83     return false;
     84     break;
     85     case RAISE:
     86       if (record->event.pressed) {
     87         layer_on(_RAISE);
     88         update_tri_layer(_LOWER, _RAISE, _ADJUST);
     89       } else {
     90         layer_off(_RAISE);
     91         update_tri_layer(_LOWER, _RAISE, _ADJUST);
     92       }
     93       return false;
     94       break;
     95     case ADJUST:
     96       if (record->event.pressed) {
     97         layer_on(_ADJUST);
     98       } else {
     99         layer_off(_ADJUST);
    100       }
    101       return false;
    102       break;
    103   }
    104   return true;
    105 }
    106 
    107 bool encoder_update_user(uint8_t index, bool clockwise) {
    108     if (index == 0) {
    109         if (clockwise) {
    110             tap_code(KC_VOLU);
    111         } else {
    112             tap_code(KC_VOLD);
    113         }
    114     }
    115     return false;
    116 }