qmk_firmware

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

keymap.c (6137B)


      1 /* Copyright 2020 Steven Nguyen
      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 framework_layers {
     20     _BASE,
     21     _LOWER,
     22     _RAISE,
     23     _BOTH,
     24     _FN
     25 };
     26 
     27 enum framework_keycodes {
     28     LOWER = SAFE_RANGE,
     29     RAISE,
     30     BOTH,
     31     FN
     32 };
     33 
     34 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     35 [_BASE] = LAYOUT_ortho_5x12(
     36     KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_MEDIA_PLAY_PAUSE,
     37     KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC,
     38     KC_ESC,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,
     39     KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT,
     40     KC_LCTL, KC_LGUI, KC_LALT, FN,      LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT
     41 ),
     42 
     43 [_LOWER] = LAYOUT_ortho_5x12(
     44     _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL,  _______,
     45     QK_LEAD, KC_F1,   KC_F2,   KC_F3,   KC_F4,   _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS,
     46     KC_DEL,  KC_F5,   KC_F6,   KC_F7,   KC_F8,   _______, _______, _______, _______, _______, _______, _______,
     47     KC_TRNS, KC_F9,   KC_F10,  KC_F11,  KC_F12,  _______, _______, _______, _______, _______, _______, _______,
     48     KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, _______, _______, KC_TRNS, KC_HOME, KC_PGDN, KC_PGUP, KC_END
     49 ),
     50 
     51 [_RAISE] = LAYOUT_ortho_5x12(
     52     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     53     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     54     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     55     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     56     _______, _______, _______, _______, KC_TRNS, _______, _______, KC_TRNS, _______, _______, _______, _______
     57 ),
     58 
     59 [_BOTH] = LAYOUT_ortho_5x12(
     60     _______, _______,     _______, _______, _______,    _______, _______, _______, _______, _______, _______, _______,
     61     _______, LALT(KC_F4), _______, KC_MYCM, LGUI(KC_R), _______, _______, _______, _______, _______, _______, _______,
     62     _______, _______,     _______, _______, _______,    _______, _______, _______, _______, _______, _______, _______,
     63     _______, _______,     _______, _______, _______,    _______, _______, _______, _______, _______, _______, _______,
     64     _______, _______,     _______, _______, _______,    _______, _______, _______, _______, _______, _______, DB_TOGG
     65 ),
     66 
     67 [_FN] = LAYOUT_ortho_5x12(
     68     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     69     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     70     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     71     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     72     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
     73 )
     74 };
     75 
     76 bool encoder_update_user(uint8_t index, bool clockwise) {
     77     if (index == 0) {
     78         switch (get_highest_layer(layer_state)) {
     79             case _BASE:
     80                 if (clockwise) {
     81                     tap_code(KC_AUDIO_VOL_UP);
     82                 } else {
     83                     tap_code(KC_AUDIO_VOL_DOWN);
     84                 }
     85                 break;
     86 
     87             case _LOWER:
     88                 if (clockwise) {
     89                     tap_code16(LCTL(KC_TAB));
     90                 } else {
     91                     tap_code16(LCTL(LSFT(KC_TAB)));
     92                 }
     93                 break;
     94 
     95             case _RAISE:
     96                 if (clockwise) {
     97                     tap_code16(LCTL(KC_RGHT));
     98                 } else {
     99                     tap_code16(LCTL(KC_LEFT));
    100                 }
    101                 break;
    102 
    103             case _BOTH:
    104                 if (clockwise) {
    105                     tap_code16(LCTL(KC_Y));
    106                 } else {
    107                     tap_code16(LCTL(KC_Z));
    108                 }
    109                 break;
    110 
    111             case _FN:
    112                 if (clockwise) {
    113                     tap_code(_______);
    114                 } else {
    115                     tap_code(_______);
    116                 }
    117                 break;
    118 
    119             default:
    120                 break;
    121         }
    122     }
    123     return true;
    124 }
    125 
    126 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    127     switch (keycode) {
    128         case LOWER:
    129             if (record->event.pressed) {
    130                 layer_on(_LOWER);
    131                 update_tri_layer(_LOWER, _RAISE, _BOTH);
    132             } else {
    133                 layer_off(_LOWER);
    134                 update_tri_layer(_LOWER, _RAISE, _BOTH);
    135             }
    136             return false;
    137 
    138         case RAISE:
    139             if (record->event.pressed) {
    140                 layer_on(_RAISE);
    141                 update_tri_layer(_LOWER, _RAISE, _BOTH);
    142             } else {
    143                 layer_off(_RAISE);
    144                 update_tri_layer(_LOWER, _RAISE, _BOTH);
    145             }
    146             return false;
    147 
    148         case FN:
    149             if (record->event.pressed) {
    150                 layer_on(_FN);
    151             } else {
    152                 layer_off(_FN);
    153             }
    154             return false;
    155     }
    156     return true;
    157 }