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

fix NKRO - switch to get_mods() and refactor encoder action code #14278

Merged
merged 19 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 6 additions & 6 deletions keyboards/keebio/quefrency/keymaps/jonavin/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,25 @@ bool encoder_update_user(uint8_t index, bool clockwise) {

default: // other encoder (Top right)
if ( clockwise ) {
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, Page up
if (get_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
} else if (get_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
} else if (get_mods() & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track
tap_code(KC_MEDIA_NEXT_TRACK);
} else {
tap_code(KC_VOLU); // Otherwise it just changes volume
}
} else {
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) {
if (get_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
} else if (get_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
} else if (get_mods() & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
tap_code(KC_MEDIA_PREV_TRACK);
} else {
tap_code(KC_VOLD);
Expand Down
14 changes: 7 additions & 7 deletions keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
case 0: // This is the only encoder right now, keeping for consistency
switch(get_highest_layer(layer_state)){ // special handling per layer
case _FN1: // on Fn layer select what the encoder does when pressed
if (!keyboard_report->mods) {
if (!get_mods()) {
if ( clockwise ) {
if ( selectedkey_idx < MAX_KEYSELECTION-1) {
selectedkey_idx ++;
Expand All @@ -138,27 +138,27 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
default: // all other layers
if ( clockwise ) {
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
if (get_mods() & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
if(selected_layer < 3) {
selected_layer ++;
layer_move(selected_layer);
}
} else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word
} else if (get_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
} else if (get_mods() & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track
tap_code(KC_MEDIA_NEXT_TRACK);
} else {
tap_code(KC_VOLU); // Otherwise it just changes volume
}
} else if ( !clockwise ) {
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) {
if (get_mods() & MOD_BIT(KC_LSFT) ) {
if (selected_layer > 0) {
selected_layer --;
layer_move(selected_layer);
}
} else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word
} else if (get_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
} else if (get_mods() & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
tap_code(KC_MEDIA_PREV_TRACK);
} else {
tap_code(KC_VOLD);
Expand Down
14 changes: 7 additions & 7 deletions keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
case 0: // This is the only encoder right now, keeping for consistency
switch(get_highest_layer(layer_state)){ // special handling per layer
case _FN1: // on Fn layer select what the encoder does when pressed
if (!keyboard_report->mods) {
if (!get_mods()) {
if ( clockwise ) {
if ( selectedkey_idx < MAX_KEYSELECTION-1) {
selectedkey_idx ++;
Expand All @@ -176,27 +176,27 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
default: // all other layers
if ( clockwise ) {
if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding Right Shift, encoder changes layers
if (get_mods() & MOD_BIT(KC_RSFT) ) { // If you are holding Right Shift, encoder changes layers
if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT-1)) {
selected_layer ++;
layer_move(selected_layer);
}
} else if (keyboard_report->mods & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate next word
} else if (get_mods() & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate next word
tap_code16(LCTL(KC_RGHT));
} else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media next track
} else if (get_mods() & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media next track
tap_code(KC_MEDIA_NEXT_TRACK);
} else {
tap_code(KC_VOLU); // Otherwise it just changes volume
}
} else if ( !clockwise ) {
if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) {
if (get_mods() & MOD_BIT(KC_RSFT) ) {
if (selected_layer > 0) {
selected_layer --;
layer_move(selected_layer);
}
} else if (keyboard_report->mods & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate previous word
} else if (get_mods() & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate previous word
tap_code16(LCTL(KC_LEFT));
} else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media previous track
} else if (get_mods() & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media previous track
tap_code(KC_MEDIA_PREV_TRACK);
} else {
tap_code(KC_VOLD);
Expand Down
16 changes: 8 additions & 8 deletions users/jonavin/jonavin.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
if (!encoder_update_keymap(index, clockwise)) { return false; }
if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match
if ( clockwise ) {
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
if (get_mods() & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) {
selected_layer ++;
layer_move(selected_layer);
}
} else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up
} else if (get_mods() & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up
unregister_mods(MOD_BIT(KC_RSFT));
register_code(KC_PGDN);
register_mods(MOD_BIT(KC_RSFT));
} else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word
} else if (get_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
} else if (get_mods() & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track
tap_code(KC_MEDIA_NEXT_TRACK);
} else {
switch (selected_layer) {
Expand All @@ -146,18 +146,18 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
}
}
} else {
if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) {
if (get_mods() & MOD_BIT(KC_LSFT) ) {
if (selected_layer > 0) {
selected_layer --;
layer_move(selected_layer);
}
} else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) {
} else if (get_mods() & MOD_BIT(KC_RSFT) ) {
unregister_mods(MOD_BIT(KC_RSFT));
register_code(KC_PGUP);
register_mods(MOD_BIT(KC_RSFT));
} else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word
} else if (get_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
} else if (get_mods() & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
tap_code(KC_MEDIA_PREV_TRACK);
} else {
switch (selected_layer) {
Expand Down
3 changes: 1 addition & 2 deletions users/jonavin/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ KEYMAP LEVEL ADDITIONAL PROCESSING FUNCTIONS
void keyboard_post_init_keymap(void)

LIST OF COMPATIBLE KEYMAPS
- gmmk/pro
- gmmk/pro/ansi
- keebio/quefrency/rev3
- mechwild/mercutio
- mechwild/murphpad (*)
- mechwild/murphpad
- mechwild/OBE (*)
- nopunin10did/kastenwagen (*)

Expand Down