1 /* Copyright 2015-2017 Jack Humbert, Christoffer Holmberg
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 "keymap_swedish.h"
21 extern keymap_config_t keymap_config;
31 enum planck_keycodes {
37 S1, S2, S3, S4, S5, S6, S7, S8, S9
40 #define ESC_LOW LT(_LOWER, KC_ESC)
41 #define BSP_RAI LT(_RAISE, KC_BSPC)
42 #define LFT_CTR CTL_T(NO_APOS)
43 #define RGT_CTR CTL_T(KC_TILD)
44 #define UTILITY MO(_UTILITY)
46 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
49 * ,-----------------------------------------------------------------------------------.
50 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Å |
51 * |------+------+------+------+------+-------------+------+------+------+------+------|
52 * | Fn | A | S | D | F | G | H | J | K | L | Ö | Ä |
53 * |------+------+------+------+------+------|------+------+------+------+------+------|
54 * | Shift| Z | X | C | V | B | N | M | , | . | - |Shift |
55 * |------+------+------+------+------+------+------+------+------+------+------+------|
56 * | Ctrl | Super| Alt | |L/Esc | Ret | Space|R/Bspc| |AltGr | * | ¨ |
57 * `-----------------------------------------------------------------------------------'
59 [_DEFAULT] = LAYOUT_planck_grid(
60 KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , NO_AA ,
61 UTILITY, KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , NO_OSLH, NO_AE ,
62 KC_LSPO, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , NO_MINS, KC_RSPC,
63 LFT_CTR, KC_LALT, KC_LGUI, NO_AT , ESC_LOW, KC_ENT , KC_SPC , BSP_RAI, _______, KC_ALGR, NO_ASTR, RGT_CTR
67 * ,-----------------------------------------------------------------------------------.
68 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | + |
69 * |------+------+------+------+------+-------------+------+------+------+------+------|
70 * | | | | | | | | | | | | |
71 * |------+------+------+------+------+------|------+------+------+------+------+------|
72 * | | | | | | | | | | | | |
73 * |------+------+------+------+------+------+------+------+------+------+------+------|
74 * | | | | | | | | | | | | |
75 * `-----------------------------------------------------------------------------------'
77 [_RAISE] = LAYOUT_planck_grid(
78 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PLUS,
79 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
80 _______, NO_GRTR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
81 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
85 * ,-----------------------------------------------------------------------------------.
86 * | | | | | | | | | | | | |
87 * |------+------+------+------+------+-------------+------+------+------+------+------|
88 * | | | | | | | | | | | | |
89 * |------+------+------+------+------+------|------+------+------+------+------+------|
90 * | | | | | | | | | | | | |
91 * |------+------+------+------+------+------+------+------+------+------+------+------|
92 * | | | | | | | | | | | | |
93 * `-----------------------------------------------------------------------------------'
95 [_LOWER] = LAYOUT_planck_grid(
96 NO_HALF, LSFT(KC_1), NO_QUO2, LSFT(KC_3), NO_BULT, LSFT(KC_5), NO_AMPR, NO_SLSH, NO_LPRN, NO_RPRN, NO_EQL , NO_QUES,
97 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
98 _______, NO_LESS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
99 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
103 * ,-----------------------------------------------------------------------------------.
104 * | | | up | | | | | | S1 | S2 | S3 | |
105 * |------+------+------+------+------+-------------+------+------+------+------+------|
106 * | | left | down | right| | | | | S4 | S5 | S6 | |
107 * |------+------+------+------+------+------|------+------+------+------+------+------|
108 * | | | | | | | | | S7 | S8 | S9 | |
109 * |------+------+------+------+------+------+------+------+------+------+------+------|
110 * | | | | | | | | Del | | | | |
111 * `-----------------------------------------------------------------------------------'
114 [_UTILITY] = LAYOUT_planck_grid(
115 _______, _______, KC_UP , _______, _______, _______, _______, _______, S1 , S2 , S3 , _______,
116 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, S4 , S5 , S6 , _______,
117 _______, _______, _______, _______, _______, _______, _______, _______, S7 , S8 , S9 , _______,
118 _______, _______, _______, _______, _______, _______, _______, KC_DEL , _______, _______, _______, _______
121 /* Adjust (Lower + Raise)
122 * ,-----------------------------------------------------------------------------------.
123 * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
124 * |------+------+------+------+------+-------------+------+------+------+------+------|
125 * | |Reset | |Aud on|Audoff|AGnorm|AGswap|Qwerty| | |Utilit| |
126 * |------+------+------+------+------+------|------+------+------+------+------+------|
127 * | | | | | | | | | | | | |
128 * |------+------+------+------+------+------+------+------+------+------+------+------|
129 * | | | | | | | | | | | | |
130 * `-----------------------------------------------------------------------------------'
132 [_ADJUST] = LAYOUT_planck_grid(
133 KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 ,
134 _______, RESET , MU_MOD , AU_ON , AU_OFF , AG_NORM, AG_SWAP, DEFAULT, XXXXXXX , XXXXXXX, UTILITY, _______,
135 _______, NO_PIPE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
136 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
143 float plover_song[][2] = SONG(PLOVER_SOUND);
144 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
145 float s1[][2] = SONG(NUMBER_ONE);
146 float s2[][2] = SONG(ZELDA_PUZZLE);
147 float s3[][2] = SONG(ZELDA_TREASURE);
148 float s4[][2] = SONG(OVERWATCH_THEME);
149 float s5[][2] = SONG(IMPERIAL_MARCH);
150 float s6[][2] = SONG(E1M1_DOOM);
151 float s7[][2] = SONG(COIN_SOUND);
152 float s8[][2] = SONG(ONE_UP_SOUND);
153 float s9[][2] = SONG(SONIC_RING);
156 uint32_t layer_state_set_user(uint32_t state) {
157 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
160 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
163 if (record->event.pressed) {
164 set_single_persistent_default_layer(_DEFAULT);
169 if (record->event.pressed) {
170 register_code(KC_RSFT);
171 #ifdef BACKLIGHT_ENABLE
174 #ifdef KEYBOARD_planck_rev5
178 unregister_code(KC_RSFT);
179 #ifdef KEYBOARD_planck_rev5
186 if (record->event.pressed) {
189 #endif //AUDIO_ENABLE
194 if (record->event.pressed) {
197 #endif //AUDIO_ENABLE
202 if (record->event.pressed) {
205 #endif //AUDIO_ENABLE
210 if (record->event.pressed) {
213 #endif //AUDIO_ENABLE
218 if (record->event.pressed) {
221 #endif //AUDIO_ENABLE
226 if (record->event.pressed) {
229 #endif //AUDIO_ENABLE
234 if (record->event.pressed) {
237 #endif //AUDIO_ENABLE
242 if (record->event.pressed) {
245 #endif //AUDIO_ENABLE
250 if (record->event.pressed) {
253 #endif //AUDIO_ENABLE
261 bool muse_mode = false;
262 uint8_t last_muse_note = 0;
263 uint16_t muse_counter = 0;
264 uint8_t muse_offset = 70;
265 uint16_t muse_tempo = 50;
267 void encoder_update(bool clockwise) {
269 if (IS_LAYER_ON(_RAISE)) {
284 register_code(KC_PGDN);
285 unregister_code(KC_PGDN);
287 register_code(KC_PGUP);
288 unregister_code(KC_PGUP);
293 void dip_update(uint8_t index, bool active) {
298 PLAY_SONG(plover_song);
303 PLAY_SONG(plover_gb_song);
320 void matrix_scan_user(void) {
323 if (muse_counter == 0) {
324 uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
325 if (muse_note != last_muse_note) {
326 stop_note(compute_freq_for_midi_note(last_muse_note));
327 play_note(compute_freq_for_midi_note(muse_note), 0xF);
328 last_muse_note = muse_note;
331 muse_counter = (muse_counter + 1) % muse_tempo;
336 bool music_mask_user(uint16_t keycode) {