[Keymap] junonum: community keymap improvement (#19727)

Co-authored-by: Minh-tri Nguyen <mtngx@PigeonMac.local>
Co-authored-by: Joel Challis <git@zvecr.com>
This commit is contained in:
Juno Nguyen 2023-02-10 05:07:00 +08:00 committed by GitHub
parent 40f0325af8
commit cdaac25861
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 160 additions and 137 deletions

View File

@ -1,5 +1,24 @@
/* Copyright 2023 Juno Nguyen <juno.ngx@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#include "muse.h"
#ifdef AUDIO_ENABLE
# include "muse.h"
#endif
enum planck_layers {
_QWERTY,
@ -120,38 +139,32 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
#ifdef AUDIO_ENABLE
float plover_song[][2] = SONG(PLOVER_SOUND);
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
float plover_song[][2] = SONG(PLOVER_SOUND);
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
float caps_song_on[][2] = SONG(NUM_LOCK_ON_SOUND);
float caps_song_off[][2] = SONG(SCROLL_LOCK_ON_SOUND);
float caps_song_on[][2] = SONG(NUM_LOCK_ON_SOUND);
float caps_song_off[][2] = SONG(SCROLL_LOCK_ON_SOUND);
// Custom songs for DPAD layer status
float dpad_song_on[][2] = {
// Custom songs for DPAD layer status
float dpad_song_on[][2] = {
HD_NOTE(_A4), HD_NOTE(_A4), HD_NOTE(_A4),
QD_NOTE(_F4), QD_NOTE(_C5), HD_NOTE(_A4),
QD_NOTE(_F4), QD_NOTE(_C5), WD_NOTE(_A4)
};
};
float dpad_song_off[][2] = {
float dpad_song_off[][2] = {
ED_NOTE(_C6), ED_NOTE(_C6),
ED_NOTE(_C6), ED_NOTE(_C6),
W__NOTE(_REST), QD_NOTE(_GS5),
QD_NOTE(_AS5), Q__NOTE(_C6),
Q__NOTE(_AS5), Q__NOTE(_C6)
};
};
#endif
#ifndef BACKLIGHT_ENABLE
layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}
#else
layer_state_t layer_state_set_user(layer_state_t state) {
// LED control, lighting up when Fn layer is activated
state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
# ifdef BACKLIGHT_ENABLE
// LED control, lighting up when Fn layer is activated
switch (get_highest_layer(state)) {
case _QWERTY:
backlight_set(0);
@ -163,11 +176,11 @@ layer_state_t layer_state_set_user(layer_state_t state) {
backlight_set(3);
break;
}
# endif
return state;
}
#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case QWERTY:
@ -192,26 +205,26 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case BACKLIT:
if (record->event.pressed) {
register_code(KC_RSFT);
#ifdef BACKLIGHT_ENABLE
# ifdef BACKLIGHT_ENABLE
backlight_step();
#endif
#ifdef KEYBOARD_planck_rev5
# endif
# ifdef KEYBOARD_planck_rev5
writePinLow(E6);
#endif
# endif
} else {
unregister_code(KC_RSFT);
#ifdef KEYBOARD_planck_rev5
# ifdef KEYBOARD_planck_rev5
writePinHigh(E6);
#endif
# endif
}
return false;
break;
case PLOVER:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
stop_all_notes();
PLAY_SONG(plover_song);
#endif
# endif
layer_off(_RAISE);
layer_off(_LOWER);
layer_off(_ADJUST);
@ -227,34 +240,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
case EXT_PLV:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
PLAY_SONG(plover_gb_song);
#endif
# endif
layer_off(_PLOVER);
}
return false;
break;
// Play audio upon switching Caps Lock and custom layers
case KC_CAPS:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
if (host_keyboard_led_state().caps_lock) {
PLAY_SONG(caps_song_off);
} else {
PLAY_SONG(caps_song_on);
}
#endif
# endif
}
return true;
case DP_ON:
if (record->event.pressed) {
} else { // only actived upon key release
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
PLAY_SONG(dpad_song_on);
#endif
# endif
layer_off(_FN1);
layer_on(_DPAD);
@ -262,9 +274,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case DP_OFF:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
PLAY_SONG(dpad_song_off);
#endif
# endif
layer_off(_DPAD);
}
@ -307,14 +319,14 @@ bool dip_switch_update_user(uint8_t index, bool active) {
switch (index) {
case 0:
if (active) {
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
PLAY_SONG(plover_song);
#endif
# endif
layer_on(_ADJUST);
} else {
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
PLAY_SONG(plover_gb_song);
#endif
# endif
layer_off(_ADJUST);
}
break;
@ -323,9 +335,9 @@ bool dip_switch_update_user(uint8_t index, bool active) {
muse_mode = true;
} else {
muse_mode = false;
#ifdef AUDIO_ENABLE
# ifdef AUDIO_ENABLE
stop_all_notes();
#endif
# endif
}
}
return true;
@ -356,3 +368,12 @@ bool music_mask_user(uint16_t keycode) {
return true;
}
}
#ifdef RGBLIGHT_ENABLE
void keyboard_post_init_user(void) {
rgblight_enable_noeeprom(); // Enables RGB, without saving settings
// Vibrant cyan
rgblight_sethsv_noeeprom(HSV_SPRINGGREEN);
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
}
#endif

View File

@ -1,4 +1,6 @@
SRC += muse.c
ifeq ($(strip $(AUDIO_ENABLE)), yes)
SRC += muse.c
endif
ifeq ($(strip $(KEYBOARD)),$(filter $(strip $(KEYBOARD)), planck/rev2 planck/rev3 planck/rev4 planck/rev5))
BACKLIGHT_ENABLE = yes