qmk_firmware

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

keymap.c (6101B)


      1  /* Copyright 2021 jrfhoutx
      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 // Each layer gets a name for readability, which is then used in the keymap matrix below.
     20 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
     21 // Layer names don't all need to be of the same length, obviously, and you can also skip them
     22 // entirely and just use numbers.
     23 
     24 
     25 enum custom_layers {
     26     _BASE,
     27     _FN1,
     28     _FN2,
     29     _FN3,
     30 };
     31 
     32 enum custom_keycodes {
     33   QWERTY = SAFE_RANGE,
     34 };
     35 
     36 #define KC_FN1 MO(_FN1)
     37 #define KC_FN2 MO(_FN2)
     38 #define SPFN1 LT(_FN1, KC_SPACE)
     39 #define BSFN2 LT(_FN2, KC_BSPC)
     40 
     41 
     42 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     43   [_BASE] = LAYOUT_all(
     44     _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   KC_F24,    _______,   _______,
     45     MO(1),     KC_ESC,    KC_Q,      KC_W,      KC_E,      KC_R,      KC_T,      KC_Y,      KC_U,      KC_I,      KC_O,      KC_P,      KC_DEL,    KC_BSPC,   _______,
     46     MO(2),     KC_TAB,    KC_A,      KC_S,      KC_D,      KC_F,      KC_G,      KC_H,      KC_J,      KC_K,      KC_L,      KC_QUOT,              KC_ENT,    _______,
     47     _______,   KC_LSFT,   KC_Z,      KC_X,      KC_C,      KC_V,      KC_B,                 KC_N,      KC_M,      KC_COMM,   KC_DOT,    KC_RSFT,   KC_UP,
     48     _______,   KC_LCTL,   KC_LALT,   KC_LGUI,   KC_FN1,    SPFN1,                                      BSFN2,     KC_RALT,   KC_FN2,    KC_LEFT,   KC_DOWN,   KC_RGHT
     49   ),
     50 
     51   [_FN1] = LAYOUT_all(
     52     _______,   QK_BOOT,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,
     53     _______,   KC_GRV,    KC_1,      KC_2,      KC_3,      KC_4,      KC_5,      KC_6,      KC_7,      KC_8,      KC_9,      KC_0,      KC_MINS,   KC_EQL,    _______,
     54     _______,   UG_TOGG,   UG_HUEU,   UG_SATU,   UG_VALU,   KC_VOLU,   KC_LBRC,   KC_RBRC,   KC_4,      KC_5,      KC_6,      KC_SCLN,              _______,   _______,
     55     _______,   UG_NEXT,   UG_HUED,   UG_SATD,   UG_VALD,   KC_VOLD,   KC_LCBR,              KC_RCBR,   KC_1,      KC_2,      KC_3,      _______,   KC_UP,
     56     _______,   _______,   _______,   _______,   _______,   _______,                                    KC_DEL,    KC_0,      _______,   KC_LEFT,   KC_DOWN,   KC_RGHT
     57   ),
     58 
     59   [_FN2] = LAYOUT_all(
     60     _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,
     61     _______,   KC_TILD,   KC_EXLM,   KC_AT,     KC_HASH,   KC_DLR,    KC_PERC,   KC_CIRC,   KC_AMPR,   KC_ASTR,   KC_LPRN,   KC_RPRN,   KC_UNDS,   KC_PLUS,   _______,
     62     _______,   _______,   _______,   _______,   KC_INS,    KC_PGUP,   KC_HOME,   _______,   _______,   _______,   _______,   KC_COLN,              _______,   _______,
     63     _______,   _______,   _______,   _______,   KC_DEL,    KC_PGDN,   KC_END,               _______,   _______,   _______,   _______,   _______,   KC_UP,
     64     _______,   _______,   _______,   _______,   _______,   KC_DEL,                                     _______,   _______,   _______,   KC_LEFT,   KC_DOWN,   KC_RGHT
     65   ),
     66 
     67   [_FN3] = LAYOUT_all(
     68     _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   _______,   KC_F24,    _______,   _______,
     69     MO(1),     KC_ESC,    KC_Q,      KC_W,      KC_E,      KC_R,      KC_T,      KC_Y,      KC_U,      KC_I,      KC_O,      KC_P,      KC_DEL,    KC_BSPC,   _______,
     70     MO(2),     KC_TAB,    KC_A,      KC_S,      KC_D,      KC_F,      KC_G,      KC_H,      KC_J,      KC_K,      KC_L,      KC_QUOT,              KC_ENT,    _______,
     71     _______,   KC_LSFT,   KC_Z,      KC_X,      KC_C,      KC_V,      KC_B,                 KC_N,      KC_M,      KC_COMM,   KC_DOT,    KC_RSFT,   KC_UP,
     72     _______,   KC_LCTL,   KC_LALT,   KC_LGUI,   KC_FN1,    SPFN1,                                      BSFN2,     KC_RALT,   KC_FN2,    KC_LEFT,   KC_DOWN,   KC_RGHT
     73   )
     74 
     75 };
     76 
     77 void keyboard_pre_init_user(void) {
     78     gpio_set_pin_output(F5);  // initialize F5 for LED
     79     gpio_set_pin_output(F6);  // initialize F6 for LED
     80     gpio_set_pin_output(F7);  // initialize F7 for LED
     81 
     82 }
     83 
     84 layer_state_t layer_state_set_user(layer_state_t state) {
     85     gpio_write_pin_low(F5);
     86     gpio_write_pin_low(F6);
     87     gpio_write_pin_low(F7);
     88     switch (get_highest_layer(state)) {
     89         case _FN1:
     90             gpio_write_pin_high(F5);
     91             break;
     92         case _FN2:
     93             gpio_write_pin_high(F6);
     94             break;
     95         case _FN3:  // replace 'XXXX' with the layer or function name
     96             gpio_write_pin_high(F7);
     97             break;
     98         case KC_F24:
     99             gpio_write_pin_high(F7);
    100             gpio_write_pin_high(F5);
    101             gpio_write_pin_high(F6);
    102             break;
    103         }
    104     return state;
    105 }
    106 
    107 
    108 bool spongebob_mode = false;
    109 bool spongebob_case = false;
    110 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    111   if (spongebob_mode) {
    112     switch(keycode) {
    113       case KC_A...KC_Z:
    114         if (record->event.pressed) {
    115           (spongebob_case ^= 1) == 0 ? tap_code16(S(keycode)) : tap_code(keycode);
    116           return false; break;
    117         }
    118     }
    119   }
    120   switch(keycode) {
    121     case KC_F24:
    122       if (record->event.pressed) {
    123         spongebob_mode ^= 1;
    124       }
    125       return false; break;
    126   }
    127   return true;
    128 }