diff options
| author | Jonas Avellana <14019120+ninjonas@users.noreply.github.com> | 2020-03-13 17:56:21 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-13 16:56:21 -0700 |
| commit | 0fdd37ee19d07d6f15217074dd3291fda4c4cb2f (patch) | |
| tree | 595a398a2977755695c1903cdf71b6fcf2ce03aa /users/ninjonas/encoder.c | |
| parent | 40e8d60ecd68c1c43e1fc911e993626943930fd0 (diff) | |
| download | qmk_firmware-0fdd37ee19d07d6f15217074dd3291fda4c4cb2f.tar.gz qmk_firmware-0fdd37ee19d07d6f15217074dd3291fda4c4cb2f.zip | |
[Keymap] ninjonas keymap updates (#8373)
* [keymap(ninjonas)] ninjonas keymap updates
* [refactor] switching encoder rotation logic. recent pull seems to have flipped encoder stuff
* [keymap(lily58)] added chrome change profile key on RAISE
Co-authored-by: Jonas Avellana <jonas.avellana@workday.com>
Diffstat (limited to 'users/ninjonas/encoder.c')
| -rw-r--r-- | users/ninjonas/encoder.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/users/ninjonas/encoder.c b/users/ninjonas/encoder.c new file mode 100644 index 000000000..3d56ff89e --- /dev/null +++ b/users/ninjonas/encoder.c | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | /* Copyright 2020 ninjonas | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "ninjonas.h" | ||
| 17 | |||
| 18 | #ifdef ENCODER_ENABLE | ||
| 19 | void left_encoder_cw(void) { | ||
| 20 | switch (get_highest_layer(layer_state)) { | ||
| 21 | case _LOWER: | ||
| 22 | tap_code16(LGUI(KC_TAB)); | ||
| 23 | break; | ||
| 24 | case _RAISE: | ||
| 25 | tap_code(KC_PGDN); | ||
| 26 | break; | ||
| 27 | case _ADJUST: | ||
| 28 | rgblight_decrease_hue(); | ||
| 29 | break; | ||
| 30 | default: | ||
| 31 | tap_code(KC_BRID); | ||
| 32 | break; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | void left_encoder_acw(void) { | ||
| 36 | switch (get_highest_layer(layer_state)) { | ||
| 37 | case _LOWER: | ||
| 38 | tap_code16(SGUI(KC_TAB)); | ||
| 39 | break; | ||
| 40 | case _RAISE: | ||
| 41 | tap_code(KC_PGUP); | ||
| 42 | break; | ||
| 43 | case _ADJUST: | ||
| 44 | rgblight_increase_hue(); | ||
| 45 | break; | ||
| 46 | default: | ||
| 47 | tap_code(KC_BRIU); | ||
| 48 | break; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | void right_encoder_cw(void) { | ||
| 52 | switch (get_highest_layer(layer_state)) { | ||
| 53 | case _LOWER: | ||
| 54 | tap_code(KC_DOWN); | ||
| 55 | break; | ||
| 56 | case _RAISE: | ||
| 57 | tap_code16(LCTL(LSFT(KC_TAB))); | ||
| 58 | break; | ||
| 59 | case _ADJUST: | ||
| 60 | rgblight_decrease_val(); | ||
| 61 | break; | ||
| 62 | default: | ||
| 63 | tap_code(KC_VOLD); | ||
| 64 | break; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | void right_encoder_acw(void) { | ||
| 68 | switch (get_highest_layer(layer_state)) { | ||
| 69 | case _LOWER: | ||
| 70 | tap_code(KC_UP); | ||
| 71 | break; | ||
| 72 | case _RAISE: | ||
| 73 | tap_code16(LCTL(KC_TAB)); | ||
| 74 | break; | ||
| 75 | case _ADJUST: | ||
| 76 | rgblight_increase_val(); | ||
| 77 | break; | ||
| 78 | default: | ||
| 79 | tap_code(KC_VOLU); | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | void encoder_update_user(uint8_t index, bool clockwise) { | ||
| 85 | encoder_rotated_timer = timer_read(); | ||
| 86 | if (index == 0) { | ||
| 87 | left_encoder_rotated = true; | ||
| 88 | if (clockwise) { | ||
| 89 | left_encoder_cw(); | ||
| 90 | } else { | ||
| 91 | left_encoder_acw(); | ||
| 92 | } | ||
| 93 | } | ||
| 94 | else if (index == 1) { | ||
| 95 | right_encoder_rotated = true; | ||
| 96 | if (clockwise) { | ||
| 97 | right_encoder_cw(); | ||
| 98 | } else { | ||
| 99 | right_encoder_acw(); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | #endif \ No newline at end of file | ||
