qmk_firmware

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

keymap.c (9846B)


      1 /*  Keymap for Space Oddity Keyboard
      2     Copyright (C) 2017  James Taylor
      3 
      4     This program is free software: you can redistribute it and/or modify
      5     it under the terms of the GNU General Public License as published by
      6     the Free Software Foundation, either version 3 of the License, or
      7     (at your option) any later version.
      8 
      9     This program is distributed in the hope that it will be useful,
     10     but WITHOUT ANY WARRANTY; without even the implied warranty of
     11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12     GNU General Public License for more details.
     13 
     14     You should have received a copy of the GNU General Public License
     15     along with this program.  If not, see <https://www.gnu.org/licenses/>.
     16 */
     17 
     18 #include QMK_KEYBOARD_H
     19 
     20 // Custom keycodes needed for dynamic macros.
     21 enum custom_keycodes {
     22 
     23   QWERTY = SAFE_RANGE,
     24   PAIR_PR,
     25   PAIR_BR,
     26   PAIR_CB,
     27   LAMBDA
     28 };
     29 
     30 // Tap Dance initializer.
     31 enum {
     32 
     33   SFT_CAPS = 0,
     34 
     35 };
     36 
     37 // Tap dance actions - double tap for Caps Lock.
     38 tap_dance_action_t tap_dance_actions[] = {
     39 
     40   [SFT_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
     41 
     42 };
     43 
     44 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     45 
     46   /* Here is an ASCII version of the base layout. Note that Dynamic Macros 1 and 2 are considered Macro 5 and Macro 6.
     47    *
     48    *  ___________________________________________________________________________________
     49    * |           |           |           |           |           |  Dynamic  |  Dynamic  |
     50    * |    ()     |    []     |    {}     |   NO OP   |   NO OP   |  Macro 1  |  Macro 2  |
     51    * |___________|___________|___________|___________|___________|___________|___________|
     52    * |           |     |     |     |     |     |     |     |     |     |     |           |
     53    * |     `     |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  0  |   BKSP    |
     54    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
     55    * |           |     |     |     |     |     |     |     |     |     |     |           |
     56    * |    TAB    |  Q  |  W  |  E  |  R  |  T  |  Y  |  U  |  I  |  O  |  P  |     -     |
     57    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
     58    * |           |     |     |     |     |     |     |     |     |     |     |           |
     59    * |ESC (CTL_T)|  A  |  S  |  D  |  F  |  G  |  H  |  J  |  K  |  L  |  ;  |     '     |
     60    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
     61    *   |         |     |     |     |     |     |     |     |     |     |     |         |
     62    *   |  SHFT   |  Z  |  X  |  C  |  V  |  B  |  N  |  M  |  ,  |  .  |  /  |SHFT(ENT)|
     63    *   |_________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_________|
     64    *       |     |     |     |     |           |           | ALT | HYP | LT 1| LT 2|
     65    *       |MO(2)|MO(1)| GUI | ALT |    CTRL   |    SPC    |(LFT)|(RGT)| (UP)|(DWN)|
     66    *       |_____|_____|_____|_____|___________|___________|_____|_____|_____|_____|
     67    */
     68 
     69   [0] = LAYOUT(
     70     PAIR_PR,       PAIR_BR,          PAIR_CB,          XXXXXXX,          XXXXXXX,                 DM_PLY1,                      DM_PLY2,
     71     KC_GRV,        KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,           KC_9,           KC_0,         KC_BSPC,
     72     KC_TAB,        KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,           KC_O,           KC_P,         KC_MINS,
     73     CTL_T(KC_ESC), KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,           KC_L,           KC_SCLN,      KC_QUOT,
     74     TD(SFT_CAPS),  KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM,        KC_DOT,         KC_SLSH,      SFT_T(KC_ENT),
     75     MO(2),         MO(1),   KC_LGUI, KC_RALT,          KC_LCTL, KC_SPC,           ALT_T(KC_LEFT), HYPR_T(KC_RGHT), LT(1, KC_UP), LT(2, KC_DOWN)
     76   ),
     77 
     78   /* Function layer.
     79    * Blank keys correspond to the KC_TRNS keycode.
     80    *
     81    *  ___________________________________________________________________________________
     82    * |           |           |           |           |           |  DYN REC  |  DYN REC  |
     83    * |  LAMBDA   |           |           |           |           |     1     |     2     |
     84    * |___________|___________|___________|___________|___________|___________|___________|
     85    * |  DYN REC  |     |     |     |     |     |     |     |     |     |     |           |
     86    * |   STOP    | F1  | F2  | F3  | F4  | F5  |  [  |  7  |  8  |  9  |  *  |    DEL    |
     87    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
     88    * |           |     |     |     |     |     |     |     |     |     |     |           |
     89    * |           | F6  | F7  | F8  | F9  | F10 |  ]  |  4  |  5  |  6  |  +  |     =     |
     90    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
     91    * |           |     |     |     |     |     |     |     |     |     |     |           |
     92    * |     \     | F11 | F12 | F13 | F14 | F15 |  {  |  1  |  2  |  3  |  -  |     |     |
     93    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
     94    *   |         |     |     |     |     |     |     |     |     |     |     |         |
     95    *   |         | F16 | F17 | F18 | F19 | F20 |  }  |  0  |  ,  |  .  |  /  |         |
     96    *   |_________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_________|
     97    *       |     |     |     |     |           |           |     |     |     |     |
     98    *       |     |     |     |     |           |           |     |     |     |     |
     99    *       |_____|_____|_____|_____|___________|___________|_____|_____|_____|_____|
    100    *
    101    */
    102 
    103   [1] = LAYOUT(
    104     LAMBDA,       _______,          _______,          _______,          _______,          DM_REC1,          DM_REC2,
    105     DM_RSTP,      KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_LBRC, KC_P7,   KC_P8,   KC_P9,   KC_ASTR, KC_DEL,
    106     _______,      KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_RBRC, KC_P4,   KC_P5,   KC_P6,   KC_PLUS, KC_EQL,
    107     KC_BSLS,      KC_F11,  KC_F12,  KC_F13,  KC_F14,  KC_F15,  KC_LCBR, KC_P1,   KC_P2,   KC_P3,   KC_MINS, KC_PIPE,
    108     _______,      KC_F16,  KC_F17,  KC_F18,  KC_F19,  KC_F20,  KC_RCBR, KC_P0,   KC_COMM, KC_DOT,  KC_SLSH, _______,
    109     _______,      _______, _______, _______,          _______, _______,          _______, _______, _______, _______
    110   ),
    111 
    112   /* Mouse layer.
    113    *
    114    *  ___________________________________________________________________________________
    115    * |           |           |           |           |           |           |           |
    116    * |           |           |           |           |           |           |           |
    117    * |___________|___________|___________|___________|___________|___________|___________|
    118    * |           |     |     | MS  |     |     |     |     |     |     |     |           |
    119    * |           |     |     | UP  |     |     |     |     |     |     |     |           |
    120    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
    121    * |           |     | MS  | MS  | MS  |     |     |     |     |     |     |           |
    122    * |           |     | LFT | DWN | RGT |     |     | MS1 | MS3 | MS2 |     |           |
    123    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
    124    * |           |     |     |     |     |     |     |     |     |     |     |           |
    125    * |           |     |     |     |     |     |     |     |     |     |     |           |
    126    * |___________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|___________|
    127    *   |         |     |     |     |     |     |     |     |     |     |     |         |
    128    *   |         |QK_BOOT|     |     |     |     |     |     |     |     |     |         |
    129    *   |_________|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_________|
    130    *       |     |     |     |     |           |           |     |     |     |     |
    131    *       |     |     |     |     |           |           |     |     |     | F(2)|
    132    *       |_____|_____|_____|_____|___________|___________|_____|_____|_____|_____|
    133    *
    134    */
    135 
    136   [2] = LAYOUT(
    137     _______, _______,          _______,          _______,          _______,          _______,          _______,
    138     _______, _______, _______, MS_UP,   _______, _______, _______, _______, _______, _______, _______, _______,
    139     _______, _______, MS_LEFT, MS_DOWN, MS_RGHT, _______, _______, MS_BTN1, MS_BTN3, MS_BTN2, _______, _______,
    140     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
    141     _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
    142     _______, _______, _______, _______,          _______, _______,          _______, _______, _______, TG(2)
    143   )
    144 };
    145 
    146 // Simple macro ideas follow. Each of them is designed to give you a quick way to create pairs of
    147 // delimiters and then position the cursor between them, much like Emacs' ParEdit does. This way,
    148 // you can have some convenient coding "helpers" even when not using Emacs. It is also nice for
    149 // LaTeX editing.
    150 //
    151 // Customize to your heart's content!
    152 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    153   switch (keycode) {
    154 
    155     case PAIR_PR:
    156       if (record->event.pressed) {
    157         SEND_STRING("()"SS_TAP(X_LEFT));
    158       }
    159       return false;
    160 
    161     case PAIR_BR:
    162       if (record->event.pressed) {
    163         SEND_STRING("[]"SS_TAP(X_LEFT));
    164       }
    165       return false;
    166 
    167     case PAIR_CB:
    168       if (record->event.pressed) {
    169         SEND_STRING("{}"SS_TAP(X_LEFT));
    170       }
    171       return false;
    172 
    173     // Probably something only Lisp users will appreciate...
    174     case LAMBDA:
    175       if (record->event.pressed) {
    176         SEND_STRING("(lambda ())"SS_TAP(X_LEFT)SS_TAP(X_LEFT));
    177       }
    178       return false;
    179   }
    180 
    181   return true;
    182 }