aboutsummaryrefslogtreecommitdiff
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)
downloadqmk_firmware-bc41d37bafefc098d36eabafdc8f4c23af188c34.tar.gz
qmk_firmware-bc41d37bafefc098d36eabafdc8f4c23af188c34.zip
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 bd6c55e9f..6ecadc7b4 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/>.
104#endif // IDLE_TIMEOUT_ENABLE 104#endif // IDLE_TIMEOUT_ENABLE
105 105
106 106
107#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality 107#ifdef ENCODER_ENABLE
108 #ifndef DYNAMIC_KEYMAP_LAYER_COUNT 108 #ifndef DYNAMIC_KEYMAP_LAYER_COUNT
109 #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere 109 #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere
110 #endif 110 #endif
@@ -112,67 +112,86 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
112 #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders 112 #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders
113 #endif 113 #endif
114 114
115uint8_t selected_layer = 0; 115 void encoder_action_volume(bool clockwise) {
116 if (clockwise)
117 tap_code(KC_VOLU);
118 else
119 tap_code(KC_VOLD);
120 }
116 121
117__attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; } 122 void encoder_action_mediatrack(bool clockwise) {
123 if (clockwise)
124 tap_code(KC_MEDIA_NEXT_TRACK);
125 else
126 tap_code(KC_MEDIA_PREV_TRACK);
127 }
118 128
119bool encoder_update_user(uint8_t index, bool clockwise) { 129 void encoder_action_navword(bool clockwise) {
120 if (!encoder_update_keymap(index, clockwise)) { return false; } 130 if (clockwise)
121 if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match 131 tap_code16(LCTL(KC_RGHT));
122 if ( clockwise ) { 132 else
123 if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers 133 tap_code16(LCTL(KC_LEFT));
124 if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) { 134 }
125 selected_layer ++; 135
126 layer_move(selected_layer); 136 void encoder_action_navpage(bool clockwise) {
127 } 137 if (clockwise)
128 } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up 138 tap_code16(KC_PGUP);
129 unregister_mods(MOD_BIT(KC_RSFT)); 139 else
130 register_code(KC_PGDN); 140 tap_code16(KC_PGDN);
131 register_mods(MOD_BIT(KC_RSFT)); 141 }
132 } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word 142
133 tap_code16(LCTL(KC_RGHT)); 143 // LAYER HANDLING
134 } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track 144 uint8_t selected_layer = 0;
135 tap_code(KC_MEDIA_NEXT_TRACK); 145
136 } else { 146 uint8_t get_selected_layer(void) {
137 switch (selected_layer) { 147 return selected_layer;
138 case _FN1: 148 }
139 #ifdef IDLE_TIMEOUT_ENABLE 149
140 timeout_update_threshold(true); 150 void encoder_action_layerchange(bool clockwise) {
141 #endif 151 if (clockwise) {
142 break; 152 if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) {
143 default: 153 selected_layer ++;
144 tap_code(KC_VOLU); // Otherwise it just changes volume 154 layer_move(selected_layer);
145 break;
146 }
147 } 155 }
148 } else { 156 } else {
149 if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { 157 if (selected_layer > 0) {
150 if (selected_layer > 0) { 158 selected_layer --;
151 selected_layer --; 159 layer_move(selected_layer);
152 layer_move(selected_layer);
153 }
154 } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) {
155 unregister_mods(MOD_BIT(KC_RSFT));
156 register_code(KC_PGUP);
157 register_mods(MOD_BIT(KC_RSFT));
158 } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word
159 tap_code16(LCTL(KC_LEFT));
160 } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
161 tap_code(KC_MEDIA_PREV_TRACK);
162 } else {
163 switch (selected_layer) {
164 case _FN1:
165 #ifdef IDLE_TIMEOUT_ENABLE
166 timeout_update_threshold(false);
167 #endif
168 break;
169 default:
170 tap_code(KC_VOLD);
171 break;
172 }
173 } 160 }
174 } 161 }
162 }
163#endif // ENCODER_ENABLE
164
165#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality
175 166
167 __attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; }
168
169 bool encoder_update_user(uint8_t index, bool clockwise) {
170 if (!encoder_update_keymap(index, clockwise)) { return false; }
171 if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match
172 uint8_t mods_state = get_mods();
173 if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
174 encoder_action_layerchange(clockwise);
175 } else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up/dn
176 unregister_mods(MOD_BIT(KC_RSFT));
177 encoder_action_navpage(clockwise);
178 register_mods(MOD_BIT(KC_RSFT));
179 } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word
180 encoder_action_navword(clockwise);
181 } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track
182 encoder_action_mediatrack(clockwise);
183 } else {
184 switch(get_highest_layer(layer_state)) {
185 case _FN1:
186 #ifdef IDLE_TIMEOUT_ENABLE
187 timeout_update_threshold(clockwise);
188 #endif
189 break;
190 default:
191 encoder_action_volume(clockwise); // Otherwise it just changes volume
192 break;
193 }
194 }
176 return true; 195 return true;
177 } 196 }
178#endif // ENCODER_ENABLE 197#endif // ENCODER_ENABLE
diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h
index 5f467bc84..316483940 100644
--- a/users/jonavin/jonavin.h
+++ b/users/jonavin/jonavin.h
@@ -58,6 +58,18 @@ enum custom_user_keycodes {
58#endif // TD_LSFT_CAPSLOCK_ENABLE 58#endif // TD_LSFT_CAPSLOCK_ENABLE
59 59
60 60
61// ENCODER ACTIONS
62#ifdef ENCODER_ENABLE
63 void encoder_action_volume(bool clockwise);
64 void encoder_action_mediatrack(bool clockwise);
65 void encoder_action_navword(bool clockwise);
66 void encoder_action_navpage(bool clockwise);
67
68 uint8_t get_selected_layer(void);
69 void encoder_action_layerchange(bool clockwise);
70#endif // ENCODER_ENABLE
71
72
61#ifdef RGB_MATRIX_ENABLE 73#ifdef RGB_MATRIX_ENABLE
62//RGB custom colours 74//RGB custom colours
63 #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps 75 #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps
diff --git a/users/jonavin/readme.md b/users/jonavin/readme.md
index 97fff6520..c029796b4 100644
--- a/users/jonavin/readme.md
+++ b/users/jonavin/readme.md
@@ -65,11 +65,10 @@ KEYMAP LEVEL ADDITIONAL PROCESSING FUNCTIONS
65 void keyboard_post_init_keymap(void) 65 void keyboard_post_init_keymap(void)
66 66
67LIST OF COMPATIBLE KEYMAPS 67LIST OF COMPATIBLE KEYMAPS
68 - gmmk/pro
69 - gmmk/pro/ansi 68 - gmmk/pro/ansi
70 - keebio/quefrency/rev3 69 - keebio/quefrency/rev3
71 - mechwild/mercutio 70 - mechwild/mercutio
72 - mechwild/murphpad (*) 71 - mechwild/murphpad
73 - mechwild/OBE (*) 72 - mechwild/OBE (*)
74 - nopunin10did/kastenwagen (*) 73 - nopunin10did/kastenwagen (*)
75 74