1 /* Copyright 2015-2017 Jack Humbert
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.
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.
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/>.
17 #include QMK_KEYBOARD_H
18 #include "action_layer.h"
21 extern keymap_config_t keymap_config;
32 enum planck_keycodes {
41 #define LOWER MO(_LOWER)
42 #define RAISE MO(_RAISE)
45 #define LT_ESC LT(_NAV, KC_ESC) //tap for esc, hold for mouse nav layer
46 #define DEV MO(_DEV) // get to dev layer
47 #define KC_CAD LALT(LCTL(KC_DEL)) // because awkwardness
49 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
52 * ,-----------------------------------------------------------------------------------.
53 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
54 * |------+------+------+------+------+-------------+------+------+------+------+------|
55 * | CTRL | A | S | D | F | G | H | J | K | L | ; | " |
56 * |------+------+------+------+------+------|------+------+------+------+------+------|
57 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
58 * |------+------+------+------+------+------+------+------+------+------+------+------|
59 * | ESC | APP | GUI | ALT |Lower | Space |Raise | DEV | | | |
60 * `-----------------------------------------------------------------------------------'
62 [_QWERTY] = LAYOUT_planck_grid(
63 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
64 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
65 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
66 LT_ESC, KC_APP, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_SPC, RAISE, DEV, _______, _______, _______
71 * ,-----------------------------------------------------------------------------------.
72 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp|
73 * |------+------+------+------+------+-------------+------+------+------+------+------|
74 * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
75 * |------+------+------+------+------+------|------+------+------+------+------+------|
76 * | | F7 | F8 | F9 | F10 | F11 | F12 | | Home | END | | |
77 * |------+------+------+------+------+------+------+------+------+------+------+------|
78 * | DEL | | | | | | | Next | Vol- | Vol+ | Play |
79 * `-----------------------------------------------------------------------------------'
81 [_LOWER] = LAYOUT_planck_grid(
82 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
83 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
84 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_HOME, KC_END, _______, _______,
85 KC_DEL, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
89 * ,-----------------------------------------------------------------------------------.
90 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
91 * |------+------+------+------+------+-------------+------+------+------+------+------|
92 * | | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
93 * |------+------+------+------+------+------|------+------+------+------+------+------|
94 * | | F7 | F8 | F9 | F10 | F11 | F12 | |Pg Up |Pg Dn | | |
95 * |------+------+------+------+------+------+------+------+------+------+------+------|
96 * | Del | | | | | | | Next | Vol- | Vol+ | Play
97 * `-----------------------------------------------------------------------------------'
99 [_RAISE] = LAYOUT_planck_grid(
100 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
101 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
102 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_PGUP, KC_PGDN, _______, _______,
103 KC_DEL, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
106 /* Adjust (Lower + Raise)
107 * ,-----------------------------------------------------------------------------------.
108 * | | Reset| | | | | | | | | | Del |
109 * |------+------+------+------+------+-------------+------+------+------+------+------|
110 * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty| | | | |
111 * |------+------+------+------+------+------|------+------+------+------+------+------|
112 * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
113 * |------+------+------+------+------+------+------+------+------+------+------+------|
114 * | | | | | | | | | | | |
115 * `-----------------------------------------------------------------------------------'
117 [_ADJUST] = LAYOUT_planck_grid(
118 _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
119 _______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, _______, _______, _______, _______,
120 _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, _______, _______, _______,
121 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
125 * ,-----------------------------------------------------------------------------------.
126 * | | | | | | | | PGUP | UP | PGDN | |KC_CAD|
127 * |------+------+------+------+------+-------------+------+------+------+------+------|
128 * | | | | | | | HOME | LEFT | DOWN |RIGHT | | |
129 * |------+------+------+------+------+------|------+------+------+------+------+------|
130 * | | | | | | | END | | | | | |
131 * |------+------+------+------+------+------+------+------+------+------+------+------|
132 * | | | | | | | | | | | |
133 * `-----------------------------------------------------------------------------------'
135 [_NAV] = LAYOUT_planck_grid(
136 _______, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_UP, KC_PGDN, _______, KC_CAD,
137 _______, _______, _______, _______, _______, _______, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______,
138 _______, _______, _______, _______, _______, _______, KC_END, _______, _______, _______, _______, _______,
139 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
143 * ,-----------------------------------------------------------------------------------.
144 * | | | |R_CMLM| | | | | | | |KC_CAD|
145 * |------+------+------+------+------+-------------+------+------+------+------+------|
146 * | | | | | | | |R_ASGN|R_PIPE| | | |
147 * |------+------+------+------+------+------|------+------+------+------+------+------|
148 * | | | | | | | | | | | | |
149 * |------+------+------+------+------+------+------+------+------+------+------+------|
150 * | | | | | | | | | | | |
151 * `-----------------------------------------------------------------------------------'
153 [_DEV] = LAYOUT_planck_grid(
154 _______, _______, _______, R_CMLN, _______, _______, _______, _______, _______, _______, _______, KC_CAD,
155 _______, _______, _______, _______, _______, _______, _______, R_ASGN, R_PIPE, _______, _______, _______,
156 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
157 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
163 float plover_song[][2] = SONG(PLOVER_SOUND);
164 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
167 uint32_t layer_state_set_user(uint32_t state) {
168 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
171 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
174 if (record->event.pressed) {
175 print("mode just switched to qwerty and this is a huge string\n");
176 set_single_persistent_default_layer(_QWERTY);
181 if (record->event.pressed) {
182 register_code(KC_RSFT);
183 #ifdef BACKLIGHT_ENABLE
186 #ifdef KEYBOARD_planck_rev5
190 unregister_code(KC_RSFT);
191 #ifdef KEYBOARD_planck_rev5
199 if (record->event.pressed) {
205 if (record->event.pressed) {
206 SEND_STRING(" %>%\n");
211 if (record->event.pressed) {
212 SEND_STRING("################################################################################");
220 bool muse_mode = false;
221 uint8_t last_muse_note = 0;
222 uint16_t muse_counter = 0;
223 uint8_t muse_offset = 70;
224 uint16_t muse_tempo = 50;
226 void encoder_update(bool clockwise) {
228 if (IS_LAYER_ON(_RAISE)) {
243 register_code(KC_PGDN);
244 unregister_code(KC_PGDN);
246 register_code(KC_PGUP);
247 unregister_code(KC_PGUP);
252 void dip_update(uint8_t index, bool active) {
257 PLAY_SONG(plover_song);
262 PLAY_SONG(plover_gb_song);
279 void matrix_scan_user(void) {
282 if (muse_counter == 0) {
283 uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
284 if (muse_note != last_muse_note) {
285 stop_note(compute_freq_for_midi_note(last_muse_note));
286 play_note(compute_freq_for_midi_note(muse_note), 0xF);
287 last_muse_note = muse_note;
290 muse_counter = (muse_counter + 1) % muse_tempo;
295 bool music_mask_user(uint16_t keycode) {