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
20 extern keymap_config_t keymap_config;
29 enum planck_keycodes {
35 #define LOWER MO(_LOWER)
36 #define RAISE MO(_RAISE)
38 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
41 * ,-----------------------------------------------------------------------------------.
42 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
43 * |------+------+------+------+------+-------------+------+------+------+------+------|
44 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
45 * |------+------+------+------+------+------|------+------+------+------+------+------|
46 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
47 * |------+------+------+------+------+------+------+------+------+------+------+------|
48 * | Ctrl | Alt | GUI |Brite |Lower | Space |Raise | Left | Down | Up |Right |
49 * `-----------------------------------------------------------------------------------'
51 [_QWERTY] = LAYOUT_planck_grid(
52 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
53 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
54 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
55 KC_LCTL, KC_LALT, KC_LGUI, BACKLIT, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
59 * ,-----------------------------------------------------------------------------------.
60 * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
61 * |------+------+------+------+------+-------------+------+------+------+------+------|
62 * | | Prev | Play | Next | | | * | 4 | 5 | 6 | - | Del |
63 * |------+------+------+------+------+------|------+------+------+------+------+------|
64 * | Pwd | Vol- | MUTE | Vol+ | | | / | 1 | 2 | 3 | + | PgUp |
65 * |------+------+------+------+------+------+------+------+------+------+------+------|
66 * | | | | | | | | 0 | . | = | PgDn |
67 * `-----------------------------------------------------------------------------------'
69 [_LOWER] = LAYOUT_planck_grid(
70 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
71 _______, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, KC_ASTR, KC_4, KC_5, KC_6, KC_MINS, KC_DEL,
72 MY_PWD, KC_VOLD, KC_MUTE, KC_VOLU, _______, _______, KC_SLSH, KC_1, KC_2, KC_3, KC_PLUS, KC_PGUP,
73 _______, _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_EQL, KC_PGDN
77 * ,-----------------------------------------------------------------------------------.
78 * | ` | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
79 * |------+------+------+------+------+-------------+------+------+------+------+------|
80 * | | ~ | | / | { | [ | ] | } | \ | - | + | | |
81 * |------+------+------+------+------+------|------+------+------+------+------+------|
82 * | | | | | | | | | | _ | = | |
83 * |------+------+------+------+------+------+------+------+------+------+------+------|
84 * | | | | | | | | Home | PgDn | PgUp | End |
85 * `-----------------------------------------------------------------------------------'
87 [_RAISE] = LAYOUT_planck_grid(
89 KC_GRV, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
90 _______, KC_TILD, _______, KC_SLSH, KC_LCBR, KC_LBRC, KC_RBRC, KC_RCBR, KC_BSLS, KC_MINS, KC_PLUS, KC_PIPE,
91 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_EQL, _______,
92 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
95 /* Adjust (Lower + Raise)
96 * ,-----------------------------------------------------------------------------------.
97 * | | Reset| | | | | | | | | | Del |
98 * |------+------+------+------+------+-------------+------+------+------+------+------|
99 * | | | |Aud on|Audoff|AGnorm|AGswap| | | | | |
100 * |------+------+------+------+------+------|------+------+------+------+------+------|
101 * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
102 * |------+------+------+------+------+------+------+------+------+------+------+------|
103 * | | | | | | | | | | | |
104 * `-----------------------------------------------------------------------------------'
106 [_ADJUST] = LAYOUT_planck_grid(
107 _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
108 _______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______,
109 _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______,
110 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
117 float plover_song[][2] = SONG(PLOVER_SOUND);
118 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
121 uint32_t layer_state_set_user(uint32_t state) {
122 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
125 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
128 if (record->event.pressed) {
129 register_code(KC_RSFT);
130 #ifdef BACKLIGHT_ENABLE
133 #ifdef KEYBOARD_planck_rev5
137 unregister_code(KC_RSFT);
138 #ifdef KEYBOARD_planck_rev5
145 if (record->event.pressed) {
146 SEND_STRING("My secret password!");
154 bool muse_mode = false;
155 uint8_t last_muse_note = 0;
156 uint16_t muse_counter = 0;
157 uint8_t muse_offset = 70;
158 uint16_t muse_tempo = 50;
160 void encoder_update(bool clockwise) {
162 if (IS_LAYER_ON(_RAISE)) {
177 register_code(KC_PGDN);
178 unregister_code(KC_PGDN);
180 register_code(KC_PGUP);
181 unregister_code(KC_PGUP);
186 void dip_update(uint8_t index, bool active) {
191 PLAY_SONG(plover_song);
196 PLAY_SONG(plover_gb_song);
213 void matrix_scan_user(void) {
216 if (muse_counter == 0) {
217 uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
218 if (muse_note != last_muse_note) {
219 stop_note(compute_freq_for_midi_note(last_muse_note));
220 play_note(compute_freq_for_midi_note(muse_note), 0xF);
221 last_muse_note = muse_note;
224 muse_counter = (muse_counter + 1) % muse_tempo;
229 bool music_mask_user(uint16_t keycode) {