summaryrefslogtreecommitdiff
path: root/quantum/keycode_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/keycode_config.c')
-rw-r--r--quantum/keycode_config.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c
index 0dc5105d21..f340905eab 100644
--- a/quantum/keycode_config.c
+++ b/quantum/keycode_config.c
@@ -18,8 +18,12 @@
extern keymap_config_t keymap_config;
+/** \brief keycode_config
+ *
+ * This function is used to check a specific keycode against the bootmagic config,
+ * and will return the corrected keycode, when appropriate.
+ */
uint16_t keycode_config(uint16_t keycode) {
-
switch (keycode) {
case KC_CAPSLOCK:
case KC_LOCKING_CAPS:
@@ -31,6 +35,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 +54,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 +81,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;
}
@@ -89,6 +113,12 @@ uint16_t keycode_config(uint16_t keycode) {
}
}
+/** \brief mod_config
+ *
+ * This function checks the mods passed to it against the bootmagic config,
+ * and will remove or replace mods, based on that.
+ */
+
uint8_t mod_config(uint8_t mod) {
if (keymap_config.swap_lalt_lgui) {
if ((mod & MOD_RGUI) == MOD_LGUI) {
@@ -108,6 +138,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;