1
0
Fork 0

Improve according to suggestion in PR

This commit is contained in:
Josef Adamcik 2020-05-01 16:37:07 +02:00
parent 3de4c3ea6a
commit 3d760caa85

View file

@ -257,43 +257,54 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case KC_PRVWD: case KC_PRVWD:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
register_code16(A(KC_LEFT)); register_mods(mod_config(MOD_LALT));
register_code(KC_LEFT);
} else { } else {
register_code16(C(KC_LEFT)); register_mods(mod_config(MOD_LCTL));
register_code(KC_LEFT);
} }
} else { } else {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
unregister_code16(A(KC_LEFT)); unregister_mods(mod_config(MOD_LALT));
unregister_code(KC_LEFT);
} else { } else {
unregister_code16(C(KC_LEFT)); unregister_mods(mod_config(MOD_LCTL));
unregister_code(KC_LEFT);
} }
} }
break; break;
case KC_NXTWD: case KC_NXTWD:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
register_code16(A(KC_RIGHT)); register_mods(mod_config(MOD_LALT));
register_code(KC_RIGHT);
} else { } else {
register_code16(C(KC_RIGHT)); register_mods(mod_config(MOD_LCTL));
register_code(KC_RIGHT);
} }
} else { } else {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
unregister_code16(A(KC_RIGHT)); unregister_mods(mod_config(MOD_LALT));
unregister_code(KC_RIGHT);
} else { } else {
unregister_code16(C(KC_RIGHT)); unregister_mods(mod_config(MOD_LCTL));
unregister_code(KC_RIGHT);
} }
} }
break; break;
case KC_LSTRT: case KC_LSTRT:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
register_code16(G(KC_LEFT)); //CMD-arrow on Mac, but we have CTL and GUI swapped
register_mods(mod_config(MOD_LCTL));
register_code(KC_LEFT);
} else { } else {
register_code(KC_HOME); register_code(KC_HOME);
} }
} else { } else {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_LEFT)); unregister_mods(mod_config(MOD_LCTL));
unregister_code(KC_LEFT);
} else { } else {
unregister_code(KC_HOME); unregister_code(KC_HOME);
} }
@ -302,13 +313,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case KC_LEND: case KC_LEND:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
register_code16(G(KC_RIGHT)); //CMD-arrow on Mac, but we have CTL and GUI swapped
register_mods(mod_config(MOD_LCTL));
register_code(KC_RIGHT);
} else { } else {
register_code(KC_END); register_code(KC_END);
} }
} else { } else {
if (keymap_config.swap_lctl_lgui) { if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_RIGHT)); unregister_mods(mod_config(MOD_LCTL));
unregister_code(KC_RIGHT);
} else { } else {
unregister_code(KC_END); unregister_code(KC_END);
} }
@ -316,80 +330,50 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break; break;
case KC_DLINE: case KC_DLINE:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { register_mods(mod_config(MOD_LCTL));
register_code16(G(KC_BSPC)); register_code(KC_BSPC);
} else { } else {
register_code16(C(KC_BSPC)); unregister_mods(mod_config(MOD_LCTL));
} unregister_code(KC_BSPC);
} else {
if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_BSPC));
} else {
unregister_code16(C(KC_BSPC));
}
} }
break; break;
case KC_COPY: case KC_COPY:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { register_mods(mod_config(MOD_LCTL));
register_code16(G(KC_C)); register_code(KC_C);
} else { } else {
register_code16(C(KC_C)); unregister_mods(mod_config(MOD_LCTL));
} unregister_code(KC_C);
} else {
if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_C));
} else {
unregister_code16(C(KC_C));
}
} }
return false; return false;
break; break;
case KC_PASTE: case KC_PASTE:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { register_mods(mod_config(MOD_LCTL));
register_code16(G(KC_V)); register_code(KC_V);
} else { } else {
register_code16(C(KC_V)); unregister_mods(mod_config(MOD_LCTL));
} unregister_code(KC_V);
} else {
if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_V));
} else {
unregister_code16(C(KC_V));
}
} }
return false; return false;
break; break;
case KC_CUT: case KC_CUT:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { register_mods(mod_config(MOD_LCTL));
register_code16(G(KC_X)); register_code(KC_X);
} else { } else {
register_code16(C(KC_X)); unregister_mods(mod_config(MOD_LCTL));
} unregister_code(KC_X);
} else {
if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_X));
} else {
unregister_code16(C(KC_X));
}
} }
return false; return false;
break; break;
case KC_UNDO: case KC_UNDO:
if (record->event.pressed) { if (record->event.pressed) {
if (keymap_config.swap_lctl_lgui) { register_mods(mod_config(MOD_LCTL));
register_code16(G(KC_Z)); register_code(KC_Z);
} else { } else {
register_code16(C(KC_Z)); unregister_mods(mod_config(MOD_LCTL));
} unregister_code(KC_Z);
} else {
if (keymap_config.swap_lctl_lgui) {
unregister_code16(G(KC_Z));
} else {
unregister_code16(C(KC_Z));
}
} }
return false; return false;
break; break;