diff options
author | QMK Bot <hello@qmk.fm> | 2021-09-28 19:24:40 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-09-28 19:24:40 +0000 |
commit | bc41d37bafefc098d36eabafdc8f4c23af188c34 (patch) | |
tree | bf08da39937c9cd1f0d018c2c7c87fda521f9bc4 /keyboards/mechwild/murphpad | |
parent | f89620d7af11f4f7e155ae7f015281d2526bbe46 (diff) | |
parent | 705cd433c22aad00b12183eaa3bada50d90fd97b (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/mechwild/murphpad')
-rw-r--r-- | keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c | 89 |
1 files changed, 37 insertions, 52 deletions
diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c index 001abc5027..39e6ac87e4 100644 --- a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c @@ -144,67 +144,52 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { #ifdef ENCODER_ENABLE // Encoder Functionality - uint8_t selected_layer = 0; + void encoder_action_selectkey(bool clockwise) { + if ( clockwise ) { + if ( selectedkey_idx < MAX_KEYSELECTION-1) { + selectedkey_idx ++; + } else { + // do nothing + } + } else if ( !clockwise ) { + if ( selectedkey_idx > 0){ + selectedkey_idx --; + } else { + // do nothing + } + } + set_selectedkey(selectedkey_idx); + } bool encoder_update_user(uint8_t index, bool clockwise) { #ifdef OLED_ENABLE oled_clear(); oled_render(); #endif + uint8_t mods_state = get_mods(); switch (index) { 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 ( clockwise ) { - if ( selectedkey_idx < MAX_KEYSELECTION-1) { - selectedkey_idx ++; - } else { - // do nothing - } - } else if ( !clockwise ) { - if ( selectedkey_idx > 0){ - selectedkey_idx --; - } else { - // do nothing - } - } - set_selectedkey(selectedkey_idx); - break; - } else { - // continue to default - } - default: // all other layers - if ( clockwise ) { - if (keyboard_report->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 - tap_code16(LCTL(KC_RGHT)); - } else if (keyboard_report->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 (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 - tap_code16(LCTL(KC_LEFT)); - } else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media previous track - tap_code(KC_MEDIA_PREV_TRACK); - } else { - tap_code(KC_VOLD); - } - } + switch(get_highest_layer(layer_state)){ // special handling per layer + case _FN1: // on Fn layer select what the encoder does when pressed + if (!mods_state) { + encoder_action_selectkey(clockwise); break; + } else { + // continue to default + } + default: // all other layers + if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, encoder changes layers + encoder_action_layerchange(clockwise); + } else if (mods_state & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate next/prev word + encoder_action_navword(clockwise); + } else if (mods_state & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media next/prev track + encoder_action_mediatrack(clockwise); + } else { + encoder_action_volume(clockwise); // Otherwise it just changes volume } break; + } + break; } return true; } @@ -232,7 +217,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { render_logo(); oled_set_cursor(8,2); - switch(selected_layer){ + switch(get_selected_layer()){ case _BASE: oled_write_P(PSTR("BASE"), false); break; @@ -257,7 +242,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { } oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false); oled_set_cursor(8,3); - if (get_highest_layer(layer_state) == selected_layer) { + if (get_highest_layer(layer_state) == get_selected_layer()) { oled_write_P(PSTR(" "), false); } else { switch (get_highest_layer(layer_state)) { |