diff options
Diffstat (limited to 'users/jonavin/jonavin.c')
-rw-r--r-- | users/jonavin/jonavin.c | 177 |
1 files changed, 17 insertions, 160 deletions
diff --git a/users/jonavin/jonavin.c b/users/jonavin/jonavin.c index 367601dfb..b66b444f3 100644 --- a/users/jonavin/jonavin.c +++ b/users/jonavin/jonavin.c | |||
@@ -95,171 +95,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
95 | } // timeout_threshold = 0 will disable timeout | 95 | } // timeout_threshold = 0 will disable timeout |
96 | } | 96 | } |
97 | 97 | ||
98 | #endif // IDLE_TIMEOUT_ENABLE | ||
99 | |||
100 | #if defined(ALTTAB_SCROLL_ENABLE) || defined(IDLE_TIMEOUT_ENABLE) // timer features | ||
98 | __attribute__((weak)) void matrix_scan_keymap(void) {} | 101 | __attribute__((weak)) void matrix_scan_keymap(void) {} |
99 | 102 | ||
100 | void matrix_scan_user(void) { | 103 | void matrix_scan_user(void) { |
101 | timeout_tick_timer(); | 104 | #ifdef ALTTAB_SCROLL_ENABLE |
105 | encoder_tick_alttabscroll(); | ||
106 | #endif | ||
107 | #ifdef IDLE_TIMEOUT_ENABLE | ||
108 | timeout_tick_timer(); | ||
109 | #endif | ||
102 | matrix_scan_keymap(); | 110 | matrix_scan_keymap(); |
103 | } | 111 | } |
104 | #endif // IDLE_TIMEOUT_ENABLE | 112 | #endif // ALTTAB_SCROLL_ENABLE or IDLE_TIMEOUT_ENABLE |
105 | |||
106 | |||
107 | #ifdef ENCODER_ENABLE | ||
108 | #ifndef DYNAMIC_KEYMAP_LAYER_COUNT | ||
109 | #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere | ||
110 | #endif | ||
111 | #ifndef ENCODER_DEFAULTACTIONS_INDEX | ||
112 | #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders | ||
113 | #endif | ||
114 | |||
115 | void encoder_action_volume(bool clockwise) { | ||
116 | if (clockwise) | ||
117 | tap_code(KC_VOLU); | ||
118 | else | ||
119 | tap_code(KC_VOLD); | ||
120 | } | ||
121 | |||
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 | } | ||
128 | |||
129 | void encoder_action_navword(bool clockwise) { | ||
130 | if (clockwise) | ||
131 | tap_code16(LCTL(KC_RGHT)); | ||
132 | else | ||
133 | tap_code16(LCTL(KC_LEFT)); | ||
134 | } | ||
135 | |||
136 | void encoder_action_navpage(bool clockwise) { | ||
137 | if (clockwise) | ||
138 | tap_code16(KC_PGUP); | ||
139 | else | ||
140 | tap_code16(KC_PGDN); | ||
141 | } | ||
142 | |||
143 | // LAYER HANDLING | ||
144 | uint8_t selected_layer = 0; | ||
145 | |||
146 | uint8_t get_selected_layer(void) { | ||
147 | return selected_layer; | ||
148 | } | ||
149 | |||
150 | void encoder_action_layerchange(bool clockwise) { | ||
151 | if (clockwise) { | ||
152 | if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) { | ||
153 | selected_layer ++; | ||
154 | layer_move(selected_layer); | ||
155 | } | ||
156 | } else { | ||
157 | if (selected_layer > 0) { | ||
158 | selected_layer --; | ||
159 | layer_move(selected_layer); | ||
160 | } | ||
161 | } | ||
162 | } | ||
163 | |||
164 | #ifdef RGB_MATRIX_ENABLE | ||
165 | void encoder_action_rgb_speed(bool clockwise) { | ||
166 | if (clockwise) | ||
167 | rgb_matrix_increase_speed_noeeprom(); | ||
168 | else | ||
169 | rgb_matrix_decrease_speed_noeeprom(); | ||
170 | } | ||
171 | void encoder_action_rgb_hue(bool clockwise) { | ||
172 | if (clockwise) | ||
173 | rgb_matrix_increase_hue_noeeprom(); | ||
174 | else | ||
175 | rgb_matrix_decrease_hue_noeeprom(); | ||
176 | } | ||
177 | void encoder_action_rgb_saturation(bool clockwise) { | ||
178 | if (clockwise) | ||
179 | rgb_matrix_increase_sat_noeeprom(); | ||
180 | else | ||
181 | rgb_matrix_decrease_sat_noeeprom(); | ||
182 | } | ||
183 | void encoder_action_rgb_brightness(bool clockwise) { | ||
184 | if (clockwise) | ||
185 | rgb_matrix_increase_val_noeeprom(); | ||
186 | else | ||
187 | rgb_matrix_decrease_val_noeeprom(); | ||
188 | } | ||
189 | void encoder_action_rgb_mode(bool clockwise) { | ||
190 | if (clockwise) | ||
191 | rgb_matrix_step_noeeprom(); | ||
192 | else | ||
193 | rgb_matrix_step_reverse_noeeprom(); | ||
194 | } | ||
195 | #elif defined(RGBLIGHT_ENABLE) | ||
196 | void encoder_action_rgb_speed(bool clockwise) { | ||
197 | if (clockwise) | ||
198 | rgblight_increase_speed_noeeprom(); | ||
199 | else | ||
200 | rgblight_decrease_speed_noeeprom(); | ||
201 | } | ||
202 | void encoder_action_rgb_hue(bool clockwise) { | ||
203 | if (clockwise) | ||
204 | rgblight_increase_hue_noeeprom(); | ||
205 | else | ||
206 | rgblight_decrease_hue_noeeprom(); | ||
207 | } | ||
208 | void encoder_action_rgb_saturation(bool clockwise) { | ||
209 | if (clockwise) | ||
210 | rgblight_increase_sat_noeeprom(); | ||
211 | else | ||
212 | rgblight_decrease_sat_noeeprom(); | ||
213 | } | ||
214 | void encoder_action_rgb_brightness(bool clockwise) { | ||
215 | if (clockwise) | ||
216 | rgblight_increase_val_noeeprom(); | ||
217 | else | ||
218 | rgblight_decrease_val_noeeprom(); | ||
219 | } | ||
220 | void encoder_action_rgb_mode(bool clockwise) { | ||
221 | if (clockwise) | ||
222 | rgblight_step_noeeprom(); | ||
223 | else | ||
224 | rgblight_step_reverse_noeeprom(); | ||
225 | } | ||
226 | #endif // RGB_MATRIX_ENABLE || RGBLIGHT_ENABLE | ||
227 | #endif // ENCODER_ENABLE | ||
228 | |||
229 | #if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality | ||
230 | |||
231 | __attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; } | ||
232 | |||
233 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
234 | if (!encoder_update_keymap(index, clockwise)) { return false; } | ||
235 | if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match | ||
236 | uint8_t mods_state = get_mods(); | ||
237 | if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers | ||
238 | encoder_action_layerchange(clockwise); | ||
239 | } else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up/dn | ||
240 | unregister_mods(MOD_BIT(KC_RSFT)); | ||
241 | encoder_action_navpage(clockwise); | ||
242 | register_mods(MOD_BIT(KC_RSFT)); | ||
243 | } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word | ||
244 | encoder_action_navword(clockwise); | ||
245 | } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track | ||
246 | encoder_action_mediatrack(clockwise); | ||
247 | } else { | ||
248 | switch(get_highest_layer(layer_state)) { | ||
249 | case _FN1: | ||
250 | #ifdef IDLE_TIMEOUT_ENABLE | ||
251 | timeout_update_threshold(clockwise); | ||
252 | #endif | ||
253 | break; | ||
254 | default: | ||
255 | encoder_action_volume(clockwise); // Otherwise it just changes volume | ||
256 | break; | ||
257 | } | ||
258 | } | ||
259 | return false; | ||
260 | } | ||
261 | #endif // ENCODER_ENABLE | ||
262 | |||
263 | 113 | ||
264 | // PROCESS KEY CODES | 114 | // PROCESS KEY CODES |
265 | __attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } | 115 | __attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } |
@@ -326,6 +176,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
326 | break; | 176 | break; |
327 | #endif // EMOTICON_ENABLE | 177 | #endif // EMOTICON_ENABLE |
328 | 178 | ||
179 | #ifdef ALTTAB_SCROLL_ENABLE | ||
180 | case KC_TSTOG: | ||
181 | if (record->event.pressed) encoder_toggle_alttabscroll(); | ||
182 | else unregister_code16(keycode); | ||
183 | break; | ||
184 | #endif // ALTTAB_SCROLL_ENABLE | ||
185 | |||
329 | default: | 186 | default: |
330 | if (record->event.pressed) { | 187 | if (record->event.pressed) { |
331 | #ifdef RGB_MATRIX_ENABLE | 188 | #ifdef RGB_MATRIX_ENABLE |