diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/keycode_config.c | 38 | ||||
-rw-r--r-- | quantum/keycode_config.h | 2 | ||||
-rw-r--r-- | quantum/quantum.c | 48 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 13 |
4 files changed, 100 insertions, 1 deletions
diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c index 0dc5105d21..73fe15861d 100644 --- a/quantum/keycode_config.c +++ b/quantum/keycode_config.c @@ -31,6 +31,12 @@ uint16_t keycode_config(uint16_t keycode) { if (keymap_config.swap_control_capslock) { return KC_CAPSLOCK; } + if (keymap_config.swap_lctl_lgui) { + if (keymap_config.no_gui) { + return KC_NO; + } + return KC_LGUI; + } return KC_LCTL; case KC_LALT: if (keymap_config.swap_lalt_lgui) { @@ -44,10 +50,21 @@ uint16_t keycode_config(uint16_t keycode) { if (keymap_config.swap_lalt_lgui) { return KC_LALT; } + if (keymap_config.swap_lctl_lgui) { + return KC_LCTRL; + } if (keymap_config.no_gui) { return KC_NO; } return KC_LGUI; + case KC_RCTL: + if (keymap_config.swap_rctl_rgui) { + if (keymap_config.no_gui) { + return KC_NO; + } + return KC_RGUI; + } + return KC_RCTL; case KC_RALT: if (keymap_config.swap_ralt_rgui) { if (keymap_config.no_gui) { @@ -60,6 +77,9 @@ uint16_t keycode_config(uint16_t keycode) { if (keymap_config.swap_ralt_rgui) { return KC_RALT; } + if (keymap_config.swap_rctl_rgui) { + return KC_RCTL; + } if (keymap_config.no_gui) { return KC_NO; } @@ -108,6 +128,24 @@ uint8_t mod_config(uint8_t mod) { mod |= MOD_RGUI; } } + if (keymap_config.swap_lctl_lgui) { + if ((mod & MOD_RGUI) == MOD_LGUI) { + mod &= ~MOD_LGUI; + mod |= MOD_LCTL; + } else if ((mod & MOD_RCTL) == MOD_LCTL) { + mod &= ~MOD_LCTL; + mod |= MOD_LGUI; + } + } + if (keymap_config.swap_rctl_rgui) { + if ((mod & MOD_RGUI) == MOD_RGUI) { + mod &= ~MOD_RGUI; + mod |= MOD_RCTL; + } else if ((mod & MOD_RCTL) == MOD_RCTL) { + mod &= ~MOD_RCTL; + mod |= MOD_RGUI; + } + } if (keymap_config.no_gui) { mod &= ~MOD_LGUI; mod &= ~MOD_RGUI; diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index 022f4bd19b..7b01fcea45 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -36,6 +36,8 @@ typedef union { bool swap_grave_esc:1; bool swap_backslash_backspace:1; bool nkro:1; + bool swap_lctl_lgui:1; + bool swap_rctl_rgui:1; }; } keymap_config_t; diff --git a/quantum/quantum.c b/quantum/quantum.c index 77cbbb2e77..f489c90310 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -65,9 +65,17 @@ extern backlight_config_t backlight_config; #ifndef AG_SWAP_SONG #define AG_SWAP_SONG SONG(AG_SWAP_SOUND) #endif + #ifndef CG_NORM_SONG + #define CG_NORM_SONG SONG(AG_NORM_SOUND) + #endif + #ifndef CG_SWAP_SONG + #define CG_SWAP_SONG SONG(AG_SWAP_SOUND) + #endif float goodbye_song[][2] = GOODBYE_SONG; float ag_norm_song[][2] = AG_NORM_SONG; float ag_swap_song[][2] = AG_SWAP_SONG; + float cg_norm_song[][2] = CG_NORM_SONG; + float cg_swap_song[][2] = CG_SWAP_SONG; #ifdef DEFAULT_LAYER_SONGS float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; #endif @@ -563,7 +571,8 @@ bool process_record_quantum(keyrecord_t *record) { return false; #endif #endif - case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: + case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI: + case MAGIC_SWAP_LCTL_LGUI ... MAGIC_TOGGLE_CTL_GUI: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { @@ -585,6 +594,12 @@ bool process_record_quantum(keyrecord_t *record) { case MAGIC_SWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = true; break; + case MAGIC_SWAP_LCTL_LGUI: + keymap_config.swap_lctl_lgui = true; + break; + case MAGIC_SWAP_RCTL_RGUI: + keymap_config.swap_rctl_rgui = true; + break; case MAGIC_NO_GUI: keymap_config.no_gui = true; break; @@ -604,6 +619,13 @@ bool process_record_quantum(keyrecord_t *record) { PLAY_SONG(ag_swap_song); #endif break; + case MAGIC_SWAP_CTL_GUI: + keymap_config.swap_lctl_lgui = true; + keymap_config.swap_rctl_rgui = true; + #ifdef AUDIO_ENABLE + PLAY_SONG(cg_swap_song); + #endif + break; case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; break; @@ -616,6 +638,12 @@ bool process_record_quantum(keyrecord_t *record) { case MAGIC_UNSWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = false; break; + case MAGIC_UNSWAP_LCTL_LGUI: + keymap_config.swap_lctl_lgui = false; + break; + case MAGIC_UNSWAP_RCTL_RGUI: + keymap_config.swap_rctl_rgui = false; + break; case MAGIC_UNNO_GUI: keymap_config.no_gui = false; break; @@ -635,6 +663,13 @@ bool process_record_quantum(keyrecord_t *record) { PLAY_SONG(ag_norm_song); #endif break; + case MAGIC_UNSWAP_CTL_GUI: + keymap_config.swap_lctl_lgui = false; + keymap_config.swap_rctl_rgui = false; + #ifdef AUDIO_ENABLE + PLAY_SONG(cg_norm_song); + #endif + break; case MAGIC_TOGGLE_ALT_GUI: keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; @@ -646,6 +681,17 @@ bool process_record_quantum(keyrecord_t *record) { } #endif break; + case MAGIC_TOGGLE_CTL_GUI: + keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; + keymap_config.swap_rctl_rgui = !keymap_config.swap_rctl_rgui; + #ifdef AUDIO_ENABLE + if (keymap_config.swap_rctl_rgui) { + PLAY_SONG(cg_swap_song); + } else { + PLAY_SONG(cg_norm_song); + } + #endif + break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; break; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index b5c6783e5e..bb16da4d50 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -492,6 +492,15 @@ enum quantum_keycodes { CMB_ON, CMB_OFF, CMB_TOG, + + MAGIC_SWAP_LCTL_LGUI, + MAGIC_SWAP_RCTL_RGUI, + MAGIC_UNSWAP_LCTL_LGUI, + MAGIC_UNSWAP_RCTL_RGUI, + MAGIC_SWAP_CTL_GUI, + MAGIC_UNSWAP_CTL_GUI, + MAGIC_TOGGLE_CTL_GUI, + // always leave at the end SAFE_RANGE }; @@ -639,6 +648,10 @@ enum quantum_keycodes { #define AG_NORM MAGIC_UNSWAP_ALT_GUI #define AG_TOGG MAGIC_TOGGLE_ALT_GUI +#define CG_SWAP MAGIC_SWAP_CTL_GUI +#define CG_NORM MAGIC_UNSWAP_CTL_GUI +#define CG_TOGG MAGIC_TOGGLE_CTL_GUI + // GOTO layer - 16 layers max // when: // ON_PRESS = 1 |