qmk/keymap.c

199 lines
10 KiB
C

/* Copyright 2015-2021 Jack Humbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
// our layers, used as index in layers and rgb lights
enum planck_layers {
_QWERTY,
_LOWER,
_RAISE,
_NAV,
_CMD,
_FN
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Qwerty
* ,-----------------------------------------------------------------------------------.
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Esc | A | S | D | F | G | H | J | K | L | ; | ' |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Ctrl | GUI | Alt | Cmd |Lower |Space |Space |Raise | Fn | Alt | GUI | Ctrl |
* `-----------------------------------------------------------------------------------'
*/
[_QWERTY] = LAYOUT_planck_grid(
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
LCTL_T(KC_ESC), KC_A, RALT_T(KC_S), LALT_T(KC_D), LSFT_T(KC_F), LGUI_T(KC_G), RGUI_T(KC_H), RSFT_T(KC_J), LALT_T(KC_K), RALT_T(KC_L), LT(_NAV, KC_SCLN), RCTL_T(KC_QUOT),
LSFT_T(KC_ENT), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_ENT),
KC_LCTL, KC_LGUI, KC_LALT, MO(_CMD), MO(_LOWER), LT(_LOWER, KC_SPC), LT(_RAISE, KC_SPC), MO(_RAISE), MO(_FN), KC_RALT, KC_RGUI, KC_RCTL
),
/* Lower
* ,-----------------------------------------------------------------------------------.
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | Home | End | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
*/
[_LOWER] = LAYOUT_planck_grid(
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
/* Raise
* ,-----------------------------------------------------------------------------------.
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
*/
[_RAISE] = LAYOUT_planck_grid(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
/* Navigation layer
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | Up | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | Home | PgUp | PgDn | End | | | Left | Down | Right| | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_NAV] = LAYOUT_planck_grid(
_______, _______, _______, _______, _______, _______, _______, _______, KC_UP, _______, _______, _______,
_______, KC_HOME, KC_PGUP, KC_PGDN, KC_END, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
/* Command layer
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* |Print | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_CMD] = LAYOUT_planck_grid(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),
/*
* Function layer
* v------------------------RGB CONTROL--------------------v
* ,-----------------------------------------------------------------------------------.
* | | | RGB |RGBMOD| HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Boot | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | |Reboot|
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_FN] = LAYOUT_planck_grid(
_______, _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______,
QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_RBT,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
)
};
/* plwnck rev6 RGB layout:
* ----------------------------------
* | 6 5 4 3 |
* | 0 |
* | 7 8 1 2 |
* ----------------------------------
*/
const rgblight_segment_t PROGMEM qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{1, 8, HSV_WHITE}
);
const rgblight_segment_t PROGMEM lower_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{1, 8, HSV_BLUE}
);
const rgblight_segment_t PROGMEM raise_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{1, 8, HSV_YELLOW}
);
const rgblight_segment_t PROGMEM nav_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{1, 8, HSV_WHITE}
);
const rgblight_segment_t PROGMEM cmd_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{1, 8, HSV_GREEN}
);
const rgblight_segment_t PROGMEM fn_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{1, 8, HSV_RED}
);
const rgblight_segment_t * const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
[_QWERTY] = qwerty_layer,
[_LOWER] = lower_layer,
[_RAISE] = raise_layer,
[_NAV] = nav_layer,
[_CMD] = cmd_layer,
[_FN] = fn_layer
);
void keyboard_post_init_user(void) {
// Enable the LED layers
rgblight_layers = my_rgb_layers;
}
layer_state_t layer_state_set_user(layer_state_t state)
{
rgblight_set_layer_state(_LOWER, layer_state_cmp(state, _LOWER));
rgblight_set_layer_state(_RAISE, layer_state_cmp(state, _RAISE));
rgblight_set_layer_state(_NAV, layer_state_cmp(state, _NAV));
rgblight_set_layer_state(_CMD, layer_state_cmp(state, _CMD));
rgblight_set_layer_state(_FN, layer_state_cmp(state, _FN));
return state;
}