qmk_firmware

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

keymap.c (5902B)


      1 /* Copyright 2018 James Laird-Wah
      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 #include QMK_KEYBOARD_H
     17 
     18 /* layer constants */
     19 enum {
     20   DEF = 0,
     21   NUM,
     22   FUN,
     23 };
     24 
     25 
     26 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     27 [DEF] = LAYOUT(
     28   QK_BOOT  , KC_1   , KC_2   , KC_3   , KC_4   , KC_5   ,                      KC_6   , KC_7   , KC_8   , KC_9   , KC_0   , TG(NUM),
     29   KC_GRV , KC_Q   , KC_W   , KC_E   , KC_R   , KC_T   , RM_NEXT,    _______, KC_Y   , KC_U   , KC_I   , KC_O   , KC_P   , KC_EQL ,
     30   KC_PGUP, KC_A   , KC_S   , KC_D   , KC_F   , KC_G   , KC_TAB ,    KC_ENT , KC_H   , KC_J   , KC_K   , KC_L   , KC_SCLN, KC_QUOT,
     31   KC_PGDN, KC_Z   , KC_X   , KC_C   , KC_V   , KC_B   , KC_ESC ,    _______, KC_N   , KC_M   , KC_COMM, KC_DOT , KC_SLSH, KC_MINS,
     32                                          KC_LCTL,                                 KC_RCTL,
     33                                             KC_BSPC,                           KC_SPC ,
     34                                                KC_LGUI,                     KC_RALT,
     35                                                   KC_LSFT,               KC_RSFT,
     36                                       MO(FUN),                                        MO(FUN)
     37   ),
     38 [NUM] = LAYOUT(
     39   _______, _______, _______, _______, _______, _______,                      _______, KC_P7  , KC_P8  , KC_P9  , KC_PMNS, _______,
     40   _______, _______, _______, _______, _______, _______, _______,    _______, _______, KC_P4  , KC_P5  , KC_P6  , KC_PPLS, _______,
     41   _______, _______, _______, _______, _______, _______, _______,    _______, _______, KC_P1  , KC_P2  , KC_P3  , KC_PEQL, _______,
     42   _______, _______, _______, _______, _______, _______, _______,    _______, _______, KC_P0  , KC_PDOT, KC_PAST, KC_PSLS, KC_PENT,
     43                                          _______,                                 _______,
     44                                             _______,                           _______,
     45                                                _______,                     _______,
     46                                                   _______,               _______,
     47                                       _______,                                        _______
     48   ),
     49 [FUN] = LAYOUT(
     50   _______, KC_F1  , KC_F2  , KC_F3  , KC_F4  , KC_F5  ,                      KC_F6  , KC_F7  , KC_F8  , KC_F9  , KC_F10 , KC_F11 ,
     51   KC_TAB , _______, MS_UP,   _______, MS_BTN3, _______, RM_TOGG,    KC_MPRV, KC_MNXT, KC_LCBR, KC_RCBR, KC_LBRC, KC_RBRC, KC_F12 ,
     52   KC_HOME, MS_LEFT, MS_DOWN, MS_RGHT, MS_BTN1, _______, _______,    KC_MPLY, KC_LEFT, KC_DOWN, KC_UP  , KC_RGHT, _______, _______,
     53   KC_END , KC_PSCR, KC_INS , _______, MS_BTN2, _______, _______,    _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, KC_BSLS, KC_PIPE,
     54                                          _______,                                 _______,
     55                                             KC_DEL ,                           KC_ENT ,
     56                                                _______,                     _______,
     57                                                   _______,               _______,
     58                                       _______,                                        _______
     59   )
     60 };
     61 
     62 /* template for new layouts:
     63 LAYOUT(
     64   _______, _______, _______, _______, _______, _______,                      _______, _______, _______, _______, _______, _______,
     65   _______, _______, _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______, _______, _______,
     66   _______, _______, _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______, _______, _______,
     67   _______, _______, _______, _______, _______, _______, _______,    _______, _______, _______, _______, _______, _______, _______,
     68                                          _______,                                 _______,
     69                                             _______,                           _______,
     70                                                _______,                     _______,
     71                                                   _______,               _______,
     72                                       _______,                                        _______
     73   )
     74 */
     75 
     76 static void set_numpad_colours(int on, void (*write)(int, uint8_t, uint8_t, uint8_t)) {
     77   if (!on) {
     78     for (int i=44; i<=60; i++)
     79       write(i, 0, 0, 0);
     80     write(63, 0, 0, 0);
     81     return;
     82   }
     83 
     84   /* main number keys */
     85   for (int i=44; i<=47; i++)
     86     write(i, 255, 0, 0);
     87   for (int i=49; i<=54; i++)
     88     write(i, 255, 0, 0);
     89 
     90   /* accessory keys */
     91   write(48, 128, 128, 0);
     92   for (int i=55; i<=59; i++)
     93     write(i, 128, 128, 0);
     94 
     95   // enter
     96   write(63, 0, 128, 0);
     97 
     98   // num key
     99   write(60, 128, 0, 128);
    100 }
    101 
    102 #ifdef RGB_MATRIX_ENABLE
    103 /* the RGB matrix effects will overwrite the numpad indicator.
    104  * this handy mechanism allows to override the matrix effects.
    105  */
    106 bool rgb_matrix_indicators_user(void) {
    107     if (layer_state & (1 << NUM)) {
    108         set_numpad_colours(1, &rgb_matrix_set_color);
    109     }
    110     return false;
    111 }
    112 #else   /* no RGB matrix support */
    113 
    114 layer_state_t layer_state_set_user(layer_state_t state) {
    115   if (state & (1<<NUM)) {
    116     set_numpad_colours(1, &set_led_to);
    117   } else {
    118     set_numpad_colours(0, &set_led_to);
    119   }
    120 
    121   return state;
    122 }
    123 #endif
    124 
    125 /* vim: set ts=2 sw=2 et: */