[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 QMK_KEYBOARD_H
#include "muse.h"
#ifdef AUDIO_ENABLE
# include "muse.h"
#endif
enum planck_layers { enum planck_layers {
_QWERTY, _QWERTY,
@ -120,39 +139,33 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
float plover_song[][2] = SONG(PLOVER_SOUND); float plover_song[][2] = SONG(PLOVER_SOUND);
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND); float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
float caps_song_on[][2] = SONG(NUM_LOCK_ON_SOUND); float caps_song_on[][2] = SONG(NUM_LOCK_ON_SOUND);
float caps_song_off[][2] = SONG(SCROLL_LOCK_ON_SOUND); float caps_song_off[][2] = SONG(SCROLL_LOCK_ON_SOUND);
// Custom songs for DPAD layer status // Custom songs for DPAD layer status
float dpad_song_on[][2] = { float dpad_song_on[][2] = {
HD_NOTE(_A4), HD_NOTE(_A4), HD_NOTE(_A4), HD_NOTE(_A4), HD_NOTE(_A4), HD_NOTE(_A4),
QD_NOTE(_F4), QD_NOTE(_C5), HD_NOTE(_A4), QD_NOTE(_F4), QD_NOTE(_C5), HD_NOTE(_A4),
QD_NOTE(_F4), QD_NOTE(_C5), WD_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),
ED_NOTE(_C6), ED_NOTE(_C6), ED_NOTE(_C6), ED_NOTE(_C6),
W__NOTE(_REST), QD_NOTE(_GS5), W__NOTE(_REST), QD_NOTE(_GS5),
QD_NOTE(_AS5), Q__NOTE(_C6), QD_NOTE(_AS5), Q__NOTE(_C6),
Q__NOTE(_AS5), Q__NOTE(_C6) Q__NOTE(_AS5), Q__NOTE(_C6)
}; };
#endif #endif
#ifndef BACKLIGHT_ENABLE
layer_state_t layer_state_set_user(layer_state_t state) { 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); state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
switch (get_highest_layer(state)) { # ifdef BACKLIGHT_ENABLE
// LED control, lighting up when Fn layer is activated
switch (get_highest_layer(state)) {
case _QWERTY: case _QWERTY:
backlight_set(0); backlight_set(0);
break; break;
@ -162,112 +175,111 @@ layer_state_t layer_state_set_user(layer_state_t state) {
case _DPAD: case _DPAD:
backlight_set(3); backlight_set(3);
break; break;
} }
# endif
return state; return state;
} }
#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
case QWERTY: case QWERTY:
if (record->event.pressed) { if (record->event.pressed) {
print("mode just switched to qwerty and this is a huge string\n"); print("mode just switched to qwerty and this is a huge string\n");
set_single_persistent_default_layer(_QWERTY); set_single_persistent_default_layer(_QWERTY);
} }
return false; return false;
break; break;
case COLEMAK: case COLEMAK:
if (record->event.pressed) { if (record->event.pressed) {
set_single_persistent_default_layer(_COLEMAK); set_single_persistent_default_layer(_COLEMAK);
} }
return false; return false;
break; break;
case DVORAK: case DVORAK:
if (record->event.pressed) { if (record->event.pressed) {
set_single_persistent_default_layer(_DVORAK); set_single_persistent_default_layer(_DVORAK);
} }
return false; return false;
break; break;
case BACKLIT: case BACKLIT:
if (record->event.pressed) { if (record->event.pressed) {
register_code(KC_RSFT); register_code(KC_RSFT);
#ifdef BACKLIGHT_ENABLE # ifdef BACKLIGHT_ENABLE
backlight_step(); backlight_step();
#endif # endif
#ifdef KEYBOARD_planck_rev5 # ifdef KEYBOARD_planck_rev5
writePinLow(E6); writePinLow(E6);
#endif # endif
} else { } else {
unregister_code(KC_RSFT); unregister_code(KC_RSFT);
#ifdef KEYBOARD_planck_rev5 # ifdef KEYBOARD_planck_rev5
writePinHigh(E6); writePinHigh(E6);
#endif # endif
} }
return false; return false;
break; break;
case PLOVER: case PLOVER:
if (record->event.pressed) { if (record->event.pressed) {
#ifdef AUDIO_ENABLE # ifdef AUDIO_ENABLE
stop_all_notes(); stop_all_notes();
PLAY_SONG(plover_song); PLAY_SONG(plover_song);
#endif # endif
layer_off(_RAISE); layer_off(_RAISE);
layer_off(_LOWER); layer_off(_LOWER);
layer_off(_ADJUST); layer_off(_ADJUST);
layer_on(_PLOVER); layer_on(_PLOVER);
if (!eeconfig_is_enabled()) { if (!eeconfig_is_enabled()) {
eeconfig_init(); eeconfig_init();
}
keymap_config.raw = eeconfig_read_keymap();
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
} }
return false; keymap_config.raw = eeconfig_read_keymap();
break; keymap_config.nkro = 1;
case EXT_PLV: eeconfig_update_keymap(keymap_config.raw);
if (record->event.pressed) { }
#ifdef AUDIO_ENABLE return false;
break;
case EXT_PLV:
if (record->event.pressed) {
# ifdef AUDIO_ENABLE
PLAY_SONG(plover_gb_song); PLAY_SONG(plover_gb_song);
#endif # endif
layer_off(_PLOVER); layer_off(_PLOVER);
} }
return false; return false;
break; break;
// Play audio upon switching Caps Lock and custom layers // Play audio upon switching Caps Lock and custom layers
case KC_CAPS:
case KC_CAPS: if (record->event.pressed) {
if (record->event.pressed) { # ifdef AUDIO_ENABLE
#ifdef AUDIO_ENABLE
if (host_keyboard_led_state().caps_lock) { if (host_keyboard_led_state().caps_lock) {
PLAY_SONG(caps_song_off); PLAY_SONG(caps_song_off);
} else { } else {
PLAY_SONG(caps_song_on); PLAY_SONG(caps_song_on);
} }
#endif # endif
} }
return true; return true;
case DP_ON: case DP_ON:
if (record->event.pressed) { if (record->event.pressed) {
} else { // only actived upon key release } else { // only actived upon key release
#ifdef AUDIO_ENABLE # ifdef AUDIO_ENABLE
PLAY_SONG(dpad_song_on); PLAY_SONG(dpad_song_on);
#endif # endif
layer_off(_FN1); layer_off(_FN1);
layer_on(_DPAD); layer_on(_DPAD);
} }
case DP_OFF: case DP_OFF:
if (record->event.pressed) { if (record->event.pressed) {
#ifdef AUDIO_ENABLE # ifdef AUDIO_ENABLE
PLAY_SONG(dpad_song_off); PLAY_SONG(dpad_song_off);
#endif # endif
layer_off(_DPAD); layer_off(_DPAD);
} }
} }
return true; return true;
} }
@ -305,28 +317,28 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
bool dip_switch_update_user(uint8_t index, bool active) { bool dip_switch_update_user(uint8_t index, bool active) {
switch (index) { switch (index) {
case 0: case 0:
if (active) { if (active) {
#ifdef AUDIO_ENABLE # ifdef AUDIO_ENABLE
PLAY_SONG(plover_song); PLAY_SONG(plover_song);
#endif # endif
layer_on(_ADJUST); layer_on(_ADJUST);
} else { } else {
#ifdef AUDIO_ENABLE # ifdef AUDIO_ENABLE
PLAY_SONG(plover_gb_song); PLAY_SONG(plover_gb_song);
#endif # endif
layer_off(_ADJUST); layer_off(_ADJUST);
} }
break; break;
case 1: case 1:
if (active) { if (active) {
muse_mode = true; muse_mode = true;
} else { } else {
muse_mode = false; muse_mode = false;
#ifdef AUDIO_ENABLE # ifdef AUDIO_ENABLE
stop_all_notes(); stop_all_notes();
#endif # endif
} }
} }
return true; return true;
} }
@ -349,10 +361,19 @@ void matrix_scan_user(void) {
bool music_mask_user(uint16_t keycode) { bool music_mask_user(uint16_t keycode) {
switch (keycode) { switch (keycode) {
case RAISE: case RAISE:
case LOWER: case LOWER:
return false; return false;
default: default:
return true; 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,13 +1,15 @@
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)) ifeq ($(strip $(KEYBOARD)),$(filter $(strip $(KEYBOARD)), planck/rev2 planck/rev3 planck/rev4 planck/rev5))
BACKLIGHT_ENABLE = yes BACKLIGHT_ENABLE = yes
else else
BACKLIGHT_ENABLE = no BACKLIGHT_ENABLE = no
endif endif
ifeq ($(strip $(KEYBOARD)), vitamins_included/rev1) ifeq ($(strip $(KEYBOARD)), vitamins_included/rev1)
NKRO_ENABLE = no NKRO_ENABLE = no
endif endif
MIDI_ENABLE=no MIDI_ENABLE=no