summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-10-30 18:54:36 +0000
committerQMK Bot <hello@qmk.fm>2021-10-30 18:54:36 +0000
commit9e4dd8bfcba41ccac0d28ee8ea218142e7aba674 (patch)
treec9fe4c255d0665067e330918e313f66978749e20 /users
parentfb739a67c92483f6c072886b9ffbb90e55b6582d (diff)
parent5334e087ef848d54266537ecdc0b87cac976517e (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users')
-rw-r--r--users/jonavin/jonavin.c177
-rw-r--r--users/jonavin/jonavin.h8
-rw-r--r--users/jonavin/jonavin_encoder.c219
-rw-r--r--users/jonavin/readme.md11
-rw-r--r--users/jonavin/rules.mk11
5 files changed, 263 insertions, 163 deletions
diff --git a/users/jonavin/jonavin.c b/users/jonavin/jonavin.c
index 367601dfba..b66b444f36 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/>.
} // timeout_threshold = 0 will disable timeout
}
+#endif // IDLE_TIMEOUT_ENABLE
+
+#if defined(ALTTAB_SCROLL_ENABLE) || defined(IDLE_TIMEOUT_ENABLE) // timer features
__attribute__((weak)) void matrix_scan_keymap(void) {}
void matrix_scan_user(void) {
- timeout_tick_timer();
+ #ifdef ALTTAB_SCROLL_ENABLE
+ encoder_tick_alttabscroll();
+ #endif
+ #ifdef IDLE_TIMEOUT_ENABLE
+ timeout_tick_timer();
+ #endif
matrix_scan_keymap();
}
-#endif // IDLE_TIMEOUT_ENABLE
-
-
-#ifdef ENCODER_ENABLE
- #ifndef DYNAMIC_KEYMAP_LAYER_COUNT
- #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere
- #endif
- #ifndef ENCODER_DEFAULTACTIONS_INDEX
- #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders
- #endif
-
- void encoder_action_volume(bool clockwise) {
- if (clockwise)
- tap_code(KC_VOLU);
- else
- tap_code(KC_VOLD);
- }
-
- void encoder_action_mediatrack(bool clockwise) {
- if (clockwise)
- tap_code(KC_MEDIA_NEXT_TRACK);
- else
- tap_code(KC_MEDIA_PREV_TRACK);
- }
-
- 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 (selected_layer > 0) {
- selected_layer --;
- layer_move(selected_layer);
- }
- }
- }
-
- #ifdef RGB_MATRIX_ENABLE
- void encoder_action_rgb_speed(bool clockwise) {
- if (clockwise)
- rgb_matrix_increase_speed_noeeprom();
- else
- rgb_matrix_decrease_speed_noeeprom();
- }
- void encoder_action_rgb_hue(bool clockwise) {
- if (clockwise)
- rgb_matrix_increase_hue_noeeprom();
- else
- rgb_matrix_decrease_hue_noeeprom();
- }
- void encoder_action_rgb_saturation(bool clockwise) {
- if (clockwise)
- rgb_matrix_increase_sat_noeeprom();
- else
- rgb_matrix_decrease_sat_noeeprom();
- }
- void encoder_action_rgb_brightness(bool clockwise) {
- if (clockwise)
- rgb_matrix_increase_val_noeeprom();
- else
- rgb_matrix_decrease_val_noeeprom();
- }
- void encoder_action_rgb_mode(bool clockwise) {
- if (clockwise)
- rgb_matrix_step_noeeprom();
- else
- rgb_matrix_step_reverse_noeeprom();
- }
- #elif defined(RGBLIGHT_ENABLE)
- void encoder_action_rgb_speed(bool clockwise) {
- if (clockwise)
- rgblight_increase_speed_noeeprom();
- else
- rgblight_decrease_speed_noeeprom();
- }
- void encoder_action_rgb_hue(bool clockwise) {
- if (clockwise)
- rgblight_increase_hue_noeeprom();
- else
- rgblight_decrease_hue_noeeprom();
- }
- void encoder_action_rgb_saturation(bool clockwise) {
- if (clockwise)
- rgblight_increase_sat_noeeprom();
- else
- rgblight_decrease_sat_noeeprom();
- }
- void encoder_action_rgb_brightness(bool clockwise) {
- if (clockwise)
- rgblight_increase_val_noeeprom();
- else
- rgblight_decrease_val_noeeprom();
- }
- void encoder_action_rgb_mode(bool clockwise) {
- if (clockwise)
- rgblight_step_noeeprom();
- else
- rgblight_step_reverse_noeeprom();
- }
- #endif // RGB_MATRIX_ENABLE || RGBLIGHT_ENABLE
-#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 false;
- }
-#endif // ENCODER_ENABLE
-
+#endif // ALTTAB_SCROLL_ENABLE or IDLE_TIMEOUT_ENABLE
// PROCESS KEY CODES
__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) {
break;
#endif // EMOTICON_ENABLE
+ #ifdef ALTTAB_SCROLL_ENABLE
+ case KC_TSTOG:
+ if (record->event.pressed) encoder_toggle_alttabscroll();
+ else unregister_code16(keycode);
+ break;
+ #endif // ALTTAB_SCROLL_ENABLE
+
default:
if (record->event.pressed) {
#ifdef RGB_MATRIX_ENABLE
diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h
index 21b972ed75..ab2ce0dff2 100644
--- a/users/jonavin/jonavin.h
+++ b/users/jonavin/jonavin.h
@@ -45,6 +45,8 @@ enum custom_user_keycodes {
EMO_JOY, // (^o^)
EMO_TEARS, // (T_T)
+ KC_TSTOG, // Tab Scroll Toggle
+
NEW_SAFE_RANGE // new safe range for keymap level custom keycodes
};
@@ -91,6 +93,12 @@ enum custom_user_keycodes {
void encoder_action_rgb_brightness(bool clockwise);
void encoder_action_rgb_mode(bool clockwise);
#endif // RGB_MATRIX_ENABLE / RGBLIGHT_ENABLE
+
+ #ifdef ALTTAB_SCROLL_ENABLE
+ void encoder_action_alttabscroll(bool clockwise);
+ void encoder_toggle_alttabscroll(void);
+ void encoder_tick_alttabscroll(void);
+ #endif // ALTTAB_SCROLL_ENABLE
#endif // ENCODER_ENABLE
diff --git a/users/jonavin/jonavin_encoder.c b/users/jonavin/jonavin_encoder.c
new file mode 100644
index 0000000000..387ed5f430
--- /dev/null
+++ b/users/jonavin/jonavin_encoder.c
@@ -0,0 +1,219 @@
+
+/* Copyright 2021 Jonavin Eng @Jonavin
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include QMK_KEYBOARD_H
+#include "jonavin.h"
+
+#ifdef ENCODER_ENABLE
+ #ifndef DYNAMIC_KEYMAP_LAYER_COUNT
+ #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere
+ #endif
+ #ifndef ENCODER_DEFAULTACTIONS_INDEX
+ #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders
+ #endif
+
+ void encoder_action_volume(bool clockwise) {
+ if (clockwise)
+ tap_code(KC_VOLU);
+ else
+ tap_code(KC_VOLD);
+ }
+
+ void encoder_action_mediatrack(bool clockwise) {
+ if (clockwise)
+ tap_code(KC_MEDIA_NEXT_TRACK);
+ else
+ tap_code(KC_MEDIA_PREV_TRACK);
+ }
+
+ 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 (selected_layer > 0) {
+ selected_layer --;
+ layer_move(selected_layer);
+ }
+ }
+ }
+
+ #ifdef RGB_MATRIX_ENABLE
+ void encoder_action_rgb_speed(bool clockwise) {
+ if (clockwise)
+ rgb_matrix_increase_speed_noeeprom();
+ else
+ rgb_matrix_decrease_speed_noeeprom();
+ }
+ void encoder_action_rgb_hue(bool clockwise) {
+ if (clockwise)
+ rgb_matrix_increase_hue_noeeprom();
+ else
+ rgb_matrix_decrease_hue_noeeprom();
+ }
+ void encoder_action_rgb_saturation(bool clockwise) {
+ if (clockwise)
+ rgb_matrix_increase_sat_noeeprom();
+ else
+ rgb_matrix_decrease_sat_noeeprom();
+ }
+ void encoder_action_rgb_brightness(bool clockwise) {
+ if (clockwise)
+ rgb_matrix_increase_val_noeeprom();
+ else
+ rgb_matrix_decrease_val_noeeprom();
+ }
+ void encoder_action_rgb_mode(bool clockwise) {
+ if (clockwise)
+ rgb_matrix_step_noeeprom();
+ else
+ rgb_matrix_step_reverse_noeeprom();
+ }
+ #elif defined(RGBLIGHT_ENABLE)
+ void encoder_action_rgb_speed(bool clockwise) {
+ if (clockwise)
+ rgblight_increase_speed_noeeprom();
+ else
+ rgblight_decrease_speed_noeeprom();
+ }
+ void encoder_action_rgb_hue(bool clockwise) {
+ if (clockwise)
+ rgblight_increase_hue_noeeprom();
+ else
+ rgblight_decrease_hue_noeeprom();
+ }
+ void encoder_action_rgb_saturation(bool clockwise) {
+ if (clockwise)
+ rgblight_increase_sat_noeeprom();
+ else
+ rgblight_decrease_sat_noeeprom();
+ }
+ void encoder_action_rgb_brightness(bool clockwise) {
+ if (clockwise)
+ rgblight_increase_val_noeeprom();
+ else
+ rgblight_decrease_val_noeeprom();
+ }
+ void encoder_action_rgb_mode(bool clockwise) {
+ if (clockwise)
+ rgblight_step_noeeprom();
+ else
+ rgblight_step_reverse_noeeprom();
+ }
+ #endif // RGB_MATRIX_ENABLE || RGBLIGHT_ENABLE
+
+ #ifdef ALTTAB_SCROLL_ENABLE
+ bool is_tab_scrolling = false;
+ bool is_alt_tab_active = false;
+ uint16_t alt_tab_timer = 0;
+
+
+ void encoder_toggle_alttabscroll(void) {
+ is_tab_scrolling = !is_tab_scrolling;
+ }
+
+ void encoder_action_alttabscroll(bool clockwise) {
+ if (clockwise) {
+ if (!is_alt_tab_active) {
+ is_alt_tab_active = true;
+ register_mods(MOD_RALT);
+ }
+ tap_code16(KC_TAB);
+ }
+ else {
+ tap_code16(S(KC_TAB));
+ }
+ alt_tab_timer = timer_read();
+ }
+
+ void encoder_tick_alttabscroll(void) {
+ if (is_alt_tab_active) {
+ if (timer_elapsed(alt_tab_timer) > 600) {
+ unregister_mods(MOD_RALT);
+ is_alt_tab_active = false;
+ }
+ }
+ }
+ #endif // ALTTAB_SCROLL_ENABLE
+#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:
+ #ifdef ALTTAB_SCROLL_ENABLE
+ if (is_tab_scrolling)
+ encoder_action_alttabscroll(clockwise);
+ else
+ encoder_action_volume(clockwise); // Otherwise it just changes volume
+ #else
+ encoder_action_volume(clockwise); // Otherwise it just changes volume
+ #endif // ALTTAB_SCROLL_ENABLE
+ break;
+ }
+ }
+ return false;
+ }
+#endif // ENCODER_ENABLE
+
+
diff --git a/users/jonavin/readme.md b/users/jonavin/readme.md
index 1b064ddc3c..8ec0e0ea16 100644
--- a/users/jonavin/readme.md
+++ b/users/jonavin/readme.md
@@ -35,6 +35,7 @@ KEYCODES:
- KC_SFTUP RShift when held, Up arrow when tapped
- KC_RAISESPC _RAISE layer mod when held, space when tapped
- KC_LOWERSPC _LOWER layer mod when held, space when tapped
+- KC_TSTOG toggles between volume and Alt-Tab encoder control
-
When EMOTICON_ENABLE = yes
- EMO_SHRUG `\_("/)_/`
@@ -59,7 +60,9 @@ AVAILABLE ENCODER ACTIONS:
- void encoder_action_rgb_saturation(bool clockwise);
- void encoder_action_rgb_brightness(bool clockwise);
- void encoder_action_rgb_mode(bool clockwise);
-
+-
+- void encoder_action_alttabscroll(bool clockwise)
+- void encoder_toggle_alttabscroll(void);
ENABLE FEATURES your keymap rules.mk
---------------------------------------
@@ -89,6 +92,12 @@ EMOTICON_ENABLE
INVERT_NUMLOCK_INDICATOR
- inverts the Num lock indicator, LED is on when num lock is off
+ALTTAB_SCROLL_ENABLE
+- When ENCODER_DEFAULTACTIONS_ENABLE = yes,
+ Enables Alt-Tab scrolling functions in default encoder,
+ bind KS_TSTOG to a key to enable/disable Alt-Tab vs Volume control
+- When defining your own encoder functions use encoder_action_alttabscroll(bool clockwise) to assign the encodr action
+
FUNCTIONS
------------------------
diff --git a/users/jonavin/rules.mk b/users/jonavin/rules.mk
index 6460021247..4f65db27b9 100644
--- a/users/jonavin/rules.mk
+++ b/users/jonavin/rules.mk
@@ -1,6 +1,13 @@
SRC += jonavin.c
-ifeq ($(strip $(ENCODER_DEFAULTACTIONS_ENABLE)), yes)
- OPT_DEFS += -DENCODER_DEFAULTACTIONS_ENABLE
+ifdef ENCODER_ENABLE
+ # include encoder related code when enabled
+ ifeq ($(strip $(ENCODER_DEFAULTACTIONS_ENABLE)), yes)
+ OPT_DEFS += -DENCODER_DEFAULTACTIONS_ENABLE
+ endif
+ ifeq ($(strip $(ALTTAB_SCROLL_ENABLE)), yes)
+ OPT_DEFS += -DALTTAB_SCROLL_ENABLE
+ endif
+ SRC += jonavin_encoder.c
endif
ifeq ($(strip $(TD_LSFT_CAPSLOCK_ENABLE)), yes)
OPT_DEFS += -DTD_LSFT_CAPSLOCK_ENABLE