aboutsummaryrefslogtreecommitdiff
path: root/keyboards/planck/keymaps/hvp/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/planck/keymaps/hvp/keymap.c')
-rw-r--r--keyboards/planck/keymaps/hvp/keymap.c184
1 files changed, 184 insertions, 0 deletions
diff --git a/keyboards/planck/keymaps/hvp/keymap.c b/keyboards/planck/keymaps/hvp/keymap.c
new file mode 100644
index 000000000..c9aa61981
--- /dev/null
+++ b/keyboards/planck/keymaps/hvp/keymap.c
@@ -0,0 +1,184 @@
1/* Copyright 2015-2017 Jack Humbert
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 "hvp.c"
17#include QMK_KEYBOARD_H
18#include "muse.h"
19
20enum planck_layers {
21 _QWERTY,
22 _LOWER,
23 _RAISE,
24 _NAVI,
25 _ADJUST
26};
27
28enum planck_keycodes {
29 QWERTY = SAFE_RANGE
30};
31
32#define _QWERTY 0
33#define _RAISE 1
34#define _LOWER 2
35#define _NAVI 3
36#define _ADJUST 5
37
38#define LT3_ESC LT(3, KC_ESC)
39#define LT4_TAB LT(5, KC_TAB)
40
41#define LOWER MO(_LOWER)
42#define RAISE MO(_RAISE)
43
44const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
45
46[_QWERTY] = LAYOUT_planck_grid(
47 LT4_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
48 LT3_ESC, KC_A, KC_S, KC_D, LT(3,KC_F), KC_G, KC_H, KC_J, KC_K, KC_L, TD(TD1), TD(TD2),
49 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, TD(TD3), KC_SFTENT,
50 KC_LCTL, KC_APP, KC_LGUI, KC_LALT, MO(2), KC_SPC, KC_SPC, MO(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
51),
52
53[_RAISE] = LAYOUT_planck_grid( /* Right */
54 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
55 KC_DEL, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
56 _______, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
57 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
58),
59
60[_LOWER] = LAYOUT_planck_grid( /* Left */
61 KC_TILDE, KC_EXCLAIM, KC_AT, KC_HASH, KC_DOLLAR, KC_PERCENT, KC_CIRCUMFLEX, KC_AMPERSAND, KC_ASTERISK, KC_LEFT_PAREN, KC_RIGHT_PAREN, KC_BSPC,
62 KC_DEL, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_BSLS,
63 _______, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_TILD,
64 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
65),
66
67[_NAVI] = LAYOUT_planck_grid( /* Esc */
68 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
69 _______, _______, _______, D_NAVI, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, KC_PSCR,
70 _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______,
71 _______, _______, _______, _______, KC_MSTP, KC_MPLY, KC_MPLY, KC_MSTP, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT
72),
73
74[_ADJUST] = LAYOUT_planck_grid( /* Tab */
75 _______, _______, AG_NORM, AG_SWAP, _______, _______, _______, KC_7, KC_8, KC_9, KC_0, _______,
76 _______, _______, MU_MOD, AU_ON, AU_OFF, _______, _______, KC_4, KC_5, KC_6, _______, _______,
77 KC_PSCR, MUV_DE, MUV_IN, MU_ON, MU_OFF, _______, _______, KC_0, KC_1, KC_2, KC_3, _______,
78 RESET, _______, TERM_ON, TERM_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______, DEBUG
79)};
80
81#ifdef AUDIO_ENABLE
82 float plover_song[][2] = SONG(PLOVER_SOUND);
83 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
84#endif
85
86bool muse_mode = false;
87uint8_t last_muse_note = 0;
88uint16_t muse_counter = 0;
89uint8_t muse_offset = 70;
90uint16_t muse_tempo = 50;
91
92void encoder_update(bool clockwise) {
93 if (muse_mode) {
94 if (IS_LAYER_ON(_RAISE)) {
95 if (clockwise) {
96 muse_offset++;
97 } else {
98 muse_offset--;
99 }
100 } else {
101 if (clockwise) {
102 muse_tempo+=1;
103 } else {
104 muse_tempo-=1;
105 }
106 }
107 } else {
108 if (clockwise) {
109 #ifdef MOUSEKEY_ENABLE
110 tap_code(KC_MS_WH_DOWN);
111 #else
112 tap_code(KC_PGDN);
113 #endif
114 } else {
115 #ifdef MOUSEKEY_ENABLE
116 tap_code(KC_MS_WH_UP);
117 #else
118 tap_code(KC_PGUP);
119 #endif
120 }
121 }
122}
123
124void dip_switch_update_user(uint8_t index, bool active) {
125 switch (index) {
126 case 0: {
127#ifdef AUDIO_ENABLE
128 static bool play_sound = false;
129#endif
130 if (active) {
131#ifdef AUDIO_ENABLE
132 if (play_sound) { PLAY_SONG(plover_song); }
133#endif
134 layer_on(_ADJUST);
135 } else {
136#ifdef AUDIO_ENABLE
137 if (play_sound) { PLAY_SONG(plover_gb_song); }
138#endif
139 layer_off(_ADJUST);
140 }
141#ifdef AUDIO_ENABLE
142 play_sound = true;
143#endif
144 break;
145 }
146 case 1:
147 if (active) {
148 muse_mode = true;
149 } else {
150 muse_mode = false;
151 }
152 }
153}
154
155void matrix_scan_user(void) {
156#ifdef AUDIO_ENABLE
157 if (muse_mode) {
158 if (muse_counter == 0) {
159 uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
160 if (muse_note != last_muse_note) {
161 stop_note(compute_freq_for_midi_note(last_muse_note));
162 play_note(compute_freq_for_midi_note(muse_note), 0xF);
163 last_muse_note = muse_note;
164 }
165 }
166 muse_counter = (muse_counter + 1) % muse_tempo;
167 } else {
168 if (muse_counter) {
169 stop_all_notes();
170 muse_counter = 0;
171 }
172 }
173#endif
174}
175
176bool music_mask_user(uint16_t keycode) {
177 switch (keycode) {
178 case RAISE:
179 case LOWER:
180 return false;
181 default:
182 return true;
183 }
184}