Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added keycodes for swapping and unswapping the Control and OS keys #6110

Merged
merged 17 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ This is a reference only. Each group of keys links to the page documenting their
|----------------------------------|---------|------------------------------------|
|`MAGIC_SWAP_CONTROL_CAPSLOCK` | |Swap Caps Lock and Left Control |
|`MAGIC_CAPSLOCK_TO_CONTROL` | |Treat Caps Lock as Control |
|`MAGIC_SWAP_LCTL_LGUI` | |Swap Left Control and GUI |
|`MAGIC_SWAP_RCTL_RGUI` | |Swap Right Control and GUI |
|`MAGIC_SWAP_LALT_LGUI` | |Swap Left Alt and GUI |
|`MAGIC_SWAP_RALT_RGUI` | |Swap Right Alt and GUI |
|`MAGIC_NO_GUI` | |Disable the GUI key |
Expand All @@ -265,6 +267,8 @@ This is a reference only. Each group of keys links to the page documenting their
|`MAGIC_SWAP_ALT_GUI` |`AG_SWAP`|Swap Alt and GUI on both sides |
|`MAGIC_UNSWAP_CONTROL_CAPSLOCK` | |Unswap Caps Lock and Left Control |
|`MAGIC_UNCAPSLOCK_TO_CONTROL` | |Stop treating Caps Lock as Control |
|`MAGIC_UNSWAP_LCTL_LGUI` | |Unswap Left Control and GUI |
|`MAGIC_UNSWAP_RCTL_RGUI` | |Unswap Right Control and GUI |
|`MAGIC_UNSWAP_LALT_LGUI` | |Unswap Left Alt and GUI |
|`MAGIC_UNSWAP_RALT_RGUI` | |Unswap Right Alt and GUI |
|`MAGIC_UNNO_GUI` | |Enable the GUI key |
Expand Down
20 changes: 20 additions & 0 deletions quantum/keycode_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions quantum/keycode_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 12 additions & 0 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,12 @@ bool process_record_quantum(keyrecord_t *record) {
case MAGIC_CAPSLOCK_TO_CONTROL:
keymap_config.capslock_to_control = 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_SWAP_LALT_LGUI:
keymap_config.swap_lalt_lgui = true;
break;
Expand Down Expand Up @@ -649,6 +655,12 @@ bool process_record_quantum(keyrecord_t *record) {
case MAGIC_UNCAPSLOCK_TO_CONTROL:
keymap_config.capslock_to_control = 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_UNSWAP_LALT_LGUI:
keymap_config.swap_lalt_lgui = false;
break;
Expand Down
5 changes: 5 additions & 0 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ enum quantum_keycodes {
HPT_DWLI,
HPT_DWLD,

MAGIC_SWAP_LCTL_LGUI,
MAGIC_SWAP_RCTL_RGUI,
MAGIC_UNSWAP_LCTL_LGUI,
MAGIC_UNSWAP_RCTL_RGUI,

// always leave at the end
SAFE_RANGE
};
Expand Down
2 changes: 2 additions & 0 deletions tmk_core/common/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ static void print_eeconfig(void)
print("keymap_config.raw: "); print_hex8(kc.raw); print("\n");
print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n");
print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n");
print(".swap_lctl_lgui: "); print_dec(kc.swap_lctl_lgui); print("\n");
print(".swap_rctl_rgui: "); print_dec(kc.swap_rctl_rgui); print("\n");
print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n");
print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n");
print(".no_gui: "); print_dec(kc.no_gui); print("\n");
Expand Down