summaryrefslogtreecommitdiff
path: root/keyboards/mechwild/mercutio
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-09-28 19:24:40 +0000
committerQMK Bot <hello@qmk.fm>2021-09-28 19:24:40 +0000
commitbc41d37bafefc098d36eabafdc8f4c23af188c34 (patch)
treebf08da39937c9cd1f0d018c2c7c87fda521f9bc4 /keyboards/mechwild/mercutio
parentf89620d7af11f4f7e155ae7f015281d2526bbe46 (diff)
parent705cd433c22aad00b12183eaa3bada50d90fd97b (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/mechwild/mercutio')
-rwxr-xr-xkeyboards/mechwild/mercutio/keymaps/jonavin/keymap.c75
1 files changed, 30 insertions, 45 deletions
diff --git a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
index 74811cbc35..22d26db3c2 100755
--- a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
+++ b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
@@ -106,63 +106,48 @@ 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);
+ if (!mods_state) {
+ encoder_action_selectkey(clockwise);
break;
} else {
// continue to default
}
default: // all other layers
- if ( clockwise ) {
- if (keyboard_report->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
- 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);
- } else {
- tap_code(KC_VOLU); // Otherwise it just changes volume
- }
- } else if ( !clockwise ) {
- if (keyboard_report->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
- 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);
- }
+ if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
+ encoder_action_layerchange(clockwise);
+ } 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 {
+ encoder_action_volume(clockwise); // Otherwise it just changes volume
}
break;
}
@@ -205,7 +190,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
void oled_task_user(void) {
- if ( IS_HOST_LED_OFF(USB_LED_NUM_LOCK) && IS_HOST_LED_OFF(USB_LED_CAPS_LOCK) && selected_layer == 0 && get_highest_layer(layer_state) == 0 ) {
+ if ( IS_HOST_LED_OFF(USB_LED_NUM_LOCK) && IS_HOST_LED_OFF(USB_LED_CAPS_LOCK) && get_selected_layer() == 0 && get_highest_layer(layer_state) == 0 ) {
render_name();
clear_screen = true;
} else {
@@ -217,7 +202,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
render_logo();
oled_set_cursor(8,2);
char fn_str[12];
- switch(selected_layer){
+ switch(get_selected_layer()){
case 0:
oled_write_P(PSTR("BASE"), false);
break;
@@ -237,7 +222,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)) {