[Keymap] fix NKRO - switch to get_mods() and refactor encoder action code (#14278)
Co-authored-by: Jonavin <=>
This commit is contained in:
parent
724ee24075
commit
705cd433c2
9 changed files with 213 additions and 190 deletions
|
@ -57,46 +57,31 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|||
};
|
||||
|
||||
#ifdef ENCODER_ENABLE // Encoder Functionality
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
switch (index)
|
||||
{
|
||||
case 0: // first encoder (Left Macro set)
|
||||
if (clockwise) {
|
||||
tap_code(KC_PGDN);
|
||||
} else {
|
||||
tap_code(KC_PGUP);
|
||||
}
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
uint8_t mods_state = get_mods();
|
||||
switch (index) {
|
||||
case 0: // first encoder (Left Macro set)
|
||||
encoder_action_navpage(clockwise);
|
||||
break;
|
||||
|
||||
default: // other encoder (Top right)
|
||||
if ( clockwise ) {
|
||||
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, Page up
|
||||
unregister_mods(MOD_BIT(KC_LSFT));
|
||||
register_code(KC_PGDN);
|
||||
register_mods(MOD_BIT(KC_LSFT));
|
||||
} else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word
|
||||
tap_code16(LCTL(KC_RGHT));
|
||||
} else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track
|
||||
tap_code(KC_MEDIA_NEXT_TRACK);
|
||||
default: // other encoder (Top right)
|
||||
if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding Left shift, change layers
|
||||
encoder_action_layerchange(clockwise);
|
||||
} else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding Right shift, Page up
|
||||
unregister_mods(MOD_BIT(KC_RSFT));
|
||||
encoder_action_navpage(clockwise);
|
||||
register_mods(MOD_BIT(KC_RSFT));
|
||||
} else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word
|
||||
encoder_action_navword(clockwise);
|
||||
} else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track
|
||||
encoder_action_mediatrack(clockwise);
|
||||
} else {
|
||||
tap_code(KC_VOLU); // Otherwise it just changes volume
|
||||
}
|
||||
} else {
|
||||
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) {
|
||||
unregister_mods(MOD_BIT(KC_LSFT));
|
||||
register_code(KC_PGUP);
|
||||
register_mods(MOD_BIT(KC_LSFT));
|
||||
} else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word
|
||||
tap_code16(LCTL(KC_LEFT));
|
||||
} else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
|
||||
tap_code(KC_MEDIA_PREV_TRACK);
|
||||
} else {
|
||||
tap_code(KC_VOLD);
|
||||
encoder_action_volume(clockwise); // Otherwise it just changes volume
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue