qmk

QMK Firmware
git clone git://git.z3bra.org/qmk.git
Log | Files | Refs | Submodules | LICENSE

keymap.c (7324B)


      1 #include QMK_KEYBOARD_H
      2 
      3 extern keymap_config_t keymap_config;
      4 
      5 #define _COLEMAK 0
      6 #define _QWERTY 1
      7 #define _NUMPAD 2
      8 #define _LOWER 3
      9 #define _RAISE 4
     10 #define _ADJUST 16
     11 
     12 enum custom_keycodes {
     13   COLEMAK = SAFE_RANGE,
     14   QWERTY,
     15   NUMPAD,
     16   LOWER,
     17   RAISE,
     18   ADJUST,
     19 };
     20 
     21 /* Fn keys */
     22 
     23 enum {
     24 
     25   F_SFT = 0,
     26   F_ALT,
     27   F_CTRL,
     28   F_NUMPAD
     29 // F_LOWER,
     30 //  F_RAISE,
     31 };
     32 
     33 #define KC_ KC_TRNS
     34 #define KC_XXXX KC_NO
     35 
     36 #define KC_CMK COLEMAK
     37 #define KC_QWE QWERTY
     38 #define KC_LOWR LOWER
     39 #define KC_RASE RAISE
     40 #define KC_QRAS QRAISE
     41 #define KC_ADJT ADJUST
     42 #define KC_RST RESET
     43 #define KC_BL_S BL_STEP
     44 #define KC_DBUG DEBUG
     45 #define KC_RTOG RGB_TOG
     46 #define KC_RMOD RGB_MOD
     47 #define KC_RHUI RGB_HUI
     48 #define KC_RHUD RGB_HUD
     49 #define KC_RSAI RGB_SAI
     50 #define KC_RSAD RGB_SAD
     51 #define KC_RVAI RGB_VAI
     52 #define KC_RVAD RGB_VAD
     53 //#define KC_CATDEL LCTL(LALT(KC_DEL)) // Ctrl alt del
     54 #define KC_CPY LCTL(KC_C)
     55 #define KC_PST LCTL(KC_V)
     56 #define KC_SELA LCTL(KC_A)
     57 #define KC_UDO LCTL(KC_Z)
     58 #define KC_CUT LCTL(KC_X)
     59 #define KC_SVE LCTL(KC_S)
     60 #define KC_OSH F(F_SFT)
     61 #define KC_OCTL F(F_CTRL)
     62 #define KC_NUMP TT(_NUMPAD)
     63 #define KC_SHESC MT(MOD_LSFT,KC_ESC)
     64 #define KC_SHENT MT(MOD_RSFT,KC_ENT)
     65 //#define KC_NUMP TG(_NUMPAD)  // Toggle layer NUMPAD for use in KC_keymaps
     66 //#define KC_RST RESET
     67 
     68 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     69 // Colemak Mod-DH is used. https://colemakmods.github.io/mod-dh/
     70   [_COLEMAK] = LAYOUT_kc(
     71   //,----+----+----+----+----+----+----.     ,----+----+----+----+----+----+----.
     72      TAB , Q  , W  , F  , P  , B  ,LPRN,      RPRN, J  , L  , U  , Y  ,SCLN,BSPC,
     73   //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
     74      BSPC, A  , R  , S  , T  , G  ,EQL ,      MINS, K  , N  , E  , I  , O  ,QUOT,
     75   //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
     76     SHESC, Z  , X  , C  , D  , V  ,NUMP,       ENT, M  , H  ,COMM,DOT ,SLSH,SHENT,
     77   //|----+----+----+----+----+----+----.     .----+----+----+----+----+----+----|
     78      OCTL,LALT,LGUI,DEL ,LOWR, SPC,                OSH, RASE,LEFT,RIGHT,RALT,RCTL
     79   //`----+----+----+--+-+----/----/               \----\----+----+----+----+----'
     80   ),
     81 
     82   [_QWERTY] = LAYOUT_kc(
     83   //,----+----+----+----+----+----+----.     ,----+----+----+----+----+----+----.
     84      ESC , Q  , W  , E  , R  , T  ,LBRC,      RBRC, Y  , U  , I  , O  , P  ,BSPC,
     85   //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
     86      TAB , A  , S  , D  , F  , G  ,LPRN,      RPRN, H  , J  , K  , L  ,SCLN,QUOT,
     87   //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
     88      LSFT, Z  , X  , C  , V  , B  ,    ,          , N  , M  ,COMM,DOT ,SLSH,ENT ,
     89   //|----+----+----+----+----+----+----.     .----+----+----+----+----+----+----|
     90      LCTL,LGUI,LALT,DEL ,    , SPC,                SPC ,    ,LEFT,DOWN, UP ,RIGHT
     91   //`----+----+----+--+-+----/----/               \----\----+----+----+----+----'
     92   ),
     93 
     94   [_NUMPAD] = LAYOUT_kc(
     95     //,----+----+----+----+----+----+----.     ,----+----+----+----+----+----+----.
     96            ,    ,    ,    ,    ,    ,    ,          ,ASTR, P7 , P8 , P9 ,SLSH,    ,
     97     //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
     98            ,    ,    ,    ,    ,    ,    ,          ,PIPE, P4 , P5 , P6 ,MINS,    ,
     99     //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    100            ,    ,    ,    ,    ,    ,    ,          ,COMM, P1 , P2 , P3 ,PLUS,    ,
    101     //|----+----+----+----+----+----+----.     .----+----+----+----+----+----+----|
    102            ,    ,    ,    ,    ,    ,                    , P0 ,NLCK,    ,    ,
    103     //`----+----+----+--+-+----/----/               \----\----+----+----+----+----'
    104   ),
    105 
    106   [_LOWER] = LAYOUT_kc(
    107   //,----+----+----+----+----+----+----.     ,----+----+----+----+----+----+----.
    108          ,XXXX,XXXX,XXXX,XXXX,CAPS,    ,          ,PGUP,HOME, UP ,END ,DEL ,    ,
    109   //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    110          ,SELA,LALT,LSFT,LCTL,SVE ,    ,          ,PGDN,LEFT,DOWN,RGHT,BSPC,INS ,
    111   //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    112          ,UDO ,CUT ,CPY ,PST ,XXXX,    ,          ,XXXX,XXXX,COMM,DOT ,SLSH,    ,
    113   //|----+----+----+----+----+----+----.     .----+----+----+----+----+----+----|
    114          ,    ,    ,    ,    ,    ,                    ,    ,    ,    ,    ,
    115   //`----+----+----+--+-+----/----/               \----\----+----+----+----+----'
    116   ),
    117 
    118   [_RAISE] = LAYOUT_kc(
    119     //,----+----+----+----+----+----+----.     ,----+----+----+----+----+----+----.
    120            ,AMPR,PERC,HASH,EXLM,LPRN,    ,          ,ASTR,RPRN, AT ,DLR ,CIRC,BSPC,
    121     //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    122            , 7  , 5  , 3  , 1  , 9  ,LBRC,      RBRC,  8 , 0  , 2  , 4  , 6  ,BSLS,
    123     //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    124            , GRV,TILD,XXXX,EQL ,PLUS,    ,          ,UNDS,MINS,COMM,DOT ,SLSH,ENT ,
    125     //|----+----+----+----+----+----+----.     .----+----+----+----+----+----+----|
    126            ,    ,    ,    ,    ,    ,                    ,    ,    ,    ,    ,
    127     //`----+----+----+--+-+----/----/               \----\----+----+----+----+----'
    128   ),
    129 
    130 
    131   [_ADJUST] = LAYOUT_kc(
    132     //,----+----+----+----+----+----+----.     ,----+----+----+----+----+----+----.
    133            , F1 , F2 , F3 , F4 , F5 , F6,         F7,  F8, F9 ,F10 , F11, F12,BSPC,
    134     //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    135            ,    ,    ,    ,    ,    ,    ,          ,    , CMK,QWE ,    ,    ,    ,
    136     //|----+----+----+----+----+----+----|     |----+----+----+----+----+----+----|
    137            ,    ,    ,    ,    ,    ,    ,          ,    ,    ,    ,    ,    ,    ,
    138     //|----+----+----+----+----+----+----.     .----+----+----+----+----+----+----|
    139            ,    ,    ,    ,    ,    ,                    ,    ,    ,VOLD,VOLU,MUTE
    140     //`----+----+----+--+-+----/----/               \----\----+----+----+----+----'
    141   )
    142 
    143 };
    144 
    145 const uint16_t PROGMEM fn_actions[] = {
    146   [F_SFT]  = ACTION_MODS_ONESHOT (MOD_LSFT)
    147   ,[F_ALT]  = ACTION_MODS_ONESHOT (MOD_LALT)
    148   ,[F_CTRL] = ACTION_MODS_ONESHOT (MOD_LCTL)
    149 };
    150 
    151 
    152 
    153 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    154   switch (keycode) {
    155     case COLEMAK:
    156       if (record->event.pressed) {
    157         set_single_persistent_default_layer(_COLEMAK);
    158 
    159       }
    160       return false;
    161       break;
    162     case QWERTY:
    163       if (record->event.pressed) {
    164         set_single_persistent_default_layer(_QWERTY);
    165       }
    166       return false;
    167       break;
    168     case LOWER:
    169       if (record->event.pressed) {
    170         layer_on(_LOWER);
    171         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    172       } else {
    173         layer_off(_LOWER);
    174         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    175       }
    176       return false;
    177       break;
    178     case RAISE:
    179       if (record->event.pressed) {
    180         layer_on(_RAISE);
    181         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    182       } else {
    183         layer_off(_RAISE);
    184         update_tri_layer(_LOWER, _RAISE, _ADJUST);
    185       }
    186       return false;
    187       break;
    188     case ADJUST:
    189       if (record->event.pressed) {
    190         layer_on(_ADJUST);
    191       } else {
    192         layer_off(_ADJUST);
    193       }
    194       return false;
    195       break;
    196   }
    197   return true;
    198 }