X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Fkeymap_common.c;h=8f00f9cc32226ec1cff4acf986d64a168ae8ab2c;hb=35a72ca5e1abaf2eece7f61c17f94260ea1d16c7;hp=61a51aedb43e46cafaddb030870b7359a0add532;hpb=45f10b4c4b308226fa1568277654a13853a03ab4;p=qmk_firmware.git diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 61a51aedb..8f00f9cc3 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -24,8 +24,13 @@ along with this program. If not, see . #include "action_macro.h" #include "debug.h" #include "backlight.h" -#include "keymap_midi.h" #include "bootloader.h" +#include "eeconfig.h" + +#ifdef MIDI_ENABLE + #include "keymap_midi.h" +#endif + extern keymap_config_t keymap_config; @@ -33,20 +38,14 @@ extern keymap_config_t keymap_config; #include #ifdef AUDIO_ENABLE #include "audio.h" - - float goodbye[][2] = { - {440.0*pow(2.0,(31)/12.0), 8}, - {440.0*pow(2.0,(24)/12.0), 8}, - {440.0*pow(2.0,(19)/12.0), 12}, - }; -#endif +#endif /* AUDIO_ENABLE */ static action_t keycode_to_action(uint16_t keycode); /* converts key to action */ action_t action_for_key(uint8_t layer, keypos_t key) { - // 16bit keycodes - important + // 16bit keycodes - important uint16_t keycode = keymap_key_to_keycode(layer, key); switch (keycode) { @@ -189,7 +188,8 @@ static action_t keycode_to_action(uint16_t keycode) case RESET: ; // RESET is 0x5000, which is why this is here clear_keyboard(); #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(goodbye, false, 0); + stop_all_notes(); + play_goodbye_tone(); #endif _delay_ms(250); #ifdef ATREUS_ASTAR @@ -249,7 +249,7 @@ static action_t keycode_to_action(uint16_t keycode) keymap_config.swap_lalt_lgui = 0; keymap_config.swap_ralt_rgui = 0; } - eeconfig_write_keymap(keymap_config.raw); + eeconfig_update_keymap(keymap_config.raw); break; case 0x5100 ... 0x5FFF: ; // Layer movement shortcuts @@ -272,6 +272,14 @@ static action_t keycode_to_action(uint16_t keycode) // Set default layer int layer = keycode & 0xFF; action.code = ACTION_LAYER_TOGGLE(layer); + } else if (type == 0x5) { + // OSL(layer) - One-shot layer + int layer = keycode & 0xFF; + action.code = ACTION_LAYER_ONESHOT(layer); + } else if (type == 0x6) { + // OSM(mod) - One-shot mod + int mod = keycode & 0xFF; + action.code = ACTION_MODS_ONESHOT(mod); } break; #ifdef MIDI_ENABLE @@ -302,7 +310,7 @@ static action_t keycode_to_action(uint16_t keycode) /* translates key to keycode */ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { - // Read entire word (16bits) + // Read entire word (16bits) return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); } @@ -314,7 +322,7 @@ action_t keymap_fn_to_action(uint16_t keycode) action_t keymap_func_to_action(uint16_t keycode) { - // For FUNC without 8bit limit + // For FUNC without 8bit limit return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) }; }