Skip to content

Instantly share code, notes, and snippets.

@drashna
Created July 15, 2024 23:05
Show Gist options
  • Save drashna/63dfef52c8f4cc2e82d7e19474c7098d to your computer and use it in GitHub Desktop.
Save drashna/63dfef52c8f4cc2e82d7e19474c7098d to your computer and use it in GitHub Desktop.
os configed replacements
uint16_t keycode_config(uint16_t keycode) {
switch (keycode) {
case KC_CAPS_LOCK:
case KC_LOCKING_CAPS_LOCK:
if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
return KC_LEFT_CTRL;
} else if (keymap_config.swap_escape_capslock) {
return KC_ESCAPE;
}
return keycode;
case KC_LEFT_CTRL:
if (keymap_config.swap_control_capslock) {
return KC_CAPS_LOCK;
}
if (keymap_config.swap_lctl_lgui) {
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_LEFT_GUI;
}
return KC_LEFT_CTRL;
case KC_LEFT_ALT:
if (keymap_config.swap_lalt_lgui) {
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_LEFT_GUI;
}
return KC_LEFT_ALT;
case KC_LEFT_GUI:
if (keymap_config.swap_lalt_lgui) {
return KC_LEFT_ALT;
}
if (keymap_config.swap_lctl_lgui) {
return KC_LEFT_CTRL;
}
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_LEFT_GUI;
case KC_RIGHT_CTRL:
if (keymap_config.swap_rctl_rgui) {
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_RIGHT_GUI;
}
return KC_RIGHT_CTRL;
case KC_RIGHT_ALT:
if (keymap_config.swap_ralt_rgui) {
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_RIGHT_GUI;
}
return KC_RIGHT_ALT;
case KC_RIGHT_GUI:
if (keymap_config.swap_ralt_rgui) {
return KC_RIGHT_ALT;
}
if (keymap_config.swap_rctl_rgui) {
return KC_RIGHT_CTRL;
}
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_RIGHT_GUI;
case KC_GRAVE:
if (keymap_config.swap_grave_esc) {
return KC_ESCAPE;
}
return KC_GRAVE;
case KC_ESCAPE:
if (keymap_config.swap_grave_esc) {
return KC_GRAVE;
} else if (keymap_config.swap_escape_capslock) {
return KC_CAPS_LOCK;
}
return KC_ESCAPE;
case KC_BACKSLASH:
if (keymap_config.swap_backslash_backspace) {
return KC_BACKSPACE;
#ifdef OS_DETECTION_ENABLE
} else if (detected_host_os() == HOST_OS_MACOS || detected_host_os() == HOST_OS_IOS) {
return KC_SLASH;
#endif
}
return KC_BACKSLASH;
#ifdef OS_DETECTION_ENABLE
case KC_SLASH:
if (detected_host_os() == OS_MACOS || detected_host_os() == OS_IOS) {
return KC_BACKSLASH;
}
return KC_SLASH;
#endif
case KC_BACKSPACE:
if (keymap_config.swap_backslash_backspace) {
return KC_BACKSLASH;
}
return KC_BACKSPACE;
default:
return keycode;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment