diff options
Diffstat (limited to 'keyboards/planck/keymaps/default/keymap.c')
| -rw-r--r-- | keyboards/planck/keymaps/default/keymap.c | 100 |
1 files changed, 24 insertions, 76 deletions
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c index 61275cb26..ddb93c885 100644 --- a/keyboards/planck/keymaps/default/keymap.c +++ b/keyboards/planck/keymaps/default/keymap.c | |||
| @@ -1,20 +1,28 @@ | |||
| 1 | // This is the canonical layout file for the Quantum project. If you want to add another keyboard, | 1 | /* Copyright 2015-2017 Jack Humbert |
| 2 | // this is the style you want to emulate. | 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 | */ | ||
| 3 | 16 | ||
| 4 | #include "planck.h" | 17 | #include "planck.h" |
| 5 | #include "action_layer.h" | 18 | #include "action_layer.h" |
| 19 | #include "eeconfig.h" | ||
| 6 | #ifdef AUDIO_ENABLE | 20 | #ifdef AUDIO_ENABLE |
| 7 | #include "audio.h" | 21 | #include "audio.h" |
| 8 | #endif | 22 | #endif |
| 9 | #include "eeconfig.h" | ||
| 10 | 23 | ||
| 11 | extern keymap_config_t keymap_config; | 24 | extern keymap_config_t keymap_config; |
| 12 | 25 | ||
| 13 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
| 14 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
| 15 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
| 16 | // entirely and just use numbers. | ||
| 17 | |||
| 18 | enum planck_layers { | 26 | enum planck_layers { |
| 19 | _QWERTY, | 27 | _QWERTY, |
| 20 | _COLEMAK, | 28 | _COLEMAK, |
| @@ -36,10 +44,6 @@ enum planck_keycodes { | |||
| 36 | EXT_PLV | 44 | EXT_PLV |
| 37 | }; | 45 | }; |
| 38 | 46 | ||
| 39 | // Fillers to make layering more clear | ||
| 40 | #define _______ KC_TRNS | ||
| 41 | #define XXXXXXX KC_NO | ||
| 42 | |||
| 43 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 47 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 44 | 48 | ||
| 45 | /* Qwerty | 49 | /* Qwerty |
| @@ -173,50 +177,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 173 | }; | 177 | }; |
| 174 | 178 | ||
| 175 | #ifdef AUDIO_ENABLE | 179 | #ifdef AUDIO_ENABLE |
| 176 | 180 | float plover_song[][2] = SONG(PLOVER_SOUND); | |
| 177 | float tone_startup[][2] = SONG(STARTUP_SOUND); | 181 | float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND); |
| 178 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
| 179 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
| 180 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
| 181 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
| 182 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
| 183 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
| 184 | |||
| 185 | float tone_goodbye[][2] = SONG(GOODBYE_SOUND); | ||
| 186 | #endif | 182 | #endif |
| 187 | 183 | ||
| 188 | |||
| 189 | void persistent_default_layer_set(uint16_t default_layer) { | ||
| 190 | eeconfig_update_default_layer(default_layer); | ||
| 191 | default_layer_set(default_layer); | ||
| 192 | } | ||
| 193 | |||
| 194 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 184 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 195 | switch (keycode) { | 185 | switch (keycode) { |
| 196 | case QWERTY: | 186 | case QWERTY: |
| 197 | if (record->event.pressed) { | 187 | if (record->event.pressed) { |
| 198 | #ifdef AUDIO_ENABLE | 188 | set_single_persistent_default_layer(_QWERTY); |
| 199 | PLAY_NOTE_ARRAY(tone_qwerty, false, 0); | ||
| 200 | #endif | ||
| 201 | persistent_default_layer_set(1UL<<_QWERTY); | ||
| 202 | } | 189 | } |
| 203 | return false; | 190 | return false; |
| 204 | break; | 191 | break; |
| 205 | case COLEMAK: | 192 | case COLEMAK: |
| 206 | if (record->event.pressed) { | 193 | if (record->event.pressed) { |
| 207 | #ifdef AUDIO_ENABLE | 194 | set_single_persistent_default_layer(_COLEMAK); |
| 208 | PLAY_NOTE_ARRAY(tone_colemak, false, 0); | ||
| 209 | #endif | ||
| 210 | persistent_default_layer_set(1UL<<_COLEMAK); | ||
| 211 | } | 195 | } |
| 212 | return false; | 196 | return false; |
| 213 | break; | 197 | break; |
| 214 | case DVORAK: | 198 | case DVORAK: |
| 215 | if (record->event.pressed) { | 199 | if (record->event.pressed) { |
| 216 | #ifdef AUDIO_ENABLE | 200 | set_single_persistent_default_layer(_DVORAK); |
| 217 | PLAY_NOTE_ARRAY(tone_dvorak, false, 0); | ||
| 218 | #endif | ||
| 219 | persistent_default_layer_set(1UL<<_DVORAK); | ||
| 220 | } | 201 | } |
| 221 | return false; | 202 | return false; |
| 222 | break; | 203 | break; |
| @@ -255,7 +236,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 255 | if (record->event.pressed) { | 236 | if (record->event.pressed) { |
| 256 | #ifdef AUDIO_ENABLE | 237 | #ifdef AUDIO_ENABLE |
| 257 | stop_all_notes(); | 238 | stop_all_notes(); |
| 258 | PLAY_NOTE_ARRAY(tone_plover, false, 0); | 239 | PLAY_SONG(plover_song); |
| 259 | #endif | 240 | #endif |
| 260 | layer_off(_RAISE); | 241 | layer_off(_RAISE); |
| 261 | layer_off(_LOWER); | 242 | layer_off(_LOWER); |
| @@ -273,7 +254,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 273 | case EXT_PLV: | 254 | case EXT_PLV: |
| 274 | if (record->event.pressed) { | 255 | if (record->event.pressed) { |
| 275 | #ifdef AUDIO_ENABLE | 256 | #ifdef AUDIO_ENABLE |
| 276 | PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); | 257 | PLAY_SONG(plover_gb_song); |
| 277 | #endif | 258 | #endif |
| 278 | layer_off(_PLOVER); | 259 | layer_off(_PLOVER); |
| 279 | } | 260 | } |
| @@ -281,37 +262,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 281 | break; | 262 | break; |
| 282 | } | 263 | } |
| 283 | return true; | 264 | return true; |
| 284 | } | 265 | } \ No newline at end of file |
| 285 | |||
| 286 | void matrix_init_user(void) { | ||
| 287 | #ifdef AUDIO_ENABLE | ||
| 288 | startup_user(); | ||
| 289 | #endif | ||
| 290 | } | ||
| 291 | |||
| 292 | #ifdef AUDIO_ENABLE | ||
| 293 | |||
| 294 | void startup_user() | ||
| 295 | { | ||
| 296 | _delay_ms(20); // gets rid of tick | ||
| 297 | PLAY_NOTE_ARRAY(tone_startup, false, 0); | ||
| 298 | } | ||
| 299 | |||
| 300 | void shutdown_user() | ||
| 301 | { | ||
| 302 | PLAY_NOTE_ARRAY(tone_goodbye, false, 0); | ||
| 303 | _delay_ms(150); | ||
| 304 | stop_all_notes(); | ||
| 305 | } | ||
| 306 | |||
| 307 | void music_on_user(void) | ||
| 308 | { | ||
| 309 | music_scale_user(); | ||
| 310 | } | ||
| 311 | |||
| 312 | void music_scale_user(void) | ||
| 313 | { | ||
| 314 | PLAY_NOTE_ARRAY(music_scale, false, 0); | ||
| 315 | } | ||
| 316 | |||
| 317 | #endif | ||
