summaryrefslogtreecommitdiffstats
path: root/users/kuchosauronad0/encoder.c
diff options
context:
space:
mode:
authorkuchosauronad0 <22005492+kuchosauronad0@users.noreply.github.com>2019-08-24 09:01:12 -0700
committerDrashna Jaelre <drashna@live.com>2019-08-24 09:01:12 -0700
commit2ef6bbbf5ffba0142613bc394c41ba580a7e2c7e (patch)
tree84a21a557f13e08ef6cc660a05f2fb2edc011ddf /users/kuchosauronad0/encoder.c
parent51bcadf38cfccc08b287554ab17e21624abf55b8 (diff)
[Keymap] Update to userspace kuchosauroand0 (#6596)
* added combos * minor adjustments, added combos * Add second encoder, add modifiers to encoders Added a skeleton for the possibily having a second encoder. Added 9 modifiers for the first rotary encoder: - None General navigation. Page up/down - SHIFT Fast navigation. Home/end - CTRL Vertical navigation. Up/down - CTRL+SHIFT Horizontal navigation. Left/right - ALT Audio volume control. - GUI Browser navigation(windows). Forward/backward - ALT+SHIFT Form navigation. Tab up/down - ALT+CTRL Media control. (Play|pause)/mute - HYPER Media navigation. Next/prev track Key codes are stored in `uint16_t encoder_actions[2][9]` * Add second encoder, add modifiers to encoders Added a skeleton for the possibily having a second encoder. Added 9 modifiers for the first rotary encoder: - None General navigation. Page up/down - SHIFT Fast navigation. Home/end - CTRL Vertical navigation. Up/down - CTRL+SHIFT Horizontal navigation. Left/right - ALT Audio volume control. - GUI Browser navigation(windows). Forward/backward - ALT+SHIFT Form navigation. Tab up/down - ALT+CTRL Media control. (Play|pause)/mute - HYPER Media navigation. Next/prev track Key codes are stored in `uint16_t encoder_actions[2][9]` * Clean up; added combos Combos: - CV: Copy - XC: Cut - ZV: Paste - QP: KC_SLEEP * Fix LEADER_DICTIONARY to be more useful * Add documentation * Minor fixes * Raise TAPPING_TERM * testing * Rearrange modifiers * Fix kc being stored in uint8 instead of uint16 * Update documentation * Clean up * Remove excess comments * Put encoder_actions in progmem
Diffstat (limited to 'users/kuchosauronad0/encoder.c')
-rw-r--r--users/kuchosauronad0/encoder.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/users/kuchosauronad0/encoder.c b/users/kuchosauronad0/encoder.c
index 1b9b2cb12f..06b7b51233 100644
--- a/users/kuchosauronad0/encoder.c
+++ b/users/kuchosauronad0/encoder.c
@@ -1,10 +1,63 @@
#include "encoder.h"
-
void encoder_update_user(uint8_t index, bool clockwise) {
- if (clockwise) {
- tap_code(KC_1);
- } else {
- tap_code(KC_0);
+ static uint16_t kc;
+ uint8_t temp_mod = get_mods();
+ if (index == 0) { /* first encoder */
+ if (clockwise) {
+ //if (temp_mod & MOD_BIT(KC_HYPR)){ // TODO: not how this works, only registers CTRL
+ if ((temp_mod & MOD_MASK_CTRL) && (temp_mod & MOD_MASK_SHIFT) && (temp_mod & MOD_MASK_ALT) && (temp_mod & MOD_MASK_GUI)) { // HYPER
+ kc = encoder_actions[0][8];
+ } else if ( (temp_mod & MOD_MASK_SHIFT) && (temp_mod & MOD_MASK_ALT) ) { // ALT+SHIFT
+ kc = encoder_actions[0][7];
+ } else if ( (temp_mod & MOD_MASK_SHIFT) && (temp_mod & MOD_MASK_CTRL) ) { // CTRL+SHIFT
+ kc = encoder_actions[0][6];
+ } else if ( (temp_mod & MOD_MASK_CTRL) && (temp_mod & MOD_MASK_ALT) ) { // CTRL+ALT
+ kc = encoder_actions[0][5];
+ } else if (temp_mod & MOD_MASK_GUI) { // GUI
+ kc = encoder_actions[0][4];
+ } else if (temp_mod & MOD_MASK_SHIFT) { // SHIFT
+ kc = encoder_actions[0][3];
+ } else if (temp_mod & MOD_MASK_ALT) { // ALT
+ kc = encoder_actions[0][2];
+ } else if (temp_mod & MOD_MASK_CTRL) { // CTRL
+ kc = encoder_actions[0][1];
+ } else { // None
+ kc = encoder_actions[0][0];
+ }
+ } else { // Counter Clockwise
+ if ((temp_mod & MOD_MASK_CTRL) && (temp_mod & MOD_MASK_SHIFT) && (temp_mod & MOD_MASK_ALT) && (temp_mod & MOD_MASK_GUI)) { // HYPER
+ kc = encoder_actions[1][8];
+ } else if ( (temp_mod & MOD_MASK_SHIFT) && (temp_mod & MOD_MASK_ALT) ) { // ALT+SHIFT
+ kc = encoder_actions[1][7];
+ } else if ( (temp_mod & MOD_MASK_SHIFT) && (temp_mod & MOD_MASK_CTRL) ) { // CTRL+SHIFT
+ kc = encoder_actions[1][6];
+ } else if ( (temp_mod & MOD_MASK_CTRL) && (temp_mod & MOD_MASK_ALT) ) { // CTRL+ALT
+ kc = encoder_actions[1][5];
+ } else if (temp_mod & MOD_MASK_GUI) { // GUI
+ kc = encoder_actions[1][4];
+ } else if (temp_mod & MOD_MASK_SHIFT) { // SHIFT
+ kc = encoder_actions[1][3];
+ } else if (temp_mod & MOD_MASK_ALT) { // ALT
+ kc = encoder_actions[1][2];
+ } else if (temp_mod & MOD_MASK_CTRL) { // CTRL
+ kc = encoder_actions[1][1];
+ } else { // None
+ kc = encoder_actions[1][0];
+ }
+ }
+ clear_mods();
+ tap_code16(kc);
+ set_mods(temp_mod);
+ } else if (index == 1){ // second Encoder
+ if (clockwise) {
+ tap_code(KC_0);
+ } else{
+ tap_code(KC_1);
+ }
}
}
-
+const uint16_t PROGMEM encoder_actions[][9] = { \
+// None CTRL ALT SHIFT GUI CTRL+ALT CTRL+SHFT ALT+SHFT HYPER
+ { KC_PGDN, KC_DOWN, KC_AUDIO_VOL_UP, KC_END, KC_WWW_FORWARD, KC_AUDIO_MUTE, KC_RIGHT, LSFT(KC_TAB), KC_MEDIA_NEXT_TRACK}, \
+ { KC_PGUP, KC_UP, KC_AUDIO_VOL_DOWN, KC_HOME, KC_WWW_BACK, KC_MEDIA_PLAY_PAUSE, KC_LEFT, KC_TAB, KC_MEDIA_PREV_TRACK}
+};