diff options
author | William Chang <william@factual.com> | 2019-11-20 22:17:07 -0800 |
---|---|---|
committer | William Chang <william@factual.com> | 2019-11-20 22:17:07 -0800 |
commit | e7f4d56592b3975c38af329e77b4efd9108495e8 (patch) | |
tree | 0a416bccbf70bfdbdb9ffcdb3bf136b47378c014 /users/kuchosauronad0/encoder.c | |
parent | 71493b2f9bbd5f3d18373c518fa14ccafcbf48fc (diff) | |
parent | 8416a94ad27b3ff058576f09f35f0704a8b39ff3 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'users/kuchosauronad0/encoder.c')
-rw-r--r-- | users/kuchosauronad0/encoder.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/users/kuchosauronad0/encoder.c b/users/kuchosauronad0/encoder.c new file mode 100644 index 0000000000..06b7b51233 --- /dev/null +++ b/users/kuchosauronad0/encoder.c @@ -0,0 +1,63 @@ +#include "encoder.h" +void encoder_update_user(uint8_t index, bool clockwise) { + 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} +}; |