2 #include "action_layer.h"
4 #include "keymap_plover.h"
5 #include "action_tapping.h"
7 extern keymap_config_t keymap_config;
21 // Key aliases for legibility
22 #define _______ KC_TRNS
32 #define KC_NDSH LALT(KC_MINS)
33 #define KC_MDSH S(LALT(KC_MINS))
35 // Window manager keys
36 #define WM_FULL LALT(LGUI(KC_F))
37 #define WM_NEXT LCTL(LALT(LGUI(KC_RGHT)))
38 #define WM_PREV LCTL(LALT(LGUI(KC_LEFT)))
39 #define WM_NW LCTL(LGUI(KC_LEFT))
40 #define WM_N LALT(LGUI(KC_UP))
41 #define WM_NE LCTL(LGUI(KC_RGHT))
42 #define WM_E LALT(LGUI(KC_RGHT))
43 #define WM_SE S(LCTL(LGUI(KC_RGHT)))
44 #define WM_S LALT(LGUI(KC_DOWN))
45 #define WM_SW S(LCTL(LGUI(KC_LEFT)))
46 #define WM_W LALT(LGUI(KC_LEFT))
47 #define WM_CNTR LALT(LGUI(KC_C))
50 enum planck_keycodes {
60 //Tap Dance Declarations
65 // Tap Dance Definitions
66 qk_tap_dance_action_t tap_dance_actions[] = {
67 // Tap once for Esc, twice for Backspace
68 [TD_ESC_GRV] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_GRV)
69 // Other declarations would go here, separated by commas, if you have them
72 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
73 /* Base layer (Qwerty)
74 * ,-----------------------------------------------------------------------.
75 * Double tap 4 ~ | ESC | Q | W | E | R | T | Y | U | I | O | P | ' |
76 * |-----------------------------------------------------------------------|
77 * Tap for Tab -- |Ctrl | A | S | D | F | G | H | J | K | L |; Fn4|Ctrl | -- Tap for Enter
78 * |-----------------------------------------------------------------------|
79 * Tap for ( -- |Shift| Z | X | C | V | B | N | M | , | . | / |Shift| -- Tap for )
80 * |-----------------------------------------------------------------------|
81 * Tap for [ -- | Fn3 |Hyper| Alt |Super| Fn1 | Space | Fn2 |Super| Alt |Hyper| Fn3 | -- Tap for ]
82 * `-----------------------------------------------------------------------'
84 * Tap for ] [ --------'-----------------------------------------------------'
86 [BASE_QWERTY_LAYER] = {
87 {TD(TD_ESC_GRV), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_QUOT},
88 {F(5), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, F(1), F(6)},
89 {KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC},
90 {F(3), ALL_T(KC_RBRC), M(LALT_BRACE), KC_LGUI, LOWER, KC_SPC, KC_BSPC, RAISE, KC_RGUI, M(RALT_BRACE), ALL_T(KC_LBRC), F(4)}
93 /* Base layer (Colemak)
94 * ,-----------------------------------------------------------------------.
95 * | | Q | W | F | P | G | J | L | U | Y | ; | |
96 * |-----------------------------------------------------------------------|
97 * | | A | R | S | T | D | H | N | E | I |O Fn4| |
98 * |-----------------------------------------------------------------------|
99 * | | Z | X | C | V | B | K | M | | | | |
100 * |-----------------------------------------------------------------------|
101 * | | | | | | | | | | | |
102 * `-----------------------------------------------------------------------'
104 [BASE_COLEMAK_LAYER] = {
105 {_______, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, _______},
106 {_______, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, F(2), _______},
107 {_______, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, _______, _______, _______, _______},
108 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
111 /* Base layer (Qwerty-Steno)
112 * ,-----------------------------------------------------------------------.
113 * | # | # | # | # | # | # | # | # | # | # | # | # |
114 * |-----------------------------------------------------------------------|
115 * |Look | | T | P | H | | F | P | L | T | D |
116 * | -up | S |-----+-----+-----| * |-----+-----+-----+-----+-----|
117 * | | | K | W | R | | R | B | G | S | Z |
118 * |-----------------------------------------------------------------------|
119 * |Exit | | | A | O | | E | U | | | |
120 * `-----------------------------------------------------------------------'
122 [BASE_STENO_LAYER] = {
123 {PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM},
124 {PV_LOOK, PV_LS, PV_LT, PV_LP, PV_LH, PV_STAR, PV_STAR, PV_RF, PV_RP, PV_RL, PV_RT, PV_RD},
125 {PV_LOOK, PV_LS, PV_LK, PV_LW, PV_LR, PV_STAR, PV_STAR, PV_RR, PV_RB, PV_RG, PV_RS, PV_RZ},
126 {PV_EXIT, ___x___, ___x___, PV_A, PV_O, _______, _______, PV_E, PV_U, ___x___, ___x___, ___x___}
130 * ,-----------------------------------------------------------------------.
131 * Application -- |D-Grv| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | # |
132 * window |-----------------------------------------------------------------------|
133 * switcher | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
134 * |-----------------------------------------------------------------------|
135 * | | - | = | ` | \ | |ndash|mdash| , | . | / | |
136 * |-----------------------------------------------------------------------|
137 * | | | | | | Backspace | | | | | |
138 * `-----------------------------------------------------------------------'
141 {LGUI(KC_GRV), KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, S(KC_3)},
142 {F(5), KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, F(6)},
143 {KC_LSPO, KC_MINS, KC_EQL, KC_GRV, KC_BSLS, ___x___, KC_NDSH, KC_MDSH, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC},
144 {F(3), ALL_T(KC_LBRC), M(LALT_BRACE), KC_LGUI, LOWER, KC_BSPC, KC_BSPC, RAISE, KC_RGUI, M(RALT_BRACE), ALL_T(KC_RBRC), F(4)}
148 * ,-----------------------------------------------------------------------.
149 * | | F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | # |
150 * |-----------------------------------------------------------------------|
151 * | | ! | @ | # | $ | % | ^ | & | * | ' | " | | \
152 * |-----------------------------------------------------------------------| |-- Mostly shifted version
153 * | | _ | + | ~ | | | |ndash|mdash| , | . | / | | / of lower layer
154 * |-----------------------------------------------------------------------|
155 * | | | | | | Delete | | | | | |
156 * `-----------------------------------------------------------------------'
159 {_______, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, S(KC_3)},
160 {_______, S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), KC_QUOT, S(KC_QUOT), _______},
161 {_______, KC_UNDS, KC_PLUS, KC_TILD, KC_PIPE, ___x___, KC_NDSH, KC_MDSH, KC_COMM, KC_DOT, KC_SLSH, _______},
162 {_______, _______, _______, _______, _______, KC_DEL, KC_DEL, _______, _______, _______, _______, _______}
165 /* Directional navigation layer
167 * Large movements -----/```````````````````\ /```````````````````\----- Vim-style arrow keys
168 * ,-----------------------------------------------------------------------.
169 * | | | | | | | | | | | | |
170 * |-----------------------------------------------------------------------|
171 * | | |Home |PgUp |PgDn | End |Left |Down | Up |Right| | |
172 * |-----------------------------------------------------------------------|
173 * | | | | | | | | | | | | |
174 * |-----------------------------------------------------------------------|
175 * | | | | | | | | | | | |
176 * `-----------------------------------------------------------------------'
178 [NAVIGATION_LAYER] = {
179 {___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___},
180 {_______, ___x___, KC_HOME, KC_PGUP, KC_PGDN, KC_END, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, F(1), _______},
181 {_______, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, _______},
182 {_______, _______, _______, _______, ___x___, ___x___, ___x___, ___x___, _______, _______, _______, _______}
185 /* GUI (window management/mouse/media controls) layer
187 * Mouse keys -----/```````````````````\ /```````````````````\----- Window manager
188 * ,-----------------------------------------------------------------------.
189 * | |Ms B2|Ms Up|Ms B1|Ms WD| | |Prev | NW | N | NE | |
190 * |-----------------------------------------------------------------------|
191 * | |Ms L |Ms Dn|Ms R |Ms WU| | |Full | W |Centr| E | |
192 * |-----------------------------------------------------------------------|
193 * | |Ms WL|Ms B3|Ms WR| | | |Next | SW | S | SE | |
194 * |-----------------------------------------------------------------------|
195 * | |Prev |Play |Next |Brig-| Sleep |Brig+|Mute |Vol- |Vol+ | |
196 * `-----------------------------------------------------------------------'
197 * \___ Media ___/ \___ Screen/sleep __/ \___ Volume __/
200 {_______, KC_BTN2, KC_MS_U, KC_BTN1, KC_WH_D, ___x___, ___x___, WM_PREV, WM_NW, WM_N, WM_NE, _______},
201 {_______, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_U, ___x___, ___x___, WM_FULL, WM_W, WM_CNTR, WM_E, _______},
202 {_______, KC_WH_L, KC_BTN3, KC_WH_R, ___x___, ___x___, ___x___, WM_NEXT, WM_SW, WM_S, WM_SE, _______},
203 {_______, KC_MPRV, KC_MPLY, KC_MNXT, KC_SLCK, KC_SLEP, KC_SLEP, KC_PAUS, KC_MUTE, KC_VOLD, KC_VOLU, _______}
206 /* Keyboard settings layer
207 * ,-----------------------------------------------------------------------.
208 * Firmware -- | |Reset| | | | | | | | | | |
209 * |-----------------------------------------------------------------------|
210 * Set layer -- | |Qwert|Colem|Steno| ... | | | | | | | |
211 * |-----------------------------------------------------------------------|
212 * Audio -- | |Voic-|Voic+|Mus +|Mus -|MIDI+|MIDI-| | |Aud +|Aud -| |
213 * |-----------------------------------------------------------------------|
214 * | | | | | | Toggle | |Toggl| BL- | BL+ | |
215 * `-----------------------------------------------------------------------'
216 * \_____________\_ Backlight _/
219 {___x___, RESET, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___},
220 {___x___, QWERTY, COLEMAK, STENO, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___, ___x___},
221 {___x___, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, ___x___, ___x___, AU_ON, AU_OFF, ___x___},
222 {___x___, ___x___, ___x___, ___x___, LOWER, BL_TOGG, BL_TOGG, RAISE, BL_TOGG, BL_DEC, BL_INC, ___x___}
226 const uint16_t PROGMEM fn_actions[] = {
228 [1] = ACTION_LAYER_TAP_KEY(NAVIGATION_LAYER, KC_SCOLON),
229 [2] = ACTION_LAYER_TAP_KEY(NAVIGATION_LAYER, KC_O),
230 [3] = ACTION_LAYER_TAP_KEY(GUI_LAYER, KC_LBRACKET),
231 [4] = ACTION_LAYER_TAP_KEY(GUI_LAYER, KC_RBRACKET),
234 [5] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_TAB),
235 [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT),
238 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
242 if (record->event.pressed) {
243 register_mods(MOD_LALT);
244 record->tap.interrupted = 0;
246 unregister_mods(MOD_LALT);
248 if (record->tap.count && !record->tap.interrupted) {
249 add_weak_mods(MOD_LSFT);
250 register_code(KC_LBRACKET);
251 unregister_code(KC_LBRACKET);
252 del_weak_mods(MOD_LSFT);
255 record->tap.count = 0;
259 if (record->event.pressed) {
260 register_mods(MOD_RALT);
261 record->tap.interrupted = 0;
263 unregister_mods(MOD_RALT);
265 if (record->tap.count && !record->tap.interrupted) {
266 add_weak_mods(MOD_LSFT);
267 register_code(KC_RBRACKET);
268 unregister_code(KC_RBRACKET);
269 del_weak_mods(MOD_LSFT);
272 record->tap.count = 0;
281 float tone_startup[][2] = SONG(STARTUP_SOUND);
282 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
283 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
284 float tone_plover[][2] = SONG(PLOVER_SOUND);
285 float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
286 float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
287 float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
291 void persistant_default_layer_set(uint16_t default_layer) {
292 eeconfig_update_default_layer(default_layer);
293 default_layer_set(default_layer);
296 // Send PHROPB ({PLOVER:RESUME}).
297 void plover_resume(void) {
298 register_code(PV_LP);
299 register_code(PV_LH);
300 register_code(PV_LR);
302 register_code(PV_RP);
303 register_code(PV_RB);
304 unregister_code(PV_LP);
305 unregister_code(PV_LH);
306 unregister_code(PV_LR);
307 unregister_code(PV_O);
308 unregister_code(PV_RP);
309 unregister_code(PV_RB);
312 // Send PHROF ({PLOVER:SUSPEND}).
313 void plover_suspend(void) {
314 register_code(PV_LP);
315 register_code(PV_LH);
316 register_code(PV_LR);
318 register_code(PV_RF);
319 unregister_code(PV_LP);
320 unregister_code(PV_LH);
321 unregister_code(PV_LR);
322 unregister_code(PV_O);
323 unregister_code(PV_RF);
326 // Send PHROBG ({PLOVER:LOOKUP}).
327 void plover_lookup(void) {
328 register_code(PV_LP);
329 register_code(PV_LH);
330 register_code(PV_LR);
332 register_code(PV_RB);
333 register_code(PV_RG);
334 unregister_code(PV_LP);
335 unregister_code(PV_LH);
336 unregister_code(PV_LR);
337 unregister_code(PV_O);
338 unregister_code(PV_RB);
339 unregister_code(PV_RG);
342 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
345 if (record->event.pressed) {
346 persistant_default_layer_set(1UL<<BASE_QWERTY_LAYER);
350 if (record->event.pressed) {
351 persistant_default_layer_set(1UL<<BASE_COLEMAK_LAYER);
355 if (record->event.pressed) {
356 layer_on(LOWER_LAYER);
357 update_tri_layer(LOWER_LAYER, RAISE_LAYER, KEYBOARD_LAYER);
359 layer_off(LOWER_LAYER);
360 update_tri_layer(LOWER_LAYER, RAISE_LAYER, KEYBOARD_LAYER);
364 if (record->event.pressed) {
365 layer_on(RAISE_LAYER);
366 update_tri_layer(LOWER_LAYER, RAISE_LAYER, KEYBOARD_LAYER);
368 layer_off(RAISE_LAYER);
369 update_tri_layer(LOWER_LAYER, RAISE_LAYER, KEYBOARD_LAYER);
373 if (record->event.pressed) {
374 layer_off(RAISE_LAYER);
375 layer_off(LOWER_LAYER);
376 layer_off(KEYBOARD_LAYER);
377 layer_on(BASE_STENO_LAYER);
378 if (!eeconfig_is_enabled()) {
381 keymap_config.raw = eeconfig_read_keymap();
382 keymap_config.nkro = 1;
383 eeconfig_update_keymap(keymap_config.raw);
388 if (record->event.pressed) {
390 layer_off(BASE_STENO_LAYER);
394 if (record->event.pressed) {
402 void matrix_init_user(void) {