summary refs log tree commit diff
path: root/users
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 /users
parentf89620d7af11f4f7e155ae7f015281d2526bbe46 (diff)
parent705cd433c22aad00b12183eaa3bada50d90fd97b (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users')
-rw-r--r--users/jonavin/jonavin.c129
-rw-r--r--users/jonavin/jonavin.h12
-rw-r--r--users/jonavin/readme.md3
3 files changed, 87 insertions, 57 deletions
diff --git a/users/jonavin/jonavin.c b/users/jonavin/jonavin.c
index bd6c55e9fe..6ecadc7b47 100644
--- a/users/jonavin/jonavin.c
+++ b/users/jonavin/jonavin.c
@@ -104,7 +104,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #endif // IDLE_TIMEOUT_ENABLE
 
 
-#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE)       // Encoder Functionality
+#ifdef ENCODER_ENABLE
     #ifndef DYNAMIC_KEYMAP_LAYER_COUNT
         #define DYNAMIC_KEYMAP_LAYER_COUNT 4  //default in case this is not already defined elsewhere
     #endif
@@ -112,67 +112,86 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
         #define ENCODER_DEFAULTACTIONS_INDEX 0  // can select encoder index if there are multiple encoders
     #endif
 
-uint8_t selected_layer = 0;
+    void encoder_action_volume(bool clockwise) {
+        if (clockwise)
+            tap_code(KC_VOLU);
+        else
+            tap_code(KC_VOLD);
+    }
 
-__attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; }
+    void encoder_action_mediatrack(bool clockwise) {
+        if (clockwise)
+            tap_code(KC_MEDIA_NEXT_TRACK);
+        else
+            tap_code(KC_MEDIA_PREV_TRACK);
+    }
 
-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(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
-                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
-                    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  {
-                switch (selected_layer) {
-                case _FN1:
-                    #ifdef IDLE_TIMEOUT_ENABLE
-                        timeout_update_threshold(true);
-                    #endif
-                    break;
-                default:
-                    tap_code(KC_VOLU);       // Otherwise it just changes volume
-                    break;
-                }
+    void encoder_action_navword(bool clockwise) {
+        if (clockwise)
+            tap_code16(LCTL(KC_RGHT));
+        else
+            tap_code16(LCTL(KC_LEFT));
+    }
+
+    void encoder_action_navpage(bool clockwise) {
+        if (clockwise)
+            tap_code16(KC_PGUP);
+        else
+            tap_code16(KC_PGDN);
+    }
+
+    // LAYER HANDLING
+    uint8_t selected_layer = 0;
+
+    uint8_t get_selected_layer(void) {
+        return selected_layer;
+    }
+
+    void encoder_action_layerchange(bool clockwise) {
+        if (clockwise) {
+            if(selected_layer  < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) {
+                selected_layer ++;
+                layer_move(selected_layer);
             }
         } else {
-            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_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
-                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 {
-                switch (selected_layer) {
-                case _FN1:
-                    #ifdef IDLE_TIMEOUT_ENABLE
-                        timeout_update_threshold(false);
-                    #endif
-                    break;
-                default:
-                    tap_code(KC_VOLD);
-                    break;
-                }
+            if (selected_layer  > 0) {
+                selected_layer --;
+                layer_move(selected_layer);
             }
         }
+    }
+#endif // ENCODER_ENABLE
+
+#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE)       // Encoder Functionality
 
+    __attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; }
+
+    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
+        uint8_t mods_state = get_mods();
+        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_RSFT) ) { // If you are holding R shift, Page up/dn
+            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  {
+            switch(get_highest_layer(layer_state)) {
+            case _FN1:
+                #ifdef IDLE_TIMEOUT_ENABLE
+                    timeout_update_threshold(clockwise);
+                #endif
+                break;
+            default:
+                encoder_action_volume(clockwise);       // Otherwise it just changes volume
+                break;
+            }
+        }
         return true;
     }
 #endif // ENCODER_ENABLE
diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h
index 5f467bc845..316483940a 100644
--- a/users/jonavin/jonavin.h
+++ b/users/jonavin/jonavin.h
@@ -58,6 +58,18 @@ enum custom_user_keycodes {
 #endif // TD_LSFT_CAPSLOCK_ENABLE
 
 
+// ENCODER ACTIONS
+#ifdef ENCODER_ENABLE
+    void encoder_action_volume(bool clockwise);
+    void encoder_action_mediatrack(bool clockwise);
+    void encoder_action_navword(bool clockwise);
+    void encoder_action_navpage(bool clockwise);
+
+    uint8_t get_selected_layer(void);
+    void encoder_action_layerchange(bool clockwise);
+#endif // ENCODER_ENABLE
+
+
 #ifdef RGB_MATRIX_ENABLE
 //RGB custom colours
     #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps
diff --git a/users/jonavin/readme.md b/users/jonavin/readme.md
index 97fff6520c..c029796b4e 100644
--- a/users/jonavin/readme.md
+++ b/users/jonavin/readme.md
@@ -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 (*)