summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-09-14 19:59:44 -0700
committerGitHub <noreply@github.com>2019-09-14 19:59:44 -0700
commit6c871408dfe971dce72910a0868b564eb8e76e27 (patch)
tree168fb24c2e94f6ade277909893d854015191845b
parent265d8abee16ef73bcaf8cdc70a8e0532fbfb0fda (diff)
downloadqmk_firmware-6c871408dfe971dce72910a0868b564eb8e76e27.tar.gz
qmk_firmware-6c871408dfe971dce72910a0868b564eb8e76e27.zip
[Keyboard] Fix default keymaps for OLKB boards to play Startup Sound (#6721)
* Fix Planck default keymap to play sounds on rev6 The dip_switch_update callback was overriding the default startup sound. This should prevent that from happening, and still allow it to play sounds, or stop them, when appropriate. * Fix Preonic default keymap to play sounds on Rev 3 The dip_switch_update callback was overriding the default startup sound. This should prevent that from happening, and still allow it to play sounds, or stop them, when appropriate.
-rw-r--r--keyboards/planck/keymaps/default/keymap.c73
-rw-r--r--keyboards/preonic/keymaps/default/keymap.c59
2 files changed, 70 insertions, 62 deletions
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c
index e4f3cafbfc..e3818fec7a 100644
--- a/keyboards/planck/keymaps/default/keymap.c
+++ b/keyboards/planck/keymaps/default/keymap.c
@@ -290,46 +290,51 @@ void encoder_update(bool clockwise) {
}
void dip_switch_update_user(uint8_t index, bool active) {
- switch (index) {
- case 0:
- if (active) {
- #ifdef AUDIO_ENABLE
- PLAY_SONG(plover_song);
- #endif
- layer_on(_ADJUST);
- } else {
- #ifdef AUDIO_ENABLE
- PLAY_SONG(plover_gb_song);
- #endif
- layer_off(_ADJUST);
- }
- break;
- case 1:
- if (active) {
- muse_mode = true;
- } else {
- muse_mode = false;
- #ifdef AUDIO_ENABLE
- stop_all_notes();
- #endif
- }
- }
+ switch (index) {
+ case 0: {
+ static bool play_sound = false;
+ if (active) {
+#ifdef AUDIO_ENABLE
+ if (play_sound) { PLAY_SONG(plover_song); }
+#endif
+ layer_on(_ADJUST);
+ } else {
+#ifdef AUDIO_ENABLE
+ if (play_sound) { PLAY_SONG(plover_gb_song); }
+#endif
+ layer_off(_ADJUST);
+ }
+ play_sound = true;
+ break;
+ }
+ case 1:
+ if (active) {
+ muse_mode = true;
+ } else {
+ muse_mode = false;
+ }
+ }
}
void matrix_scan_user(void) {
- #ifdef AUDIO_ENABLE
+#ifdef AUDIO_ENABLE
if (muse_mode) {
- if (muse_counter == 0) {
- uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
- if (muse_note != last_muse_note) {
- stop_note(compute_freq_for_midi_note(last_muse_note));
- play_note(compute_freq_for_midi_note(muse_note), 0xF);
- last_muse_note = muse_note;
+ if (muse_counter == 0) {
+ uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
+ if (muse_note != last_muse_note) {
+ stop_note(compute_freq_for_midi_note(last_muse_note));
+ play_note(compute_freq_for_midi_note(muse_note), 0xF);
+ last_muse_note = muse_note;
+ }
+ }
+ muse_counter = (muse_counter + 1) % muse_tempo;
+ } else {
+ if (muse_counter) {
+ stop_all_notes();
+ muse_counter = 0;
}
- }
- muse_counter = (muse_counter + 1) % muse_tempo;
}
- #endif
+#endif
}
bool music_mask_user(uint16_t keycode) {
diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c
index b45ed0835d..b3678a44ed 100644
--- a/keyboards/preonic/keymaps/default/keymap.c
+++ b/keyboards/preonic/keymaps/default/keymap.c
@@ -260,40 +260,43 @@ void encoder_update_user(uint8_t index, bool clockwise) {
}
void dip_switch_update_user(uint8_t index, bool active) {
- switch (index) {
- case 0:
- if (active) {
- layer_on(_ADJUST);
- } else {
- layer_off(_ADJUST);
- }
- break;
- case 1:
- if (active) {
- muse_mode = true;
- } else {
- muse_mode = false;
- #ifdef AUDIO_ENABLE
- stop_all_notes();
- #endif
- }
- }
+ switch (index) {
+ case 0:
+ if (active) {
+ layer_on(_ADJUST);
+ } else {
+ layer_off(_ADJUST);
+ }
+ break;
+ case 1:
+ if (active) {
+ muse_mode = true;
+ } else {
+ muse_mode = false;
+ }
+ xs}
}
+
void matrix_scan_user(void) {
- #ifdef AUDIO_ENABLE
+#ifdef AUDIO_ENABLE
if (muse_mode) {
- if (muse_counter == 0) {
- uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
- if (muse_note != last_muse_note) {
- stop_note(compute_freq_for_midi_note(last_muse_note));
- play_note(compute_freq_for_midi_note(muse_note), 0xF);
- last_muse_note = muse_note;
+ if (muse_counter == 0) {
+ uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
+ if (muse_note != last_muse_note) {
+ stop_note(compute_freq_for_midi_note(last_muse_note));
+ play_note(compute_freq_for_midi_note(muse_note), 0xF);
+ last_muse_note = muse_note;
+ }
+ }
+ muse_counter = (muse_counter + 1) % muse_tempo;
+ } else {
+ if (muse_counter) {
+ stop_all_notes();
+ muse_counter = 0;
}
- }
- muse_counter = (muse_counter + 1) % muse_tempo;
}
- #endif
+#endif
}
bool music_mask_user(uint16_t keycode) {